Use standard inheritance to propagage NBT events (#3058)
* Remove the old annotation system * Use TileEntity#onLoad instead of onChunkLoad event * Do not call invalidate in onChunkUnload and validate in onLoad
This commit is contained in:
@@ -32,7 +32,6 @@ import com.google.common.collect.LinkedListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
@@ -166,18 +165,6 @@ public class TickHandler
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoad( final ChunkEvent.Load load )
|
||||
{
|
||||
for( final Object te : load.getChunk().getTileEntityMap().values() )
|
||||
{
|
||||
if( te instanceof AEBaseTile )
|
||||
{
|
||||
( (AEBaseTile) te ).onChunkLoad();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onTick( final TickEvent ev )
|
||||
{
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.helpers.ItemHandlerUtil;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
@@ -46,9 +45,10 @@ import appeng.util.inv.InvOperation;
|
||||
public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInventory
|
||||
{
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AEBaseInvTile( final net.minecraft.nbt.NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
final IItemHandler inv = this.getInternalInventory();
|
||||
if( inv != EmptyHandler.INSTANCE )
|
||||
{
|
||||
@@ -63,9 +63,10 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
|
||||
public abstract @Nonnull IItemHandler getInternalInventory();
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AEBaseInvTile( final net.minecraft.nbt.NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
final IItemHandler inv = this.getInternalInventory();
|
||||
if( inv != EmptyHandler.INSTANCE )
|
||||
{
|
||||
@@ -82,6 +83,7 @@ public abstract class AEBaseInvTile extends AEBaseTile implements IAEAppEngInven
|
||||
}
|
||||
data.setTag( "inv", opt );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,12 +19,9 @@
|
||||
package appeng.tile;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -55,8 +52,6 @@ import appeng.core.AELog;
|
||||
import appeng.core.features.IStackSrc;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.SettingsFrom;
|
||||
@@ -66,14 +61,12 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
{
|
||||
|
||||
private static final ThreadLocal<WeakReference<AEBaseTile>> DROP_NO_ITEMS = new ThreadLocal<>();
|
||||
private static final Map<Class<? extends AEBaseTile>, Map<TileEventType, List<AETileEventHandler>>> HANDLERS = new HashMap<>();
|
||||
private static final Map<Class<? extends TileEntity>, IStackSrc> ITEM_STACKS = new HashMap<>();
|
||||
private int renderFragment = 0;
|
||||
@Nullable
|
||||
private String customName;
|
||||
private EnumFacing forward = null;
|
||||
private EnumFacing up = null;
|
||||
|
||||
private IBlockState state;
|
||||
|
||||
@Override
|
||||
@@ -125,20 +118,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* for dormant chunk cache.
|
||||
*/
|
||||
public void onChunkLoad()
|
||||
{
|
||||
if( this.isInvalid() )
|
||||
{
|
||||
this.validate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public final void readFromNBT( final NBTTagCompound data )
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
|
||||
@@ -162,16 +143,10 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
catch( final IllegalArgumentException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_READ ) )
|
||||
{
|
||||
h.readFromNBT( this, data );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// NOTE: WAS FINAL, changed for Immibis
|
||||
public final NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
|
||||
@@ -186,11 +161,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
data.setString( "customName", this.customName );
|
||||
}
|
||||
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_WRITE ) )
|
||||
{
|
||||
h.writeToNBT( this, data );
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -200,13 +170,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return new SPacketUpdateTileEntity( this.pos, 64, this.getUpdateTag() );
|
||||
}
|
||||
|
||||
private boolean hasHandlerFor( final TileEventType type )
|
||||
{
|
||||
final List<AETileEventHandler> list = this.getHandlerListFor( type );
|
||||
|
||||
return !list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket( final NetworkManager net, final SPacketUpdateTileEntity pkt )
|
||||
{
|
||||
@@ -217,13 +180,8 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload()
|
||||
public void onReady()
|
||||
{
|
||||
if( !this.isInvalid() )
|
||||
{
|
||||
this.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,6 +212,30 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return data;
|
||||
}
|
||||
|
||||
private boolean readUpdateData( ByteBuf stream )
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
try
|
||||
{
|
||||
this.renderFragment = 100;
|
||||
|
||||
output = readFromStream( stream );
|
||||
|
||||
if( ( this.renderFragment & 1 ) == 1 )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
this.renderFragment = 0;
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.debug( t );
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles tile entites that are being sent to the client as part of a full chunk.
|
||||
*/
|
||||
@@ -280,52 +262,36 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
public void handleUpdateTag( NBTTagCompound tag )
|
||||
{
|
||||
final ByteBuf stream = Unpooled.copiedBuffer( tag.getByteArray( "X" ) );
|
||||
if( this.readFromStream( stream ) )
|
||||
|
||||
if( this.readUpdateData( stream ) )
|
||||
{
|
||||
this.markForUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean readFromStream( final ByteBuf data )
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
boolean output = false;
|
||||
|
||||
try
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
final EnumFacing old_Forward = this.forward;
|
||||
final EnumFacing old_Up = this.up;
|
||||
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
final EnumFacing old_Forward = this.forward;
|
||||
final EnumFacing old_Up = this.up;
|
||||
final byte orientation = data.readByte();
|
||||
this.forward = EnumFacing.VALUES[orientation & 0x7];
|
||||
this.up = EnumFacing.VALUES[orientation >> 3];
|
||||
|
||||
final byte orientation = data.readByte();
|
||||
this.forward = EnumFacing.VALUES[orientation & 0x7];
|
||||
this.up = EnumFacing.VALUES[orientation >> 3];
|
||||
|
||||
output = this.forward != old_Forward || this.up != old_Up;
|
||||
}
|
||||
|
||||
this.renderFragment = 100;
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_READ ) )
|
||||
{
|
||||
if( h.readFromStream( this, data ) )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( ( this.renderFragment & 1 ) == 1 )
|
||||
{
|
||||
output = true;
|
||||
}
|
||||
this.renderFragment = 0;
|
||||
return this.forward != old_Forward || this.up != old_Up;
|
||||
}
|
||||
catch( final Throwable t )
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
AELog.debug( t );
|
||||
final byte orientation = (byte) ( ( this.up.ordinal() << 3 ) | this.forward.ordinal() );
|
||||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public void markForUpdate()
|
||||
@@ -345,27 +311,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
}
|
||||
}
|
||||
|
||||
private final void writeToStream( final ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( this.canBeRotated() )
|
||||
{
|
||||
final byte orientation = (byte) ( ( this.up.ordinal() << 3 ) | this.forward.ordinal() );
|
||||
data.writeByte( orientation );
|
||||
}
|
||||
|
||||
for( final AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_WRITE ) )
|
||||
{
|
||||
h.writeToStream( this, data );
|
||||
}
|
||||
}
|
||||
catch( final Throwable t )
|
||||
{
|
||||
AELog.debug( t );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* By default all blocks can have orientation, this handles saving, and loading, as well as synchronization.
|
||||
*
|
||||
@@ -377,75 +322,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<AETileEventHandler> getHandlerListFor( final TileEventType type )
|
||||
{
|
||||
final Map<TileEventType, List<AETileEventHandler>> eventToHandlers = this.getEventToHandlers();
|
||||
final List<AETileEventHandler> handlers = this.getHandlers( eventToHandlers, type );
|
||||
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private Map<TileEventType, List<AETileEventHandler>> getEventToHandlers()
|
||||
{
|
||||
final Class<? extends AEBaseTile> clazz = this.getClass();
|
||||
final Map<TileEventType, List<AETileEventHandler>> storedHandlers = HANDLERS.get( clazz );
|
||||
|
||||
if( storedHandlers == null )
|
||||
{
|
||||
final Map<TileEventType, List<AETileEventHandler>> newStoredHandlers = new EnumMap<>( TileEventType.class );
|
||||
|
||||
HANDLERS.put( clazz, newStoredHandlers );
|
||||
|
||||
for( final Method method : clazz.getMethods() )
|
||||
{
|
||||
final TileEvent event = method.getAnnotation( TileEvent.class );
|
||||
if( event != null )
|
||||
{
|
||||
this.addHandler( newStoredHandlers, event.value(), method );
|
||||
}
|
||||
}
|
||||
|
||||
return newStoredHandlers;
|
||||
}
|
||||
else
|
||||
{
|
||||
return storedHandlers;
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<AETileEventHandler> getHandlers( final Map<TileEventType, List<AETileEventHandler>> eventToHandlers, final TileEventType event )
|
||||
{
|
||||
final List<AETileEventHandler> oldHandlers = eventToHandlers.get( event );
|
||||
|
||||
if( oldHandlers == null )
|
||||
{
|
||||
final List<AETileEventHandler> newHandlers = new LinkedList<>();
|
||||
eventToHandlers.put( event, newHandlers );
|
||||
|
||||
return newHandlers;
|
||||
}
|
||||
else
|
||||
{
|
||||
return oldHandlers;
|
||||
}
|
||||
}
|
||||
|
||||
private void addHandler( final Map<TileEventType, List<AETileEventHandler>> handlerSet, final TileEventType value, final Method m )
|
||||
{
|
||||
List<AETileEventHandler> list = handlerSet.get( value );
|
||||
|
||||
if( list == null )
|
||||
{
|
||||
list = new ArrayList<>();
|
||||
handlerSet.put( value, list );
|
||||
}
|
||||
|
||||
list.add( new AETileEventHandler( m ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getForward()
|
||||
{
|
||||
@@ -542,11 +418,6 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
||||
|
||||
}
|
||||
|
||||
public void onReady()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* null means nothing to store...
|
||||
*
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -32,8 +32,6 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import appeng.api.implementations.tiles.IColorableTile;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
@@ -49,9 +47,10 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
private IAEItemStack dspPlay;
|
||||
private AEColor paintedColor = AEColor.TRANSPARENT;
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCraftingMonitorTile( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
@@ -67,12 +66,13 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
|
||||
this.setUpdateList( true );
|
||||
return oldPaintedColor != this.paintedColor; // tesr!
|
||||
return oldPaintedColor != this.paintedColor || c; // tesr!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCraftingMonitorTile( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
|
||||
if( this.dspPlay == null )
|
||||
@@ -86,19 +86,22 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCraftingMonitorTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
{
|
||||
this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )];
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCraftingMonitorTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,8 +51,6 @@ 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.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -194,19 +192,22 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
||||
return this.cluster != null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCraftingTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "core", this.isCoreBlock() );
|
||||
if( this.isCoreBlock() && this.cluster != null )
|
||||
{
|
||||
this.cluster.writeToNBT( data );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCraftingTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setCoreBlock( data.getBoolean( "core" ) );
|
||||
if( this.isCoreBlock() )
|
||||
{
|
||||
|
||||
@@ -65,8 +65,6 @@ import appeng.items.misc.ItemEncodedPattern;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.DefinitionUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -198,23 +196,26 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
return this.upgrades.getInstalledUpgrades( u );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileMolecularAssembler( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean oldPower = this.isPowered;
|
||||
this.isPowered = data.readBoolean();
|
||||
return this.isPowered != oldPower;
|
||||
return this.isPowered != oldPower || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileMolecularAssembler( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.isPowered );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileMolecularAssembler( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
if( this.forcePlan && this.myPlan != null )
|
||||
{
|
||||
final ItemStack pattern = this.myPlan.getPattern();
|
||||
@@ -228,14 +229,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
}
|
||||
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
this.gridInv.writeToNBT( data, "inv" );
|
||||
this.patternInv.writeToNBT( data, "pattern" );
|
||||
this.settings.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileMolecularAssembler( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "myPlan" ) )
|
||||
{
|
||||
final ItemStack myPat = new ItemStack( data.getCompoundTag( "myPlan" ) );
|
||||
@@ -255,8 +256,6 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
|
||||
}
|
||||
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
this.gridInv.readFromNBT( data, "inv" );
|
||||
this.patternInv.readFromNBT( data, "pattern" );
|
||||
this.settings.readFromNBT( data );
|
||||
this.recalculatePlan();
|
||||
}
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile.events;
|
||||
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
import appeng.tile.AEBaseTile;
|
||||
|
||||
|
||||
public final class AETileEventHandler
|
||||
{
|
||||
|
||||
private final Method method;
|
||||
|
||||
public AETileEventHandler( final Method method )
|
||||
{
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
// TICK
|
||||
public void tick( final AEBaseTile tile )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// WORLD_NBT
|
||||
public void writeToNBT( final AEBaseTile tile, final NBTTagCompound data )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// WORLD NBT
|
||||
public void readFromNBT( final AEBaseTile tile, final NBTTagCompound data )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
public void writeToStream( final AEBaseTile tile, final ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
|
||||
// NETWORK
|
||||
|
||||
/**
|
||||
* returning true from this method, will update the block's render
|
||||
*
|
||||
* @param data data of stream
|
||||
*
|
||||
* @return true of method could be invoked
|
||||
*/
|
||||
@SideOnly( Side.CLIENT )
|
||||
public boolean readFromStream( final AEBaseTile tile, final ByteBuf data )
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Boolean) this.method.invoke( tile, data );
|
||||
}
|
||||
catch( final IllegalAccessException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final IllegalArgumentException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
catch( final InvocationTargetException e )
|
||||
{
|
||||
throw new IllegalStateException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.tile.events;
|
||||
|
||||
|
||||
public enum TileEventType
|
||||
{
|
||||
WORLD_NBT_READ,
|
||||
WORLD_NBT_WRITE,
|
||||
|
||||
/**
|
||||
* Methods annotated with this need to return a boolean
|
||||
*/
|
||||
NETWORK_READ,
|
||||
|
||||
NETWORK_WRITE
|
||||
}
|
||||
@@ -27,8 +27,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionHost, IGridProxyable
|
||||
@@ -36,16 +34,19 @@ public abstract class AENetworkInvTile extends AEBaseInvTile implements IActionH
|
||||
|
||||
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,8 +28,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.powersink.AEBasePoweredTile;
|
||||
|
||||
|
||||
@@ -38,16 +36,19 @@ public abstract class AENetworkPowerTile extends AEBasePoweredTile implements IA
|
||||
|
||||
private final AENetworkProxy gridProxy = new AENetworkProxy( this, "proxy", this.getItemFromTile( this ), true );
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,8 +29,6 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.helpers.AENetworkProxy;
|
||||
import appeng.me.helpers.IGridProxyable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxyable
|
||||
@@ -38,16 +36,19 @@ public class AENetworkTile extends AEBaseTile implements IActionHost, IGridProxy
|
||||
|
||||
private final AENetworkProxy gridProxy = this.createProxy();
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getProxy().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getProxy().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
protected AENetworkProxy createProxy()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.grindstone;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,8 +37,6 @@ import net.minecraft.world.World;
|
||||
import appeng.api.implementations.tiles.ICrankable;
|
||||
import appeng.helpers.ICustomCollision;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -90,16 +89,18 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCrank( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
this.rotation = data.readInt();
|
||||
return false;
|
||||
return c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCrank( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeInt( this.rotation );
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ import appeng.api.implementations.IUpgradeableHost;
|
||||
import appeng.api.storage.ICellWorkbenchItem;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -104,17 +102,20 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I
|
||||
return null;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCellWorkbench( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cell.writeToNBT( data, "cell" );
|
||||
this.config.writeToNBT( data, "config" );
|
||||
this.manager.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCellWorkbench( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.cell.readFromNBT( data, "cell" );
|
||||
this.config.readFromNBT( data, "config" );
|
||||
this.manager.readFromNBT( data );
|
||||
|
||||
@@ -49,8 +49,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -81,9 +79,10 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCharger( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
try
|
||||
{
|
||||
final IAEItemStack item = AEItemStack.loadItemStackFromPacket( data );
|
||||
@@ -94,12 +93,13 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
|
||||
{
|
||||
this.inv.setStackInSlot( 0, ItemStack.EMPTY );
|
||||
}
|
||||
return false; // TESR doesn't need updates!
|
||||
return c; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCharger( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
final AEItemStack is = AEItemStack.create( this.inv.getStackInSlot( 0 ) );
|
||||
if( is != null )
|
||||
{
|
||||
|
||||
@@ -48,8 +48,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
@@ -78,16 +76,19 @@ public class TileCondenser extends AEBaseInvTile implements IConfigManagerHost,
|
||||
this.cm.registerSetting( Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCondenser( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.setDouble( "storedPower", this.getStoredPower() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCondenser( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.cm.readFromNBT( data );
|
||||
this.setStoredPower( data.getDouble( "storedPower" ) );
|
||||
}
|
||||
|
||||
@@ -58,12 +58,9 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.DefinitionUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -103,7 +100,6 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
|
||||
private final IItemHandlerModifiable inv = new WrapperChainedItemHandler( this.topItemHandler, this.bottomItemHandler, this.sideItemHandler );
|
||||
|
||||
@Reflected
|
||||
public TileInscriber()
|
||||
{
|
||||
this.getProxy().setValidSides( EnumSet.noneOf( EnumFacing.class ) );
|
||||
@@ -133,29 +129,27 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileInscriber( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
this.topItemHandler.writeToNBT( data, "inscriberInvTop" );
|
||||
this.bottomItemHandler.writeToNBT( data, "inscriberInvBottom" );
|
||||
this.sideItemHandler.writeToNBT( data, "inscriberInvSided" );
|
||||
super.writeToNBT( data );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
this.settings.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileInscriber( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
this.topItemHandler.readFromNBT( data, "inscriberInvTop" );
|
||||
this.bottomItemHandler.readFromNBT( data, "inscriberInvBottom" );
|
||||
this.sideItemHandler.readFromNBT( data, "inscriberInvSided" );
|
||||
super.readFromNBT( data );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
this.settings.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileInscriber( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int slot = data.readByte();
|
||||
|
||||
final boolean oldSmash = this.isSmash();
|
||||
@@ -179,12 +173,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileInscriber( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int slot = this.isSmash() ? 64 : 0;
|
||||
|
||||
for( int num = 0; num < this.inv.getSlots(); num++ )
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -58,8 +59,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.DualityInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
@@ -171,32 +170,37 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
|
||||
this.duality.initialize();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileInterface( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setBoolean( "omniDirectional", this.omniDirectional );
|
||||
this.duality.writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileInterface( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.omniDirectional = data.getBoolean( "omniDirectional" );
|
||||
|
||||
this.duality.readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileInterface( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
boolean oldOmniDirectional = this.omniDirectional;
|
||||
this.omniDirectional = data.readBoolean();
|
||||
return oldOmniDirectional != this.omniDirectional;
|
||||
return oldOmniDirectional != this.omniDirectional || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileInterface( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.omniDirectional );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -40,8 +41,6 @@ import appeng.api.util.AEColor;
|
||||
import appeng.helpers.Splotch;
|
||||
import appeng.items.misc.ItemPaintBall;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public class TilePaint extends AEBaseTile
|
||||
@@ -58,15 +57,17 @@ public class TilePaint extends AEBaseTile
|
||||
return false;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TilePaint( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
final ByteBuf myDat = Unpooled.buffer();
|
||||
this.writeBuffer( myDat );
|
||||
if( myDat.hasArray() )
|
||||
{
|
||||
data.setByteArray( "dots", myDat.array() );
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private void writeBuffer( final ByteBuf out )
|
||||
@@ -85,9 +86,10 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TilePaint( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "dots" ) )
|
||||
{
|
||||
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
|
||||
@@ -136,15 +138,17 @@ public class TilePaint extends AEBaseTile
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TilePaint( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.writeBuffer( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TilePaint( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.readFromStream( data );
|
||||
this.readBuffer( data );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -32,8 +33,6 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.Platform;
|
||||
|
||||
@@ -62,17 +61,19 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileQuartzGrowthAccelerator( final ByteBuf data )
|
||||
@Override
|
||||
public boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean hadPower = this.isPowered();
|
||||
this.setPowered( data.readBoolean() );
|
||||
return this.isPowered() != hadPower;
|
||||
return this.isPowered() != hadPower || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileQuartzGrowthAccelerator( final ByteBuf data )
|
||||
@Override
|
||||
public void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
try
|
||||
{
|
||||
data.writeBoolean( this.getProxy().getEnergy().isNetworkPowered() );
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -68,8 +69,6 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.helpers.PlayerSecurityWrapper;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.SecurityStationInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -135,28 +134,31 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSecurity( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean wasActive = this.isActive;
|
||||
this.isActive = data.readBoolean();
|
||||
|
||||
final AEColor oldPaintedColor = this.paintedColor;
|
||||
this.paintedColor = AEColor.values()[data.readByte()];
|
||||
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive;
|
||||
return oldPaintedColor != this.paintedColor || wasActive != this.isActive || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSecurity( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getProxy().isActive() );
|
||||
data.writeByte( this.paintedColor.ordinal() );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSecurity( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.cm.writeToNBT( data );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
|
||||
@@ -175,11 +177,13 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
|
||||
}
|
||||
|
||||
data.setTag( "storedItems", storedItems );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSecurity( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.cm.readFromNBT( data );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.tile.misc;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -40,10 +42,7 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -80,35 +79,38 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
|
||||
return AECableType.COVERED;
|
||||
}
|
||||
|
||||
@Reflected
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean hasUpdate( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean wasOn = this.isOn;
|
||||
|
||||
this.isOn = data.readBoolean();
|
||||
|
||||
return wasOn != this.isOn; // TESR doesn't need updates!
|
||||
return wasOn != this.isOn || c; // TESR doesn't need updates!
|
||||
}
|
||||
|
||||
@Reflected
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToNetwork( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getBurnTime() > 0 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileVibrationChamber( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "burnTime", this.getBurnTime() );
|
||||
data.setDouble( "maxBurnTime", this.getMaxBurnTime() );
|
||||
data.setInteger( "burnSpeed", this.getBurnSpeed() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileVibrationChamber( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setBurnTime( data.getDouble( "burnTime" ) );
|
||||
this.setMaxBurnTime( data.getDouble( "maxBurnTime" ) );
|
||||
this.setBurnSpeed( data.getInteger( "burnSpeed" ) );
|
||||
|
||||
@@ -54,8 +54,6 @@ import appeng.helpers.ICustomCollision;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.CableBusContainer;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -66,21 +64,25 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
|
||||
private int oldLV = -1; // on re-calculate light when it changes
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileCableBus( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.getCableBus().readFromNBT( data );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileCableBus( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.getCableBus().writeToNBT( data );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileCableBus( final ByteBuf data ) throws IOException
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final boolean ret = this.getCableBus().readFromStream( data );
|
||||
|
||||
final int newLV = this.getCableBus().getLightValue();
|
||||
@@ -91,7 +93,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
}
|
||||
|
||||
this.updateTileSetting();
|
||||
return ret;
|
||||
return ret || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.getCableBus().writeToStream( data );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,12 +131,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
|
||||
oldTile.setCableBus( tmpCB );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileCableBus( final ByteBuf data ) throws IOException
|
||||
{
|
||||
this.getCableBus().writeToStream( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxRenderDistanceSquared()
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ package appeng.tile.networking;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
@@ -41,22 +40,6 @@ public class TileEnergyAcceptor extends AENetworkPowerTile
|
||||
this.setInternalMaxPower( 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT_AENetwork( final NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT_AENetwork( final NBTTagCompound data )
|
||||
{
|
||||
/**
|
||||
* Does nothing here since the NBT tag in the parent is not needed anymore
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public AECableType getCableConnectionType( final AEPartLocation dir )
|
||||
{
|
||||
|
||||
@@ -31,8 +31,6 @@ import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.block.networking.BlockEnergyCell;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
import appeng.util.SettingsFrom;
|
||||
|
||||
@@ -100,18 +98,18 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileEnergyCell( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
if( !this.world.isRemote )
|
||||
{
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
}
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "internalCurrentPower", this.internalCurrentPower );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileEnergyCell( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.internalCurrentPower = data.getDouble( "internalCurrentPower" );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.networking;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -40,8 +41,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -85,18 +84,20 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
|
||||
this.markForUpdate();
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileWireless( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int old = this.getClientFlags();
|
||||
this.setClientFlags( data.readByte() );
|
||||
|
||||
return old != this.getClientFlags();
|
||||
return old != this.getClientFlags() || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileWireless( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
this.setClientFlags( 0 );
|
||||
|
||||
try
|
||||
|
||||
@@ -38,8 +38,6 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.integration.Integrations;
|
||||
import appeng.integration.abstraction.IC2PowerSink;
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
|
||||
|
||||
public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowerStorage, IExternalPowerSink
|
||||
@@ -81,15 +79,18 @@ public abstract class AEBasePoweredTile extends AEBaseInvTile implements IAEPowe
|
||||
// trigger re-calc!
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_AERootPoweredTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setDouble( "internalCurrentPower", this.getInternalCurrentPower() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_AERootPoweredTile( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.setInternalCurrentPower( data.getDouble( "internalCurrentPower" ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.qnb;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -46,8 +47,6 @@ 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.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -87,9 +86,10 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void onNetworkWriteEvent( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int out = this.constructed;
|
||||
|
||||
if( !this.internalInventory.getStackInSlot( 0 ).isEmpty() && this.constructed != -1 )
|
||||
@@ -105,12 +105,13 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
|
||||
data.writeByte( (byte) out );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean onNetworkReadEvent( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int oldValue = this.constructed;
|
||||
this.constructed = data.readByte();
|
||||
return this.constructed != oldValue;
|
||||
return this.constructed != oldValue || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,8 +43,6 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.me.cache.SpatialPylonCache;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.IWorldCallable;
|
||||
@@ -66,15 +64,18 @@ public class TileSpatialIOPort extends AENetworkInvTile implements IWorldCallabl
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileSpatialIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileSpatialIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
{
|
||||
this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )];
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.spatial;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -35,8 +36,6 @@ 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.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkTile;
|
||||
|
||||
|
||||
@@ -217,17 +216,19 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
|
||||
return 0;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSpatialPylon( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int old = this.displayBits;
|
||||
this.displayBits = data.readByte();
|
||||
return old != this.displayBits;
|
||||
return old != this.displayBits || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSpatialPylon( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeByte( this.displayBits );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -89,8 +90,6 @@ import appeng.capabilities.Capabilities;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkPowerTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -433,9 +432,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileChest( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
|
||||
if( this.world.getTotalWorldTime() - this.lastStateChange > 8 )
|
||||
{
|
||||
this.state = 0;
|
||||
@@ -474,9 +475,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileChest( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
|
||||
final int oldState = this.state;
|
||||
final ItemStack oldType = this.storageType;
|
||||
|
||||
@@ -498,12 +501,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
this.lastStateChange = this.world.getTotalWorldTime();
|
||||
|
||||
return oldPaintedColor != this.paintedColor || ( this.state & 0xDB6DB6DB ) != ( oldState & 0xDB6DB6DB ) || !Platform.itemComparisons()
|
||||
.isSameItem( oldType, this.storageType );
|
||||
.isSameItem( oldType, this.storageType ) || c;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileChest( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.config.readFromNBT( data );
|
||||
this.priority = data.getInteger( "priority" );
|
||||
if( data.hasKey( "paintedColor" ) )
|
||||
@@ -512,12 +516,14 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileChest( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.config.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
data.setByte( "paintedColor", (byte) this.paintedColor.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -51,8 +52,6 @@ import appeng.helpers.IPriorityHost;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.DriveWatcher;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.Platform;
|
||||
@@ -99,9 +98,10 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
this.inv.setFilter( new CellValidInventoryFilter() );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileDrive( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
int newState = 0;
|
||||
|
||||
if( this.getProxy().isActive() )
|
||||
@@ -117,6 +117,15 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
data.writeInt( newState );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK ) || c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCellCount()
|
||||
{
|
||||
@@ -176,25 +185,20 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
|
||||
return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileDrive( final ByteBuf data )
|
||||
{
|
||||
final int oldState = this.state;
|
||||
this.state = data.readInt();
|
||||
return ( this.state & BIT_STATE_MASK ) != ( oldState & BIT_STATE_MASK );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileDrive( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.isCached = false;
|
||||
this.priority = data.getInteger( "priority" );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileDrive( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
data.setInteger( "priority", this.priority );
|
||||
return data;
|
||||
}
|
||||
|
||||
@MENetworkEventSubscribe
|
||||
|
||||
@@ -58,12 +58,9 @@ import appeng.api.util.AEPartLocation;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.settings.TickRates;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.automation.BlockUpgradeInventory;
|
||||
import appeng.parts.automation.UpgradeInventory;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.grid.AENetworkInvTile;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
@@ -96,7 +93,6 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
private IMEInventory<IAEFluidStack> cachedFluid;
|
||||
private IMEInventory<IAEItemStack> cachedItem;
|
||||
|
||||
@Reflected
|
||||
public TileIOPort()
|
||||
{
|
||||
this.getProxy().setFlags( GridFlags.REQUIRE_CHANNEL );
|
||||
@@ -111,22 +107,21 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
||||
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, 3 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_WRITE )
|
||||
public void writeToNBT_TileIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
this.manager.writeToNBT( data );
|
||||
this.inputCells.writeToNBT( data, "cellsInput" );
|
||||
this.outputCells.writeToNBT( data, "cellsOutput" );
|
||||
this.upgrades.writeToNBT( data, "upgrades" );
|
||||
data.setInteger( "lastRedstoneState", this.lastRedstoneState.ordinal() );
|
||||
return data;
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.WORLD_NBT_READ )
|
||||
public void readFromNBT_TileIOPort( final NBTTagCompound data )
|
||||
@Override
|
||||
public void readFromNBT( final NBTTagCompound data )
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
this.manager.readFromNBT( data );
|
||||
this.inputCells.readFromNBT( data, "cellsInput" );
|
||||
this.outputCells.readFromNBT( data, "cellsOutput" );
|
||||
this.upgrades.readFromNBT( data, "upgrades" );
|
||||
if( data.hasKey( "lastRedstoneState" ) )
|
||||
{
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package appeng.tile.storage;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@@ -29,8 +31,6 @@ import net.minecraft.util.SoundCategory;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.tile.AEBaseInvTile;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
@@ -46,15 +46,17 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
private float lidAngle;
|
||||
private float prevLidAngle;
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_WRITE )
|
||||
public void writeToStream_TileSkyChest( final ByteBuf data )
|
||||
@Override
|
||||
protected void writeToStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
super.writeToStream( data );
|
||||
data.writeBoolean( this.getPlayerOpen() > 0 );
|
||||
}
|
||||
|
||||
@TileEvent( TileEventType.NETWORK_READ )
|
||||
public boolean readFromStream_TileSkyChest( final ByteBuf data )
|
||||
@Override
|
||||
protected boolean readFromStream( final ByteBuf data ) throws IOException
|
||||
{
|
||||
final boolean c = super.readFromStream( data );
|
||||
final int wasOpen = this.getPlayerOpen();
|
||||
this.setPlayerOpen( data.readBoolean() ? 1 : 0 );
|
||||
|
||||
@@ -63,7 +65,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickable
|
||||
this.setLastEvent( System.currentTimeMillis() );
|
||||
}
|
||||
|
||||
return false; // TESR yo!
|
||||
return c; // TESR yo!
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user