From 18c4373aa4e8e7329c536e07ea7e0aa32ba89641 Mon Sep 17 00:00:00 2001 From: Tech22 Date: Wed, 11 Aug 2021 02:19:53 -0400 Subject: [PATCH] prevent DT jei page overlaps --- .../java/gregtech/api/gui/GuiTextures.java | 1 + .../machines/RecipeMapDistillationTower.java | 61 ++++++++++++++++++ .../progress_bar_distillation_tower.png | Bin 0 -> 2069 bytes 3 files changed, 62 insertions(+) create mode 100644 src/main/resources/assets/gregtech/textures/gui/progress_bar/progress_bar_distillation_tower.png diff --git a/src/main/java/gregtech/api/gui/GuiTextures.java b/src/main/java/gregtech/api/gui/GuiTextures.java index 6d59d5870c6..bc2c9990945 100644 --- a/src/main/java/gregtech/api/gui/GuiTextures.java +++ b/src/main/java/gregtech/api/gui/GuiTextures.java @@ -143,6 +143,7 @@ public class GuiTextures { public static final TextureArea PROGRESS_BAR_COMPRESS = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_compress.png"); public static final TextureArea PROGRESS_BAR_CRACKING = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_cracking.png"); public static final TextureArea PROGRESS_BAR_CRYSTALLIZATION = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_crystallization.png"); + public static final TextureArea PROGRESS_BAR_DISTILLATION_TOWER = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_distillation_tower.png"); public static final TextureArea PROGRESS_BAR_EXTRACT = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_extract.png"); public static final TextureArea PROGRESS_BAR_EXTRUDER = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_extruder.png"); public static final TextureArea PROGRESS_BAR_FUSION = TextureArea.fullImage("textures/gui/progress_bar/progress_bar_fusion.png"); diff --git a/src/main/java/gregtech/api/recipes/machines/RecipeMapDistillationTower.java b/src/main/java/gregtech/api/recipes/machines/RecipeMapDistillationTower.java index bacc00327a2..24fd3b405aa 100644 --- a/src/main/java/gregtech/api/recipes/machines/RecipeMapDistillationTower.java +++ b/src/main/java/gregtech/api/recipes/machines/RecipeMapDistillationTower.java @@ -4,12 +4,15 @@ import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; import gregtech.api.gui.resources.TextureArea; +import gregtech.api.gui.widgets.ImageWidget; import gregtech.api.gui.widgets.SlotWidget; import gregtech.api.gui.widgets.TankWidget; import gregtech.api.recipes.RecipeMap; import gregtech.api.recipes.builders.UniversalDistillationRecipeBuilder; import net.minecraftforge.items.IItemHandlerModifiable; +import java.util.function.DoubleSupplier; + public class RecipeMapDistillationTower extends RecipeMap { public RecipeMapDistillationTower(String unlocalizedName, int inputs, int outputs, int fluidInputs, int fluidOutputs, UniversalDistillationRecipeBuilder defaultRecipe, boolean isHidden) { @@ -32,6 +35,7 @@ else if (slotIndex == 1 || slotIndex == 4 || slotIndex == 7 || slotIndex == 10) else if (slotIndex == 2 || slotIndex == 5 || slotIndex == 8 || slotIndex == 11) tankWidget.setBackgroundTexture(base, GuiTextures.BEAKER_OVERLAY_4); + tankWidget.setAlwaysShowFull(true); builder.widget(tankWidget); } else { SlotWidget slotWidget = new SlotWidget(itemHandler, slotIndex, x, y, true, !isOutputs); @@ -42,4 +46,61 @@ else if (slotIndex == 2 || slotIndex == 5 || slotIndex == 8 || slotIndex == 11) builder.widget(slotWidget); } } + + @Override + //this DOES NOT include machine control widgets or binds player inventory + public ModularUI.Builder createUITemplate(DoubleSupplier progressSupplier, IItemHandlerModifiable importItems, IItemHandlerModifiable exportItems, FluidTankList importFluids, FluidTankList exportFluids, int yOffset) { + ModularUI.Builder builder = ModularUI.defaultBuilder(yOffset); + builder.widget(new ImageWidget(41, 1, 72, 72, GuiTextures.PROGRESS_BAR_DISTILLATION_TOWER)); + addInventorySlotGroup(builder, importItems, importFluids, false, yOffset); + addInventorySlotGroup(builder, exportItems, exportFluids, true, yOffset); + if (this.specialTexture != null && this.specialTexturePosition != null) + addSpecialTexture(builder); + return builder; + } + + @Override + protected void addInventorySlotGroup(ModularUI.Builder builder, IItemHandlerModifiable itemHandler, FluidTankList fluidHandler, boolean isOutputs, int yOffset) { + int itemInputsCount = itemHandler.getSlots(); + int fluidInputsCount = fluidHandler.getTanks(); + boolean invertFluids = false; + if (itemInputsCount == 0) { + int tmp = itemInputsCount; + itemInputsCount = fluidInputsCount; + fluidInputsCount = tmp; + invertFluids = true; + } + int[] inputSlotGrid = determineSlotsGrid(itemInputsCount); + int itemSlotsToLeft = inputSlotGrid[0]; + int itemSlotsToDown = inputSlotGrid[1]; + int startInputsX = isOutputs ? 104 : 68 - itemSlotsToLeft * 18; + int startInputsY = 55 - (int) (itemSlotsToDown / 2.0 * 18) + yOffset; + boolean wasGroupOutput = itemHandler.getSlots() + fluidHandler.getTanks() == 12; + if (wasGroupOutput && isOutputs) startInputsY -= 9; + if (itemHandler.getSlots() == 6 && fluidHandler.getTanks() == 2 && !isOutputs) startInputsY -= 9; + if (!isOutputs) + addSlot(builder, 40, startInputsY + (itemSlotsToDown - 1) * 18 - 18, 0, itemHandler, fluidHandler, invertFluids, false); + else + addSlot(builder, 94, startInputsY + (itemSlotsToDown - 1) * 18, 0, itemHandler, fluidHandler, invertFluids, true); + + if (wasGroupOutput) startInputsY += 2; + + if (!isOutputs) + return; + + if (!invertFluids) { + startInputsY -= 18; + startInputsX += 9; + } + + if (fluidInputsCount > 0 || invertFluids) { + + int startSpecY = startInputsY + itemSlotsToDown * 18; + for (int i = 0; i < fluidInputsCount; i++) { + int x = startInputsX + 18 * (i % 3); + int y = startSpecY - (i / 3) * 18; + addSlot(builder, x, y, i, itemHandler, fluidHandler, true, true); + } + } + } } diff --git a/src/main/resources/assets/gregtech/textures/gui/progress_bar/progress_bar_distillation_tower.png b/src/main/resources/assets/gregtech/textures/gui/progress_bar/progress_bar_distillation_tower.png new file mode 100644 index 0000000000000000000000000000000000000000..930dc03a2b8513dfe64b0b7a361684ccf6963ead GIT binary patch literal 2069 zcmcIlUuYaf9NwfM#MnSUMF~jP?MsBt?d;#XU3$r-x%?}=B%~*ef|A*p*}F~dcDB2l z+$B%qTML4Sh>HL4pt(f<>h#}bjHT4oG$oMlIW4Vbj~QjQZPxY z-t1OL&u-0^@zxr)h%`PXo^0A2piW~XHtRJ%vYUCSg=_P1@>-U}R!F>-mnM>g;&N$G zoMa&t%?tz>LRHLK8O79f6P^%Ns6rVUvZ4aTw4rV*S+V_-c(#zZ_EK@Wor^!^rD_}p zwk$UqjZ8z!u&^R4mSxFMl~on+2oP=hF=_%oI^IDj(g=rM5PQrQ6GY^&^*Aqars)>y zK^NAK+A?v${TeWOO2fTI=rlBS71A=07xL`&+ck?iz zrIJ18M=|m-oh#-gPAcPh#HPAoIl7?$-7s9>QXK+hViRbFrs_FeQ*y*<@#5=?46i3j zB z%#9l;q!Sgc^drqBKa6~YHV&qKxWfOB)Z4P+D)K9oADpt3Y(`Fwn6xPJf9rL>-W|_O za5pE_jM_4sLY1x{WBXea=5j91a%)+pN`YqSF0e57DReAVBgD*FR8LvdyhmXX4P~K$ zG++>@fh^Xuz;RIym?kD_PIVMR%^eoYg(^X=i$M-?1kKbjXQ*KSk!6}D2~FVb!kQJImA06^UjbAyDf=7bekIWc|k(nvVLwX{K(tgjk)4Px%tz*JIdfKc(kwZ z_v*1vXMVf<)`c&E^E+o&b_@L{zIL|VOLxbHg`VENf#Hv}@txJTH?_sa!kf2+)0ei{ zkk+BN0Vg_PW~{u`lNC3=G9wQKL5&n