2013-12-27 23:59:59 +01:00
|
|
|
package appeng.tile.grid;
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2014-02-09 02:34:52 +01:00
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.networking.IGridNode;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.api.networking.security.IActionHost;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.api.util.AECableType;
|
|
|
|
import appeng.api.util.DimensionalCoord;
|
|
|
|
import appeng.me.helpers.AENetworkProxy;
|
|
|
|
import appeng.me.helpers.IGridProxyable;
|
|
|
|
import appeng.tile.AEBaseTile;
|
2014-01-27 05:00:36 +01:00
|
|
|
import appeng.tile.events.AETileEventHandler;
|
|
|
|
import appeng.tile.events.TileEventType;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
|
2014-01-27 05:00:36 +01:00
|
|
|
class AENetworkTileHandler extends AETileEventHandler
|
|
|
|
{
|
|
|
|
|
|
|
|
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() );
|
|
|
|
}
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
final protected AENetworkProxy gridProxy = createProxy();
|
|
|
|
|
|
|
|
protected AENetworkProxy createProxy()
|
|
|
|
{
|
2014-01-23 17:28:12 +01:00
|
|
|
return new AENetworkProxy( this, "proxy", getItemFromTile( this ), true );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IGridNode getGridNode(ForgeDirection dir)
|
|
|
|
{
|
|
|
|
return gridProxy.getNode();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReady()
|
|
|
|
{
|
|
|
|
super.onReady();
|
|
|
|
gridProxy.onReady();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChunkUnload()
|
|
|
|
{
|
|
|
|
super.onChunkUnload();
|
|
|
|
gridProxy.onChunkUnload();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void validate()
|
|
|
|
{
|
|
|
|
super.validate();
|
|
|
|
gridProxy.validate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void invalidate()
|
|
|
|
{
|
|
|
|
super.invalidate();
|
|
|
|
gridProxy.invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DimensionalCoord getLocation()
|
|
|
|
{
|
|
|
|
return new DimensionalCoord( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AECableType getCableConnectionType(ForgeDirection dir)
|
|
|
|
{
|
|
|
|
return AECableType.SMART;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void gridChanged()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2014-01-27 05:00:36 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public AENetworkProxy getProxy()
|
|
|
|
{
|
|
|
|
return gridProxy;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IGridNode getActionableNode()
|
|
|
|
{
|
|
|
|
return gridProxy.getNode();
|
|
|
|
}
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|