55import com .evandev .fieldguide .client .gui .screens .FieldGuidePhotographScreen ;
66import com .evandev .fieldguide .client .gui .widget .FieldGuidePhotographWidget ;
77import com .evandev .fieldguide .client .progress .ProgressManager ;
8+ import com .mojang .blaze3d .vertex .Tesselator ;
9+ import io .github .mortuusars .exposure .ExposureClient ;
810import io .github .mortuusars .exposure .gui .screen .ItemListScreen ;
911import io .github .mortuusars .exposure .item .PhotographItem ;
12+ import io .github .mortuusars .exposure .render .PhotographRenderProperties ;
13+ import io .github .mortuusars .exposure .render .PhotographRenderer ;
1014import io .github .mortuusars .exposure .util .ItemAndStack ;
1115import net .minecraft .ChatFormatting ;
1216import net .minecraft .client .Minecraft ;
17+ import net .minecraft .client .gui .GuiGraphics ;
1318import net .minecraft .client .gui .components .ImageButton ;
1419import net .minecraft .client .gui .components .Tooltip ;
1520import net .minecraft .client .gui .screens .Screen ;
21+ import net .minecraft .client .renderer .LightTexture ;
22+ import net .minecraft .client .renderer .MultiBufferSource ;
1623import net .minecraft .client .renderer .Rect2i ;
1724import net .minecraft .network .chat .Component ;
1825import net .minecraft .resources .ResourceLocation ;
2532
2633public class ExposureCompat {
2734 private static final ResourceLocation ADD_PHOTO_ICON = new ResourceLocation ("fieldguide" , "textures/gui/exposure/add_photo.png" );
28- private static final ResourceLocation PHOTOGRAPH_BACKGROUND = new ResourceLocation ("fieldguide" , "textures/gui/exposure/photograph.png" );
2935
3036 public static void setupExposureWidgets (FieldGuideEntryScreen screen , Object entry ) {
3137 if (!ClientFieldGuideManager .isUnlocked (entry )) return ;
@@ -36,8 +42,8 @@ public static void setupExposureWidgets(FieldGuideEntryScreen screen, Object ent
3642 int leftHeight = screen .getLeftPageBounds ().height ();
3743
3844 int iconSize = 16 ;
39- int iconX = leftX + leftWidth - iconSize - 8 ;
40- int iconY = leftY + 10 ;
45+ int iconX = leftX + leftWidth - iconSize - 12 ;
46+ int iconY = leftY + 12 ;
4147
4248 ItemStack existingPhoto = ProgressManager .getInstance ().getPhotograph (entry );
4349
@@ -49,12 +55,12 @@ public static void setupExposureWidgets(FieldGuideEntryScreen screen, Object ent
4955 addPhotoButton .setTooltip (Tooltip .create (Component .translatable ("gui.fieldguide.add_photograph" )));
5056 screen .addWidgetPublic (addPhotoButton );
5157 } else {
52- int photoWidth = 112 ;
53- int photoHeight = 112 ;
58+ int photoWidth = 108 ;
59+ int photoHeight = 108 ;
5460 int photoX = leftX + (leftWidth / 2 ) - (photoWidth / 2 );
55- int photoY = leftY + (leftHeight / 2 ) - (photoHeight / 2 ) - 14 ;
61+ int photoY = leftY + (leftHeight / 2 ) - (photoHeight / 2 ) - 15 ;
5662
57- Rect2i exposureArea = new Rect2i (photoX + 8 , photoY + 8 , photoWidth - 16 , photoHeight - 16 );
63+ Rect2i exposureArea = new Rect2i (photoX + 6 , photoY + 6 , photoWidth - 12 , photoHeight - 12 );
5864
5965 Component tooltipText = Component .empty ()
6066 .append (Component .literal ("[" ).withStyle (ChatFormatting .DARK_GRAY ))
@@ -66,10 +72,11 @@ public static void setupExposureWidgets(FieldGuideEntryScreen screen, Object ent
6672 .append (Component .literal ("Right Click" ).withStyle (ChatFormatting .GRAY ))
6773 .append (Component .literal ("] to Remove" ).withStyle (ChatFormatting .DARK_GRAY ));
6874
75+
76+
6977 FieldGuidePhotographWidget photoWidget = new FieldGuidePhotographWidget (
7078 photoX , photoY , photoWidth , photoHeight ,
7179 exposureArea ,
72- PHOTOGRAPH_BACKGROUND ,
7380 () -> ProgressManager .getInstance ().getPhotograph (entry ),
7481
7582 () -> Minecraft .getInstance ().setScreen (new FieldGuidePhotographScreen (screen , List .of (new ItemAndStack <>(existingPhoto )))),
@@ -85,6 +92,44 @@ public static void setupExposureWidgets(FieldGuideEntryScreen screen, Object ent
8592 }
8693 }
8794
95+ public static void renderPhotographInGrid (GuiGraphics guiGraphics , int x , int y , int width , int height , ItemStack photograph ) {
96+ if (photograph .getItem () instanceof PhotographItem ) {
97+ PhotographRenderProperties renderProperties = PhotographRenderProperties .get (photograph );
98+ Rect2i exposureArea = new Rect2i (x + 4 , y + 4 , width - 8 , height - 8 );
99+ int textureSize = 64 ;
100+ int sliceSize = width / 2 ;
101+
102+ // Paper
103+ guiGraphics .blit (renderProperties .getPaperTexture (), x , y , 0 , 0 , 0 , sliceSize , sliceSize , textureSize , textureSize );
104+ guiGraphics .blit (renderProperties .getPaperTexture (), x + sliceSize , y , 0 , textureSize - sliceSize , 0 , sliceSize , sliceSize , textureSize , textureSize );
105+ guiGraphics .blit (renderProperties .getPaperTexture (), x , y + sliceSize , 0 , 0 , textureSize - sliceSize , sliceSize , sliceSize , textureSize , textureSize );
106+ guiGraphics .blit (renderProperties .getPaperTexture (), x + sliceSize , y + sliceSize , 0 , textureSize - sliceSize , textureSize - sliceSize , sliceSize , sliceSize , textureSize , textureSize );
107+
108+ // Exposure
109+ guiGraphics .pose ().pushPose ();
110+ float scale = exposureArea .getWidth () / (float ) ExposureClient .getExposureRenderer ().getSize ();
111+ guiGraphics .pose ().translate (exposureArea .getX (), exposureArea .getY (), 1 );
112+ guiGraphics .pose ().scale (scale , scale , scale );
113+
114+ MultiBufferSource .BufferSource bufferSource = MultiBufferSource .immediate (Tesselator .getInstance ().getBuilder ());
115+ PhotographRenderer .render (photograph , false , false , guiGraphics .pose (),
116+ bufferSource , LightTexture .FULL_BRIGHT , 255 , 255 , 255 , 255 );
117+ bufferSource .endBatch ();
118+ guiGraphics .pose ().popPose ();
119+
120+ // Paper overlay
121+ if (renderProperties .hasPaperOverlayTexture ()) {
122+ guiGraphics .pose ().pushPose ();
123+ guiGraphics .pose ().translate (0 , 0 , 2 );
124+ guiGraphics .blit (renderProperties .getPaperOverlayTexture (), x , y , 0 , 0 , 0 , sliceSize , sliceSize , textureSize , textureSize );
125+ guiGraphics .blit (renderProperties .getPaperOverlayTexture (), x + sliceSize , y , 0 , textureSize - sliceSize , 0 , sliceSize , sliceSize , textureSize , textureSize );
126+ guiGraphics .blit (renderProperties .getPaperOverlayTexture (), x , y + sliceSize , 0 , 0 , textureSize - sliceSize , sliceSize , sliceSize , textureSize , textureSize );
127+ guiGraphics .blit (renderProperties .getPaperOverlayTexture (), x + sliceSize , y + sliceSize , 0 , textureSize - sliceSize , textureSize - sliceSize , sliceSize , sliceSize , textureSize , textureSize );
128+ guiGraphics .pose ().popPose ();
129+ }
130+ }
131+ }
132+
88133 private static void openPhotographSelector (FieldGuideEntryScreen parent , Object entry ) {
89134 Player player = Minecraft .getInstance ().player ;
90135 if (player == null ) return ;
0 commit comments