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