Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
reobf committed Oct 5, 2024
1 parent 771dcf5 commit 8ca5285
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@
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;
import reobf.proghatches.util.IIconTexture;
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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand All @@ -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;

}

}
12 changes: 10 additions & 2 deletions src/main/java/reobf/proghatches/gt/metatileentity/SuperTankME.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@
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;
import reobf.proghatches.util.IIconTexture;
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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -943,6 +945,12 @@ protected void updateStatus() {
}
boolean voidFull;
boolean voidOverflow;
private boolean update;
@Override
public void cellUpdate() {
update=true;

}



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package reobf.proghatches.gt.metatileentity.util;

import appeng.api.networking.events.MENetworkChannelsChanged;

public interface IStoageCellUpdate {



void cellUpdate();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}
}


}

0 comments on commit 8ca5285

Please sign in to comment.