From 0a5c21841fa3eb0ad581173868a06983e0bc0baf Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 21 Oct 2021 00:18:55 +0800 Subject: Make Input Bus and Input Hatch to remember recipe map This recipe map is used to filter input. After chunk load, there will be a short delay between event "chunk finished loading" and "multiblock controller sets the recipe map". Not remembering it makes the hatch to temporarily accept arbitrary input until that happens. --- .../implementations/GT_MetaTileEntity_Hatch_Input.java | 14 ++++++++++++++ .../implementations/GT_MetaTileEntity_Hatch_InputBus.java | 3 +++ 2 files changed, 17 insertions(+) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index a0fc7abcc7..2ff1e87348 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -9,6 +9,7 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import static gregtech.api.enums.Textures.BlockIcons.FLUID_IN_SIGN; @@ -65,6 +66,19 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { return new GT_MetaTileEntity_Hatch_Input(mName, mTier, mDescriptionArray, mTextures); } + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (mRecipeMap != null) + aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mRecipeMap = GT_Recipe_Map.sIndexedMappings.getOrDefault(aNBT.getString("recipeMap"), null); + } + @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java index 96667ddb8c..37a98162b8 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java @@ -169,6 +169,8 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { aNBT.setBoolean("disableSort", disableSort); aNBT.setBoolean("disableFilter", disableFilter); aNBT.setBoolean("disableLimited", disableLimited); + if (mRecipeMap != null) + aNBT.setString("recipeMap", mRecipeMap.mUniqueIdentifier); } @Override @@ -178,6 +180,7 @@ public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { disableFilter = aNBT.getBoolean("disableFilter"); if(aNBT.hasKey("disableLimited")) disableLimited = aNBT.getBoolean("disableLimited"); + mRecipeMap = GT_Recipe_Map.sIndexedMappings.getOrDefault(aNBT.getString("recipeMap"), null); } @Override -- cgit From 7e421ba5da769ac6b1b06215538004979070900c Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 22 Oct 2021 01:37:29 +0800 Subject: Try start processing immediately upon manual fluid manipulation --- src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java | 5 ++++- src/main/java/gregtech/api/interfaces/tileentity/IHasInventory.java | 2 ++ src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api/metatileentity') diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java index 5d2a9321c4..fbae0b6752 100644 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_Container_BasicMachine.java @@ -204,7 +204,10 @@ public class GT_Container_BasicMachine extends GT_Container_BasicTank { } GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); IFluidAccess tFillableAccess = IFluidAccess.from(tTank, true); - return handleFluidSlotClick(tFillableAccess, aPlayer, aMouseclick == 0, true, true); + ItemStack tToken = handleFluidSlotClick(tFillableAccess, aPlayer, aMouseclick == 0, true, true); + if (mTileEntity.isServerSide() && tToken != null) + mTileEntity.markInventoryBeenModified(); + return tToken; } else { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IHasInventory.java b/src/main/java/gregtech/api/interfaces/tileentity/IHasInventory.java index 437d896800..74ad58c407 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IHasInventory.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IHasInventory.java @@ -5,6 +5,8 @@ import net.minecraft.item.ItemStack; public interface IHasInventory extends ISidedInventory, IHasWorldObjectAndCoords { + default void markInventoryBeenModified() {} + /** * if the Inventory of this TileEntity got modified this tick */ diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 397d03e0df..41203c3ad2 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -1748,6 +1748,11 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE return mInventoryChanged; } + @Override + public void markInventoryBeenModified() { + mInventoryChanged = true; + } + @Override public void setGenericRedstoneOutput(boolean aOnOff) { mRedstone = aOnOff; -- cgit