From 8ca528565628c6ff595afb5934b1c7787841a90a Mon Sep 17 00:00:00 2001 From: reobf <2215595288@qq.com> Date: Sat, 5 Oct 2024 17:21:53 +0800 Subject: [PATCH] update --- .../gt/metatileentity/SuperChestME.java | 19 +++++++++-- .../gt/metatileentity/SuperTankME.java | 12 +++++-- .../util/IStoageCellUpdate.java | 11 +++++++ .../mixin/mixins/MixinStorageChangeEvent.java | 32 +++++++++++++++++-- 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 src/main/java/reobf/proghatches/gt/metatileentity/util/IStoageCellUpdate.java diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java b/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java index 9ab3982..65695f8 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/SuperChestME.java @@ -94,6 +94,7 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched; +import reobf.proghatches.gt.metatileentity.util.IStoageCellUpdate; import reobf.proghatches.gt.metatileentity.util.MappingFluidTank; import reobf.proghatches.lang.LangManager; import reobf.proghatches.main.registration.Registration; @@ -101,7 +102,7 @@ import reobf.proghatches.util.ProghatchesUtil; public class SuperChestME extends GT_MetaTileEntity_Hatch implements ICellContainer, IGridProxyable -,IPriorityHost +,IPriorityHost,IStoageCellUpdate { public SuperChestME(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { @@ -467,6 +468,7 @@ protected void fillStacksIntoFirstSlots() { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if(!aBaseMetaTileEntity.getWorld().isRemote){ + if(update){update=false;updateStatus();} if(wasActive!=this.getProxy().isActive()){ wasActive=this.getProxy().isActive(); post(); @@ -824,7 +826,8 @@ public void chanRender(final MENetworkChannelsChanged changedChannels) { public void updateChannels(final MENetworkChannelsChanged changedChannels) { this.updateStatus(); }*/ -protected void updateStatus() { +boolean update; +public void updateStatus() { try { this.getProxy().getGrid().postEvent(new MENetworkCellArrayUpdate()); @@ -848,5 +851,17 @@ public ItemStack decrStackSize(int aIndex, int aAmount) { boolean voidFull; boolean voidOverflow; +@MENetworkEventSubscribe +public void powerRender(final MENetworkPowerStatusChange c) { + this.updateStatus(); +} +public void updateChannels(final MENetworkChannelsChanged changedChannels) { + this.updateStatus(); +} +@Override +public void cellUpdate() { + update=true; + +} } diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java b/src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java index 1fc10c5..23b604a 100644 --- a/src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java +++ b/src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java @@ -109,6 +109,7 @@ import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; import reobf.proghatches.gt.metatileentity.util.BaseSlotPatched; +import reobf.proghatches.gt.metatileentity.util.IStoageCellUpdate; import reobf.proghatches.gt.metatileentity.util.MappingFluidTank; import reobf.proghatches.lang.LangManager; import reobf.proghatches.main.registration.Registration; @@ -116,7 +117,7 @@ import reobf.proghatches.util.ProghatchesUtil; public class SuperTankME extends GT_MetaTileEntity_Hatch implements ICellContainer, IGridProxyable -,IPriorityHost +,IPriorityHost,IStoageCellUpdate { public SuperTankME(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { @@ -519,6 +520,7 @@ public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if(!aBaseMetaTileEntity.getWorld().isRemote){ + if(update){update=false;updateStatus();} if(wasActive!=this.getProxy().isActive()){ wasActive=this.getProxy().isActive(); post(); @@ -931,7 +933,7 @@ public void updateChannels(final MENetworkChannelsChanged changedChannels) { this.updateStatus(); }*/ static MENetworkCellArrayUpdate event=new MENetworkCellArrayUpdate(); -protected void updateStatus() { +public void updateStatus() { try { this.getProxy().getGrid().postEvent(event); @@ -943,6 +945,12 @@ protected void updateStatus() { } boolean voidFull; boolean voidOverflow; +private boolean update; +@Override +public void cellUpdate() { + update=true; + +} diff --git a/src/main/java/reobf/proghatches/gt/metatileentity/util/IStoageCellUpdate.java b/src/main/java/reobf/proghatches/gt/metatileentity/util/IStoageCellUpdate.java new file mode 100644 index 0000000..ba5a416 --- /dev/null +++ b/src/main/java/reobf/proghatches/gt/metatileentity/util/IStoageCellUpdate.java @@ -0,0 +1,11 @@ +package reobf.proghatches.gt.metatileentity.util; + +import appeng.api.networking.events.MENetworkChannelsChanged; + +public interface IStoageCellUpdate { + + + + void cellUpdate(); + +} diff --git a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinStorageChangeEvent.java b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinStorageChangeEvent.java index 16aac1d..575c55f 100644 --- a/src/main/java/reobf/proghatches/main/mixin/mixins/MixinStorageChangeEvent.java +++ b/src/main/java/reobf/proghatches/main/mixin/mixins/MixinStorageChangeEvent.java @@ -3,11 +3,14 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import appeng.api.networking.events.MENetworkChannelsChanged; import appeng.api.networking.events.MENetworkEventSubscribe; +import appeng.api.networking.events.MENetworkPowerStatusChange; import appeng.api.networking.events.MENetworkStorageEvent; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import reobf.proghatches.gt.metatileentity.util.IMEStorageChangeAwareness; +import reobf.proghatches.gt.metatileentity.util.IStoageCellUpdate; @Mixin(value=BaseMetaTileEntity.class,remap=false) public abstract class MixinStorageChangeEvent { @@ -25,8 +28,31 @@ public void storageChange_Mixin(MENetworkStorageEvent w){ IMetaTileEntity te = getMetaTileEntity(); if(te!=null)((IMEStorageChangeAwareness)te).storageChange(w); } - - - } + + + private Boolean isMETank; + @MENetworkEventSubscribe + public void powerRender(final MENetworkPowerStatusChange w) { + + if(isMETank==null){ + isMETank=getMetaTileEntity() instanceof IStoageCellUpdate; + } + if(isMETank){ + IMetaTileEntity te = getMetaTileEntity(); + if(te!=null)((IStoageCellUpdate)te).cellUpdate(); + } + } + @MENetworkEventSubscribe + public void updateChannels(final MENetworkChannelsChanged w) { + if(isMETank==null){ + isMETank=getMetaTileEntity() instanceof IStoageCellUpdate; + } + if(isMETank){ + IMetaTileEntity te = getMetaTileEntity(); + if(te!=null)((IStoageCellUpdate)te).cellUpdate(); + } + } + + }