mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 11:10:29 +00:00
A couple of minor reformats
- nbttagcompount -> nbt. It's shorter, and hopefully will avoid ambiguities with 'tag' in 1.13+. - Remove several redundant != null checks.
This commit is contained in:
parent
54acf1d087
commit
ca334e7e5c
@ -5,6 +5,7 @@ package dan200.computercraft.core.apis;
|
||||
*
|
||||
* @see dan200.computercraft.api.lua.ILuaAPI
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ILuaAPI extends dan200.computercraft.api.lua.ILuaAPI
|
||||
{
|
||||
void advance( double v );
|
||||
|
@ -321,55 +321,55 @@ public class Terminal
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
public synchronized NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public synchronized NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound.setInteger( "term_cursorX", m_cursorX );
|
||||
nbttagcompound.setInteger( "term_cursorY", m_cursorY );
|
||||
nbttagcompound.setBoolean( "term_cursorBlink", m_cursorBlink );
|
||||
nbttagcompound.setInteger( "term_textColour", m_cursorColour );
|
||||
nbttagcompound.setInteger( "term_bgColour", m_cursorBackgroundColour );
|
||||
nbt.setInteger( "term_cursorX", m_cursorX );
|
||||
nbt.setInteger( "term_cursorY", m_cursorY );
|
||||
nbt.setBoolean( "term_cursorBlink", m_cursorBlink );
|
||||
nbt.setInteger( "term_textColour", m_cursorColour );
|
||||
nbt.setInteger( "term_bgColour", m_cursorBackgroundColour );
|
||||
for( int n = 0; n < m_height; n++ )
|
||||
{
|
||||
nbttagcompound.setString( "term_text_" + n, m_text[n].toString() );
|
||||
nbttagcompound.setString( "term_textColour_" + n, m_textColour[n].toString() );
|
||||
nbttagcompound.setString( "term_textBgColour_" + n, m_backgroundColour[n].toString() );
|
||||
nbt.setString( "term_text_" + n, m_text[n].toString() );
|
||||
nbt.setString( "term_textColour_" + n, m_textColour[n].toString() );
|
||||
nbt.setString( "term_textBgColour_" + n, m_backgroundColour[n].toString() );
|
||||
}
|
||||
if( m_palette != null )
|
||||
{
|
||||
m_palette.writeToNBT( nbttagcompound );
|
||||
m_palette.writeToNBT( nbt );
|
||||
}
|
||||
return nbttagcompound;
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public synchronized void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public synchronized void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
m_cursorX = nbttagcompound.getInteger( "term_cursorX" );
|
||||
m_cursorY = nbttagcompound.getInteger( "term_cursorY" );
|
||||
m_cursorBlink = nbttagcompound.getBoolean( "term_cursorBlink" );
|
||||
m_cursorColour = nbttagcompound.getInteger( "term_textColour" );
|
||||
m_cursorBackgroundColour = nbttagcompound.getInteger( "term_bgColour" );
|
||||
m_cursorX = nbt.getInteger( "term_cursorX" );
|
||||
m_cursorY = nbt.getInteger( "term_cursorY" );
|
||||
m_cursorBlink = nbt.getBoolean( "term_cursorBlink" );
|
||||
m_cursorColour = nbt.getInteger( "term_textColour" );
|
||||
m_cursorBackgroundColour = nbt.getInteger( "term_bgColour" );
|
||||
|
||||
for( int n = 0; n < m_height; n++ )
|
||||
{
|
||||
m_text[n].fill( ' ' );
|
||||
if( nbttagcompound.hasKey( "term_text_" + n ) )
|
||||
if( nbt.hasKey( "term_text_" + n ) )
|
||||
{
|
||||
m_text[n].write( nbttagcompound.getString( "term_text_" + n ) );
|
||||
m_text[n].write( nbt.getString( "term_text_" + n ) );
|
||||
}
|
||||
m_textColour[n].fill( base16.charAt( m_cursorColour ) );
|
||||
if( nbttagcompound.hasKey( "term_textColour_" + n ) )
|
||||
if( nbt.hasKey( "term_textColour_" + n ) )
|
||||
{
|
||||
m_textColour[n].write( nbttagcompound.getString( "term_textColour_" + n ) );
|
||||
m_textColour[n].write( nbt.getString( "term_textColour_" + n ) );
|
||||
}
|
||||
m_backgroundColour[n].fill( base16.charAt( m_cursorBackgroundColour ) );
|
||||
if( nbttagcompound.hasKey( "term_textBgColour_" + n ) )
|
||||
if( nbt.hasKey( "term_textBgColour_" + n ) )
|
||||
{
|
||||
m_backgroundColour[n].write( nbttagcompound.getString( "term_textBgColour_" + n ) );
|
||||
m_backgroundColour[n].write( nbt.getString( "term_textBgColour_" + n ) );
|
||||
}
|
||||
}
|
||||
if( m_palette != null )
|
||||
{
|
||||
m_palette.readFromNBT( nbttagcompound );
|
||||
m_palette.readFromNBT( nbt );
|
||||
}
|
||||
m_changed = true;
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ public class ClientTerminal implements ITerminal
|
||||
return m_colour;
|
||||
}
|
||||
|
||||
public void readDescription( NBTTagCompound nbttagcompound )
|
||||
public void readDescription( NBTTagCompound nbt )
|
||||
{
|
||||
m_colour = nbttagcompound.getBoolean( "colour" );
|
||||
if( nbttagcompound.hasKey( "terminal" ) )
|
||||
m_colour = nbt.getBoolean( "colour" );
|
||||
if( nbt.hasKey( "terminal" ) )
|
||||
{
|
||||
NBTTagCompound terminal = nbttagcompound.getCompoundTag( "terminal" );
|
||||
NBTTagCompound terminal = nbt.getCompoundTag( "terminal" );
|
||||
resizeTerminal( terminal.getInteger( "term_width" ), terminal.getInteger( "term_height" ) );
|
||||
m_terminal.readFromNBT( terminal );
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class DefaultBundledRedstoneProvider implements IBundledRedstoneProvider
|
||||
public static int getDefaultBundledRedstoneOutput( World world, BlockPos pos, EnumFacing side )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
if( block != null && block instanceof BlockGeneric )
|
||||
if( block instanceof BlockGeneric )
|
||||
{
|
||||
BlockGeneric generic = (BlockGeneric) block;
|
||||
if( generic.getBundledRedstoneConnectivity( world, pos, side ) )
|
||||
|
@ -90,16 +90,16 @@ public class ServerTerminal implements ITerminal
|
||||
|
||||
// Networking stuff
|
||||
|
||||
public void writeDescription( NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound.setBoolean( "colour", m_colour );
|
||||
nbt.setBoolean( "colour", m_colour );
|
||||
if( m_terminal != null )
|
||||
{
|
||||
NBTTagCompound terminal = new NBTTagCompound();
|
||||
terminal.setInteger( "term_width", m_terminal.getWidth() );
|
||||
terminal.setInteger( "term_height", m_terminal.getHeight() );
|
||||
m_terminal.writeToNBT( terminal );
|
||||
nbttagcompound.setTag( "terminal", terminal );
|
||||
nbt.setTag( "terminal", terminal );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,11 +108,11 @@ public abstract class TileGeneric extends TileEntity
|
||||
player.getDistanceSq( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= (range * range);
|
||||
}
|
||||
|
||||
protected void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
protected void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
}
|
||||
|
||||
protected void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
protected void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
}
|
||||
|
||||
@ -126,24 +126,15 @@ public abstract class TileGeneric extends TileEntity
|
||||
public final SPacketUpdateTileEntity getUpdatePacket()
|
||||
{
|
||||
// Communicate properties
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
writeDescription( nbttagcompound );
|
||||
return new SPacketUpdateTileEntity( getPos(), 0, nbttagcompound );
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
writeDescription( nbt );
|
||||
return new SPacketUpdateTileEntity( getPos(), 0, nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDataPacket( NetworkManager net, SPacketUpdateTileEntity packet )
|
||||
{
|
||||
switch( packet.getTileEntityType() )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// Receive properties
|
||||
NBTTagCompound nbttagcompound = packet.getNbtCompound();
|
||||
readDescription( nbttagcompound );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( packet.getTileEntityType() == 0 ) readDescription( packet.getNbtCompound() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -121,7 +121,7 @@ public class BlockCommandComputer extends BlockComputerBase
|
||||
{
|
||||
// Not sure why this is necessary
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileCommandComputer )
|
||||
if( tile instanceof TileCommandComputer )
|
||||
{
|
||||
tile.setWorld( world ); // Not sure why this is necessary
|
||||
tile.setPos( pos ); // Not sure why this is necessary
|
||||
|
@ -159,7 +159,7 @@ public class BlockComputer extends BlockComputerBase
|
||||
{
|
||||
// Not sure why this is necessary
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileComputer )
|
||||
if( tile instanceof TileComputer )
|
||||
{
|
||||
tile.setWorld( world ); // Not sure why this is necessary
|
||||
tile.setPos( pos ); // Not sure why this is necessary
|
||||
|
@ -74,7 +74,7 @@ public abstract class BlockComputerBase extends BlockDirectional
|
||||
protected void updateInput( IBlockAccess world, BlockPos pos )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileComputerBase )
|
||||
if( tile instanceof TileComputerBase )
|
||||
{
|
||||
TileComputerBase computer = (TileComputerBase) tile;
|
||||
computer.updateInput();
|
||||
|
@ -74,17 +74,17 @@ public class TileComputer extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDescription( @Nonnull NBTTagCompound tag )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.writeDescription( tag );
|
||||
tag.setInteger( TAG_STATE, state.ordinal() );
|
||||
super.writeDescription( nbt );
|
||||
nbt.setInteger( TAG_STATE, state.ordinal() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( @Nonnull NBTTagCompound tag )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( tag );
|
||||
state = ComputerState.valueOf( tag.getInteger( TAG_STATE ) );
|
||||
super.readDescription( nbt );
|
||||
state = ComputerState.valueOf( nbt.getInteger( TAG_STATE ) );
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
public BlockComputerBase getBlock()
|
||||
{
|
||||
Block block = super.getBlock();
|
||||
if( block != null && block instanceof BlockComputerBase )
|
||||
if( block instanceof BlockComputerBase )
|
||||
{
|
||||
return (BlockComputerBase) block;
|
||||
}
|
||||
@ -228,39 +228,39 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbt = super.writeToNBT( nbt );
|
||||
|
||||
// Save ID, label and power state
|
||||
if( m_computerID >= 0 )
|
||||
{
|
||||
nbttagcompound.setInteger( "computerID", m_computerID );
|
||||
nbt.setInteger( "computerID", m_computerID );
|
||||
}
|
||||
if( m_label != null )
|
||||
{
|
||||
nbttagcompound.setString( "label", m_label );
|
||||
nbt.setString( "label", m_label );
|
||||
}
|
||||
nbttagcompound.setBoolean( "on", m_on );
|
||||
return nbttagcompound;
|
||||
nbt.setBoolean( "on", m_on );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
super.readFromNBT( nbttagcompound );
|
||||
super.readFromNBT( nbt );
|
||||
|
||||
// Load ID
|
||||
int id = -1;
|
||||
if( nbttagcompound.hasKey( "computerID" ) )
|
||||
if( nbt.hasKey( "computerID" ) )
|
||||
{
|
||||
// Post-1.6 computers
|
||||
id = nbttagcompound.getInteger( "computerID" );
|
||||
id = nbt.getInteger( "computerID" );
|
||||
}
|
||||
else if( nbttagcompound.hasKey( "userDir" ) )
|
||||
else if( nbt.hasKey( "userDir" ) )
|
||||
{
|
||||
// Pre-1.6 computers
|
||||
String userDir = nbttagcompound.getString( "userDir" );
|
||||
String userDir = nbt.getString( "userDir" );
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt( userDir );
|
||||
@ -273,17 +273,10 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
m_computerID = id;
|
||||
|
||||
// Load label
|
||||
if( nbttagcompound.hasKey( "label" ) )
|
||||
{
|
||||
m_label = nbttagcompound.getString( "label" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_label = null;
|
||||
}
|
||||
m_label = nbt.hasKey( "label" ) ? nbt.getString( "label" ) : null;
|
||||
|
||||
// Load power state
|
||||
m_startOn = nbttagcompound.getBoolean( "on" );
|
||||
m_startOn = nbt.getBoolean( "on" );
|
||||
m_on = m_startOn;
|
||||
}
|
||||
|
||||
@ -489,21 +482,21 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
// Networking stuff
|
||||
|
||||
@Override
|
||||
public void writeDescription( @Nonnull NBTTagCompound tag )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.writeDescription( tag );
|
||||
tag.setInteger( "instanceID", createServerComputer().getInstanceID() );
|
||||
if( m_label != null ) tag.setString( "label", m_label );
|
||||
if( m_computerID >= 0 ) tag.setInteger( "computerID", m_computerID );
|
||||
super.writeDescription( nbt );
|
||||
nbt.setInteger( "instanceID", createServerComputer().getInstanceID() );
|
||||
if( m_label != null ) nbt.setString( "label", m_label );
|
||||
if( m_computerID >= 0 ) nbt.setInteger( "computerID", m_computerID );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDescription( @Nonnull NBTTagCompound tag )
|
||||
public void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( tag );
|
||||
m_instanceID = tag.getInteger( "instanceID" );
|
||||
m_label = tag.hasKey( "label" ) ? tag.getString( "label" ) : null;
|
||||
m_computerID = tag.hasKey( "computerID" ) ? tag.getInteger( "computerID" ) : -1;
|
||||
super.readDescription( nbt );
|
||||
m_instanceID = nbt.getInteger( "instanceID" );
|
||||
m_label = nbt.hasKey( "label" ) ? nbt.getString( "label" ) : null;
|
||||
m_computerID = nbt.hasKey( "computerID" ) ? nbt.getInteger( "computerID" ) : -1;
|
||||
}
|
||||
|
||||
protected void transferStateFrom( TileComputerBase copy )
|
||||
|
@ -301,6 +301,7 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
|
||||
m_computer.addAPI( api );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "deprecation" )
|
||||
public void addAPI( dan200.computercraft.core.apis.ILuaAPI api )
|
||||
{
|
||||
m_computer.addAPI( api );
|
||||
@ -371,23 +372,6 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
|
||||
return ComputerCraftAPI.createUniqueNumberedSaveDir( m_world, "computer" );
|
||||
}
|
||||
|
||||
// Networking stuff
|
||||
public void writeComputerDescription( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
nbttagcompound.setInteger( "id", m_computer.getID() );
|
||||
String label = m_computer.getLabel();
|
||||
if( label != null )
|
||||
{
|
||||
nbttagcompound.setString( "label", label );
|
||||
}
|
||||
nbttagcompound.setBoolean( "on", m_computer.isOn() );
|
||||
nbttagcompound.setBoolean( "blinking", m_computer.isBlinking() );
|
||||
if( m_userData != null )
|
||||
{
|
||||
nbttagcompound.setTag( "userData", m_userData.copy() );
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInteracting( EntityPlayer player )
|
||||
{
|
||||
if( player == null ) return false;
|
||||
|
@ -88,7 +88,7 @@ public class ItemComputer extends ItemComputerBase
|
||||
if( super.placeBlockAt( stack, player, world, pos, side, hitX, hitY, hitZ, newState ) )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof IComputerTile )
|
||||
if( tile instanceof IComputerTile )
|
||||
{
|
||||
IComputerTile computer = (IComputerTile) tile;
|
||||
setupComputerAfterPlacement( stack, computer );
|
||||
|
@ -22,7 +22,7 @@ public class CommandBlockPeripheralProvider implements IPeripheralProvider
|
||||
public IPeripheral getPeripheral( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull EnumFacing side )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileEntityCommandBlock )
|
||||
if( tile instanceof TileEntityCommandBlock )
|
||||
{
|
||||
TileEntityCommandBlock commandBlock = (TileEntityCommandBlock) tile;
|
||||
return new CommandBlockPeripheral( commandBlock );
|
||||
|
@ -191,7 +191,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
int anim;
|
||||
EnumFacing dir;
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TilePeripheralBase )
|
||||
if( tile instanceof TilePeripheralBase )
|
||||
{
|
||||
TilePeripheralBase peripheral = (TilePeripheralBase) tile;
|
||||
anim = peripheral.getAnim();
|
||||
@ -348,7 +348,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
{
|
||||
EnumFacing front;
|
||||
int xIndex, yIndex, width, height;
|
||||
if( tile != null && tile instanceof TileMonitor )
|
||||
if( tile instanceof TileMonitor )
|
||||
{
|
||||
TileMonitor monitor = (TileMonitor) tile;
|
||||
dir = monitor.getDirection();
|
||||
@ -563,7 +563,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
{
|
||||
// Not sure why this is necessary
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TilePeripheralBase )
|
||||
if( tile instanceof TilePeripheralBase )
|
||||
{
|
||||
tile.setWorld( world ); // Not sure why this is necessary
|
||||
tile.setPos( pos ); // Not sure why this is necessary
|
||||
@ -577,7 +577,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
{
|
||||
EnumFacing dir = DirectionUtil.fromEntityRot( player );
|
||||
setDirection( world, pos, dir );
|
||||
if( stack.hasDisplayName() && tile != null && tile instanceof TilePeripheralBase )
|
||||
if( stack.hasDisplayName() && tile instanceof TilePeripheralBase )
|
||||
{
|
||||
TilePeripheralBase peripheral = (TilePeripheralBase) tile;
|
||||
peripheral.setLabel( stack.getDisplayName() );
|
||||
@ -587,7 +587,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
case Monitor:
|
||||
case AdvancedMonitor:
|
||||
{
|
||||
if( tile != null && tile instanceof TileMonitor )
|
||||
if( tile instanceof TileMonitor )
|
||||
{
|
||||
int direction = DirectionUtil.fromEntityRot( player ).getIndex();
|
||||
if( player.rotationPitch > 66.5F )
|
||||
|
@ -130,48 +130,45 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
// Read properties
|
||||
super.readFromNBT( nbttagcompound );
|
||||
if( nbttagcompound.hasKey( "dir" ) )
|
||||
super.readFromNBT( nbt );
|
||||
if( nbt.hasKey( "dir" ) )
|
||||
{
|
||||
m_dir = EnumFacing.byIndex( nbttagcompound.getInteger( "dir" ) );
|
||||
m_dir = EnumFacing.byIndex( nbt.getInteger( "dir" ) );
|
||||
}
|
||||
if( nbttagcompound.hasKey( "anim" ) )
|
||||
if( nbt.hasKey( "anim" ) )
|
||||
{
|
||||
m_anim = nbttagcompound.getInteger( "anim" );
|
||||
m_anim = nbt.getInteger( "anim" );
|
||||
}
|
||||
if( nbttagcompound.hasKey( "label" ) )
|
||||
if( nbt.hasKey( "label" ) )
|
||||
{
|
||||
m_label = nbttagcompound.getString( "label" );
|
||||
m_label = nbt.getString( "label" );
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
// Write properties
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound.setInteger( "dir", m_dir.getIndex() );
|
||||
nbttagcompound.setInteger( "anim", m_anim );
|
||||
if( m_label != null )
|
||||
{
|
||||
nbttagcompound.setString( "label", m_label );
|
||||
}
|
||||
return nbttagcompound;
|
||||
nbt = super.writeToNBT( nbt );
|
||||
nbt.setInteger( "dir", m_dir.getIndex() );
|
||||
nbt.setInteger( "anim", m_anim );
|
||||
if( m_label != null ) nbt.setString( "label", m_label );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
m_dir = EnumFacing.byIndex( nbttagcompound.getInteger( "dir" ) );
|
||||
m_anim = nbttagcompound.getInteger( "anim" );
|
||||
if( nbttagcompound.hasKey( "label" ) )
|
||||
super.readDescription( nbt );
|
||||
m_dir = EnumFacing.byIndex( nbt.getInteger( "dir" ) );
|
||||
m_anim = nbt.getInteger( "anim" );
|
||||
if( nbt.hasKey( "label" ) )
|
||||
{
|
||||
m_label = nbttagcompound.getString( "label" );
|
||||
m_label = nbt.getString( "label" );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -180,14 +177,14 @@ public abstract class TilePeripheralBase extends TileGeneric
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
nbttagcompound.setInteger( "dir", m_dir.getIndex() );
|
||||
nbttagcompound.setInteger( "anim", m_anim );
|
||||
super.writeDescription( nbt );
|
||||
nbt.setInteger( "dir", m_dir.getIndex() );
|
||||
nbt.setInteger( "anim", m_anim );
|
||||
if( m_label != null )
|
||||
{
|
||||
nbttagcompound.setString( "label", m_label );
|
||||
nbt.setString( "label", m_label );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
super.readFromNBT( nbttagcompound );
|
||||
if( nbttagcompound.hasKey( "item" ) )
|
||||
super.readFromNBT( nbt );
|
||||
if( nbt.hasKey( "item" ) )
|
||||
{
|
||||
NBTTagCompound item = nbttagcompound.getCompoundTag( "item" );
|
||||
NBTTagCompound item = nbt.getCompoundTag( "item" );
|
||||
m_diskStack = new ItemStack( item );
|
||||
m_diskMount = null;
|
||||
}
|
||||
@ -150,16 +150,16 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbt = super.writeToNBT( nbt );
|
||||
if( !m_diskStack.isEmpty() )
|
||||
{
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
m_diskStack.writeToNBT( item );
|
||||
nbttagcompound.setTag( "item", item );
|
||||
nbt.setTag( "item", item );
|
||||
}
|
||||
return nbttagcompound;
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -577,12 +577,12 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
if( nbttagcompound.hasKey( "item" ) )
|
||||
super.readDescription( nbt );
|
||||
if( nbt.hasKey( "item" ) )
|
||||
{
|
||||
m_diskStack = new ItemStack( nbttagcompound.getCompoundTag( "item" ) );
|
||||
m_diskStack = new ItemStack( nbt.getCompoundTag( "item" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -592,14 +592,14 @@ public class TileDiskDrive extends TilePeripheralBase implements DefaultInventor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
super.writeDescription( nbt );
|
||||
if( !m_diskStack.isEmpty() )
|
||||
{
|
||||
NBTTagCompound item = new NBTTagCompound();
|
||||
m_diskStack.writeToNBT( item );
|
||||
nbttagcompound.setTag( "item", item );
|
||||
nbt.setTag( "item", item );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,9 @@ public abstract class TileModemBase extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
super.readDescription( nbt );
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
|
@ -308,23 +308,23 @@ public class TileCable extends TileModemBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
// Read properties
|
||||
super.readFromNBT( nbttagcompound );
|
||||
m_peripheralAccessAllowed = nbttagcompound.getBoolean( "peripheralAccess" );
|
||||
m_peripheral.readNBT( nbttagcompound, "" );
|
||||
super.readFromNBT( nbt );
|
||||
m_peripheralAccessAllowed = nbt.getBoolean( "peripheralAccess" );
|
||||
m_peripheral.readNBT( nbt, "" );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
// Write properties
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound.setBoolean( "peripheralAccess", m_peripheralAccessAllowed );
|
||||
m_peripheral.writeNBT( nbttagcompound, "" );
|
||||
return nbttagcompound;
|
||||
nbt = super.writeToNBT( nbt );
|
||||
nbt.setBoolean( "peripheralAccess", m_peripheralAccessAllowed );
|
||||
m_peripheral.writeNBT( nbt, "" );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -214,21 +214,21 @@ public class TileWiredModemFull extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound tag )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
super.readFromNBT( tag );
|
||||
m_peripheralAccessAllowed = tag.getBoolean( "peripheralAccess" );
|
||||
for( int i = 0; i < m_peripherals.length; i++ ) m_peripherals[i].readNBT( tag, "_" + i );
|
||||
super.readFromNBT( nbt );
|
||||
m_peripheralAccessAllowed = nbt.getBoolean( "peripheralAccess" );
|
||||
for( int i = 0; i < m_peripherals.length; i++ ) m_peripherals[i].readNBT( nbt, "_" + i );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound tag )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
tag = super.writeToNBT( tag );
|
||||
tag.setBoolean( "peripheralAccess", m_peripheralAccessAllowed );
|
||||
for( int i = 0; i < m_peripherals.length; i++ ) m_peripherals[i].writeNBT( tag, "_" + i );
|
||||
return tag;
|
||||
nbt = super.writeToNBT( nbt );
|
||||
nbt.setBoolean( "peripheralAccess", m_peripheralAccessAllowed );
|
||||
for( int i = 0; i < m_peripherals.length; i++ ) m_peripherals[i].writeNBT( nbt, "_" + i );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
protected void updateAnim()
|
||||
@ -240,9 +240,9 @@ public class TileWiredModemFull extends TilePeripheralBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( @Nonnull NBTTagCompound tag )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( tag );
|
||||
super.readDescription( nbt );
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ public class MonitorPeripheral implements IPeripheral
|
||||
@Override
|
||||
public boolean equals( IPeripheral other )
|
||||
{
|
||||
if( other != null && other instanceof MonitorPeripheral )
|
||||
if( other instanceof MonitorPeripheral )
|
||||
{
|
||||
MonitorPeripheral otherMonitor = (MonitorPeripheral) other;
|
||||
if( otherMonitor.m_monitor == this.m_monitor )
|
||||
|
@ -123,26 +123,26 @@ public class TileMonitor extends TilePeripheralBase
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound.setInteger( "xIndex", m_xIndex );
|
||||
nbttagcompound.setInteger( "yIndex", m_yIndex );
|
||||
nbttagcompound.setInteger( "width", m_width );
|
||||
nbttagcompound.setInteger( "height", m_height );
|
||||
nbttagcompound.setInteger( "dir", m_dir );
|
||||
return nbttagcompound;
|
||||
nbt = super.writeToNBT( nbt );
|
||||
nbt.setInteger( "xIndex", m_xIndex );
|
||||
nbt.setInteger( "yIndex", m_yIndex );
|
||||
nbt.setInteger( "width", m_width );
|
||||
nbt.setInteger( "height", m_height );
|
||||
nbt.setInteger( "dir", m_dir );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
super.readFromNBT( nbttagcompound );
|
||||
m_xIndex = nbttagcompound.getInteger( "xIndex" );
|
||||
m_yIndex = nbttagcompound.getInteger( "yIndex" );
|
||||
m_width = nbttagcompound.getInteger( "width" );
|
||||
m_height = nbttagcompound.getInteger( "height" );
|
||||
m_dir = nbttagcompound.getInteger( "dir" );
|
||||
super.readFromNBT( nbt );
|
||||
m_xIndex = nbt.getInteger( "xIndex" );
|
||||
m_yIndex = nbt.getInteger( "yIndex" );
|
||||
m_width = nbt.getInteger( "width" );
|
||||
m_height = nbt.getInteger( "height" );
|
||||
m_dir = nbt.getInteger( "dir" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -262,25 +262,25 @@ public class TileMonitor extends TilePeripheralBase
|
||||
// Networking stuff
|
||||
|
||||
@Override
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
nbttagcompound.setInteger( "xIndex", m_xIndex );
|
||||
nbttagcompound.setInteger( "yIndex", m_yIndex );
|
||||
nbttagcompound.setInteger( "width", m_width );
|
||||
nbttagcompound.setInteger( "height", m_height );
|
||||
nbttagcompound.setInteger( "monitorDir", m_dir );
|
||||
super.writeDescription( nbt );
|
||||
nbt.setInteger( "xIndex", m_xIndex );
|
||||
nbt.setInteger( "yIndex", m_yIndex );
|
||||
nbt.setInteger( "width", m_width );
|
||||
nbt.setInteger( "height", m_height );
|
||||
nbt.setInteger( "monitorDir", m_dir );
|
||||
|
||||
if( m_xIndex == 0 && m_yIndex == 0 && m_serverMonitor != null )
|
||||
{
|
||||
m_serverMonitor.writeDescription( nbttagcompound );
|
||||
m_serverMonitor.writeDescription( nbt );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
super.readDescription( nbt );
|
||||
|
||||
int oldXIndex = m_xIndex;
|
||||
int oldYIndex = m_yIndex;
|
||||
@ -288,11 +288,11 @@ public class TileMonitor extends TilePeripheralBase
|
||||
int oldHeight = m_height;
|
||||
int oldDir = m_dir;
|
||||
|
||||
m_xIndex = nbttagcompound.getInteger( "xIndex" );
|
||||
m_yIndex = nbttagcompound.getInteger( "yIndex" );
|
||||
m_width = nbttagcompound.getInteger( "width" );
|
||||
m_height = nbttagcompound.getInteger( "height" );
|
||||
m_dir = nbttagcompound.getInteger( "monitorDir" );
|
||||
m_xIndex = nbt.getInteger( "xIndex" );
|
||||
m_yIndex = nbt.getInteger( "yIndex" );
|
||||
m_width = nbt.getInteger( "width" );
|
||||
m_height = nbt.getInteger( "height" );
|
||||
m_dir = nbt.getInteger( "monitorDir" );
|
||||
|
||||
if( oldXIndex != m_xIndex || oldYIndex != m_yIndex )
|
||||
{
|
||||
@ -306,7 +306,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
{
|
||||
// If we're the origin terminal then read the description
|
||||
if( m_clientMonitor == null ) m_clientMonitor = new ClientMonitor( m_advanced, this );
|
||||
m_clientMonitor.readDescription( nbttagcompound );
|
||||
m_clientMonitor.readDescription( nbt );
|
||||
}
|
||||
|
||||
if( oldXIndex != m_xIndex || oldYIndex != m_yIndex ||
|
||||
@ -427,7 +427,7 @@ public class TileMonitor extends TilePeripheralBase
|
||||
if( world != null && world.isBlockLoaded( pos ) )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileMonitor )
|
||||
if( tile instanceof TileMonitor )
|
||||
{
|
||||
TileMonitor monitor = (TileMonitor) tile;
|
||||
if( monitor.getDir() == getDir() && monitor.m_advanced == m_advanced &&
|
||||
|
@ -88,22 +88,22 @@ public class TilePrinter extends TilePeripheralBase implements DefaultSidedInven
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
super.readFromNBT( nbttagcompound );
|
||||
super.readFromNBT( nbt );
|
||||
|
||||
// Read page
|
||||
synchronized( m_page )
|
||||
{
|
||||
m_printing = nbttagcompound.getBoolean( "printing" );
|
||||
m_pageTitle = nbttagcompound.getString( "pageTitle" );
|
||||
m_page.readFromNBT( nbttagcompound );
|
||||
m_printing = nbt.getBoolean( "printing" );
|
||||
m_pageTitle = nbt.getString( "pageTitle" );
|
||||
m_page.readFromNBT( nbt );
|
||||
}
|
||||
|
||||
// Read inventory
|
||||
synchronized( m_inventory )
|
||||
{
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
NBTTagList nbttaglist = nbt.getTagList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
for( int i = 0; i < nbttaglist.tagCount(); i++ )
|
||||
{
|
||||
NBTTagCompound itemTag = nbttaglist.getCompoundTagAt( i );
|
||||
@ -118,16 +118,16 @@ public class TilePrinter extends TilePeripheralBase implements DefaultSidedInven
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbt = super.writeToNBT( nbt );
|
||||
|
||||
// Write page
|
||||
synchronized( m_page )
|
||||
{
|
||||
nbttagcompound.setBoolean( "printing", m_printing );
|
||||
nbttagcompound.setString( "pageTitle", m_pageTitle );
|
||||
m_page.writeToNBT( nbttagcompound );
|
||||
nbt.setBoolean( "printing", m_printing );
|
||||
nbt.setString( "pageTitle", m_pageTitle );
|
||||
m_page.writeToNBT( nbt );
|
||||
}
|
||||
|
||||
// Write inventory
|
||||
@ -144,16 +144,16 @@ public class TilePrinter extends TilePeripheralBase implements DefaultSidedInven
|
||||
nbttaglist.appendTag( itemtag );
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag( "Items", nbttaglist );
|
||||
nbt.setTag( "Items", nbttaglist );
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public final void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
super.readDescription( nbt );
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.diskDriveGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileDiskDrive )
|
||||
if( tile instanceof TileDiskDrive )
|
||||
{
|
||||
TileDiskDrive drive = (TileDiskDrive) tile;
|
||||
return new ContainerDiskDrive( player.inventory, drive );
|
||||
@ -446,7 +446,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.computerGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileComputer )
|
||||
if( tile instanceof TileComputer )
|
||||
{
|
||||
TileComputer computer = (TileComputer) tile;
|
||||
return new ContainerComputer( computer );
|
||||
@ -456,7 +456,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.printerGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TilePrinter )
|
||||
if( tile instanceof TilePrinter )
|
||||
{
|
||||
TilePrinter printer = (TilePrinter) tile;
|
||||
return new ContainerPrinter( player.inventory, printer );
|
||||
@ -466,7 +466,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.turtleGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileTurtle )
|
||||
if( tile instanceof TileTurtle )
|
||||
{
|
||||
TileTurtle turtle = (TileTurtle) tile;
|
||||
return new ContainerTurtle( player.inventory, turtle.getAccess(), turtle.getServerComputer() );
|
||||
@ -499,7 +499,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.diskDriveGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileDiskDrive )
|
||||
if( tile instanceof TileDiskDrive )
|
||||
{
|
||||
TileDiskDrive drive = (TileDiskDrive) tile;
|
||||
return getDiskDriveGUI( player.inventory, drive );
|
||||
@ -509,7 +509,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.computerGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileComputer )
|
||||
if( tile instanceof TileComputer )
|
||||
{
|
||||
TileComputer computer = (TileComputer) tile;
|
||||
return getComputerGUI( computer );
|
||||
@ -519,7 +519,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.printerGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TilePrinter )
|
||||
if( tile instanceof TilePrinter )
|
||||
{
|
||||
TilePrinter printer = (TilePrinter) tile;
|
||||
return getPrinterGUI( player.inventory, printer );
|
||||
@ -529,7 +529,7 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
|
||||
case ComputerCraft.turtleGUIID:
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileTurtle )
|
||||
if( tile instanceof TileTurtle )
|
||||
{
|
||||
TileTurtle turtle = (TileTurtle) tile;
|
||||
return getTurtleGUI( player.inventory, turtle );
|
||||
|
@ -297,12 +297,12 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT( NBTTagCompound nbttagcompound )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
super.readFromNBT( nbttagcompound );
|
||||
super.readFromNBT( nbt );
|
||||
|
||||
// Read inventory
|
||||
NBTTagList nbttaglist = nbttagcompound.getTagList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
NBTTagList nbttaglist = nbt.getTagList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
m_inventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
m_previousInventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
for( int i = 0; i < nbttaglist.tagCount(); i++ )
|
||||
@ -317,14 +317,14 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
|
||||
// Read state
|
||||
m_brain.readFromNBT( nbttagcompound );
|
||||
m_brain.readFromNBT( nbt );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
nbt = super.writeToNBT( nbt );
|
||||
|
||||
// Write inventory
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
@ -338,12 +338,12 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
nbttaglist.appendTag( itemtag );
|
||||
}
|
||||
}
|
||||
nbttagcompound.setTag( "Items", nbttaglist );
|
||||
nbt.setTag( "Items", nbttaglist );
|
||||
|
||||
// Write brain
|
||||
nbttagcompound = m_brain.writeToNBT( nbttagcompound );
|
||||
nbt = m_brain.writeToNBT( nbt );
|
||||
|
||||
return nbttagcompound;
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -608,17 +608,17 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
// Networking stuff
|
||||
|
||||
@Override
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.writeDescription( nbttagcompound );
|
||||
m_brain.writeDescription( nbttagcompound );
|
||||
super.writeDescription( nbt );
|
||||
m_brain.writeDescription( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readDescription( @Nonnull NBTTagCompound nbttagcompound )
|
||||
public void readDescription( @Nonnull NBTTagCompound nbt )
|
||||
{
|
||||
super.readDescription( nbttagcompound );
|
||||
m_brain.readDescription( nbttagcompound );
|
||||
super.readDescription( nbt );
|
||||
m_brain.readDescription( nbt );
|
||||
updateBlock();
|
||||
}
|
||||
|
||||
|
@ -132,24 +132,17 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
}
|
||||
|
||||
public void readFromNBT( NBTTagCompound tag )
|
||||
public void readFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
// Read state
|
||||
m_direction = EnumFacing.byIndex( tag.getInteger( "dir" ) );
|
||||
m_selectedSlot = tag.getInteger( "selectedSlot" );
|
||||
if( tag.hasKey( "fuelLevel" ) )
|
||||
{
|
||||
m_fuelLevel = tag.getInteger( "fuelLevel" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fuelLevel = 0;
|
||||
}
|
||||
m_direction = EnumFacing.byIndex( nbt.getInteger( "dir" ) );
|
||||
m_selectedSlot = nbt.getInteger( "selectedSlot" );
|
||||
m_fuelLevel = nbt.hasKey( "fuelLevel" ) ? nbt.getInteger( "fuelLevel" ) : 0;
|
||||
|
||||
// Read owner
|
||||
if( tag.hasKey( "owner", Constants.NBT.TAG_COMPOUND ) )
|
||||
if( nbt.hasKey( "owner", Constants.NBT.TAG_COMPOUND ) )
|
||||
{
|
||||
NBTTagCompound owner = tag.getCompoundTag( "owner" );
|
||||
NBTTagCompound owner = nbt.getCompoundTag( "owner" );
|
||||
m_owningPlayer = new GameProfile(
|
||||
new UUID( owner.getLong( "upper_id" ), owner.getLong( "lower_id" ) ),
|
||||
owner.getString( "name" )
|
||||
@ -161,15 +154,15 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
// Read colour
|
||||
m_colourHex = ColourUtils.getHexColour( tag );
|
||||
m_colourHex = ColourUtils.getHexColour( nbt );
|
||||
|
||||
// Read overlay
|
||||
if( tag.hasKey( "overlay_mod" ) )
|
||||
if( nbt.hasKey( "overlay_mod" ) )
|
||||
{
|
||||
String overlay_mod = tag.getString( "overlay_mod" );
|
||||
if( tag.hasKey( "overlay_path" ) )
|
||||
String overlay_mod = nbt.getString( "overlay_mod" );
|
||||
if( nbt.hasKey( "overlay_path" ) )
|
||||
{
|
||||
String overlay_path = tag.getString( "overlay_path" );
|
||||
String overlay_path = nbt.getString( "overlay_path" );
|
||||
m_overlay = new ResourceLocation( overlay_mod, overlay_path );
|
||||
}
|
||||
else
|
||||
@ -186,10 +179,10 @@ public class TurtleBrain implements ITurtleAccess
|
||||
// (pre-1.4 turtles will have a "subType" variable, newer things will have "leftUpgrade" and "rightUpgrade")
|
||||
ITurtleUpgrade leftUpgrade = null;
|
||||
ITurtleUpgrade rightUpgrade = null;
|
||||
if( tag.hasKey( "subType" ) )
|
||||
if( nbt.hasKey( "subType" ) )
|
||||
{
|
||||
// Loading a pre-1.4 world
|
||||
int subType = tag.getInteger( "subType" );
|
||||
int subType = nbt.getInteger( "subType" );
|
||||
if( (subType & 0x1) > 0 )
|
||||
{
|
||||
leftUpgrade = ComputerCraft.Upgrades.diamondPickaxe;
|
||||
@ -202,26 +195,26 @@ public class TurtleBrain implements ITurtleAccess
|
||||
else
|
||||
{
|
||||
// Loading a post-1.4 world
|
||||
if( tag.hasKey( "leftUpgrade" ) )
|
||||
if( nbt.hasKey( "leftUpgrade" ) )
|
||||
{
|
||||
if( tag.getTagId( "leftUpgrade" ) == Constants.NBT.TAG_STRING )
|
||||
if( nbt.getTagId( "leftUpgrade" ) == Constants.NBT.TAG_STRING )
|
||||
{
|
||||
leftUpgrade = TurtleUpgrades.get( tag.getString( "leftUpgrade" ) );
|
||||
leftUpgrade = TurtleUpgrades.get( nbt.getString( "leftUpgrade" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
leftUpgrade = TurtleUpgrades.get( tag.getShort( "leftUpgrade" ) );
|
||||
leftUpgrade = TurtleUpgrades.get( nbt.getShort( "leftUpgrade" ) );
|
||||
}
|
||||
}
|
||||
if( tag.hasKey( "rightUpgrade" ) )
|
||||
if( nbt.hasKey( "rightUpgrade" ) )
|
||||
{
|
||||
if( tag.getTagId( "rightUpgrade" ) == Constants.NBT.TAG_STRING )
|
||||
if( nbt.getTagId( "rightUpgrade" ) == Constants.NBT.TAG_STRING )
|
||||
{
|
||||
rightUpgrade = TurtleUpgrades.get( tag.getString( "rightUpgrade" ) );
|
||||
rightUpgrade = TurtleUpgrades.get( nbt.getString( "rightUpgrade" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
rightUpgrade = TurtleUpgrades.get( tag.getShort( "rightUpgrade" ) );
|
||||
rightUpgrade = TurtleUpgrades.get( nbt.getShort( "rightUpgrade" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,28 +223,28 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
// NBT
|
||||
m_upgradeNBTData.clear();
|
||||
if( tag.hasKey( "leftUpgradeNBT" ) )
|
||||
if( nbt.hasKey( "leftUpgradeNBT" ) )
|
||||
{
|
||||
m_upgradeNBTData.put( TurtleSide.Left, tag.getCompoundTag( "leftUpgradeNBT" ).copy() );
|
||||
m_upgradeNBTData.put( TurtleSide.Left, nbt.getCompoundTag( "leftUpgradeNBT" ).copy() );
|
||||
}
|
||||
if( tag.hasKey( "rightUpgradeNBT" ) )
|
||||
if( nbt.hasKey( "rightUpgradeNBT" ) )
|
||||
{
|
||||
m_upgradeNBTData.put( TurtleSide.Right, tag.getCompoundTag( "rightUpgradeNBT" ).copy() );
|
||||
m_upgradeNBTData.put( TurtleSide.Right, nbt.getCompoundTag( "rightUpgradeNBT" ).copy() );
|
||||
}
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbt )
|
||||
{
|
||||
// Write state
|
||||
nbttagcompound.setInteger( "dir", m_direction.getIndex() );
|
||||
nbttagcompound.setInteger( "selectedSlot", m_selectedSlot );
|
||||
nbttagcompound.setInteger( "fuelLevel", m_fuelLevel );
|
||||
nbt.setInteger( "dir", m_direction.getIndex() );
|
||||
nbt.setInteger( "selectedSlot", m_selectedSlot );
|
||||
nbt.setInteger( "fuelLevel", m_fuelLevel );
|
||||
|
||||
// Write owner
|
||||
if( m_owningPlayer != null )
|
||||
{
|
||||
NBTTagCompound owner = new NBTTagCompound();
|
||||
nbttagcompound.setTag( "owner", owner );
|
||||
nbt.setTag( "owner", owner );
|
||||
|
||||
owner.setLong( "upper_id", m_owningPlayer.getId().getMostSignificantBits() );
|
||||
owner.setLong( "lower_id", m_owningPlayer.getId().getLeastSignificantBits() );
|
||||
@ -262,38 +255,38 @@ public class TurtleBrain implements ITurtleAccess
|
||||
String leftUpgradeID = getUpgradeID( getUpgrade( TurtleSide.Left ) );
|
||||
if( leftUpgradeID != null )
|
||||
{
|
||||
nbttagcompound.setString( "leftUpgrade", leftUpgradeID );
|
||||
nbt.setString( "leftUpgrade", leftUpgradeID );
|
||||
}
|
||||
String rightUpgradeID = getUpgradeID( getUpgrade( TurtleSide.Right ) );
|
||||
if( rightUpgradeID != null )
|
||||
{
|
||||
nbttagcompound.setString( "rightUpgrade", rightUpgradeID );
|
||||
nbt.setString( "rightUpgrade", rightUpgradeID );
|
||||
}
|
||||
|
||||
// Write colour
|
||||
if( m_colourHex != -1 )
|
||||
{
|
||||
nbttagcompound.setInteger( "colour", m_colourHex );
|
||||
nbt.setInteger( "colour", m_colourHex );
|
||||
}
|
||||
|
||||
// Write overlay
|
||||
if( m_overlay != null )
|
||||
{
|
||||
nbttagcompound.setString( "overlay_mod", m_overlay.getNamespace() );
|
||||
nbttagcompound.setString( "overlay_path", m_overlay.getPath() );
|
||||
nbt.setString( "overlay_mod", m_overlay.getNamespace() );
|
||||
nbt.setString( "overlay_path", m_overlay.getPath() );
|
||||
}
|
||||
|
||||
// Write NBT
|
||||
if( m_upgradeNBTData.containsKey( TurtleSide.Left ) )
|
||||
{
|
||||
nbttagcompound.setTag( "leftUpgradeNBT", getUpgradeNBTData( TurtleSide.Left ).copy() );
|
||||
nbt.setTag( "leftUpgradeNBT", getUpgradeNBTData( TurtleSide.Left ).copy() );
|
||||
}
|
||||
if( m_upgradeNBTData.containsKey( TurtleSide.Right ) )
|
||||
{
|
||||
nbttagcompound.setTag( "rightUpgradeNBT", getUpgradeNBTData( TurtleSide.Right ).copy() );
|
||||
nbt.setTag( "rightUpgradeNBT", getUpgradeNBTData( TurtleSide.Right ).copy() );
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
return nbt;
|
||||
}
|
||||
|
||||
private String getUpgradeID( ITurtleUpgrade upgrade )
|
||||
@ -305,63 +298,63 @@ public class TurtleBrain implements ITurtleAccess
|
||||
return null;
|
||||
}
|
||||
|
||||
public void writeDescription( NBTTagCompound nbttagcompound )
|
||||
public void writeDescription( NBTTagCompound nbt )
|
||||
{
|
||||
// Upgrades
|
||||
String leftUpgradeID = getUpgradeID( getUpgrade( TurtleSide.Left ) );
|
||||
if( leftUpgradeID != null )
|
||||
{
|
||||
nbttagcompound.setString( "leftUpgrade", leftUpgradeID );
|
||||
nbt.setString( "leftUpgrade", leftUpgradeID );
|
||||
}
|
||||
String rightUpgradeID = getUpgradeID( getUpgrade( TurtleSide.Right ) );
|
||||
if( rightUpgradeID != null )
|
||||
{
|
||||
nbttagcompound.setString( "rightUpgrade", rightUpgradeID );
|
||||
nbt.setString( "rightUpgrade", rightUpgradeID );
|
||||
}
|
||||
|
||||
// NBT
|
||||
if( m_upgradeNBTData.containsKey( TurtleSide.Left ) )
|
||||
{
|
||||
nbttagcompound.setTag( "leftUpgradeNBT", getUpgradeNBTData( TurtleSide.Left ).copy() );
|
||||
nbt.setTag( "leftUpgradeNBT", getUpgradeNBTData( TurtleSide.Left ).copy() );
|
||||
}
|
||||
if( m_upgradeNBTData.containsKey( TurtleSide.Right ) )
|
||||
{
|
||||
nbttagcompound.setTag( "rightUpgradeNBT", getUpgradeNBTData( TurtleSide.Right ).copy() );
|
||||
nbt.setTag( "rightUpgradeNBT", getUpgradeNBTData( TurtleSide.Right ).copy() );
|
||||
}
|
||||
|
||||
// Colour
|
||||
if( m_colourHex != -1 )
|
||||
{
|
||||
nbttagcompound.setInteger( "colour", m_colourHex );
|
||||
nbt.setInteger( "colour", m_colourHex );
|
||||
}
|
||||
|
||||
// Overlay
|
||||
if( m_overlay != null )
|
||||
{
|
||||
nbttagcompound.setString( "overlay_mod", m_overlay.getNamespace() );
|
||||
nbttagcompound.setString( "overlay_path", m_overlay.getPath() );
|
||||
nbt.setString( "overlay_mod", m_overlay.getNamespace() );
|
||||
nbt.setString( "overlay_path", m_overlay.getPath() );
|
||||
}
|
||||
|
||||
// Animation
|
||||
nbttagcompound.setInteger( "animation", m_animation.ordinal() );
|
||||
nbttagcompound.setInteger( "direction", m_direction.getIndex() );
|
||||
nbttagcompound.setInteger( "fuelLevel", m_fuelLevel );
|
||||
nbt.setInteger( "animation", m_animation.ordinal() );
|
||||
nbt.setInteger( "direction", m_direction.getIndex() );
|
||||
nbt.setInteger( "fuelLevel", m_fuelLevel );
|
||||
}
|
||||
|
||||
public void readDescription( NBTTagCompound nbttagcompound )
|
||||
public void readDescription( NBTTagCompound nbt )
|
||||
{
|
||||
// Upgrades
|
||||
if( nbttagcompound.hasKey( "leftUpgrade" ) )
|
||||
if( nbt.hasKey( "leftUpgrade" ) )
|
||||
{
|
||||
setUpgrade( TurtleSide.Left, TurtleUpgrades.get( nbttagcompound.getString( "leftUpgrade" ) ) );
|
||||
setUpgrade( TurtleSide.Left, TurtleUpgrades.get( nbt.getString( "leftUpgrade" ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
setUpgrade( TurtleSide.Left, null );
|
||||
}
|
||||
if( nbttagcompound.hasKey( "rightUpgrade" ) )
|
||||
if( nbt.hasKey( "rightUpgrade" ) )
|
||||
{
|
||||
setUpgrade( TurtleSide.Right, TurtleUpgrades.get( nbttagcompound.getString( "rightUpgrade" ) ) );
|
||||
setUpgrade( TurtleSide.Right, TurtleUpgrades.get( nbt.getString( "rightUpgrade" ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -370,23 +363,23 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
// NBT
|
||||
m_upgradeNBTData.clear();
|
||||
if( nbttagcompound.hasKey( "leftUpgradeNBT" ) )
|
||||
if( nbt.hasKey( "leftUpgradeNBT" ) )
|
||||
{
|
||||
m_upgradeNBTData.put( TurtleSide.Left, nbttagcompound.getCompoundTag( "leftUpgradeNBT" ).copy() );
|
||||
m_upgradeNBTData.put( TurtleSide.Left, nbt.getCompoundTag( "leftUpgradeNBT" ).copy() );
|
||||
}
|
||||
if( nbttagcompound.hasKey( "rightUpgradeNBT" ) )
|
||||
if( nbt.hasKey( "rightUpgradeNBT" ) )
|
||||
{
|
||||
m_upgradeNBTData.put( TurtleSide.Right, nbttagcompound.getCompoundTag( "rightUpgradeNBT" ).copy() );
|
||||
m_upgradeNBTData.put( TurtleSide.Right, nbt.getCompoundTag( "rightUpgradeNBT" ).copy() );
|
||||
}
|
||||
|
||||
// Colour
|
||||
m_colourHex = ColourUtils.getHexColour( nbttagcompound );
|
||||
m_colourHex = ColourUtils.getHexColour( nbt );
|
||||
|
||||
// Overlay
|
||||
if( nbttagcompound.hasKey( "overlay_mod" ) && nbttagcompound.hasKey( "overlay_path" ) )
|
||||
if( nbt.hasKey( "overlay_mod" ) && nbt.hasKey( "overlay_path" ) )
|
||||
{
|
||||
String overlay_mod = nbttagcompound.getString( "overlay_mod" );
|
||||
String overlay_path = nbttagcompound.getString( "overlay_path" );
|
||||
String overlay_mod = nbt.getString( "overlay_mod" );
|
||||
String overlay_path = nbt.getString( "overlay_path" );
|
||||
m_overlay = new ResourceLocation( overlay_mod, overlay_path );
|
||||
}
|
||||
else
|
||||
@ -395,19 +388,19 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
// Animation
|
||||
TurtleAnimation anim = TurtleAnimation.values()[nbttagcompound.getInteger( "animation" )];
|
||||
TurtleAnimation anim = TurtleAnimation.values()[nbt.getInteger( "animation" )];
|
||||
if( anim != m_animation &&
|
||||
anim != TurtleAnimation.Wait &&
|
||||
anim != TurtleAnimation.ShortWait &&
|
||||
anim != TurtleAnimation.None )
|
||||
{
|
||||
m_animation = TurtleAnimation.values()[nbttagcompound.getInteger( "animation" )];
|
||||
m_animation = TurtleAnimation.values()[nbt.getInteger( "animation" )];
|
||||
m_animationProgress = 0;
|
||||
m_lastAnimationProgress = 0;
|
||||
}
|
||||
|
||||
m_direction = EnumFacing.byIndex( nbttagcompound.getInteger( "direction" ) );
|
||||
m_fuelLevel = nbttagcompound.getInteger( "fuelLevel" );
|
||||
m_direction = EnumFacing.byIndex( nbt.getInteger( "direction" ) );
|
||||
m_fuelLevel = nbt.getInteger( "fuelLevel" );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -461,7 +454,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
if( block == oldBlock )
|
||||
{
|
||||
TileEntity newTile = world.getTileEntity( pos );
|
||||
if( newTile != null && newTile instanceof TileTurtle )
|
||||
if( newTile instanceof TileTurtle )
|
||||
{
|
||||
// Copy the old turtle state into the new turtle
|
||||
TileTurtle newTurtle = (TileTurtle) newTile;
|
||||
|
@ -107,7 +107,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
boolean storedItems = false;
|
||||
for( Entity entity : list )
|
||||
{
|
||||
if( entity != null && entity instanceof EntityItem && !entity.isDead )
|
||||
if( entity instanceof EntityItem && !entity.isDead )
|
||||
{
|
||||
// Suck up the item
|
||||
foundItems = true;
|
||||
|
Loading…
Reference in New Issue
Block a user