Use standard inheritance to propagage NBT events (#3058)
* Remove the old annotation system * Use TileEntity#onLoad instead of onChunkLoad event * Do not call invalidate in onChunkUnload and validate in onLoad
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -89,8 +90,6 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -433,9 +432,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileChest( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
if( this.world.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
{
|
||||
this.state = 0;
|
||||
@@ -474,9 +475,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileChest( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
|
||||
final int oldState = this.state;
|
||||
final ItemStack oldType = this.storageType;
|
||||
|
||||
@@ -498,12 +501,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
this.lastStateChange = this.world.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons()
|
||||
.isSameItem( oldType, this.storageType );
|
||||
.isSameItem( oldType, this.storageType ) || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileChest( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.config.readFromNBT( data );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
@@ -512,12 +516,14 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileChest( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.config.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -51,8 +52,6 @@ import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.DriveWatcher;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -99,9 +98,10 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
this.inv.setFilter( new CellValidInventoryFilter() );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileDrive( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int newState = 0;
|
||||
|
||||
if( this.getProxy().isActive() )
|
||||
@@ -117,6 +117,15 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
data.writeInt( newState );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK ) || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount()
|
||||
{
|
||||
@@ -176,25 +185,20 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileDrive( final ByteBuf data )
|
||||
{
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileDrive( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileDrive( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
||||
@@ -58,12 +58,9 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.BlockUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -96,7 +93,6 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
private IMEInventory<IAEFluidStack> cachedFluid;
|
||||
private IMEInventory<IAEItemStack> cachedItem;
|
||||
|
||||
@Reflected
|
||||
public TileIOPort()
|
||||
{
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
@@ -111,22 +107,21 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, 3 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.manager.writeToNBT( data );
|
||||
this.inputCells.writeToNBT( data, "cellsInput" );
|
||||
this.outputCells.writeToNBT( data, "cellsOutput" );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.manager.readFromNBT( data );
|
||||
this.inputCells.readFromNBT( data, "cellsInput" );
|
||||
this.outputCells.readFromNBT( data, "cellsOutput" );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -29,8 +31,6 @@ import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
@@ -46,15 +46,17 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSkyChest( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getPlayerOpen() > 0 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSkyChest( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int wasOpen = this.getPlayerOpen();
|
||||
this.setPlayerOpen( data.readBoolean() ? 1 : 0 );
|
||||
|
||||
@@ -63,7 +65,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
this.setLastEvent( System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
return false; // TESR yo!
|
||||
return c; // TESR yo!
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user