diff options
author | Harry <harryyunull@gmail.com> | 2023-07-26 09:17:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 15:17:14 +0200 |
commit | 093bfa0dc02bc330b1ed79704832152917c3d6f8 (patch) | |
tree | a53004e54ae3b026a8bdaa00b006189ab25e5426 /src/main | |
parent | 005fd2fbf72950f019cc2a20c37bb97c2c68b428 (diff) | |
download | GT5-Unofficial-093bfa0dc02bc330b1ed79704832152917c3d6f8.tar.gz GT5-Unofficial-093bfa0dc02bc330b1ed79704832152917c3d6f8.tar.bz2 GT5-Unofficial-093bfa0dc02bc330b1ed79704832152917c3d6f8.zip |
Texture & Bug fixes for Crafting Input Hatches (#2182)
* crafting input textures
* texture v2
* texture v3
* texture
* various fixes
* lazy pattern update
* fix dtpf
* fix removing pattern
* spotless
* fix lag in recipe checks
* fix
* increase tier so they look pretty
Diffstat (limited to 'src/main')
8 files changed, 71 insertions, 31 deletions
diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index b762385238..7dc0a28db2 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -1289,6 +1289,9 @@ public class Textures { OVERLAY_ME_HATCH_ACTIVE, OVERLAY_ME_INPUT_HATCH, + OVERLAY_ME_CRAFTING_INPUT_BUFFER, + OVERLAY_ME_CRAFTING_INPUT_BUS, + OVERLAY_ME_CRAFTING_INPUT_SLAVE, OVERLAY_ME_INPUT_HATCH_ACTIVE, OVERLAY_ME_CRAFTING_HATCH, OVERLAY_ME_CRAFTING_HATCH_ACTIVE, diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index c7a12f1766..d427e99d4e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -489,11 +489,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity private boolean shouldCheckRecipeThisTick(long aTick) { // do a recipe check if any crafting input hatch just got pushed in items + boolean shouldCheck = false; + // check all of them (i.e. do not return early) to reset the state of all of them. for (IDualInputHatch craftingInputMe : mDualInputHatches) { - if (craftingInputMe.justUpdated()) { - return true; - } + shouldCheck |= craftingInputMe.justUpdated(); } + if (shouldCheck) return true; // Perform more frequent recipe change after the machine just shuts down. long timeElapsed = aTick - mLastWorkingTick; diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java index ee7a3df356..cfd953c3c7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_ME.java @@ -1,7 +1,6 @@ package gregtech.common.tileentities.machines; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.*; import java.util.*; import java.util.stream.Collectors; @@ -107,11 +106,13 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ this.sharedItemGetter = getter; NBTTagList inv = nbt.getTagList("inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < inv.tagCount(); i++) { - itemInventory.add(ItemStack.loadItemStackFromNBT(inv.getCompoundTagAt(i))); + var item = ItemStack.loadItemStackFromNBT(inv.getCompoundTagAt(i)); + if (item != null && item.stackSize > 0) itemInventory.add(item); } NBTTagList fluidInv = nbt.getTagList("fluidInventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < fluidInv.tagCount(); i++) { - fluidInventory.add(FluidStack.loadFluidStackFromNBT(fluidInv.getCompoundTagAt(i))); + var fluid = FluidStack.loadFluidStackFromNBT(fluidInv.getCompoundTagAt(i)); + if (fluid != null && fluid.amount > 0) fluidInventory.add(fluid); } } @@ -122,11 +123,27 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ .getPatternForItem(pattern, world))); } + private boolean isEmpty() { + if (itemInventory.isEmpty() && fluidInventory.isEmpty()) return true; + + for (ItemStack itemStack : itemInventory) { + if (itemStack != null && itemStack.stackSize > 0) return false; + } + + for (FluidStack fluidStack : fluidInventory) { + if (fluidStack != null && fluidStack.amount > 0) return false; + } + + return true; + } + public ItemStack[] getItemInputs() { + if (isEmpty()) return new ItemStack[0]; return ArrayUtils.addAll(itemInventory.toArray(new ItemStack[0]), sharedItemGetter.getSharedItem()); } public FluidStack[] getFluidInputs() { + if (isEmpty()) return new FluidStack[0]; return fluidInventory.toArray(new FluidStack[0]); } @@ -231,7 +248,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ // a hash map for faster lookup of pattern slots, not necessarily all valid. private Map<ICraftingPatternDetails, PatternSlot> patternDetailsPatternSlotMap = new HashMap<>(MAX_PATTERN_COUNT); - private boolean initialPatternSyncDone = false; + private boolean needPatternSync = true; private boolean justHadNewItems = false; private boolean supportFluids; @@ -242,7 +259,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ aID, aName, aNameRegional, - 1, + 6, MAX_INV_COUNT, new String[] { "Advanced item input for Multiblocks", "Processes patterns directly from ME", supportFluids ? "It supports patterns including fluids" @@ -265,26 +282,21 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_ME_INPUT_HATCH_ACTIVE) }; + return getTexturesInactive(aBaseTexture); } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_ME_INPUT_HATCH) }; + return new ITexture[] { aBaseTexture, + TextureFactory.of(supportFluids ? OVERLAY_ME_CRAFTING_INPUT_BUFFER : OVERLAY_ME_CRAFTING_INPUT_BUS) }; } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { super.onPostTick(aBaseMetaTileEntity, aTimer); - if (!initialPatternSyncDone && aTimer % 10 == 0 && getBaseMetaTileEntity().isServerSide()) { - try { - getProxy().getGrid() - .postEvent(new MENetworkCraftingPatternChange(this, getProxy().getNode())); - } catch (GridAccessException ignored) { - return; - } - initialPatternSyncDone = true; + if (needPatternSync && aTimer % 10 == 0 && getBaseMetaTileEntity().isServerSide()) { + needPatternSync = !postMEPatternChange(); } } @@ -336,6 +348,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ getProxy().getNode() .updateState(); } + needPatternSync = true; } @Override @@ -537,6 +550,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ originalPattern.refund(getProxy(), getRequest()); } catch (GridAccessException ignored) {} internalInventory[slot.getSlotIndex()] = null; + needPatternSync = true; } else { return; // nothing has changed } @@ -550,10 +564,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ internalInventory[slot.getSlotIndex()] = patternSlot; patternDetailsPatternSlotMap.put(patternSlot.getPatternDetails(), patternSlot); - try { - getProxy().getGrid() - .postEvent(new MENetworkCraftingPatternChange(this, getProxy().getNode())); - } catch (GridAccessException ignored) {} + needPatternSync = true; } private ItemStack[] getSharedItems() { @@ -698,4 +709,17 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_ME extends GT_MetaTileEntity_ public ItemStack getCrafterIcon() { return getMachineCraftingIcon(); } + + private boolean postMEPatternChange() { + // don't post until it's active + if (!getProxy().isActive()) return false; + try { + getProxy().getGrid() + .postEvent(new MENetworkCraftingPatternChange(this, getProxy().getNode())); + } catch (GridAccessException ignored) { + return false; + } + return true; + } + } diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java index 04bf9da06d..51d58a38b1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_CraftingInput_Slave.java @@ -1,7 +1,6 @@ package gregtech.common.tileentities.machines; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.*; import java.util.*; @@ -31,7 +30,7 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_Slave extends GT_MetaTileEnti aID, aName, aNameRegional, - 1, + 6, 0, new String[] { "Slave for Crafting Input Buffer", "Link with Crafting Input Buffer using Data Stick to share inventory", @@ -52,12 +51,12 @@ public class GT_MetaTileEntity_Hatch_CraftingInput_Slave extends GT_MetaTileEnti @Override public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_ME_INPUT_HATCH_ACTIVE) }; + return getTexturesInactive(aBaseTexture); } @Override public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_ME_INPUT_HATCH) }; + return new ITexture[] { aBaseTexture, TextureFactory.of(OVERLAY_ME_CRAFTING_INPUT_SLAVE) }; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java index d1a2a9dd7f..7beb6e65b6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PlasmaForge.java @@ -21,6 +21,7 @@ import static java.lang.Math.log; import static java.lang.Math.pow; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import net.minecraft.item.ItemStack; @@ -59,6 +60,8 @@ import gregtech.api.util.GT_ExoticEnergyInputHelper; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gregtech.common.tileentities.machines.IDualInputHatch; +import gregtech.common.tileentities.machines.IDualInputInventory; public class GT_MetaTileEntity_PlasmaForge extends GT_MetaTileEntity_AbstractMultiFurnace<GT_MetaTileEntity_PlasmaForge> implements ISurvivalConstructable { @@ -668,11 +671,21 @@ public class GT_MetaTileEntity_PlasmaForge extends GT_MetaTileEntity_AbstractMul @NotNull public CheckRecipeResult checkProcessing() { CheckRecipeResult recipe_process = processRecipe(getCompactedInputs(), getCompactedFluids()); + if (recipe_process.wasSuccessful()) return recipe_process; + + // If not successful, then try crafting input buffers + for (IDualInputHatch hatch : mDualInputHatches) { + for (Iterator<? extends IDualInputInventory> it = hatch.inventories(); it.hasNext();) { + IDualInputInventory inventory = it.next(); + recipe_process = processRecipe(inventory.getItemInputs(), inventory.getFluidInputs()); + if (recipe_process.wasSuccessful()) { + return recipe_process; + } + } + } // If recipe cannot be found then continuity is broken and reset running time to 0. - if (!recipe_process.wasSuccessful()) { - resetDiscount(); - } + resetDiscount(); return recipe_process; } diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_BUFFER.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_BUFFER.png Binary files differnew file mode 100644 index 0000000000..ad6e2159ff --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_BUFFER.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_BUS.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_BUS.png Binary files differnew file mode 100644 index 0000000000..92325f2142 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_BUS.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_SLAVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_SLAVE.png Binary files differnew file mode 100644 index 0000000000..b1188aafb1 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_ME_CRAFTING_INPUT_SLAVE.png |