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:
@@ -54,8 +54,6 @@ import appeng.helpers.ICustomCollision;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -66,21 +64,25 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
|
||||
private int oldLV = -1; // on re-calculate light when it changes
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCableBus( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getCableBus().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCableBus( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getCableBus().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCableBus( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean ret = this.getCableBus().readFromStream( data );
|
||||
|
||||
final int newLV = this.getCableBus().getLightValue();
|
||||
@@ -91,7 +93,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
this.updateTileSetting();
|
||||
return ret;
|
||||
return ret || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.getCableBus().writeToStream( data );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,12 +131,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
oldTile.setCableBus( tmpCB );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCableBus( final ByteBuf data ) throws IOException
|
||||
{
|
||||
this.getCableBus().writeToStream( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
@@ -41,22 +40,6 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
this.setInternalMaxPower( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
|
||||
@@ -31,8 +31,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.networking.BlockEnergyCell;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
@@ -100,18 +98,18 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileEnergyCell( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
if( !this.world.isRemote )
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
}
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileEnergyCell( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -40,8 +41,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -85,18 +84,20 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileWireless( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int old = this.getClientFlags();
|
||||
this.setClientFlags( data.readByte() );
|
||||
|
||||
return old != this.getClientFlags();
|
||||
return old != this.getClientFlags() || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileWireless( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.setClientFlags( 0 );
|
||||
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user