Auto Reflection Based TileEvents.
This commit is contained in:
parent
d2f2316adb
commit
489d6e4262
38 changed files with 935 additions and 1152 deletions
|
@ -12,7 +12,7 @@ import net.minecraftforge.common.ForgeChunkManager.Type;
|
|||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
|
@ -23,27 +23,14 @@ public class TileChunkLoader extends AEBaseTile
|
|||
boolean requestTicket = true;
|
||||
Ticket ct;
|
||||
|
||||
class ChunkLoaderHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileChunkLoader()
|
||||
{
|
||||
|
||||
public ChunkLoaderHandler() {
|
||||
super( TileEventType.TICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
if ( requestTicket )
|
||||
{
|
||||
if ( requestTicket )
|
||||
{
|
||||
requestTicket = false;
|
||||
initTicket();
|
||||
}
|
||||
requestTicket = false;
|
||||
initTicket();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public TileChunkLoader() {
|
||||
addNewHandler( new ChunkLoaderHandler() );
|
||||
}
|
||||
|
||||
void initTicket()
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
package appeng.integration.abstraction.helpers;
|
||||
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
|
||||
public abstract class BaseMJperdition extends AETileEventHandler
|
||||
public abstract class BaseMJperdition
|
||||
{
|
||||
|
||||
public BaseMJperdition() {
|
||||
super( TileEventType.TICK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Method(iname = "MJ5")
|
||||
public abstract PowerReceiver getPowerReceiver();
|
||||
|
||||
|
@ -21,4 +16,10 @@ public abstract class BaseMJperdition extends AETileEventHandler
|
|||
|
||||
public abstract void configure(int i, int j, float f, int k);
|
||||
|
||||
public abstract void writeToNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void readFromNBT(NBTTagCompound tag);
|
||||
|
||||
public abstract void Tick();
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
|
@ -16,38 +15,32 @@ import appeng.tile.inventory.InvOperation;
|
|||
public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventory, IAEAppEngInventory
|
||||
{
|
||||
|
||||
public AEBaseInvTile() {
|
||||
addNewHandler( new AETileEventHandler( TileEventType.WORLD_NBT ) {
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AEBaseInvTile(net.minecraft.nbt.NBTTagCompound data)
|
||||
{
|
||||
IInventory inv = getInternalInventory();
|
||||
NBTTagCompound opt = data.getCompoundTag( "inv" );
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
{
|
||||
NBTTagCompound item = opt.getCompoundTag( "item" + x );
|
||||
inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( item ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(net.minecraft.nbt.NBTTagCompound data)
|
||||
{
|
||||
IInventory inv = getInternalInventory();
|
||||
NBTTagCompound opt = data.getCompoundTag( "inv" );
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
{
|
||||
NBTTagCompound item = opt.getCompoundTag( "item" + x );
|
||||
inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( item ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(net.minecraft.nbt.NBTTagCompound data)
|
||||
{
|
||||
IInventory inv = getInternalInventory();
|
||||
NBTTagCompound opt = new NBTTagCompound();
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
{
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack is = getStackInSlot( x );
|
||||
if ( is != null )
|
||||
is.writeToNBT( item );
|
||||
opt.setTag( "item" + x, item );
|
||||
}
|
||||
data.setTag( "inv", opt );
|
||||
}
|
||||
|
||||
} );
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AEBaseInvTile(net.minecraft.nbt.NBTTagCompound data)
|
||||
{
|
||||
IInventory inv = getInternalInventory();
|
||||
NBTTagCompound opt = new NBTTagCompound();
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
{
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
ItemStack is = getStackInSlot( x );
|
||||
if ( is != null )
|
||||
is.writeToNBT( item );
|
||||
opt.setTag( "item" + x, item );
|
||||
}
|
||||
data.setTag( "inv", opt );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,9 +3,9 @@ package appeng.tile;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -38,8 +38,8 @@ import appeng.util.SettingsFrom;
|
|||
public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, ICustomNameObject
|
||||
{
|
||||
|
||||
private final EnumMap<TileEventType, List<AETileEventHandler>> handlers = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class );
|
||||
private final static HashMap<Class, ItemStackSrc> myItem = new HashMap();
|
||||
static private final HashMap<Class, EnumMap<TileEventType, List<AETileEventHandler>>> handlers = new HashMap<Class, EnumMap<TileEventType, List<AETileEventHandler>>>();
|
||||
static private final HashMap<Class, ItemStackSrc> myItem = new HashMap();
|
||||
|
||||
private ForgeDirection forward = ForgeDirection.UNKNOWN;
|
||||
private ForgeDirection up = ForgeDirection.UNKNOWN;
|
||||
|
@ -73,26 +73,45 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
|
||||
protected boolean hasHandlerFor(TileEventType type)
|
||||
{
|
||||
List<AETileEventHandler> list = handlers.get( type );
|
||||
List<AETileEventHandler> list = getHandlerListFor( type );
|
||||
return list != null;
|
||||
}
|
||||
|
||||
protected List<AETileEventHandler> getHandlerListFor(TileEventType type)
|
||||
{
|
||||
List<AETileEventHandler> list = handlers.get( type );
|
||||
Class clz = getClass();
|
||||
EnumMap<TileEventType, List<AETileEventHandler>> handlerSet = handlers.get( clz );
|
||||
|
||||
if ( handlerSet == null )
|
||||
{
|
||||
handlers.put( clz, handlerSet = new EnumMap<TileEventType, List<AETileEventHandler>>( TileEventType.class ) );
|
||||
|
||||
for (Method m : clz.getMethods())
|
||||
{
|
||||
TileEvent te = m.getAnnotation( TileEvent.class );
|
||||
if ( te != null )
|
||||
{
|
||||
addHandler( handlerSet, te.value(), m );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<AETileEventHandler> list = handlerSet.get( type );
|
||||
|
||||
if ( list == null )
|
||||
handlers.put( type, list = new LinkedList<AETileEventHandler>() );
|
||||
handlerSet.put( type, list = new LinkedList<AETileEventHandler>() );
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
protected void addNewHandler(AETileEventHandler handler)
|
||||
private void addHandler(EnumMap<TileEventType, List<AETileEventHandler>> handlerSet, TileEventType value, Method m)
|
||||
{
|
||||
EnumSet<TileEventType> types = handler.getSubscribedEvents();
|
||||
List<AETileEventHandler> list = handlerSet.get( value );
|
||||
|
||||
for (TileEventType type : types)
|
||||
getHandlerListFor( type ).add( handler );
|
||||
if ( list == null )
|
||||
handlerSet.put( value, list = new ArrayList() );
|
||||
|
||||
list.add( new AETileEventHandler( m, value ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -101,11 +120,16 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
return hasHandlerFor( TileEventType.TICK );
|
||||
}
|
||||
|
||||
final public void Tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
final public void updateEntity()
|
||||
{
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.TICK ))
|
||||
h.Tick();
|
||||
h.Tick( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,7 +150,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
final public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
|
||||
|
@ -139,13 +163,13 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
if ( customName != null )
|
||||
data.setString( "customName", customName );
|
||||
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.WORLD_NBT ))
|
||||
h.writeToNBT( data );
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.WORLD_NBT_WRITE ))
|
||||
h.writeToNBT( this, data );
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
final public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
|
@ -166,9 +190,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
{
|
||||
}
|
||||
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.WORLD_NBT ))
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.WORLD_NBT_READ ))
|
||||
{
|
||||
h.readFromNBT( data );
|
||||
h.readFromNBT( this, data );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,8 +206,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.NETWORK ))
|
||||
h.writeToStream( data );
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.NETWORK_WRITE ))
|
||||
h.writeToStream( this, data );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
|
@ -191,7 +215,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
}
|
||||
}
|
||||
|
||||
final public boolean readfromStream(ByteBuf data)
|
||||
final public boolean readFromStream(ByteBuf data)
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
|
@ -211,8 +235,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
}
|
||||
|
||||
renderFragment = 100;
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.NETWORK ))
|
||||
if ( h.readFromStream( data ) )
|
||||
for (AETileEventHandler h : getHandlerListFor( TileEventType.NETWORK_READ ))
|
||||
if ( h.readFromStream( this, data ) )
|
||||
output = true;
|
||||
|
||||
if ( (renderFragment & 1) == 1 )
|
||||
|
@ -296,7 +320,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
if ( pkt.func_148853_f() == 64 )
|
||||
{
|
||||
ByteBuf stream = Unpooled.copiedBuffer( pkt.func_148857_g().getByteArray( "X" ) );
|
||||
if ( readfromStream( stream ) )
|
||||
if ( readFromStream( stream ) )
|
||||
markForUpdate();
|
||||
}
|
||||
}
|
||||
|
|
13
tile/TileEvent.java
Normal file
13
tile/TileEvent.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package appeng.tile;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TileEvent {
|
||||
|
||||
TileEventType value();
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
@ -28,61 +28,48 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
|||
IAEItemStack dspPlay;
|
||||
AEColor paintedColor = AEColor.Transparent;
|
||||
|
||||
class CraftingMonitorHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCraftingMonitorTile(ByteBuf data) throws IOException
|
||||
{
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
public CraftingMonitorHandler() {
|
||||
super( TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
boolean hasItem = data.readBoolean();
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
if ( hasItem )
|
||||
dspPlay = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
dspPlay = null;
|
||||
|
||||
updateList = true;
|
||||
return oldPaintedColor != paintedColor; // tesr!
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCraftingMonitorTile(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
|
||||
if ( dspPlay == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
boolean hasItem = data.readBoolean();
|
||||
|
||||
if ( hasItem )
|
||||
dspPlay = AEItemStack.loadItemStackFromPacket( data );
|
||||
else
|
||||
dspPlay = null;
|
||||
|
||||
updateList = true;
|
||||
return oldPaintedColor != paintedColor; // tesr!
|
||||
data.writeBoolean( true );
|
||||
dspPlay.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCraftingMonitorTile(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
if ( dspPlay == null )
|
||||
data.writeBoolean( false );
|
||||
else
|
||||
{
|
||||
data.writeBoolean( true );
|
||||
dspPlay.writeToPacket( data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public TileCraftingMonitorTile() {
|
||||
addNewHandler( new CraftingMonitorHandler() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCraftingMonitorTile(NBTTagCompound data)
|
||||
{
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
public boolean isAccelerator()
|
||||
|
|
|
@ -28,7 +28,7 @@ import appeng.me.cluster.implementations.CraftingCPUCalculator;
|
|||
import appeng.me.cluster.implementations.CraftingCPUCluster;
|
||||
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;
|
||||
import appeng.util.Platform;
|
||||
|
@ -78,38 +78,28 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
|||
clust.updateName();
|
||||
}
|
||||
|
||||
private class CraftingHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCraftingTile(NBTTagCompound data)
|
||||
{
|
||||
data.setBoolean( "core", isCoreBlock );
|
||||
if ( isCoreBlock && clust != null )
|
||||
clust.writeToNBT( data );
|
||||
}
|
||||
|
||||
public CraftingHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCraftingTile(NBTTagCompound data)
|
||||
{
|
||||
isCoreBlock = data.getBoolean( "core" );
|
||||
if ( isCoreBlock )
|
||||
{
|
||||
data.setBoolean( "core", isCoreBlock );
|
||||
if ( isCoreBlock && clust != null )
|
||||
clust.writeToNBT( data );
|
||||
if ( clust != null )
|
||||
clust.readFromNBT( data );
|
||||
else
|
||||
previousState = (NBTTagCompound) data.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
isCoreBlock = data.getBoolean( "core" );
|
||||
if ( isCoreBlock )
|
||||
{
|
||||
if ( clust != null )
|
||||
clust.readFromNBT( data );
|
||||
else
|
||||
previousState = (NBTTagCompound) data.copy();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public TileCraftingTile() {
|
||||
addNewHandler( new CraftingHandler() );
|
||||
gridProxy.setFlags( GridFlags.MULTIBLOCK, GridFlags.REQUIRE_CHANNEL );
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import appeng.core.sync.packets.PacketAssemblerAnimation;
|
|||
import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
@ -175,81 +175,71 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IAEAppEn
|
|||
return 5;
|
||||
}
|
||||
|
||||
private class TileMolecularAssemblerHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileMolecularAssembler(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean oldPower = isPowered;
|
||||
isPowered = data.readBoolean();
|
||||
return isPowered != oldPower;
|
||||
}
|
||||
|
||||
public TileMolecularAssemblerHandler() {
|
||||
super( TileEventType.WORLD_NBT, TileEventType.NETWORK );
|
||||
}
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileMolecularAssembler(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( isPowered );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileMolecularAssembler(NBTTagCompound data)
|
||||
{
|
||||
if ( forcePlan && myPlan != null )
|
||||
{
|
||||
boolean oldPower = isPowered;
|
||||
isPowered = data.readBoolean();
|
||||
return isPowered != oldPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( isPowered );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
if ( forcePlan && myPlan != null )
|
||||
ItemStack pattern = myPlan.getPattern();
|
||||
if ( pattern != null )
|
||||
{
|
||||
ItemStack pattern = myPlan.getPattern();
|
||||
if ( pattern != null )
|
||||
NBTTagCompound pdata = new NBTTagCompound();
|
||||
pattern.writeToNBT( pdata );
|
||||
data.setTag( "myPlan", pdata );
|
||||
data.setInteger( "pushDirection", pushDirection.ordinal() );
|
||||
}
|
||||
}
|
||||
|
||||
upgrades.writeToNBT( data, "upgrades" );
|
||||
inv.writeToNBT( data, "inv" );
|
||||
settings.writeToNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileMolecularAssembler(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "myPlan" ) )
|
||||
{
|
||||
ItemStack myPat = ItemStack.loadItemStackFromNBT( data.getCompoundTag( "myPlan" ) );
|
||||
|
||||
if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
World w = getWorldObj();
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem();
|
||||
ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w );
|
||||
if ( ph != null && ph.isCraftable() )
|
||||
{
|
||||
NBTTagCompound pdata = new NBTTagCompound();
|
||||
pattern.writeToNBT( pdata );
|
||||
data.setTag( "myPlan", pdata );
|
||||
data.setInteger( "pushDirection", pushDirection.ordinal() );
|
||||
forcePlan = true;
|
||||
myPlan = ph;
|
||||
pushDirection = ForgeDirection.getOrientation( data.getInteger( "pushDirection" ) );
|
||||
}
|
||||
}
|
||||
|
||||
upgrades.writeToNBT( data, "upgrades" );
|
||||
inv.writeToNBT( data, "inv" );
|
||||
settings.writeToNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
if ( data.hasKey( "myPlan" ) )
|
||||
{
|
||||
ItemStack myPat = ItemStack.loadItemStackFromNBT( data.getCompoundTag( "myPlan" ) );
|
||||
|
||||
if ( myPat != null && myPat.getItem() instanceof ItemEncodedPattern )
|
||||
{
|
||||
World w = getWorldObj();
|
||||
ItemEncodedPattern iep = (ItemEncodedPattern) myPat.getItem();
|
||||
ICraftingPatternDetails ph = iep.getPatternForItem( myPat, w );
|
||||
if ( ph != null && ph.isCraftable() )
|
||||
{
|
||||
forcePlan = true;
|
||||
myPlan = ph;
|
||||
pushDirection = ForgeDirection.getOrientation( data.getInteger( "pushDirection" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
upgrades.readFromNBT( data, "upgrades" );
|
||||
inv.readFromNBT( data, "inv" );
|
||||
settings.readFromNBT( data );
|
||||
recalculatePlan();
|
||||
}
|
||||
|
||||
};
|
||||
upgrades.readFromNBT( data, "upgrades" );
|
||||
inv.readFromNBT( data, "inv" );
|
||||
settings.readFromNBT( data );
|
||||
recalculatePlan();
|
||||
}
|
||||
|
||||
public TileMolecularAssembler() {
|
||||
settings.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
inv.setMaxStackSize( 1 );
|
||||
gridProxy.setIdlePowerUsage( 0.0 );
|
||||
addNewHandler( new TileMolecularAssemblerHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,46 +3,107 @@ package appeng.tile.events;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class AETileEventHandler
|
||||
public class AETileEventHandler
|
||||
{
|
||||
|
||||
final EnumSet<TileEventType> supportedEvents;
|
||||
private final Method method;
|
||||
private final TileEventType type;
|
||||
|
||||
public AETileEventHandler(TileEventType... events) {
|
||||
supportedEvents = EnumSet.noneOf( TileEventType.class );
|
||||
for (TileEventType t : events)
|
||||
supportedEvents.add( t );
|
||||
}
|
||||
|
||||
public EnumSet<TileEventType> getSubscribedEvents()
|
||||
{
|
||||
return supportedEvents;
|
||||
public AETileEventHandler(Method m, TileEventType which) {
|
||||
method = m;
|
||||
type = which;
|
||||
}
|
||||
|
||||
// TICK
|
||||
public void Tick()
|
||||
public void Tick(AEBaseTile tile)
|
||||
{
|
||||
try
|
||||
{
|
||||
method.invoke( tile );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// WORLD_NBT
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
public void writeToNBT(AEBaseTile tile, NBTTagCompound data)
|
||||
{
|
||||
try
|
||||
{
|
||||
method.invoke( tile, data );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// WORLD NBT
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
public void readFromNBT(AEBaseTile tile, NBTTagCompound data)
|
||||
{
|
||||
try
|
||||
{
|
||||
method.invoke( tile, data );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
public void writeToStream(AEBaseTile tile, ByteBuf data) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
method.invoke( tile, data );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
|
@ -54,9 +115,24 @@ public abstract class AETileEventHandler
|
|||
* @throws IOException
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
public boolean readFromStream(AEBaseTile tile, ByteBuf data) throws IOException
|
||||
{
|
||||
return false;
|
||||
try
|
||||
{
|
||||
return (Boolean) method.invoke( tile, data );
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,5 +2,9 @@ package appeng.tile.events;
|
|||
|
||||
public enum TileEventType
|
||||
{
|
||||
TICK, WORLD_NBT, NETWORK
|
||||
TICK,
|
||||
|
||||
WORLD_NBT_READ, WORLD_NBT_WRITE,
|
||||
|
||||
NETWORK_READ, NETWORK_WRITE
|
||||
}
|
||||
|
|
|
@ -7,35 +7,22 @@ import appeng.api.networking.security.IActionHost;
|
|||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable
|
||||
{
|
||||
|
||||
class AENetworkInvTileHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AENetwork(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
public AENetworkInvTileHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public AENetworkInvTile() {
|
||||
addNewHandler( new AENetworkInvTileHandler() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AENetwork(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
protected AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", getItemFromTile( this ), true );
|
||||
|
|
|
@ -8,36 +8,23 @@ import appeng.api.util.AECableType;
|
|||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.powersink.AEBasePoweredTile;
|
||||
|
||||
public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IActionHost, IGridProxyable
|
||||
{
|
||||
|
||||
class AENetworkPowerTileHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AENetwork(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
public AENetworkPowerTileHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public AENetworkPowerTile() {
|
||||
addNewHandler( new AENetworkPowerTileHandler() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AENetwork(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
protected AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", getItemFromTile( this ), true );
|
||||
|
|
|
@ -9,35 +9,22 @@ import appeng.api.util.DimensionalCoord;
|
|||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable
|
||||
{
|
||||
|
||||
class AENetworkTileHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AENetwork(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
public AENetworkTileHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public AENetworkTile() {
|
||||
addNewHandler( new AENetworkTileHandler() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AENetwork(NBTTagCompound data)
|
||||
{
|
||||
gridProxy.writeToNBT( data );
|
||||
}
|
||||
|
||||
final protected AENetworkProxy gridProxy = createProxy();
|
||||
|
|
|
@ -13,7 +13,7 @@ import net.minecraftforge.common.util.ForgeDirection;
|
|||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -29,42 +29,36 @@ public class TileCrank extends AEBaseTile implements ICustomCollision
|
|||
public int hits = 0;
|
||||
public int rotation = 0;
|
||||
|
||||
public TileCrank() {
|
||||
addNewHandler( new AETileEventHandler( TileEventType.NETWORK, TileEventType.TICK ) {
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileCrank()
|
||||
{
|
||||
if ( rotation > 0 )
|
||||
{
|
||||
visibleRotation -= 360 / (ticksPerRoation);
|
||||
charge++;
|
||||
if ( charge >= ticksPerRoation )
|
||||
{
|
||||
if ( rotation > 0 )
|
||||
{
|
||||
visibleRotation -= 360 / (ticksPerRoation);
|
||||
charge++;
|
||||
if ( charge >= ticksPerRoation )
|
||||
{
|
||||
charge -= ticksPerRoation;
|
||||
ICrankable g = getGrinder();
|
||||
if ( g != null )
|
||||
g.applyTurn();
|
||||
}
|
||||
|
||||
rotation--;
|
||||
}
|
||||
charge -= ticksPerRoation;
|
||||
ICrankable g = getGrinder();
|
||||
if ( g != null )
|
||||
g.applyTurn();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws java.io.IOException
|
||||
{
|
||||
rotation = data.readInt();
|
||||
return false;
|
||||
}
|
||||
rotation--;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws java.io.IOException
|
||||
{
|
||||
data.writeInt( rotation );
|
||||
}
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCrank(ByteBuf data) throws java.io.IOException
|
||||
{
|
||||
rotation = data.readInt();
|
||||
return false;
|
||||
}
|
||||
|
||||
} );
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCrank(ByteBuf data) throws java.io.IOException
|
||||
{
|
||||
data.writeInt( rotation );
|
||||
}
|
||||
|
||||
public ICrankable getGrinder()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,7 +33,7 @@ import appeng.integration.IntegrationType;
|
|||
import appeng.integration.abstraction.IImmibisMicroblocks;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -43,49 +43,40 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
public CableBusContainer cb = new CableBusContainer( this );
|
||||
private int oldLV = -1; // on re-calculate light when it changes
|
||||
|
||||
class CableBusHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileCableBus(NBTTagCompound data)
|
||||
{
|
||||
cb.readFromNBT( data );
|
||||
}
|
||||
|
||||
public CableBusHandler() {
|
||||
super( TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileCableBus(NBTTagCompound data)
|
||||
{
|
||||
cb.writeToNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileCableBus(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean ret = cb.readFromStream( data );
|
||||
|
||||
int newLV = cb.getLightValue();
|
||||
if ( newLV != oldLV )
|
||||
{
|
||||
cb.readFromNBT( data );
|
||||
oldLV = newLV;
|
||||
worldObj.func_147451_t( xCoord, yCoord, zCoord );
|
||||
// worldObj.updateAllLightTypes( xCoord, yCoord, zCoord );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
cb.writeToNBT( data );
|
||||
}
|
||||
updateTileSetting();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
boolean ret = cb.readFromStream( data );
|
||||
|
||||
int newLV = cb.getLightValue();
|
||||
if ( newLV != oldLV )
|
||||
{
|
||||
oldLV = newLV;
|
||||
worldObj.func_147451_t( xCoord, yCoord, zCoord );
|
||||
// worldObj.updateAllLightTypes( xCoord, yCoord, zCoord );
|
||||
}
|
||||
|
||||
updateTileSetting();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
cb.writeToStream( data );
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileCableBus(ByteBuf data) throws IOException
|
||||
{
|
||||
cb.writeToStream( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInWorld()
|
||||
|
@ -171,10 +162,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
|||
cb.getDrops( drops );
|
||||
}
|
||||
|
||||
public TileCableBus() {
|
||||
addNewHandler( new CableBusHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getGridNode(ForgeDirection dir)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ import appeng.api.config.PowerMultiplier;
|
|||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
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.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
@ -26,36 +26,28 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
|||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
private class TilePowerRelayHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileEnergyAcceptor()
|
||||
{
|
||||
|
||||
public TilePowerRelayHandler() {
|
||||
super( TileEventType.TICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
if ( internalCurrentPower > 0 )
|
||||
{
|
||||
if ( internalCurrentPower > 0 )
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
IEnergyGrid eg = gridProxy.getEnergy();
|
||||
double powerRequested = internalCurrentPower - eg.injectPower( internalCurrentPower, Actionable.SIMULATE );
|
||||
IEnergyGrid eg = gridProxy.getEnergy();
|
||||
double powerRequested = internalCurrentPower - eg.injectPower( internalCurrentPower, Actionable.SIMULATE );
|
||||
|
||||
if ( powerRequested > 0 )
|
||||
{
|
||||
eg.injectPower( extractAEPower( powerRequested, Actionable.MODULATE, PowerMultiplier.ONE ), Actionable.MODULATE );
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
if ( powerRequested > 0 )
|
||||
{
|
||||
// null net, probably bads.
|
||||
eg.injectPower( extractAEPower( powerRequested, Actionable.MODULATE, PowerMultiplier.ONE ), Actionable.MODULATE );
|
||||
}
|
||||
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// null net, probably bads.
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected double getFunnelPowerDemand(double maxRequired)
|
||||
|
@ -90,7 +82,6 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
|||
|
||||
public TileEnergyAcceptor() {
|
||||
gridProxy.setIdlePowerUsage( 0.0 );
|
||||
addNewHandler( new TilePowerRelayHandler() );
|
||||
internalMaxPower = 100;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import appeng.api.networking.events.MENetworkPowerStorage;
|
|||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
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.SettingsFrom;
|
||||
|
@ -48,31 +48,21 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
|||
}
|
||||
}
|
||||
|
||||
private class TileEnergyCellHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileEnergyCell(NBTTagCompound data)
|
||||
{
|
||||
if ( !worldObj.isRemote )
|
||||
data.setDouble( "internalCurrentPower", internalCurrentPower );
|
||||
}
|
||||
|
||||
public TileEnergyCellHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
if ( !worldObj.isRemote )
|
||||
data.setDouble( "internalCurrentPower", internalCurrentPower );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileEnergyCell(NBTTagCompound data)
|
||||
{
|
||||
internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
public TileEnergyCell() {
|
||||
gridProxy.setIdlePowerUsage( 0 );
|
||||
addNewHandler( new TileEnergyCellHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ import appeng.api.util.AECableType;
|
|||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.AEConfig;
|
||||
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;
|
||||
|
@ -40,7 +40,6 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
|||
public TileWireless() {
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
addNewHandler( new TileWirelessHandler() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,45 +61,34 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
|||
markForUpdate();
|
||||
}
|
||||
|
||||
class TileWirelessHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileWireless(ByteBuf data) throws IOException
|
||||
{
|
||||
int old = clientFlags;
|
||||
clientFlags = data.readByte();
|
||||
|
||||
public TileWirelessHandler() {
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
return old != clientFlags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileWireless(ByteBuf data) throws IOException
|
||||
{
|
||||
clientFlags = 0;
|
||||
|
||||
try
|
||||
{
|
||||
boolean eh = super.readFromStream( data );
|
||||
if ( gridProxy.getEnergy().isNetworkPowered() )
|
||||
clientFlags |= POWERED_FLAG;
|
||||
|
||||
int old = clientFlags;
|
||||
clientFlags = data.readByte();
|
||||
|
||||
return eh || old != clientFlags;
|
||||
if ( gridProxy.getNode().meetsChannelRequirements() )
|
||||
clientFlags |= CHANNEL_FLAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
|
||||
clientFlags = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if ( gridProxy.getEnergy().isNetworkPowered() )
|
||||
clientFlags |= POWERED_FLAG;
|
||||
|
||||
if ( gridProxy.getNode().meetsChannelRequirements() )
|
||||
clientFlags |= CHANNEL_FLAG;
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
// meh
|
||||
}
|
||||
|
||||
data.writeByte( (byte) clientFlags );
|
||||
// meh
|
||||
}
|
||||
|
||||
data.writeByte( (byte) clientFlags );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,7 @@ import appeng.api.config.PowerUnits;
|
|||
import appeng.api.networking.energy.IAEPowerStorage;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage.PowerEventType;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowerStorage
|
||||
|
@ -40,29 +40,16 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe
|
|||
return internalPowerSides.clone();
|
||||
}
|
||||
|
||||
private class AEPoweredRootHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_AERootPoweredTile(NBTTagCompound data)
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", internalCurrentPower );
|
||||
}
|
||||
|
||||
public AEPoweredRootHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", internalCurrentPower );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public AERootPoweredTile() {
|
||||
addNewHandler( new AEPoweredRootHandler() );
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_AERootPoweredTile(NBTTagCompound data)
|
||||
{
|
||||
internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
final protected double getExternalPowerDemand(PowerUnits externalUnit, double maxPowerRequired)
|
||||
|
|
|
@ -7,6 +7,8 @@ import appeng.core.AppEng;
|
|||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.IMJ5;
|
||||
import appeng.integration.abstraction.helpers.BaseMJperdition;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
|
@ -20,6 +22,14 @@ public abstract class MinecraftJoules5 extends AERootPoweredTile implements IPow
|
|||
|
||||
BaseMJperdition bcPowerWrapper;
|
||||
|
||||
@Method(iname = "MJ5")
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_MinecraftJoules5()
|
||||
{
|
||||
if ( bcPowerWrapper != null )
|
||||
bcPowerWrapper.Tick();
|
||||
}
|
||||
|
||||
public MinecraftJoules5() {
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
|
@ -30,7 +40,7 @@ public abstract class MinecraftJoules5 extends AERootPoweredTile implements IPow
|
|||
IMJ5 mjIntegration = (IMJ5) AppEng.instance.getIntegration( IntegrationType.MJ5 );
|
||||
if ( mjIntegration != null )
|
||||
{
|
||||
addNewHandler( bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this ) );
|
||||
bcPowerWrapper = (BaseMJperdition) mjIntegration.createPerdition( this );
|
||||
if ( bcPowerWrapper != null )
|
||||
bcPowerWrapper.configure( 1, 380, 1.0f / 5.0f, 1000 );
|
||||
}
|
||||
|
|
|
@ -3,9 +3,10 @@ package appeng.tile.powersink;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import Reika.RotaryCraft.API.ShaftPowerReceiver;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.transformer.annotations.integration.Interface;
|
||||
import appeng.transformer.annotations.integration.Method;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@Interface(iname = "RotaryCraft", iface = "Reika.RotaryCraft.API.ShaftPowerReceiver")
|
||||
|
@ -17,25 +18,12 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver
|
|||
private long power = 0;
|
||||
private int alpha = 0;
|
||||
|
||||
class RotaryCraftHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.TICK)
|
||||
@Method(iname = "RotaryCraft")
|
||||
public void Tick_RotaryCraft()
|
||||
{
|
||||
|
||||
public RotaryCraftHandler() {
|
||||
super( TileEventType.TICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
{
|
||||
if ( power > 0 )
|
||||
injectExternalPower( PowerUnits.WA, power );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public RotaryCraft() {
|
||||
if ( Platform.isServer() )
|
||||
addNewHandler( new RotaryCraftHandler() );
|
||||
if ( worldObj != null && !worldObj.isRemote && power > 0 )
|
||||
injectExternalPower( PowerUnits.WA, power );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,7 +21,7 @@ import appeng.me.cluster.IAECluster;
|
|||
import appeng.me.cluster.IAEMultiBlock;
|
||||
import appeng.me.cluster.implementations.QuantumCalculator;
|
||||
import appeng.me.cluster.implementations.QuantumCluster;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
@ -50,57 +50,46 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
|||
|
||||
private boolean updateStatus = false;
|
||||
|
||||
class QBridgeHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileQuantumBridge()
|
||||
{
|
||||
|
||||
public QBridgeHandler() {
|
||||
super( TileEventType.NETWORK, TileEventType.TICK );
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
gridProxy.setFlags( GridFlags.DENSE_CAPACITY );
|
||||
gridProxy.setIdlePowerUsage( 22 );
|
||||
inv.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
if ( updateStatus )
|
||||
{
|
||||
if ( updateStatus )
|
||||
{
|
||||
updateStatus = false;
|
||||
if ( clust != null )
|
||||
clust.updateStatus( true );
|
||||
markForUpdate();
|
||||
}
|
||||
updateStatus = false;
|
||||
if ( clust != null )
|
||||
clust.updateStatus( true );
|
||||
markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int out = xdex;
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileQuantumBridge(ByteBuf data) throws IOException
|
||||
{
|
||||
int out = xdex;
|
||||
|
||||
if ( getStackInSlot( 0 ) != null && xdex != -1 )
|
||||
out = out | hasSingularity;
|
||||
if ( getStackInSlot( 0 ) != null && xdex != -1 )
|
||||
out = out | hasSingularity;
|
||||
|
||||
if ( gridProxy.isActive() && xdex != -1 )
|
||||
out = out | powered;
|
||||
if ( gridProxy.isActive() && xdex != -1 )
|
||||
out = out | powered;
|
||||
|
||||
data.writeByte( (byte) out );
|
||||
}
|
||||
data.writeByte( (byte) out );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int oldValue = xdex;
|
||||
xdex = data.readByte();
|
||||
bridgePowered = (xdex | powered) == powered;
|
||||
return xdex != oldValue;
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileQuantumBridge(ByteBuf data) throws IOException
|
||||
{
|
||||
int oldValue = xdex;
|
||||
xdex = data.readByte();
|
||||
bridgePowered = (xdex | powered) == powered;
|
||||
return xdex != oldValue;
|
||||
}
|
||||
|
||||
public TileQuantumBridge() {
|
||||
addNewHandler( new QBridgeHandler() );
|
||||
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
|
||||
gridProxy.setFlags( GridFlags.DENSE_CAPACITY );
|
||||
gridProxy.setIdlePowerUsage( 22 );
|
||||
inv.setMaxStackSize( 1 );
|
||||
}
|
||||
|
||||
public IInventory getInternalInventory()
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ import appeng.api.util.IConfigManager;
|
|||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
@ -143,114 +143,105 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
recalculateDisplay();
|
||||
}
|
||||
|
||||
private class invManger extends AETileEventHandler
|
||||
@TileEvent(TileEventType.TICK)
|
||||
public void Tick_TileChest()
|
||||
{
|
||||
if ( worldObj.isRemote )
|
||||
return;
|
||||
|
||||
public invManger() {
|
||||
super( TileEventType.TICK, TileEventType.NETWORK, TileEventType.WORLD_NBT );
|
||||
}
|
||||
double idleUsage = gridProxy.getIdlePowerUsage();
|
||||
|
||||
@Override
|
||||
public void Tick()
|
||||
try
|
||||
{
|
||||
if ( worldObj.isRemote )
|
||||
return;
|
||||
|
||||
double idleUsage = gridProxy.getIdlePowerUsage();
|
||||
|
||||
try
|
||||
if ( !gridProxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
if ( !gridProxy.getEnergy().isNetworkPowered() )
|
||||
{
|
||||
double powerUsed = extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (state & 0x40) > 0 )
|
||||
recalculateDisplay();
|
||||
}
|
||||
}
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
double powerUsed = extractAEPower( gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
double powerUsed = extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (state & 0x40) > 0 )
|
||||
recalculateDisplay();
|
||||
}
|
||||
|
||||
if ( inv.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
tryToStoreContents();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
catch (GridAccessException e)
|
||||
{
|
||||
if ( worldObj.getTotalWorldTime() - lastStateChange > 8 )
|
||||
state = 0;
|
||||
else
|
||||
state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
|
||||
if ( isPowered() )
|
||||
state |= 0x40;
|
||||
else
|
||||
state &= ~0x40;
|
||||
|
||||
data.writeByte( state );
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
|
||||
ItemStack is = inv.getStackInSlot( 1 );
|
||||
|
||||
if ( is == null )
|
||||
{
|
||||
data.writeInt( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
data.writeInt( (is.getItemDamage() << Platform.DEF_OFFSET) | Item.getIdFromItem( is.getItem() ) );
|
||||
}
|
||||
double powerUsed = extractAEPower( gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain
|
||||
if ( powerUsed + 0.1 >= idleUsage != (state & 0x40) > 0 )
|
||||
recalculateDisplay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
if ( inv.getStackInSlot( 0 ) != null )
|
||||
{
|
||||
int oldState = state;
|
||||
ItemStack oldType = storageType;
|
||||
|
||||
state = data.readByte();
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
int item = data.readInt();
|
||||
|
||||
if ( item == 0 )
|
||||
storageType = null;
|
||||
else
|
||||
storageType = new ItemStack( Item.getItemById( item & 0xffff ), 1, item >> Platform.DEF_OFFSET );
|
||||
|
||||
lastStateChange = worldObj.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != paintedColor || (state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB) || !Platform.isSameItemPrecise( oldType, storageType );
|
||||
tryToStoreContents();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileChest(ByteBuf data) throws IOException
|
||||
{
|
||||
if ( worldObj.getTotalWorldTime() - lastStateChange > 8 )
|
||||
state = 0;
|
||||
else
|
||||
state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
|
||||
if ( isPowered() )
|
||||
state |= 0x40;
|
||||
else
|
||||
state &= ~0x40;
|
||||
|
||||
data.writeByte( state );
|
||||
data.writeByte( paintedColor.ordinal() );
|
||||
|
||||
ItemStack is = inv.getStackInSlot( 1 );
|
||||
|
||||
if ( is == null )
|
||||
{
|
||||
config.readFromNBT( data );
|
||||
priority = data.getInteger( "priority" );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
data.writeInt( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
else
|
||||
{
|
||||
config.writeToNBT( data );
|
||||
data.setInteger( "priority", priority );
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
data.writeInt( (is.getItemDamage() << Platform.DEF_OFFSET) | Item.getIdFromItem( is.getItem() ) );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileChest(ByteBuf data) throws IOException
|
||||
{
|
||||
int oldState = state;
|
||||
ItemStack oldType = storageType;
|
||||
|
||||
state = data.readByte();
|
||||
AEColor oldPaintedColor = paintedColor;
|
||||
paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
int item = data.readInt();
|
||||
|
||||
if ( item == 0 )
|
||||
storageType = null;
|
||||
else
|
||||
storageType = new ItemStack( Item.getItemById( item & 0xffff ), 1, item >> Platform.DEF_OFFSET );
|
||||
|
||||
lastStateChange = worldObj.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != paintedColor || (state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB) || !Platform.isSameItemPrecise( oldType, storageType );
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileChest(NBTTagCompound data)
|
||||
{
|
||||
config.readFromNBT( data );
|
||||
priority = data.getInteger( "priority" );
|
||||
if ( data.hasKey( "paintedColor" ) )
|
||||
paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileChest(NBTTagCompound data)
|
||||
{
|
||||
config.writeToNBT( data );
|
||||
data.setInteger( "priority", priority );
|
||||
data.setByte( "paintedColor", (byte) paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
|
@ -267,7 +258,6 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan
|
|||
public TileChest() {
|
||||
internalMaxPower = PowerMultiplier.CONFIG.multiply( 40 );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
addNewHandler( new invManger() );
|
||||
config.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
config.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
config.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
|
|
@ -32,7 +32,7 @@ import appeng.helpers.IPriorityHost;
|
|||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.DriveWatcher;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
@ -87,55 +87,46 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
|||
markForUpdate();
|
||||
}
|
||||
|
||||
private class invManger extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileDrive(ByteBuf data) throws IOException
|
||||
{
|
||||
if ( worldObj.getTotalWorldTime() - lastStateChange > 8 )
|
||||
state = 0;
|
||||
else
|
||||
state &= 0x24924924; // just keep the blinks...
|
||||
|
||||
public invManger() {
|
||||
super( TileEventType.WORLD_NBT, TileEventType.NETWORK );
|
||||
}
|
||||
if ( gridProxy.isActive() )
|
||||
state |= 0x80000000;
|
||||
else
|
||||
state &= ~0x80000000;
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
if ( worldObj.getTotalWorldTime() - lastStateChange > 8 )
|
||||
state = 0;
|
||||
else
|
||||
state &= 0x24924924; // just keep the blinks...
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
|
||||
if ( gridProxy.isActive() )
|
||||
state |= 0x80000000;
|
||||
else
|
||||
state &= ~0x80000000;
|
||||
data.writeInt( state );
|
||||
}
|
||||
|
||||
for (int x = 0; x < getCellCount(); x++)
|
||||
state |= (getCellStatus( x ) << (3 * x));
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileDrive(ByteBuf data) throws IOException
|
||||
{
|
||||
int oldState = state;
|
||||
state = data.readInt();
|
||||
lastStateChange = worldObj.getTotalWorldTime();
|
||||
return (state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB);
|
||||
}
|
||||
|
||||
data.writeInt( state );
|
||||
}
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileDrive(NBTTagCompound data)
|
||||
{
|
||||
isCached = false;
|
||||
priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int oldState = state;
|
||||
state = data.readInt();
|
||||
lastStateChange = worldObj.getTotalWorldTime();
|
||||
return (state & 0xDB6DB6DB) != (oldState & 0xDB6DB6DB);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
isCached = false;
|
||||
priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "priority", priority );
|
||||
}
|
||||
|
||||
};
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileDrive(NBTTagCompound data)
|
||||
{
|
||||
data.setInteger( "priority", priority );
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
public void powerRender(MENetworkPowerStatusChange c)
|
||||
|
@ -152,7 +143,6 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
|||
public TileDrive() {
|
||||
mySrc = new MachineSource( this );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
addNewHandler( new invManger() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ import appeng.api.util.IConfigManager;
|
|||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
|
@ -62,35 +62,26 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
|||
|
||||
YesNo lastRedstoneState = YesNo.UNDECIDED;
|
||||
|
||||
class TileIOPortHandler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.WORLD_NBT_WRITE)
|
||||
public void writeToNBT_TileIOPort(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
cells.writeToNBT( data, "cells" );
|
||||
upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", lastRedstoneState.ordinal() );
|
||||
}
|
||||
|
||||
public TileIOPortHandler() {
|
||||
super( TileEventType.WORLD_NBT );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
cells.writeToNBT( data, "cells" );
|
||||
upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", lastRedstoneState.ordinal() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
cells.readFromNBT( data, "cells" );
|
||||
upgrades.readFromNBT( data, "upgrades" );
|
||||
if ( data.hasKey( "lastRedstoneState" ) )
|
||||
lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
};
|
||||
@TileEvent(TileEventType.WORLD_NBT_READ)
|
||||
public void readFromNBT_TileIOPort(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
cells.readFromNBT( data, "cells" );
|
||||
upgrades.readFromNBT( data, "upgrades" );
|
||||
if ( data.hasKey( "lastRedstoneState" ) )
|
||||
lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
}
|
||||
|
||||
public TileIOPort() {
|
||||
addNewHandler( new TileIOPortHandler() );
|
||||
gridProxy.setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
cm.registerSetting( Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
cm.registerSetting( Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
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.InvOperation;
|
||||
|
@ -20,35 +20,22 @@ public class TileSkyChest extends AEBaseInvTile
|
|||
final int sides[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 };
|
||||
final AppEngInternalInventory inv = new AppEngInternalInventory( this, 9 * 4 );
|
||||
|
||||
class SkyChestHnadler extends AETileEventHandler
|
||||
@TileEvent(TileEventType.NETWORK_WRITE)
|
||||
public void writeToStream_TileSkyChest(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( playerOpen > 0 );
|
||||
}
|
||||
|
||||
public SkyChestHnadler() {
|
||||
super( TileEventType.NETWORK );
|
||||
}
|
||||
@TileEvent(TileEventType.NETWORK_READ)
|
||||
public boolean readFromStream_TileSkyChest(ByteBuf data) throws IOException
|
||||
{
|
||||
int wasOpen = playerOpen;
|
||||
playerOpen = data.readBoolean() ? 1 : 0;
|
||||
|
||||
@Override
|
||||
public void writeToStream(ByteBuf data) throws IOException
|
||||
{
|
||||
data.writeBoolean( playerOpen > 0 );
|
||||
}
|
||||
if ( wasOpen != playerOpen )
|
||||
lastEvent = System.currentTimeMillis();
|
||||
|
||||
@Override
|
||||
public boolean readFromStream(ByteBuf data) throws IOException
|
||||
{
|
||||
int wasOpen = playerOpen;
|
||||
playerOpen = data.readBoolean() ? 1 : 0;
|
||||
|
||||
if ( wasOpen != playerOpen )
|
||||
lastEvent = System.currentTimeMillis();
|
||||
|
||||
return false; // TESR yo!
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public TileSkyChest() {
|
||||
addNewHandler( new SkyChestHnadler() );
|
||||
return false; // TESR yo!
|
||||
}
|
||||
|
||||
// server
|
||||
|
|
Loading…
Reference in a new issue