Auto Reflection Based TileEvents.
This commit is contained in:
@@ -22,7 +22,7 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.items.storage.ItemSpatialStorageCell;
|
||||
import appeng.me.cache.SpatialPylonCache;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -36,29 +36,20 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable
|
||||
AppEngInternalInventory inv = new AppEngInternalInventory( this, 2 );
|
||||
YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
class SpatialTileIOPortHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileSpatialIOPort(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "lastRedstoneState", lastRedstoneState.ordinal() );
|
||||
}
|
||||
|
||||
public SpatialTileIOPortHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "lastRedstoneState", lastRedstoneState.ordinal() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "lastRedstoneState" ) )
|
||||
lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
};
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileSpatialIOPort(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "lastRedstoneState" ) )
|
||||
lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
|
||||
public TileSpatialIOPort() {
|
||||
addNewHandler( new SpatialTileIOPortHandler() );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import appeng.me.cluster.implementations.SpatialPylonCalculator;
|
||||
import appeng.me.cluster.implementations.SpatialPylonCluster;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.AENetworkProxyMultiblock;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
@@ -53,34 +53,24 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
return false;
|
||||
}
|
||||
|
||||
private class TileSpatialPylonHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSpatialPylon(ByteBuf data) throws IOException
|
||||
{
|
||||
int old = displayBits;
|
||||
displayBits = data.readByte();
|
||||
return old != displayBits;
|
||||
}
|
||||
|
||||
public TileSpatialPylonHandler() {
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int old = displayBits;
|
||||
displayBits = data.readByte();
|
||||
return old != displayBits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeByte( displayBits );
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSpatialPylon(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeByte( displayBits );
|
||||
}
|
||||
|
||||
public TileSpatialPylon() {
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL, GridFlags.MULTIBLOCK );
|
||||
gridProxy.setIdlePowerUsage( 0.5 );
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
addNewHandler( new TileSpatialPylonHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,14 +117,14 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
disconnect(false);
|
||||
disconnect( false );
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
{
|
||||
disconnect(false);
|
||||
disconnect( false );
|
||||
super.onChunkUnload();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user