Auto Reflection Based TileEvents.
This commit is contained in:
@@ -14,7 +14,7 @@ import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -75,33 +75,23 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
return cacheConfig;
|
||||
}
|
||||
|
||||
class TileCellWorkbenchHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
{
|
||||
cell.writeToNBT( data, "cell" );
|
||||
config.writeToNBT( data, "config" );
|
||||
cm.writeToNBT( data );
|
||||
}
|
||||
|
||||
public TileCellWorkbenchHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
cell.writeToNBT( data, "cell" );
|
||||
config.writeToNBT( data, "config" );
|
||||
cm.writeToNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
cell.readFromNBT( data, "cell" );
|
||||
config.readFromNBT( data, "config" );
|
||||
cm.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCellWorkbench(NBTTagCompound data)
|
||||
{
|
||||
cell.readFromNBT( data, "cell" );
|
||||
config.readFromNBT( data, "config" );
|
||||
cm.readFromNBT( data );
|
||||
}
|
||||
|
||||
public TileCellWorkbench() {
|
||||
addNewHandler( new TileCellWorkbenchHandler() );
|
||||
cm.registerSetting( Settings.COPY_MODE, CopyMode.CLEAR_ON_REMOVE );
|
||||
cell.enableClientEvents = true;
|
||||
}
|
||||
|
||||
+67
-77
@@ -21,7 +21,7 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.server.AccessType;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -45,105 +45,95 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
private class TileChargerHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCharger(ByteBuf data) throws IOException
|
||||
{
|
||||
|
||||
public TileChargerHandler() {
|
||||
super( TileEventType.TICK, TileEventType.NETWORK );
|
||||
try
|
||||
{
|
||||
IAEItemStack item = AEItemStack.loadItemStackFromPacket( data );
|
||||
ItemStack is = item.getItemStack();
|
||||
inv.setInventorySlotContents( 0, is );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
inv.setInventorySlotContents( 0, null );
|
||||
}
|
||||
return false; // TESR dosn't need updates!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCharger(ByteBuf data) throws IOException
|
||||
{
|
||||
AEItemStack is = AEItemStack.create( getStackInSlot( 0 ) );
|
||||
if ( is != null )
|
||||
is.writeToPacket( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileCharger()
|
||||
{
|
||||
if ( lastUpdate > 60 && requiresUpdate )
|
||||
{
|
||||
requiresUpdate = false;
|
||||
markForUpdate();
|
||||
lastUpdate = 0;
|
||||
}
|
||||
lastUpdate++;
|
||||
|
||||
tickTickTimer++;
|
||||
if ( tickTickTimer < 20 )
|
||||
return;
|
||||
tickTickTimer = 0;
|
||||
|
||||
ItemStack myItem = getStackInSlot( 0 );
|
||||
|
||||
// charge from the network!
|
||||
if ( internalCurrentPower < 1499 )
|
||||
{
|
||||
try
|
||||
{
|
||||
IAEItemStack item = AEItemStack.loadItemStackFromPacket( data );
|
||||
ItemStack is = item.getItemStack();
|
||||
inv.setInventorySlotContents( 0, is );
|
||||
injectExternalPower( PowerUnits.AE,
|
||||
gridProxy.getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - internalCurrentPower ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
tickTickTimer = 20; // keep tickin...
|
||||
}
|
||||
catch (Throwable t)
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
inv.setInventorySlotContents( 0, null );
|
||||
// continue!
|
||||
}
|
||||
return false; // TESR dosn't need updates!
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
if ( myItem == null )
|
||||
return;
|
||||
|
||||
if ( internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
|
||||
{
|
||||
AEItemStack is = AEItemStack.create( getStackInSlot( 0 ) );
|
||||
if ( is != null )
|
||||
is.writeToPacket( data );
|
||||
}
|
||||
IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if ( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
double oldPower = internalCurrentPower;
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
double adjustment = ps.injectAEPower( myItem, extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
internalCurrentPower += adjustment;
|
||||
if ( oldPower > internalCurrentPower )
|
||||
requiresUpdate = true;
|
||||
tickTickTimer = 20; // keep tickin...
|
||||
}
|
||||
}
|
||||
else if ( internalCurrentPower > 1499 && AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( myItem ) )
|
||||
{
|
||||
if ( lastUpdate > 60 && requiresUpdate )
|
||||
if ( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
requiresUpdate = false;
|
||||
markForUpdate();
|
||||
lastUpdate = 0;
|
||||
}
|
||||
lastUpdate++;
|
||||
|
||||
tickTickTimer++;
|
||||
if ( tickTickTimer < 20 )
|
||||
return;
|
||||
tickTickTimer = 0;
|
||||
|
||||
ItemStack myItem = getStackInSlot( 0 );
|
||||
|
||||
// charge from the network!
|
||||
if ( internalCurrentPower < 1499 )
|
||||
{
|
||||
try
|
||||
{
|
||||
injectExternalPower( PowerUnits.AE,
|
||||
gridProxy.getEnergy().extractAEPower( Math.min( 150.0, 1500.0 - internalCurrentPower ), Actionable.MODULATE, PowerMultiplier.ONE ) );
|
||||
tickTickTimer = 20; // keep tickin...
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// continue!
|
||||
}
|
||||
}
|
||||
|
||||
if ( myItem == null )
|
||||
return;
|
||||
|
||||
if ( internalCurrentPower > 149 && Platform.isChargeable( myItem ) )
|
||||
{
|
||||
IAEItemPowerStorage ps = (IAEItemPowerStorage) myItem.getItem();
|
||||
if ( ps.getAEMaxPower( myItem ) > ps.getAECurrentPower( myItem ) )
|
||||
{
|
||||
double oldPower = internalCurrentPower;
|
||||
|
||||
double adjustment = ps.injectAEPower( myItem, extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) );
|
||||
internalCurrentPower += adjustment;
|
||||
if ( oldPower > internalCurrentPower )
|
||||
requiresUpdate = true;
|
||||
tickTickTimer = 20; // keep tickin...
|
||||
}
|
||||
}
|
||||
else if ( internalCurrentPower > 1499 && AEApi.instance().materials().materialCertusQuartzCrystal.sameAsStack( myItem ) )
|
||||
{
|
||||
if ( Platform.getRandomFloat() > 0.8f ) // simulate wait
|
||||
{
|
||||
extractAEPower( internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
setInventorySlotContents( 0, AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( myItem.stackSize ) );
|
||||
}
|
||||
extractAEPower( internalMaxPower, Actionable.MODULATE, PowerMultiplier.CONFIG );// 1500
|
||||
setInventorySlotContents( 0, AEApi.instance().materials().materialCertusQuartzCrystalCharged.stack( myItem.stackSize ) );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public TileCharger() {
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
gridProxy.setFlags();
|
||||
internalMaxPower = 1500;
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
addNewHandler( new TileChargerHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@ import appeng.api.implementations.items.IStorageComponent;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
@@ -34,31 +34,21 @@ public class TileCondenser extends AEBaseInvTile implements IAEAppEngInventory,
|
||||
|
||||
public double storedPower = 0;
|
||||
|
||||
private class TileCondenserHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCondenser(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
data.setDouble( "storedPower", storedPower );
|
||||
}
|
||||
|
||||
public TileCondenserHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
data.setDouble( "storedPower", storedPower );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
storedPower = data.getDouble( "storedPower" );
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCondenser(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
storedPower = data.getDouble( "storedPower" );
|
||||
}
|
||||
|
||||
public TileCondenser() {
|
||||
addNewHandler( new TileCondenserHandler() );
|
||||
cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOuput.TRASH );
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.recipes.handlers.Inscribe;
|
||||
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -57,73 +57,64 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
private class TileInscriberHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileInscriber(NBTTagCompound data)
|
||||
{
|
||||
inv.writeToNBT( data, "inscriberInv" );
|
||||
}
|
||||
|
||||
public TileInscriberHandler() {
|
||||
super( TileEventType.WORLD_NBT, TileEventType.NETWORK );
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileInscriber(NBTTagCompound data)
|
||||
{
|
||||
inv.readFromNBT( data, "inscriberInv" );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileInscriber(ByteBuf data) throws IOException
|
||||
{
|
||||
int slot = data.readByte();
|
||||
|
||||
boolean oldSmash = smash;
|
||||
boolean newSmash = (slot & 64) == 64;
|
||||
|
||||
if ( oldSmash != newSmash && newSmash )
|
||||
{
|
||||
smash = true;
|
||||
clientStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
for (int num = 0; num < inv.getSizeInventory(); num++)
|
||||
{
|
||||
inv.writeToNBT( data, "inscriberInv" );
|
||||
if ( (slot & (1 << num)) > 0 )
|
||||
inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() );
|
||||
else
|
||||
inv.setInventorySlotContents( num, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
return false;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileInscriber(ByteBuf data) throws IOException
|
||||
{
|
||||
int slot = smash ? 64 : 0;
|
||||
|
||||
for (int num = 0; num < inv.getSizeInventory(); num++)
|
||||
{
|
||||
inv.readFromNBT( data, "inscriberInv" );
|
||||
if ( inv.getStackInSlot( num ) != null )
|
||||
slot = slot | (1 << num);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
data.writeByte( slot );
|
||||
for (int num = 0; num < inv.getSizeInventory(); num++)
|
||||
{
|
||||
int slot = data.readByte();
|
||||
|
||||
boolean oldSmash = smash;
|
||||
boolean newSmash = (slot & 64) == 64;
|
||||
|
||||
if ( oldSmash != newSmash && newSmash )
|
||||
if ( (slot & (1 << num)) > 0 )
|
||||
{
|
||||
smash = true;
|
||||
clientStart = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
for (int num = 0; num < inv.getSizeInventory(); num++)
|
||||
{
|
||||
if ( (slot & (1 << num)) > 0 )
|
||||
inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() );
|
||||
else
|
||||
inv.setInventorySlotContents( num, null );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int slot = smash ? 64 : 0;
|
||||
|
||||
for (int num = 0; num < inv.getSizeInventory(); num++)
|
||||
{
|
||||
if ( inv.getStackInSlot( num ) != null )
|
||||
slot = slot | (1 << num);
|
||||
}
|
||||
|
||||
data.writeByte( slot );
|
||||
for (int num = 0; num < inv.getSizeInventory(); num++)
|
||||
{
|
||||
if ( (slot & (1 << num)) > 0 )
|
||||
{
|
||||
AEItemStack st = AEItemStack.create( inv.getStackInSlot( num ) );
|
||||
st.writeToPacket( data );
|
||||
}
|
||||
AEItemStack st = AEItemStack.create( inv.getStackInSlot( num ) );
|
||||
st.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresTESR()
|
||||
@@ -135,7 +126,6 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
internalMaxPower = 1500;
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
addNewHandler( new TileInscriberHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -36,7 +36,7 @@ import appeng.api.util.IConfigureableObject;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
@@ -100,36 +100,24 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IS
|
||||
duality.gridChanged();
|
||||
}
|
||||
|
||||
class TileInterfaceHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileInterface(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "pointAt", pointAt.ordinal() );
|
||||
duality.writeToNBT( data );
|
||||
}
|
||||
|
||||
public TileInterfaceHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileInterface(NBTTagCompound data)
|
||||
{
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "pointAt", pointAt.ordinal() );
|
||||
duality.writeToNBT( data );
|
||||
}
|
||||
if ( val >= 0 && val < ForgeDirection.values().length )
|
||||
pointAt = ForgeDirection.values()[val];
|
||||
else
|
||||
pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
int val = data.getInteger( "pointAt" );
|
||||
|
||||
if ( val >= 0 && val < ForgeDirection.values().length )
|
||||
pointAt = ForgeDirection.values()[val];
|
||||
else
|
||||
pointAt = ForgeDirection.UNKNOWN;
|
||||
|
||||
duality.readFromNBT( data );
|
||||
}
|
||||
};
|
||||
|
||||
public TileInterface() {
|
||||
addNewHandler( new TileInterfaceHandler() );
|
||||
duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -16,28 +16,15 @@ public class TileLightDetector extends AEBaseTile
|
||||
return lastLight > 0;
|
||||
}
|
||||
|
||||
class LightDetectorHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileLightDetector()
|
||||
{
|
||||
|
||||
public LightDetectorHandler() {
|
||||
super( TileEventType.TICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
lastCheck++;
|
||||
if ( lastCheck > 30 )
|
||||
{
|
||||
lastCheck++;
|
||||
if ( lastCheck > 30 )
|
||||
{
|
||||
lastCheck = 0;
|
||||
updateLight();
|
||||
}
|
||||
lastCheck = 0;
|
||||
updateLight();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public TileLightDetector() {
|
||||
addNewHandler( new LightDetectorHandler() );
|
||||
}
|
||||
|
||||
public void updateLight()
|
||||
|
||||
+25
-37
@@ -19,7 +19,7 @@ import appeng.api.util.AEColor;
|
||||
import appeng.helpers.Splot;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -73,45 +73,33 @@ public class TilePaint extends AEBaseTile
|
||||
maxLit();
|
||||
}
|
||||
|
||||
class PaintHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TilePaint(NBTTagCompound data)
|
||||
{
|
||||
|
||||
public PaintHandler() {
|
||||
super( TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
writeBuffer( myDat );
|
||||
if ( myDat.hasArray() )
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "dots" ) )
|
||||
readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
writeBuffer( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
readBuffer( data );
|
||||
return true;
|
||||
}
|
||||
ByteBuf myDat = Unpooled.buffer();
|
||||
writeBuffer( myDat );
|
||||
if ( myDat.hasArray() )
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
|
||||
public TilePaint() {
|
||||
addNewHandler( new PaintHandler() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TilePaint(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "dots" ) )
|
||||
readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TilePaint(ByteBuf data) throws IOException
|
||||
{
|
||||
writeBuffer( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TilePaint(ByteBuf data) throws IOException
|
||||
{
|
||||
readBuffer( data );
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange()
|
||||
|
||||
@@ -11,7 +11,7 @@ import appeng.api.networking.events.MENetworkEventSubscribe;
|
||||
import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
@@ -33,41 +33,31 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
private class TileChargerHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean hadPower = hasPower;
|
||||
hasPower = data.readBoolean();
|
||||
return hasPower != hadPower;
|
||||
}
|
||||
|
||||
public TileChargerHandler() {
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileQuartzGrowthAccelerator(ByteBuf data) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
boolean hadPower = hasPower;
|
||||
hasPower = data.readBoolean();
|
||||
return hasPower != hadPower;
|
||||
data.writeBoolean( gridProxy.getEnergy().isNetworkPowered() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
try
|
||||
{
|
||||
data.writeBoolean( gridProxy.getEnergy().isNetworkPowered() );
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
data.writeBoolean( false );
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public TileQuartzGrowthAccelerator() {
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
gridProxy.setFlags();
|
||||
gridProxy.setIdlePowerUsage( 8 );
|
||||
addNewHandler( new TileChargerHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+54
-63
@@ -47,7 +47,7 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.PlayerSecuirtyWrapper;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.SecurityInventory;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -122,75 +122,67 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
class SecurityHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSecurity(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean wasActive = isActive;
|
||||
isActive = data.readBoolean();
|
||||
|
||||
public SecurityHandler() {
|
||||
super( TileEventType.WORLD_NBT, TileEventType.NETWORK );
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
return oldPaintedColor != paintedColor || wasActive != isActive;
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSecurity(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( gridProxy.isActive() );
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileSecurity(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
|
||||
data.setLong( "securityKey", securityKey );
|
||||
configSlot.writeToNBT( data, "config" );
|
||||
|
||||
NBTTagCompound storedItems = new NBTTagCompound();
|
||||
|
||||
int offset = 0;
|
||||
for (IAEItemStack ais : inventory.storedItems)
|
||||
{
|
||||
NBTTagCompound it = new NBTTagCompound();
|
||||
ais.getItemStack().writeToNBT( it );
|
||||
storedItems.setTag( "" + (offset++), it );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
data.setTag( "storedItems", storedItems );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileSecurity(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
|
||||
securityKey = data.getLong( "securityKey" );
|
||||
configSlot.readFromNBT( data, "config" );
|
||||
|
||||
NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
|
||||
for (Object key : storedItems.func_150296_c())
|
||||
{
|
||||
boolean wasActive = isActive;
|
||||
isActive = data.readBoolean();
|
||||
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
return oldPaintedColor != paintedColor || wasActive != isActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( gridProxy.isActive() );
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
|
||||
data.setLong( "securityKey", securityKey );
|
||||
configSlot.writeToNBT( data, "config" );
|
||||
|
||||
NBTTagCompound storedItems = new NBTTagCompound();
|
||||
|
||||
int offset = 0;
|
||||
for (IAEItemStack ais : inventory.storedItems)
|
||||
NBTBase obj = storedItems.getTag( (String) key );
|
||||
if ( obj instanceof NBTTagCompound )
|
||||
{
|
||||
NBTTagCompound it = new NBTTagCompound();
|
||||
ais.getItemStack().writeToNBT( it );
|
||||
storedItems.setTag( "" + (offset++), it );
|
||||
}
|
||||
|
||||
data.setTag( "storedItems", storedItems );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
|
||||
securityKey = data.getLong( "securityKey" );
|
||||
configSlot.readFromNBT( data, "config" );
|
||||
|
||||
NBTTagCompound storedItems = data.getCompoundTag( "storedItems" );
|
||||
for (Object key : storedItems.func_150296_c())
|
||||
{
|
||||
NBTBase obj = storedItems.getTag( (String) key );
|
||||
if ( obj instanceof NBTTagCompound )
|
||||
{
|
||||
inventory.storedItems.add( AEItemStack.create( ItemStack.loadItemStackFromNBT( (NBTTagCompound) obj ) ) );
|
||||
}
|
||||
inventory.storedItems.add( AEItemStack.create( ItemStack.loadItemStackFromNBT( (NBTTagCompound) obj ) ) );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void inventoryChanged()
|
||||
{
|
||||
@@ -243,7 +235,6 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp
|
||||
}
|
||||
|
||||
public TileSecurity() {
|
||||
addNewHandler( new SecurityHandler() );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
gridProxy.setIdlePowerUsage( 2.0 );
|
||||
diffrence++;
|
||||
|
||||
@@ -19,7 +19,7 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
@@ -46,49 +46,39 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
private class TileVibrationChamberHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileVibrationChamber(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean wasOn = isOn;
|
||||
isOn = data.readBoolean();
|
||||
return wasOn != isOn; // TESR dosn't need updates!
|
||||
}
|
||||
|
||||
public TileVibrationChamberHandler() {
|
||||
super( TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileVibrationChamber(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( burnTime > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean wasOn = isOn;
|
||||
isOn = data.readBoolean();
|
||||
return wasOn != isOn; // TESR dosn't need updates!
|
||||
}
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileVibrationChamber(NBTTagCompound data)
|
||||
{
|
||||
data.setDouble( "burnTime", burnTime );
|
||||
data.setDouble( "maxBurnTime", maxBurnTime );
|
||||
data.setInteger( "burnSpeed", burnSpeed );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( burnTime > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setDouble( "burnTime", burnTime );
|
||||
data.setDouble( "maxBurnTime", maxBurnTime );
|
||||
data.setInteger( "burnSpeed", burnSpeed );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
burnTime = data.getDouble( "burnTime" );
|
||||
maxBurnTime = data.getDouble( "maxBurnTime" );
|
||||
burnSpeed = data.getInteger( "burnSpeed" );
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileVibrationChamber(NBTTagCompound data)
|
||||
{
|
||||
burnTime = data.getDouble( "burnTime" );
|
||||
maxBurnTime = data.getDouble( "maxBurnTime" );
|
||||
burnSpeed = data.getInteger( "burnSpeed" );
|
||||
}
|
||||
|
||||
public TileVibrationChamber() {
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
gridProxy.setFlags();
|
||||
addNewHandler( new TileVibrationChamberHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user