mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-12 11:24:34 +00:00
Remove m_ (#658)
IT'S GONE! Not looking forward to the merge conflicts on this one.
This commit is contained in:
@@ -63,13 +63,13 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
MOVED
|
||||
}
|
||||
|
||||
private final NonNullList<ItemStack> m_inventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
private final NonNullList<ItemStack> m_previousInventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
private final IItemHandlerModifiable m_itemHandler = new InvWrapper( this );
|
||||
private final NonNullList<ItemStack> inventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
private final NonNullList<ItemStack> previousInventory = NonNullList.withSize( INVENTORY_SIZE, ItemStack.EMPTY );
|
||||
private final IItemHandlerModifiable itemHandler = new InvWrapper( this );
|
||||
private LazyOptional<IItemHandlerModifiable> itemHandlerCap;
|
||||
private boolean m_inventoryChanged = false;
|
||||
private TurtleBrain m_brain = new TurtleBrain( this );
|
||||
private MoveState m_moveState = MoveState.NOT_MOVED;
|
||||
private boolean inventoryChanged = false;
|
||||
private TurtleBrain brain = new TurtleBrain( this );
|
||||
private MoveState moveState = MoveState.NOT_MOVED;
|
||||
private LazyOptional<IPeripheral> peripheral;
|
||||
|
||||
public TileTurtle( TileEntityType<? extends TileGeneric> type, ComputerFamily family )
|
||||
@@ -79,7 +79,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
|
||||
private boolean hasMoved()
|
||||
{
|
||||
return m_moveState == MoveState.MOVED;
|
||||
return moveState == MoveState.MOVED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,13 +91,13 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
);
|
||||
computer.setPosition( getBlockPos() );
|
||||
computer.addAPI( new TurtleAPI( computer.getAPIEnvironment(), getAccess() ) );
|
||||
m_brain.setupComputer( computer );
|
||||
brain.setupComputer( computer );
|
||||
return computer;
|
||||
}
|
||||
|
||||
public ComputerProxy createProxy()
|
||||
{
|
||||
return m_brain.getProxy();
|
||||
return brain.getProxy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,9 +163,9 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
if( !getLevel().isClientSide )
|
||||
{
|
||||
DyeColor dye = ((DyeItem) currentItem.getItem()).getDyeColor();
|
||||
if( m_brain.getDyeColour() != dye )
|
||||
if( brain.getDyeColour() != dye )
|
||||
{
|
||||
m_brain.setDyeColour( dye );
|
||||
brain.setDyeColour( dye );
|
||||
if( !player.isCreative() )
|
||||
{
|
||||
currentItem.shrink( 1 );
|
||||
@@ -174,14 +174,14 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
else if( currentItem.getItem() == Items.WATER_BUCKET && m_brain.getColour() != -1 )
|
||||
else if( currentItem.getItem() == Items.WATER_BUCKET && brain.getColour() != -1 )
|
||||
{
|
||||
// Water to remove turtle colour
|
||||
if( !getLevel().isClientSide )
|
||||
{
|
||||
if( m_brain.getColour() != -1 )
|
||||
if( brain.getColour() != -1 )
|
||||
{
|
||||
m_brain.setColour( -1 );
|
||||
brain.setColour( -1 );
|
||||
if( !player.isCreative() )
|
||||
{
|
||||
player.setItemInHand( hand, new ItemStack( Items.BUCKET ) );
|
||||
@@ -213,16 +213,16 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
public void tick()
|
||||
{
|
||||
super.tick();
|
||||
m_brain.update();
|
||||
if( !getLevel().isClientSide && m_inventoryChanged )
|
||||
brain.update();
|
||||
if( !getLevel().isClientSide && inventoryChanged )
|
||||
{
|
||||
ServerComputer computer = getServerComputer();
|
||||
if( computer != null ) computer.queueEvent( "turtle_inventory" );
|
||||
|
||||
m_inventoryChanged = false;
|
||||
inventoryChanged = false;
|
||||
for( int n = 0; n < getContainerSize(); n++ )
|
||||
{
|
||||
m_previousInventory.set( n, getItem( n ).copy() );
|
||||
previousInventory.set( n, getItem( n ).copy() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,24 +235,24 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
@Override
|
||||
public void onNeighbourChange( @Nonnull BlockPos neighbour )
|
||||
{
|
||||
if( m_moveState == MoveState.NOT_MOVED ) super.onNeighbourChange( neighbour );
|
||||
if( moveState == MoveState.NOT_MOVED ) super.onNeighbourChange( neighbour );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighbourTileEntityChange( @Nonnull BlockPos neighbour )
|
||||
{
|
||||
if( m_moveState == MoveState.NOT_MOVED ) super.onNeighbourTileEntityChange( neighbour );
|
||||
if( moveState == MoveState.NOT_MOVED ) super.onNeighbourTileEntityChange( neighbour );
|
||||
}
|
||||
|
||||
public void notifyMoveStart()
|
||||
{
|
||||
if( m_moveState == MoveState.NOT_MOVED ) m_moveState = MoveState.IN_PROGRESS;
|
||||
if( moveState == MoveState.NOT_MOVED ) moveState = MoveState.IN_PROGRESS;
|
||||
}
|
||||
|
||||
public void notifyMoveEnd()
|
||||
{
|
||||
// MoveState.MOVED is final
|
||||
if( m_moveState == MoveState.IN_PROGRESS ) m_moveState = MoveState.NOT_MOVED;
|
||||
if( moveState == MoveState.IN_PROGRESS ) moveState = MoveState.NOT_MOVED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -262,21 +262,21 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
|
||||
// Read inventory
|
||||
ListNBT nbttaglist = nbt.getList( "Items", Constants.NBT.TAG_COMPOUND );
|
||||
m_inventory.clear();
|
||||
m_previousInventory.clear();
|
||||
inventory.clear();
|
||||
previousInventory.clear();
|
||||
for( int i = 0; i < nbttaglist.size(); i++ )
|
||||
{
|
||||
CompoundNBT tag = nbttaglist.getCompound( i );
|
||||
int slot = tag.getByte( "Slot" ) & 0xff;
|
||||
if( slot < getContainerSize() )
|
||||
{
|
||||
m_inventory.set( slot, ItemStack.of( tag ) );
|
||||
m_previousInventory.set( slot, m_inventory.get( slot ).copy() );
|
||||
inventory.set( slot, ItemStack.of( tag ) );
|
||||
previousInventory.set( slot, inventory.get( slot ).copy() );
|
||||
}
|
||||
}
|
||||
|
||||
// Read state
|
||||
m_brain.readFromNBT( nbt );
|
||||
brain.readFromNBT( nbt );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -287,18 +287,18 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
ListNBT nbttaglist = new ListNBT();
|
||||
for( int i = 0; i < INVENTORY_SIZE; i++ )
|
||||
{
|
||||
if( !m_inventory.get( i ).isEmpty() )
|
||||
if( !inventory.get( i ).isEmpty() )
|
||||
{
|
||||
CompoundNBT tag = new CompoundNBT();
|
||||
tag.putByte( "Slot", (byte) i );
|
||||
m_inventory.get( i ).save( tag );
|
||||
inventory.get( i ).save( tag );
|
||||
nbttaglist.add( tag );
|
||||
}
|
||||
}
|
||||
nbt.put( "Items", nbttaglist );
|
||||
|
||||
// Write brain
|
||||
nbt = m_brain.writeToNBT( nbt );
|
||||
nbt = brain.writeToNBT( nbt );
|
||||
|
||||
return super.save( nbt );
|
||||
}
|
||||
@@ -331,48 +331,48 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
@Override
|
||||
public ITurtleUpgrade getUpgrade( TurtleSide side )
|
||||
{
|
||||
return m_brain.getUpgrade( side );
|
||||
return brain.getUpgrade( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour()
|
||||
{
|
||||
return m_brain.getColour();
|
||||
return brain.getColour();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlay()
|
||||
{
|
||||
return m_brain.getOverlay();
|
||||
return brain.getOverlay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITurtleAccess getAccess()
|
||||
{
|
||||
return m_brain;
|
||||
return brain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
return m_brain.getRenderOffset( f );
|
||||
return brain.getRenderOffset( f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRenderYaw( float f )
|
||||
{
|
||||
return m_brain.getVisualYaw( f );
|
||||
return brain.getVisualYaw( f );
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getToolRenderAngle( TurtleSide side, float f )
|
||||
{
|
||||
return m_brain.getToolRenderAngle( side, f );
|
||||
return brain.getToolRenderAngle( side, f );
|
||||
}
|
||||
|
||||
void setOwningPlayer( GameProfile player )
|
||||
{
|
||||
m_brain.setOwningPlayer( player );
|
||||
brain.setOwningPlayer( player );
|
||||
setChanged();
|
||||
}
|
||||
|
||||
@@ -387,7 +387,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
for( ItemStack stack : m_inventory )
|
||||
for( ItemStack stack : inventory )
|
||||
{
|
||||
if( !stack.isEmpty() ) return false;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
@Override
|
||||
public ItemStack getItem( int slot )
|
||||
{
|
||||
return slot >= 0 && slot < INVENTORY_SIZE ? m_inventory.get( slot ) : ItemStack.EMPTY;
|
||||
return slot >= 0 && slot < INVENTORY_SIZE ? inventory.get( slot ) : ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -433,9 +433,9 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
@Override
|
||||
public void setItem( int i, @Nonnull ItemStack stack )
|
||||
{
|
||||
if( i >= 0 && i < INVENTORY_SIZE && !InventoryUtil.areItemsEqual( stack, m_inventory.get( i ) ) )
|
||||
if( i >= 0 && i < INVENTORY_SIZE && !InventoryUtil.areItemsEqual( stack, inventory.get( i ) ) )
|
||||
{
|
||||
m_inventory.set( i, stack );
|
||||
inventory.set( i, stack );
|
||||
onInventoryDefinitelyChanged();
|
||||
}
|
||||
}
|
||||
@@ -446,9 +446,9 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
boolean changed = false;
|
||||
for( int i = 0; i < INVENTORY_SIZE; i++ )
|
||||
{
|
||||
if( !m_inventory.get( i ).isEmpty() )
|
||||
if( !inventory.get( i ).isEmpty() )
|
||||
{
|
||||
m_inventory.set( i, ItemStack.EMPTY );
|
||||
inventory.set( i, ItemStack.EMPTY );
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
@@ -460,13 +460,13 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
public void setChanged()
|
||||
{
|
||||
super.setChanged();
|
||||
if( !m_inventoryChanged )
|
||||
if( !inventoryChanged )
|
||||
{
|
||||
for( int n = 0; n < getContainerSize(); n++ )
|
||||
{
|
||||
if( !ItemStack.matches( getItem( n ), m_previousInventory.get( n ) ) )
|
||||
if( !ItemStack.matches( getItem( n ), previousInventory.get( n ) ) )
|
||||
{
|
||||
m_inventoryChanged = true;
|
||||
inventoryChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -482,7 +482,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
private void onInventoryDefinitelyChanged()
|
||||
{
|
||||
super.setChanged();
|
||||
m_inventoryChanged = true;
|
||||
inventoryChanged = true;
|
||||
}
|
||||
|
||||
public void onTileEntityChange()
|
||||
@@ -496,14 +496,14 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
protected void writeDescription( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.writeDescription( nbt );
|
||||
m_brain.writeDescription( nbt );
|
||||
brain.writeDescription( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDescription( @Nonnull CompoundNBT nbt )
|
||||
{
|
||||
super.readDescription( nbt );
|
||||
m_brain.readDescription( nbt );
|
||||
brain.readDescription( nbt );
|
||||
}
|
||||
|
||||
// Privates
|
||||
@@ -528,20 +528,20 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
public void transferStateFrom( TileTurtle copy )
|
||||
{
|
||||
super.transferStateFrom( copy );
|
||||
Collections.copy( m_inventory, copy.m_inventory );
|
||||
Collections.copy( m_previousInventory, copy.m_previousInventory );
|
||||
m_inventoryChanged = copy.m_inventoryChanged;
|
||||
m_brain = copy.m_brain;
|
||||
m_brain.setOwner( this );
|
||||
Collections.copy( inventory, copy.inventory );
|
||||
Collections.copy( previousInventory, copy.previousInventory );
|
||||
inventoryChanged = copy.inventoryChanged;
|
||||
brain = copy.brain;
|
||||
brain.setOwner( this );
|
||||
|
||||
// Mark the other turtle as having moved, and so its peripheral is dead.
|
||||
copy.m_moveState = MoveState.MOVED;
|
||||
copy.moveState = MoveState.MOVED;
|
||||
copy.peripheral = CapabilityUtil.invalidate( copy.peripheral );
|
||||
}
|
||||
|
||||
public IItemHandlerModifiable getItemHandler()
|
||||
{
|
||||
return m_itemHandler;
|
||||
return itemHandler;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -571,6 +571,6 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
@Override
|
||||
public Container createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player )
|
||||
{
|
||||
return new ContainerTurtle( id, inventory, m_brain );
|
||||
return new ContainerTurtle( id, inventory, brain );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,55 +65,55 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
private static final int ANIM_DURATION = 8;
|
||||
|
||||
private TileTurtle m_owner;
|
||||
private ComputerProxy m_proxy;
|
||||
private GameProfile m_owningPlayer;
|
||||
private TileTurtle owner;
|
||||
private ComputerProxy proxy;
|
||||
private GameProfile owningPlayer;
|
||||
|
||||
private final IInventory m_inventory = (InventoryDelegate) () -> m_owner;
|
||||
private final IItemHandlerModifiable m_inventoryWrapper = new InvWrapper( m_inventory );
|
||||
private final IInventory inventory = (InventoryDelegate) () -> owner;
|
||||
private final IItemHandlerModifiable inventoryWrapper = new InvWrapper( inventory );
|
||||
|
||||
private final Queue<TurtleCommandQueueEntry> m_commandQueue = new ArrayDeque<>();
|
||||
private int m_commandsIssued = 0;
|
||||
private final Queue<TurtleCommandQueueEntry> commandQueue = new ArrayDeque<>();
|
||||
private int commandsIssued = 0;
|
||||
|
||||
private final Map<TurtleSide, ITurtleUpgrade> m_upgrades = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, ITurtleUpgrade> upgrades = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, IPeripheral> peripherals = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, CompoundNBT> m_upgradeNBTData = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, CompoundNBT> upgradeNBTData = new EnumMap<>( TurtleSide.class );
|
||||
|
||||
private int m_selectedSlot = 0;
|
||||
private int m_fuelLevel = 0;
|
||||
private int m_colourHex = -1;
|
||||
private ResourceLocation m_overlay = null;
|
||||
private int selectedSlot = 0;
|
||||
private int fuelLevel = 0;
|
||||
private int colourHex = -1;
|
||||
private ResourceLocation overlay = null;
|
||||
|
||||
private TurtleAnimation m_animation = TurtleAnimation.NONE;
|
||||
private int m_animationProgress = 0;
|
||||
private int m_lastAnimationProgress = 0;
|
||||
private TurtleAnimation animation = TurtleAnimation.NONE;
|
||||
private int animationProgress = 0;
|
||||
private int lastAnimationProgress = 0;
|
||||
|
||||
TurtlePlayer m_cachedPlayer;
|
||||
TurtlePlayer cachedPlayer;
|
||||
|
||||
public TurtleBrain( TileTurtle turtle )
|
||||
{
|
||||
m_owner = turtle;
|
||||
owner = turtle;
|
||||
}
|
||||
|
||||
public void setOwner( TileTurtle owner )
|
||||
{
|
||||
m_owner = owner;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public TileTurtle getOwner()
|
||||
{
|
||||
return m_owner;
|
||||
return owner;
|
||||
}
|
||||
|
||||
public ComputerProxy getProxy()
|
||||
{
|
||||
if( m_proxy == null ) m_proxy = new ComputerProxy( () -> m_owner );
|
||||
return m_proxy;
|
||||
if( proxy == null ) proxy = new ComputerProxy( () -> owner );
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public ComputerFamily getFamily()
|
||||
{
|
||||
return m_owner.getFamily();
|
||||
return owner.getFamily();
|
||||
}
|
||||
|
||||
public void setupComputer( ServerComputer computer )
|
||||
@@ -131,16 +131,16 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
// The block may have been broken while the command was executing (for instance, if a block explodes
|
||||
// when being mined). If so, abort.
|
||||
if( m_owner.isRemoved() ) return;
|
||||
if( owner.isRemoved() ) return;
|
||||
}
|
||||
|
||||
// Advance animation
|
||||
updateAnimation();
|
||||
|
||||
// Advance upgrades
|
||||
if( !m_upgrades.isEmpty() )
|
||||
if( !upgrades.isEmpty() )
|
||||
{
|
||||
for( Map.Entry<TurtleSide, ITurtleUpgrade> entry : m_upgrades.entrySet() )
|
||||
for( Map.Entry<TurtleSide, ITurtleUpgrade> entry : upgrades.entrySet() )
|
||||
{
|
||||
entry.getValue().update( this, entry.getKey() );
|
||||
}
|
||||
@@ -155,31 +155,31 @@ public class TurtleBrain implements ITurtleAccess
|
||||
private void readCommon( CompoundNBT nbt )
|
||||
{
|
||||
// Read fields
|
||||
m_colourHex = nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : -1;
|
||||
m_fuelLevel = nbt.contains( NBT_FUEL ) ? nbt.getInt( NBT_FUEL ) : 0;
|
||||
m_overlay = nbt.contains( NBT_OVERLAY ) ? new ResourceLocation( nbt.getString( NBT_OVERLAY ) ) : null;
|
||||
colourHex = nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : -1;
|
||||
fuelLevel = nbt.contains( NBT_FUEL ) ? nbt.getInt( NBT_FUEL ) : 0;
|
||||
overlay = nbt.contains( NBT_OVERLAY ) ? new ResourceLocation( nbt.getString( NBT_OVERLAY ) ) : null;
|
||||
|
||||
// Read upgrades
|
||||
setUpgrade( TurtleSide.LEFT, nbt.contains( NBT_LEFT_UPGRADE ) ? TurtleUpgrades.get( nbt.getString( NBT_LEFT_UPGRADE ) ) : null );
|
||||
setUpgrade( TurtleSide.RIGHT, nbt.contains( NBT_RIGHT_UPGRADE ) ? TurtleUpgrades.get( nbt.getString( NBT_RIGHT_UPGRADE ) ) : null );
|
||||
|
||||
// NBT
|
||||
m_upgradeNBTData.clear();
|
||||
upgradeNBTData.clear();
|
||||
if( nbt.contains( NBT_LEFT_UPGRADE_DATA ) )
|
||||
{
|
||||
m_upgradeNBTData.put( TurtleSide.LEFT, nbt.getCompound( NBT_LEFT_UPGRADE_DATA ).copy() );
|
||||
upgradeNBTData.put( TurtleSide.LEFT, nbt.getCompound( NBT_LEFT_UPGRADE_DATA ).copy() );
|
||||
}
|
||||
if( nbt.contains( NBT_RIGHT_UPGRADE_DATA ) )
|
||||
{
|
||||
m_upgradeNBTData.put( TurtleSide.RIGHT, nbt.getCompound( NBT_RIGHT_UPGRADE_DATA ).copy() );
|
||||
upgradeNBTData.put( TurtleSide.RIGHT, nbt.getCompound( NBT_RIGHT_UPGRADE_DATA ).copy() );
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCommon( CompoundNBT nbt )
|
||||
{
|
||||
nbt.putInt( NBT_FUEL, m_fuelLevel );
|
||||
if( m_colourHex != -1 ) nbt.putInt( NBT_COLOUR, m_colourHex );
|
||||
if( m_overlay != null ) nbt.putString( NBT_OVERLAY, m_overlay.toString() );
|
||||
nbt.putInt( NBT_FUEL, fuelLevel );
|
||||
if( colourHex != -1 ) nbt.putInt( NBT_COLOUR, colourHex );
|
||||
if( overlay != null ) nbt.putString( NBT_OVERLAY, overlay.toString() );
|
||||
|
||||
// Write upgrades
|
||||
String leftUpgradeId = getUpgradeId( getUpgrade( TurtleSide.LEFT ) );
|
||||
@@ -188,11 +188,11 @@ public class TurtleBrain implements ITurtleAccess
|
||||
if( rightUpgradeId != null ) nbt.putString( NBT_RIGHT_UPGRADE, rightUpgradeId );
|
||||
|
||||
// Write upgrade NBT
|
||||
if( m_upgradeNBTData.containsKey( TurtleSide.LEFT ) )
|
||||
if( upgradeNBTData.containsKey( TurtleSide.LEFT ) )
|
||||
{
|
||||
nbt.put( NBT_LEFT_UPGRADE_DATA, getUpgradeNBTData( TurtleSide.LEFT ).copy() );
|
||||
}
|
||||
if( m_upgradeNBTData.containsKey( TurtleSide.RIGHT ) )
|
||||
if( upgradeNBTData.containsKey( TurtleSide.RIGHT ) )
|
||||
{
|
||||
nbt.put( NBT_RIGHT_UPGRADE_DATA, getUpgradeNBTData( TurtleSide.RIGHT ).copy() );
|
||||
}
|
||||
@@ -203,20 +203,20 @@ public class TurtleBrain implements ITurtleAccess
|
||||
readCommon( nbt );
|
||||
|
||||
// Read state
|
||||
m_selectedSlot = nbt.getInt( NBT_SLOT );
|
||||
selectedSlot = nbt.getInt( NBT_SLOT );
|
||||
|
||||
// Read owner
|
||||
if( nbt.contains( "Owner", Constants.NBT.TAG_COMPOUND ) )
|
||||
{
|
||||
CompoundNBT owner = nbt.getCompound( "Owner" );
|
||||
m_owningPlayer = new GameProfile(
|
||||
owningPlayer = new GameProfile(
|
||||
new UUID( owner.getLong( "UpperId" ), owner.getLong( "LowerId" ) ),
|
||||
owner.getString( "Name" )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_owningPlayer = null;
|
||||
owningPlayer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,17 +225,17 @@ public class TurtleBrain implements ITurtleAccess
|
||||
writeCommon( nbt );
|
||||
|
||||
// Write state
|
||||
nbt.putInt( NBT_SLOT, m_selectedSlot );
|
||||
nbt.putInt( NBT_SLOT, selectedSlot );
|
||||
|
||||
// Write owner
|
||||
if( m_owningPlayer != null )
|
||||
if( owningPlayer != null )
|
||||
{
|
||||
CompoundNBT owner = new CompoundNBT();
|
||||
nbt.put( "Owner", owner );
|
||||
|
||||
owner.putLong( "UpperId", m_owningPlayer.getId().getMostSignificantBits() );
|
||||
owner.putLong( "LowerId", m_owningPlayer.getId().getLeastSignificantBits() );
|
||||
owner.putString( "Name", m_owningPlayer.getName() );
|
||||
owner.putLong( "UpperId", owningPlayer.getId().getMostSignificantBits() );
|
||||
owner.putLong( "LowerId", owningPlayer.getId().getLeastSignificantBits() );
|
||||
owner.putString( "Name", owningPlayer.getName() );
|
||||
}
|
||||
|
||||
return nbt;
|
||||
@@ -252,35 +252,35 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
// Animation
|
||||
TurtleAnimation anim = TurtleAnimation.values()[nbt.getInt( "Animation" )];
|
||||
if( anim != m_animation &&
|
||||
if( anim != animation &&
|
||||
anim != TurtleAnimation.WAIT &&
|
||||
anim != TurtleAnimation.SHORT_WAIT &&
|
||||
anim != TurtleAnimation.NONE )
|
||||
{
|
||||
m_animation = anim;
|
||||
m_animationProgress = 0;
|
||||
m_lastAnimationProgress = 0;
|
||||
animation = anim;
|
||||
animationProgress = 0;
|
||||
lastAnimationProgress = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeDescription( CompoundNBT nbt )
|
||||
{
|
||||
writeCommon( nbt );
|
||||
nbt.putInt( "Animation", m_animation.ordinal() );
|
||||
nbt.putInt( "Animation", animation.ordinal() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return m_owner.getLevel();
|
||||
return owner.getLevel();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return m_owner.getBlockPos();
|
||||
return owner.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -293,9 +293,9 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
// Cache info about the old turtle (so we don't access this after we delete ourselves)
|
||||
World oldWorld = getWorld();
|
||||
TileTurtle oldOwner = m_owner;
|
||||
BlockPos oldPos = m_owner.getBlockPos();
|
||||
BlockState oldBlock = m_owner.getBlockState();
|
||||
TileTurtle oldOwner = owner;
|
||||
BlockPos oldPos = owner.getBlockPos();
|
||||
BlockState oldBlock = owner.getBlockState();
|
||||
|
||||
if( oldWorld == world && oldPos.equals( pos ) )
|
||||
{
|
||||
@@ -365,7 +365,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
public Vec3d getVisualPosition( float f )
|
||||
{
|
||||
Vec3d offset = getRenderOffset( f );
|
||||
BlockPos pos = m_owner.getBlockPos();
|
||||
BlockPos pos = owner.getBlockPos();
|
||||
return new Vec3d(
|
||||
pos.getX() + 0.5 + offset.x,
|
||||
pos.getY() + 0.5 + offset.y,
|
||||
@@ -377,7 +377,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
public float getVisualYaw( float f )
|
||||
{
|
||||
float yaw = getDirection().toYRot();
|
||||
switch( m_animation )
|
||||
switch( animation )
|
||||
{
|
||||
case TURN_LEFT:
|
||||
{
|
||||
@@ -405,19 +405,19 @@ public class TurtleBrain implements ITurtleAccess
|
||||
@Override
|
||||
public Direction getDirection()
|
||||
{
|
||||
return m_owner.getDirection();
|
||||
return owner.getDirection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDirection( @Nonnull Direction dir )
|
||||
{
|
||||
m_owner.setDirection( dir );
|
||||
owner.setDirection( dir );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSelectedSlot()
|
||||
{
|
||||
return m_selectedSlot;
|
||||
return selectedSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -425,10 +425,10 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
if( getWorld().isClientSide ) throw new UnsupportedOperationException( "Cannot set the slot on the client" );
|
||||
|
||||
if( slot >= 0 && slot < m_owner.getContainerSize() )
|
||||
if( slot >= 0 && slot < owner.getContainerSize() )
|
||||
{
|
||||
m_selectedSlot = slot;
|
||||
m_owner.onTileEntityChange();
|
||||
selectedSlot = slot;
|
||||
owner.onTileEntityChange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,14 +436,14 @@ public class TurtleBrain implements ITurtleAccess
|
||||
@Override
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return m_inventory;
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IItemHandlerModifiable getItemHandler()
|
||||
{
|
||||
return m_inventoryWrapper;
|
||||
return inventoryWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -455,20 +455,20 @@ public class TurtleBrain implements ITurtleAccess
|
||||
@Override
|
||||
public int getFuelLevel()
|
||||
{
|
||||
return Math.min( m_fuelLevel, getFuelLimit() );
|
||||
return Math.min( fuelLevel, getFuelLimit() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFuelLevel( int level )
|
||||
{
|
||||
m_fuelLevel = Math.min( level, getFuelLimit() );
|
||||
m_owner.onTileEntityChange();
|
||||
fuelLevel = Math.min( level, getFuelLimit() );
|
||||
owner.onTileEntityChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFuelLimit()
|
||||
{
|
||||
if( m_owner.getFamily() == ComputerFamily.ADVANCED )
|
||||
if( owner.getFamily() == ComputerFamily.ADVANCED )
|
||||
{
|
||||
return ComputerCraft.advancedTurtleFuelLimit;
|
||||
}
|
||||
@@ -505,8 +505,8 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
private int issueCommand( ITurtleCommand command )
|
||||
{
|
||||
m_commandQueue.offer( new TurtleCommandQueueEntry( ++m_commandsIssued, command ) );
|
||||
return m_commandsIssued;
|
||||
commandQueue.offer( new TurtleCommandQueueEntry( ++commandsIssued, command ) );
|
||||
return commandsIssued;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -525,38 +525,38 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
if( getWorld().isClientSide ) throw new UnsupportedOperationException( "Cannot play animations on the client" );
|
||||
|
||||
m_animation = animation;
|
||||
if( m_animation == TurtleAnimation.SHORT_WAIT )
|
||||
this.animation = animation;
|
||||
if( this.animation == TurtleAnimation.SHORT_WAIT )
|
||||
{
|
||||
m_animationProgress = ANIM_DURATION / 2;
|
||||
m_lastAnimationProgress = ANIM_DURATION / 2;
|
||||
animationProgress = ANIM_DURATION / 2;
|
||||
lastAnimationProgress = ANIM_DURATION / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_animationProgress = 0;
|
||||
m_lastAnimationProgress = 0;
|
||||
animationProgress = 0;
|
||||
lastAnimationProgress = 0;
|
||||
}
|
||||
m_owner.updateBlock();
|
||||
owner.updateBlock();
|
||||
}
|
||||
|
||||
public ResourceLocation getOverlay()
|
||||
{
|
||||
return m_overlay;
|
||||
return overlay;
|
||||
}
|
||||
|
||||
public void setOverlay( ResourceLocation overlay )
|
||||
{
|
||||
if( !Objects.equal( m_overlay, overlay ) )
|
||||
if( !Objects.equal( this.overlay, overlay ) )
|
||||
{
|
||||
m_overlay = overlay;
|
||||
m_owner.updateBlock();
|
||||
this.overlay = overlay;
|
||||
owner.updateBlock();
|
||||
}
|
||||
}
|
||||
|
||||
public DyeColor getDyeColour()
|
||||
{
|
||||
if( m_colourHex == -1 ) return null;
|
||||
Colour colour = Colour.fromHex( m_colourHex );
|
||||
if( colourHex == -1 ) return null;
|
||||
Colour colour = Colour.fromHex( colourHex );
|
||||
return colour == null ? null : DyeColor.byId( 15 - colour.ordinal() );
|
||||
}
|
||||
|
||||
@@ -567,10 +567,10 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
newColour = Colour.values()[15 - dyeColour.getId()].getHex();
|
||||
}
|
||||
if( m_colourHex != newColour )
|
||||
if( colourHex != newColour )
|
||||
{
|
||||
m_colourHex = newColour;
|
||||
m_owner.updateBlock();
|
||||
colourHex = newColour;
|
||||
owner.updateBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,67 +579,67 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
if( colour >= 0 && colour <= 0xFFFFFF )
|
||||
{
|
||||
if( m_colourHex != colour )
|
||||
if( colourHex != colour )
|
||||
{
|
||||
m_colourHex = colour;
|
||||
m_owner.updateBlock();
|
||||
colourHex = colour;
|
||||
owner.updateBlock();
|
||||
}
|
||||
}
|
||||
else if( m_colourHex != -1 )
|
||||
else if( colourHex != -1 )
|
||||
{
|
||||
m_colourHex = -1;
|
||||
m_owner.updateBlock();
|
||||
colourHex = -1;
|
||||
owner.updateBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColour()
|
||||
{
|
||||
return m_colourHex;
|
||||
return colourHex;
|
||||
}
|
||||
|
||||
public void setOwningPlayer( GameProfile profile )
|
||||
{
|
||||
m_owningPlayer = profile;
|
||||
owningPlayer = profile;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GameProfile getOwningPlayer()
|
||||
{
|
||||
return m_owningPlayer;
|
||||
return owningPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITurtleUpgrade getUpgrade( @Nonnull TurtleSide side )
|
||||
{
|
||||
return m_upgrades.get( side );
|
||||
return upgrades.get( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUpgrade( @Nonnull TurtleSide side, ITurtleUpgrade upgrade )
|
||||
{
|
||||
// Remove old upgrade
|
||||
if( m_upgrades.containsKey( side ) )
|
||||
if( upgrades.containsKey( side ) )
|
||||
{
|
||||
if( m_upgrades.get( side ) == upgrade ) return;
|
||||
m_upgrades.remove( side );
|
||||
if( upgrades.get( side ) == upgrade ) return;
|
||||
upgrades.remove( side );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( upgrade == null ) return;
|
||||
}
|
||||
|
||||
m_upgradeNBTData.remove( side );
|
||||
upgradeNBTData.remove( side );
|
||||
|
||||
// Set new upgrade
|
||||
if( upgrade != null ) m_upgrades.put( side, upgrade );
|
||||
if( upgrade != null ) upgrades.put( side, upgrade );
|
||||
|
||||
// Notify clients and create peripherals
|
||||
if( m_owner.getLevel() != null )
|
||||
if( owner.getLevel() != null )
|
||||
{
|
||||
updatePeripherals( m_owner.createServerComputer() );
|
||||
m_owner.updateBlock();
|
||||
updatePeripherals( owner.createServerComputer() );
|
||||
owner.updateBlock();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,20 +653,20 @@ public class TurtleBrain implements ITurtleAccess
|
||||
@Override
|
||||
public CompoundNBT getUpgradeNBTData( TurtleSide side )
|
||||
{
|
||||
CompoundNBT nbt = m_upgradeNBTData.get( side );
|
||||
if( nbt == null ) m_upgradeNBTData.put( side, nbt = new CompoundNBT() );
|
||||
CompoundNBT nbt = upgradeNBTData.get( side );
|
||||
if( nbt == null ) upgradeNBTData.put( side, nbt = new CompoundNBT() );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUpgradeNBTData( @Nonnull TurtleSide side )
|
||||
{
|
||||
m_owner.updateBlock();
|
||||
owner.updateBlock();
|
||||
}
|
||||
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
switch( m_animation )
|
||||
switch( animation )
|
||||
{
|
||||
case MOVE_FORWARD:
|
||||
case MOVE_BACK:
|
||||
@@ -675,7 +675,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
// Get direction
|
||||
Direction dir;
|
||||
switch( m_animation )
|
||||
switch( animation )
|
||||
{
|
||||
case MOVE_FORWARD:
|
||||
default:
|
||||
@@ -708,8 +708,8 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
public float getToolRenderAngle( TurtleSide side, float f )
|
||||
{
|
||||
return (side == TurtleSide.LEFT && m_animation == TurtleAnimation.SWING_LEFT_TOOL) ||
|
||||
(side == TurtleSide.RIGHT && m_animation == TurtleAnimation.SWING_RIGHT_TOOL)
|
||||
return (side == TurtleSide.LEFT && animation == TurtleAnimation.SWING_LEFT_TOOL) ||
|
||||
(side == TurtleSide.RIGHT && animation == TurtleAnimation.SWING_RIGHT_TOOL)
|
||||
? 45.0f * (float) Math.sin( getAnimationFraction( f ) * Math.PI )
|
||||
: 0.0f;
|
||||
}
|
||||
@@ -759,14 +759,14 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
private void updateCommands()
|
||||
{
|
||||
if( m_animation != TurtleAnimation.NONE || m_commandQueue.isEmpty() ) return;
|
||||
if( animation != TurtleAnimation.NONE || commandQueue.isEmpty() ) return;
|
||||
|
||||
// If we've got a computer, ensure that we're allowed to perform work.
|
||||
ServerComputer computer = m_owner.getServerComputer();
|
||||
ServerComputer computer = owner.getServerComputer();
|
||||
if( computer != null && !computer.getComputer().getMainThreadMonitor().canWork() ) return;
|
||||
|
||||
// Pull a new command
|
||||
TurtleCommandQueueEntry nextCommand = m_commandQueue.poll();
|
||||
TurtleCommandQueueEntry nextCommand = commandQueue.poll();
|
||||
if( nextCommand == null ) return;
|
||||
|
||||
// Execute the command
|
||||
@@ -808,21 +808,21 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
private void updateAnimation()
|
||||
{
|
||||
if( m_animation != TurtleAnimation.NONE )
|
||||
if( animation != TurtleAnimation.NONE )
|
||||
{
|
||||
World world = getWorld();
|
||||
|
||||
if( ComputerCraft.turtlesCanPush )
|
||||
{
|
||||
// Advance entity pushing
|
||||
if( m_animation == TurtleAnimation.MOVE_FORWARD ||
|
||||
m_animation == TurtleAnimation.MOVE_BACK ||
|
||||
m_animation == TurtleAnimation.MOVE_UP ||
|
||||
m_animation == TurtleAnimation.MOVE_DOWN )
|
||||
if( animation == TurtleAnimation.MOVE_FORWARD ||
|
||||
animation == TurtleAnimation.MOVE_BACK ||
|
||||
animation == TurtleAnimation.MOVE_UP ||
|
||||
animation == TurtleAnimation.MOVE_DOWN )
|
||||
{
|
||||
BlockPos pos = getPosition();
|
||||
Direction moveDir;
|
||||
switch( m_animation )
|
||||
switch( animation )
|
||||
{
|
||||
case MOVE_FORWARD:
|
||||
default:
|
||||
@@ -846,7 +846,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
double maxY = minY + 1.0;
|
||||
double maxZ = minZ + 1.0;
|
||||
|
||||
float pushFrac = 1.0f - (float) (m_animationProgress + 1) / ANIM_DURATION;
|
||||
float pushFrac = 1.0f - (float) (animationProgress + 1) / ANIM_DURATION;
|
||||
float push = Math.max( pushFrac + 0.0125f, 0.0f );
|
||||
if( moveDir.getStepX() < 0 )
|
||||
{
|
||||
@@ -892,7 +892,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
// Advance valentines day easter egg
|
||||
if( world.isClientSide && m_animation == TurtleAnimation.MOVE_FORWARD && m_animationProgress == 4 )
|
||||
if( world.isClientSide && animation == TurtleAnimation.MOVE_FORWARD && animationProgress == 4 )
|
||||
{
|
||||
// Spawn love pfx if valentines day
|
||||
Holiday currentHoliday = HolidayUtil.getCurrentHoliday();
|
||||
@@ -915,20 +915,20 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
// Wait for anim completion
|
||||
m_lastAnimationProgress = m_animationProgress;
|
||||
if( ++m_animationProgress >= ANIM_DURATION )
|
||||
lastAnimationProgress = animationProgress;
|
||||
if( ++animationProgress >= ANIM_DURATION )
|
||||
{
|
||||
m_animation = TurtleAnimation.NONE;
|
||||
m_animationProgress = 0;
|
||||
m_lastAnimationProgress = 0;
|
||||
animation = TurtleAnimation.NONE;
|
||||
animationProgress = 0;
|
||||
lastAnimationProgress = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float getAnimationFraction( float f )
|
||||
{
|
||||
float next = (float) m_animationProgress / ANIM_DURATION;
|
||||
float previous = (float) m_lastAnimationProgress / ANIM_DURATION;
|
||||
float next = (float) animationProgress / ANIM_DURATION;
|
||||
float previous = (float) lastAnimationProgress / ANIM_DURATION;
|
||||
return previous + (next - previous) * f;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,11 @@ import java.util.List;
|
||||
|
||||
public class TurtleCompareCommand implements ITurtleCommand
|
||||
{
|
||||
private final InteractDirection m_direction;
|
||||
private final InteractDirection direction;
|
||||
|
||||
public TurtleCompareCommand( InteractDirection direction )
|
||||
{
|
||||
m_direction = direction;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -35,7 +35,7 @@ public class TurtleCompareCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
// Get world direction from direction
|
||||
Direction direction = m_direction.toWorldDir( turtle );
|
||||
Direction direction = this.direction.toWorldDir( turtle );
|
||||
|
||||
// Get currently selected stack
|
||||
ItemStack selectedStack = turtle.getInventory().getItem( turtle.getSelectedSlot() );
|
||||
|
||||
@@ -15,11 +15,11 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleCompareToCommand implements ITurtleCommand
|
||||
{
|
||||
private final int m_slot;
|
||||
private final int slot;
|
||||
|
||||
public TurtleCompareToCommand( int slot )
|
||||
{
|
||||
m_slot = slot;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -27,14 +27,9 @@ public class TurtleCompareToCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
ItemStack selectedStack = turtle.getInventory().getItem( turtle.getSelectedSlot() );
|
||||
ItemStack stack = turtle.getInventory().getItem( m_slot );
|
||||
if( InventoryUtil.areItemsStackable( selectedStack, stack ) )
|
||||
{
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
else
|
||||
{
|
||||
return TurtleCommandResult.failure();
|
||||
}
|
||||
ItemStack stack = turtle.getInventory().getItem( slot );
|
||||
return InventoryUtil.areItemsStackable( selectedStack, stack )
|
||||
? TurtleCommandResult.success()
|
||||
: TurtleCommandResult.failure();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleDetectCommand implements ITurtleCommand
|
||||
{
|
||||
private final InteractDirection m_direction;
|
||||
private final InteractDirection direction;
|
||||
|
||||
public TurtleDetectCommand( InteractDirection direction )
|
||||
{
|
||||
m_direction = direction;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -29,7 +29,7 @@ public class TurtleDetectCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
// Get world direction from direction
|
||||
Direction direction = m_direction.toWorldDir( turtle );
|
||||
Direction direction = this.direction.toWorldDir( turtle );
|
||||
|
||||
// Check if thing in front is air or not
|
||||
World world = turtle.getWorld();
|
||||
|
||||
@@ -23,13 +23,13 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleDropCommand implements ITurtleCommand
|
||||
{
|
||||
private final InteractDirection m_direction;
|
||||
private final int m_quantity;
|
||||
private final InteractDirection direction;
|
||||
private final int quantity;
|
||||
|
||||
public TurtleDropCommand( InteractDirection direction, int quantity )
|
||||
{
|
||||
m_direction = direction;
|
||||
m_quantity = quantity;
|
||||
this.direction = direction;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -37,17 +37,17 @@ public class TurtleDropCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
// Dropping nothing is easy
|
||||
if( m_quantity == 0 )
|
||||
if( quantity == 0 )
|
||||
{
|
||||
turtle.playAnimation( TurtleAnimation.WAIT );
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
||||
// Get world direction from direction
|
||||
Direction direction = m_direction.toWorldDir( turtle );
|
||||
Direction direction = this.direction.toWorldDir( turtle );
|
||||
|
||||
// Get things to drop
|
||||
ItemStack stack = InventoryUtil.takeItems( m_quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() );
|
||||
ItemStack stack = InventoryUtil.takeItems( quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() );
|
||||
if( stack.isEmpty() )
|
||||
{
|
||||
return TurtleCommandResult.failure( "No items to drop" );
|
||||
|
||||
@@ -20,11 +20,11 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleEquipCommand implements ITurtleCommand
|
||||
{
|
||||
private final TurtleSide m_side;
|
||||
private final TurtleSide side;
|
||||
|
||||
public TurtleEquipCommand( TurtleSide side )
|
||||
{
|
||||
m_side = side;
|
||||
this.side = side;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -53,7 +53,7 @@ public class TurtleEquipCommand implements ITurtleCommand
|
||||
|
||||
// Determine the upgrade to replace
|
||||
ItemStack oldUpgradeStack;
|
||||
ITurtleUpgrade oldUpgrade = turtle.getUpgrade( m_side );
|
||||
ITurtleUpgrade oldUpgrade = turtle.getUpgrade( side );
|
||||
if( oldUpgrade != null )
|
||||
{
|
||||
ItemStack craftingItem = oldUpgrade.getCraftingItem();
|
||||
@@ -87,7 +87,7 @@ public class TurtleEquipCommand implements ITurtleCommand
|
||||
WorldUtil.dropItemStack( remainder, turtle.getWorld(), position, turtle.getDirection() );
|
||||
}
|
||||
}
|
||||
turtle.setUpgrade( m_side, newUpgrade );
|
||||
turtle.setUpgrade( side, newUpgrade );
|
||||
|
||||
// Animate
|
||||
if( newUpgrade != null || oldUpgrade != null )
|
||||
|
||||
@@ -28,11 +28,11 @@ import java.util.List;
|
||||
|
||||
public class TurtleMoveCommand implements ITurtleCommand
|
||||
{
|
||||
private final MoveDirection m_direction;
|
||||
private final MoveDirection direction;
|
||||
|
||||
public TurtleMoveCommand( MoveDirection direction )
|
||||
{
|
||||
m_direction = direction;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -40,7 +40,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
// Get world direction from direction
|
||||
Direction direction = m_direction.toWorldDir( turtle );
|
||||
Direction direction = this.direction.toWorldDir( turtle );
|
||||
|
||||
// Check if we can move
|
||||
World oldWorld = turtle.getWorld();
|
||||
@@ -72,7 +72,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
||||
|
||||
if( !oldWorld.isUnobstructed( null, collision ) )
|
||||
{
|
||||
if( !ComputerCraft.turtlesCanPush || m_direction == MoveDirection.UP || m_direction == MoveDirection.DOWN )
|
||||
if( !ComputerCraft.turtlesCanPush || this.direction == MoveDirection.UP || this.direction == MoveDirection.DOWN )
|
||||
{
|
||||
return TurtleCommandResult.failure( "Movement obstructed" );
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
||||
turtle.consumeFuel( 1 );
|
||||
|
||||
// Animate
|
||||
switch( m_direction )
|
||||
switch( this.direction )
|
||||
{
|
||||
case FORWARD:
|
||||
default:
|
||||
|
||||
@@ -42,13 +42,13 @@ import java.util.List;
|
||||
|
||||
public class TurtlePlaceCommand implements ITurtleCommand
|
||||
{
|
||||
private final InteractDirection m_direction;
|
||||
private final Object[] m_extraArguments;
|
||||
private final InteractDirection direction;
|
||||
private final Object[] extraArguments;
|
||||
|
||||
public TurtlePlaceCommand( InteractDirection direction, Object[] arguments )
|
||||
{
|
||||
m_direction = direction;
|
||||
m_extraArguments = arguments;
|
||||
this.direction = direction;
|
||||
extraArguments = arguments;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -63,7 +63,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
}
|
||||
|
||||
// Remember old block
|
||||
Direction direction = m_direction.toWorldDir( turtle );
|
||||
Direction direction = this.direction.toWorldDir( turtle );
|
||||
BlockPos coordinates = turtle.getPosition().relative( direction );
|
||||
|
||||
// Create a fake player, and orient it appropriately
|
||||
@@ -78,7 +78,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Do the deploying
|
||||
String[] errorMessage = new String[1];
|
||||
ItemStack remainder = deploy( stack, turtle, turtlePlayer, direction, m_extraArguments, errorMessage );
|
||||
ItemStack remainder = deploy( stack, turtle, turtlePlayer, direction, extraArguments, errorMessage );
|
||||
if( remainder != stack )
|
||||
{
|
||||
// Put the remaining items back
|
||||
|
||||
@@ -95,11 +95,11 @@ public final class TurtlePlayer extends FakePlayer
|
||||
if( !(access instanceof TurtleBrain) ) return create( access );
|
||||
|
||||
TurtleBrain brain = (TurtleBrain) access;
|
||||
TurtlePlayer player = brain.m_cachedPlayer;
|
||||
TurtlePlayer player = brain.cachedPlayer;
|
||||
if( player == null || player.getGameProfile() != getProfile( access.getOwningPlayer() )
|
||||
|| player.getCommandSenderWorld() != access.getWorld() )
|
||||
{
|
||||
player = brain.m_cachedPlayer = create( brain );
|
||||
player = brain.cachedPlayer = create( brain );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,13 +26,13 @@ import java.util.List;
|
||||
|
||||
public class TurtleSuckCommand implements ITurtleCommand
|
||||
{
|
||||
private final InteractDirection m_direction;
|
||||
private final int m_quantity;
|
||||
private final InteractDirection direction;
|
||||
private final int quantity;
|
||||
|
||||
public TurtleSuckCommand( InteractDirection direction, int quantity )
|
||||
{
|
||||
m_direction = direction;
|
||||
m_quantity = quantity;
|
||||
this.direction = direction;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -40,14 +40,14 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
// Sucking nothing is easy
|
||||
if( m_quantity == 0 )
|
||||
if( quantity == 0 )
|
||||
{
|
||||
turtle.playAnimation( TurtleAnimation.WAIT );
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
||||
// Get world direction from direction
|
||||
Direction direction = m_direction.toWorldDir( turtle );
|
||||
Direction direction = this.direction.toWorldDir( turtle );
|
||||
|
||||
// Get inventory for thing in front
|
||||
World world = turtle.getWorld();
|
||||
@@ -68,7 +68,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
if( inventory != null )
|
||||
{
|
||||
// Take from inventory of thing in front
|
||||
ItemStack stack = InventoryUtil.takeItems( m_quantity, inventory );
|
||||
ItemStack stack = InventoryUtil.takeItems( quantity, inventory );
|
||||
if( stack.isEmpty() ) return TurtleCommandResult.failure( "No items to take" );
|
||||
|
||||
// Try to place into the turtle
|
||||
@@ -107,9 +107,9 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
|
||||
ItemStack storeStack;
|
||||
ItemStack leaveStack;
|
||||
if( stack.getCount() > m_quantity )
|
||||
if( stack.getCount() > quantity )
|
||||
{
|
||||
storeStack = stack.split( m_quantity );
|
||||
storeStack = stack.split( quantity );
|
||||
leaveStack = stack;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -16,13 +16,13 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleTransferToCommand implements ITurtleCommand
|
||||
{
|
||||
private final int m_slot;
|
||||
private final int m_quantity;
|
||||
private final int slot;
|
||||
private final int quantity;
|
||||
|
||||
public TurtleTransferToCommand( int slot, int limit )
|
||||
{
|
||||
m_slot = slot;
|
||||
m_quantity = limit;
|
||||
this.slot = slot;
|
||||
quantity = limit;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -30,7 +30,7 @@ public class TurtleTransferToCommand implements ITurtleCommand
|
||||
public TurtleCommandResult execute( @Nonnull ITurtleAccess turtle )
|
||||
{
|
||||
// Take stack
|
||||
ItemStack stack = InventoryUtil.takeItems( m_quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() );
|
||||
ItemStack stack = InventoryUtil.takeItems( quantity, turtle.getItemHandler(), turtle.getSelectedSlot(), 1, turtle.getSelectedSlot() );
|
||||
if( stack.isEmpty() )
|
||||
{
|
||||
turtle.playAnimation( TurtleAnimation.WAIT );
|
||||
@@ -38,7 +38,7 @@ public class TurtleTransferToCommand implements ITurtleCommand
|
||||
}
|
||||
|
||||
// Store stack
|
||||
ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getItemHandler(), m_slot, 1, m_slot );
|
||||
ItemStack remainder = InventoryUtil.storeItems( stack, turtle.getItemHandler(), slot, 1, slot );
|
||||
if( !remainder.isEmpty() )
|
||||
{
|
||||
// Put the remainder back
|
||||
|
||||
@@ -17,11 +17,11 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleTurnCommand implements ITurtleCommand
|
||||
{
|
||||
private final TurnDirection m_direction;
|
||||
private final TurnDirection direction;
|
||||
|
||||
public TurtleTurnCommand( TurnDirection direction )
|
||||
{
|
||||
m_direction = direction;
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -34,7 +34,7 @@ public class TurtleTurnCommand implements ITurtleCommand
|
||||
return TurtleCommandResult.failure( event.getFailureMessage() );
|
||||
}
|
||||
|
||||
switch( m_direction )
|
||||
switch( direction )
|
||||
{
|
||||
case LEFT:
|
||||
{
|
||||
|
||||
@@ -21,11 +21,8 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleCraftingTable extends AbstractTurtleUpgrade
|
||||
{
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_leftModel;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_rightModel;
|
||||
private static final ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_left", "inventory" );
|
||||
private static final ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_right", "inventory" );
|
||||
|
||||
public TurtleCraftingTable( ResourceLocation id )
|
||||
{
|
||||
@@ -38,22 +35,11 @@ public class TurtleCraftingTable extends AbstractTurtleUpgrade
|
||||
return new CraftingTablePeripheral( turtle );
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private void loadModelLocations()
|
||||
{
|
||||
if( m_leftModel == null )
|
||||
{
|
||||
m_leftModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_left", "inventory" );
|
||||
m_rightModel = new ModelResourceLocation( "computercraft:turtle_crafting_table_right", "inventory" );
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
|
||||
{
|
||||
loadModelLocations();
|
||||
return TransformedModel.of( side == TurtleSide.LEFT ? m_leftModel : m_rightModel );
|
||||
return TransformedModel.of( side == TurtleSide.LEFT ? leftModel : rightModel );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ import java.util.List;
|
||||
|
||||
public class TurtleInventoryCrafting extends CraftingInventory
|
||||
{
|
||||
private ITurtleAccess m_turtle;
|
||||
private int m_xStart;
|
||||
private int m_yStart;
|
||||
private final ITurtleAccess turtle;
|
||||
private int xStart = 0;
|
||||
private int yStart = 0;
|
||||
|
||||
@SuppressWarnings( "ConstantConditions" )
|
||||
public TurtleInventoryCrafting( ITurtleAccess turtle )
|
||||
@@ -37,26 +37,24 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
// Passing null in here is evil, but we don't have a container present. We override most methods in order to
|
||||
// avoid throwing any NPEs.
|
||||
super( null, 0, 0 );
|
||||
m_turtle = turtle;
|
||||
m_xStart = 0;
|
||||
m_yStart = 0;
|
||||
this.turtle = turtle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private IRecipe<CraftingInventory> tryCrafting( int xStart, int yStart )
|
||||
{
|
||||
m_xStart = xStart;
|
||||
m_yStart = yStart;
|
||||
this.xStart = xStart;
|
||||
this.yStart = yStart;
|
||||
|
||||
// Check the non-relevant parts of the inventory are empty
|
||||
for( int x = 0; x < TileTurtle.INVENTORY_WIDTH; x++ )
|
||||
{
|
||||
for( int y = 0; y < TileTurtle.INVENTORY_HEIGHT; y++ )
|
||||
{
|
||||
if( x < m_xStart || x >= m_xStart + 3 ||
|
||||
y < m_yStart || y >= m_yStart + 3 )
|
||||
if( x < this.xStart || x >= this.xStart + 3 ||
|
||||
y < this.yStart || y >= this.yStart + 3 )
|
||||
{
|
||||
if( !m_turtle.getInventory().getItem( x + y * TileTurtle.INVENTORY_WIDTH ).isEmpty() )
|
||||
if( !turtle.getInventory().getItem( x + y * TileTurtle.INVENTORY_WIDTH ).isEmpty() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -65,7 +63,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
}
|
||||
|
||||
// Check the actual crafting
|
||||
return m_turtle.getWorld().getRecipeManager().getRecipeFor( IRecipeType.CRAFTING, this, m_turtle.getWorld() ).orElse( null );
|
||||
return turtle.getWorld().getRecipeManager().getRecipeFor( IRecipeType.CRAFTING, this, turtle.getWorld() ).orElse( null );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -83,7 +81,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
// Special case: craft(0) just returns an empty list if crafting was possible
|
||||
if( maxCount == 0 ) return Collections.emptyList();
|
||||
|
||||
TurtlePlayer player = TurtlePlayer.get( m_turtle );
|
||||
TurtlePlayer player = TurtlePlayer.get( turtle );
|
||||
|
||||
ArrayList<ItemStack> results = new ArrayList<>();
|
||||
for( int i = 0; i < maxCount && recipe.matches( this, world ); i++ )
|
||||
@@ -147,8 +145,8 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
|
||||
private int modifyIndex( int index )
|
||||
{
|
||||
int x = m_xStart + index % getWidth();
|
||||
int y = m_yStart + index / getHeight();
|
||||
int x = xStart + index % getWidth();
|
||||
int y = yStart + index / getHeight();
|
||||
return x >= 0 && x < TileTurtle.INVENTORY_WIDTH && y >= 0 && y < TileTurtle.INVENTORY_HEIGHT
|
||||
? x + y * TileTurtle.INVENTORY_WIDTH
|
||||
: -1;
|
||||
@@ -167,7 +165,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
public ItemStack getItem( int i )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().getItem( i );
|
||||
return turtle.getInventory().getItem( i );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -175,7 +173,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
public ItemStack removeItemNoUpdate( int i )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().removeItemNoUpdate( i );
|
||||
return turtle.getInventory().removeItemNoUpdate( i );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -183,26 +181,26 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
public ItemStack removeItem( int i, int size )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().removeItem( i, size );
|
||||
return turtle.getInventory().removeItem( i, size );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( int i, @Nonnull ItemStack stack )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
m_turtle.getInventory().setItem( i, stack );
|
||||
turtle.getInventory().setItem( i, stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize()
|
||||
{
|
||||
return m_turtle.getInventory().getMaxStackSize();
|
||||
return turtle.getInventory().getMaxStackSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChanged()
|
||||
{
|
||||
m_turtle.getInventory().setChanged();
|
||||
turtle.getInventory().setChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -215,7 +213,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
public boolean canPlaceItem( int i, @Nonnull ItemStack stack )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().canPlaceItem( i, stack );
|
||||
return turtle.getInventory().canPlaceItem( i, stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,7 +222,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
for( int i = 0; i < getContainerSize(); i++ )
|
||||
{
|
||||
int j = modifyIndex( i );
|
||||
m_turtle.getInventory().setItem( j, ItemStack.EMPTY );
|
||||
turtle.getInventory().setItem( j, ItemStack.EMPTY );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,17 +63,10 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
|
||||
private final boolean advanced;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_leftOffModel;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_rightOffModel;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_leftOnModel;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_rightOnModel;
|
||||
private final ModelResourceLocation leftOffModel;
|
||||
private final ModelResourceLocation rightOffModel;
|
||||
private final ModelResourceLocation leftOnModel;
|
||||
private final ModelResourceLocation rightOnModel;
|
||||
|
||||
public TurtleModem( boolean advanced, ResourceLocation id )
|
||||
{
|
||||
@@ -84,6 +77,21 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
: Registry.ModBlocks.WIRELESS_MODEM_NORMAL
|
||||
);
|
||||
this.advanced = advanced;
|
||||
|
||||
if( advanced )
|
||||
{
|
||||
leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_left", "inventory" );
|
||||
rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_right", "inventory" );
|
||||
leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_left", "inventory" );
|
||||
rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_right", "inventory" );
|
||||
}
|
||||
else
|
||||
{
|
||||
leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_left", "inventory" );
|
||||
rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_right", "inventory" );
|
||||
leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_left", "inventory" );
|
||||
rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_right", "inventory" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,35 +107,11 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
return TurtleCommandResult.failure();
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private void loadModelLocations()
|
||||
{
|
||||
if( m_leftOffModel == null )
|
||||
{
|
||||
if( advanced )
|
||||
{
|
||||
m_leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_left", "inventory" );
|
||||
m_rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_off_right", "inventory" );
|
||||
m_leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_left", "inventory" );
|
||||
m_rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_advanced_on_right", "inventory" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_leftOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_left", "inventory" );
|
||||
m_rightOffModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_off_right", "inventory" );
|
||||
m_leftOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_left", "inventory" );
|
||||
m_rightOnModel = new ModelResourceLocation( "computercraft:turtle_modem_normal_on_right", "inventory" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
|
||||
{
|
||||
loadModelLocations();
|
||||
|
||||
boolean active = false;
|
||||
if( turtle != null )
|
||||
{
|
||||
@@ -136,8 +120,8 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
}
|
||||
|
||||
return side == TurtleSide.LEFT
|
||||
? TransformedModel.of( active ? m_leftOnModel : m_leftOffModel )
|
||||
: TransformedModel.of( active ? m_rightOnModel : m_rightOffModel );
|
||||
? TransformedModel.of( active ? leftOnModel : leftOffModel )
|
||||
: TransformedModel.of( active ? rightOnModel : rightOffModel );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,9 @@ import javax.annotation.Nonnull;
|
||||
|
||||
public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
{
|
||||
private static final ModelResourceLocation leftModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_left", "inventory" );
|
||||
private static final ModelResourceLocation rightModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_right", "inventory" );
|
||||
|
||||
private static class Peripheral extends SpeakerPeripheral
|
||||
{
|
||||
ITurtleAccess turtle;
|
||||
@@ -54,12 +57,6 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_leftModel;
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private ModelResourceLocation m_rightModel;
|
||||
|
||||
public TurtleSpeaker( ResourceLocation id )
|
||||
{
|
||||
super( id, TurtleUpgradeType.PERIPHERAL, Registry.ModBlocks.SPEAKER );
|
||||
@@ -71,33 +68,18 @@ public class TurtleSpeaker extends AbstractTurtleUpgrade
|
||||
return new TurtleSpeaker.Peripheral( turtle );
|
||||
}
|
||||
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
private void loadModelLocations()
|
||||
{
|
||||
if( m_leftModel == null )
|
||||
{
|
||||
m_leftModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_left", "inventory" );
|
||||
m_rightModel = new ModelResourceLocation( "computercraft:turtle_speaker_upgrade_right", "inventory" );
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
|
||||
{
|
||||
loadModelLocations();
|
||||
return TransformedModel.of( side == TurtleSide.LEFT ? m_leftModel : m_rightModel );
|
||||
return TransformedModel.of( side == TurtleSide.LEFT ? leftModel : rightModel );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update( @Nonnull ITurtleAccess turtle, @Nonnull TurtleSide turtleSide )
|
||||
{
|
||||
IPeripheral turtlePeripheral = turtle.getPeripheral( turtleSide );
|
||||
if( turtlePeripheral instanceof Peripheral )
|
||||
{
|
||||
Peripheral peripheral = (Peripheral) turtlePeripheral;
|
||||
peripheral.update();
|
||||
}
|
||||
if( turtlePeripheral instanceof Peripheral ) ((Peripheral) turtlePeripheral).update();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user