mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-29 04:47:39 +00:00
Converted tabs to spaces throughout
This commit is contained in:
@@ -14,74 +14,74 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleCraftCommand;
|
||||
|
||||
public class CraftingTablePeripheral
|
||||
implements IPeripheral
|
||||
implements IPeripheral
|
||||
{
|
||||
private final ITurtleAccess m_turtle;
|
||||
private final ITurtleAccess m_turtle;
|
||||
|
||||
public CraftingTablePeripheral( ITurtleAccess turtle )
|
||||
{
|
||||
m_turtle = turtle;
|
||||
m_turtle = turtle;
|
||||
}
|
||||
|
||||
// IPeripheral implementation
|
||||
|
||||
// IPeripheral implementation
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public String getType()
|
||||
{
|
||||
return "workbench";
|
||||
return "workbench";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public String[] getMethodNames()
|
||||
{
|
||||
return new String[] {
|
||||
"craft",
|
||||
};
|
||||
return new String[] {
|
||||
"craft",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private int parseCount( Object[] arguments ) throws LuaException
|
||||
{
|
||||
if( arguments.length < 1 )
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
if( !(arguments[0] instanceof Number) )
|
||||
{
|
||||
throw new LuaException( "Expected number" );
|
||||
}
|
||||
int count = ((Number)arguments[0]).intValue();
|
||||
if( count < 0 || count > 64 )
|
||||
{
|
||||
throw new LuaException( "Crafting count " + count + " out of range" );
|
||||
}
|
||||
return count;
|
||||
if( arguments.length < 1 )
|
||||
{
|
||||
return 64;
|
||||
}
|
||||
|
||||
if( !(arguments[0] instanceof Number) )
|
||||
{
|
||||
throw new LuaException( "Expected number" );
|
||||
}
|
||||
int count = ((Number)arguments[0]).intValue();
|
||||
if( count < 0 || count > 64 )
|
||||
{
|
||||
throw new LuaException( "Crafting count " + count + " out of range" );
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException
|
||||
{
|
||||
switch( method )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// craft
|
||||
final int limit = parseCount( arguments );
|
||||
return m_turtle.executeCommand( context, new TurtleCraftCommand( limit ) );
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
switch( method )
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
// craft
|
||||
final int limit = parseCount( arguments );
|
||||
return m_turtle.executeCommand( context, new TurtleCraftCommand( limit ) );
|
||||
}
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void attach( IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void detach( IComputerAccess computer )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ public class TurtleAxe extends TurtleTool
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDamageMultiplier()
|
||||
{
|
||||
return 6.0f;
|
||||
}
|
||||
protected float getDamageMultiplier()
|
||||
{
|
||||
return 6.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,35 +53,35 @@ public class TurtleCraftingTable implements ITurtleUpgrade
|
||||
return m_legacyID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalisedAdjective()
|
||||
{
|
||||
return "upgrade.minecraft:crafting_table.adjective";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleUpgradeType getType()
|
||||
{
|
||||
return TurtleUpgradeType.Peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingItem()
|
||||
{
|
||||
return m_item;
|
||||
}
|
||||
@Override
|
||||
public String getUnlocalisedAdjective()
|
||||
{
|
||||
return "upgrade.minecraft:crafting_table.adjective";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleUpgradeType getType()
|
||||
{
|
||||
return TurtleUpgradeType.Peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingItem()
|
||||
{
|
||||
return m_item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side )
|
||||
{
|
||||
return new CraftingTablePeripheral( turtle );
|
||||
}
|
||||
@Override
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side )
|
||||
{
|
||||
return new CraftingTablePeripheral( turtle );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing dir )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing dir )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private void loadModelLocations()
|
||||
|
||||
@@ -29,27 +29,27 @@ public class TurtleHoe extends TurtleTool
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
return
|
||||
material == Material.PLANTS ||
|
||||
material == Material.CACTUS ||
|
||||
material == Material.GOURD ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing direction )
|
||||
{
|
||||
if( verb == TurtleVerb.Dig )
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing direction )
|
||||
{
|
||||
if( verb == TurtleVerb.Dig )
|
||||
{
|
||||
ItemStack hoe = m_item.copy();
|
||||
ItemStack remainder = TurtlePlaceCommand.deploy( hoe, turtle, direction, null, null );
|
||||
@@ -57,7 +57,7 @@ public class TurtleHoe extends TurtleTool
|
||||
{
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
}
|
||||
return super.useTool( turtle, side, verb, direction );
|
||||
}
|
||||
}
|
||||
return super.useTool( turtle, side, verb, direction );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@ import java.util.ArrayList;
|
||||
|
||||
public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
{
|
||||
private ITurtleAccess m_turtle;
|
||||
private ITurtleAccess m_turtle;
|
||||
private int m_xStart;
|
||||
private int m_yStart;
|
||||
|
||||
public TurtleInventoryCrafting( ITurtleAccess turtle )
|
||||
{
|
||||
super( null, 0, 0 );
|
||||
m_turtle = turtle;
|
||||
super( null, 0, 0 );
|
||||
m_turtle = turtle;
|
||||
m_xStart = 0;
|
||||
m_yStart = 0;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
|
||||
// Check the actual crafting
|
||||
return CraftingManager.getInstance().findMatchingRecipe( this, m_turtle.getWorld() );
|
||||
return CraftingManager.getInstance().findMatchingRecipe( this, m_turtle.getWorld() );
|
||||
}
|
||||
|
||||
public ArrayList<ItemStack> doCrafting( World world, int maxCount )
|
||||
@@ -66,8 +66,8 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
return null;
|
||||
}
|
||||
|
||||
// Find out what we can craft
|
||||
ItemStack result = tryCrafting( 0, 0 );
|
||||
// Find out what we can craft
|
||||
ItemStack result = tryCrafting( 0, 0 );
|
||||
if( result == null )
|
||||
{
|
||||
result = tryCrafting( 0, 1 );
|
||||
@@ -82,53 +82,53 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
|
||||
// Craft it
|
||||
if( result != null )
|
||||
{
|
||||
// Special case: craft(0) just returns an empty list if crafting was possible
|
||||
if( result != null )
|
||||
{
|
||||
// Special case: craft(0) just returns an empty list if crafting was possible
|
||||
ArrayList<ItemStack> results = new ArrayList<ItemStack>();
|
||||
if( maxCount == 0 )
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
// Find out how many we can craft
|
||||
int numToCraft = 1;
|
||||
int size = getSizeInventory();
|
||||
if( maxCount > 1 )
|
||||
{
|
||||
int minStackSize = 0;
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
if( stack != null && (minStackSize == 0 || minStackSize > stack.stackSize) )
|
||||
{
|
||||
minStackSize = stack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
if( minStackSize > 1 )
|
||||
{
|
||||
numToCraft = Math.min( minStackSize, result.getMaxStackSize() / result.stackSize );
|
||||
numToCraft = Math.min( numToCraft, maxCount );
|
||||
result.stackSize = result.stackSize * numToCraft;
|
||||
}
|
||||
}
|
||||
if( maxCount == 0 )
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
// Find out how many we can craft
|
||||
int numToCraft = 1;
|
||||
int size = getSizeInventory();
|
||||
if( maxCount > 1 )
|
||||
{
|
||||
int minStackSize = 0;
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
if( stack != null && (minStackSize == 0 || minStackSize > stack.stackSize) )
|
||||
{
|
||||
minStackSize = stack.stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
if( minStackSize > 1 )
|
||||
{
|
||||
numToCraft = Math.min( minStackSize, result.getMaxStackSize() / result.stackSize );
|
||||
numToCraft = Math.min( numToCraft, maxCount );
|
||||
result.stackSize = result.stackSize * numToCraft;
|
||||
}
|
||||
}
|
||||
|
||||
// Do post-pickup stuff
|
||||
TurtlePlayer turtlePlayer = new TurtlePlayer( (WorldServer)world );
|
||||
TurtlePlayer turtlePlayer = new TurtlePlayer( (WorldServer)world );
|
||||
result.onCrafting( world, turtlePlayer, numToCraft );
|
||||
results.add( result );
|
||||
|
||||
// Consume resources from the inventory
|
||||
// Consume resources from the inventory
|
||||
ItemStack[] remainingItems = CraftingManager.getInstance().getRemainingItems( this, world );
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
if( stack != null )
|
||||
{
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
if( stack != null )
|
||||
{
|
||||
decrStackSize( n, numToCraft );
|
||||
|
||||
ItemStack replacement = remainingItems[n];
|
||||
ItemStack replacement = remainingItems[n];
|
||||
if( replacement != null )
|
||||
{
|
||||
if( !(replacement.isItemStackDamageable() && replacement.getItemDamage() >= replacement.getMaxDamage()) )
|
||||
@@ -144,20 +144,20 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ItemStack getStackInRowAndColumn(int x, int y)
|
||||
{
|
||||
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight() )
|
||||
{
|
||||
return getStackInSlot( x + y * getWidth() );
|
||||
return getStackInSlot( x + y * getWidth() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -187,18 +187,18 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
|
||||
// IInventory implementation
|
||||
|
||||
@Override
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return getWidth() * getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ItemStack getStackInSlot( int i )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().getStackInSlot( i );
|
||||
return m_turtle.getInventory().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -213,52 +213,52 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return new TextComponentString( "" );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot( int i )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().removeStackFromSlot( i );
|
||||
return m_turtle.getInventory().removeStackFromSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public ItemStack decrStackSize( int i, int size )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
return m_turtle.getInventory().decrStackSize( i, size );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void setInventorySlotContents( int i, ItemStack stack )
|
||||
{
|
||||
i = modifyIndex( i );
|
||||
m_turtle.getInventory().setInventorySlotContents( i, stack );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return m_turtle.getInventory().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
m_turtle.getInventory().markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public boolean isUseableByPlayer( EntityPlayer player )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void openInventory( EntityPlayer player )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -30,33 +30,33 @@ import javax.vecmath.Matrix4f;
|
||||
|
||||
public class TurtleModem implements ITurtleUpgrade
|
||||
{
|
||||
private static class Peripheral extends WirelessModemPeripheral
|
||||
implements IPeripheral
|
||||
{
|
||||
private final ITurtleAccess m_turtle;
|
||||
private static class Peripheral extends WirelessModemPeripheral
|
||||
implements IPeripheral
|
||||
{
|
||||
private final ITurtleAccess m_turtle;
|
||||
|
||||
public Peripheral( ITurtleAccess turtle, boolean advanced )
|
||||
{
|
||||
public Peripheral( ITurtleAccess turtle, boolean advanced )
|
||||
{
|
||||
super( advanced );
|
||||
m_turtle = turtle;
|
||||
}
|
||||
m_turtle = turtle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected World getWorld()
|
||||
{
|
||||
return m_turtle.getWorld();
|
||||
}
|
||||
protected World getWorld()
|
||||
{
|
||||
return m_turtle.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
BlockPos turtlePos = m_turtle.getPosition();
|
||||
return new Vec3d(
|
||||
(double)turtlePos.getX(),
|
||||
(double)turtlePos.getY(),
|
||||
(double)turtlePos.getZ()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( IPeripheral other )
|
||||
@@ -71,7 +71,7 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
private boolean m_advanced;
|
||||
private ResourceLocation m_id;
|
||||
private ResourceLocation m_id;
|
||||
private int m_legacyID;
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -87,11 +87,11 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
private ModelResourceLocation m_rightOnModel;
|
||||
|
||||
public TurtleModem( boolean advanced, ResourceLocation id, int legacyId )
|
||||
{
|
||||
{
|
||||
m_advanced = advanced;
|
||||
m_id = id;
|
||||
m_legacyID = legacyId;
|
||||
}
|
||||
m_legacyID = legacyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUpgradeID()
|
||||
@@ -99,15 +99,15 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
return m_id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLegacyUpgradeID()
|
||||
{
|
||||
return m_legacyID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalisedAdjective()
|
||||
{
|
||||
@Override
|
||||
public int getLegacyUpgradeID()
|
||||
{
|
||||
return m_legacyID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalisedAdjective()
|
||||
{
|
||||
if( m_advanced )
|
||||
{
|
||||
return "upgrade.computercraft:advanced_modem.adjective";
|
||||
@@ -116,17 +116,17 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
{
|
||||
return "upgrade.computercraft:wireless_modem.adjective";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleUpgradeType getType()
|
||||
{
|
||||
return TurtleUpgradeType.Peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingItem()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleUpgradeType getType()
|
||||
{
|
||||
return TurtleUpgradeType.Peripheral;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingItem()
|
||||
{
|
||||
if( m_advanced )
|
||||
{
|
||||
return PeripheralItemFactory.create( PeripheralType.AdvancedModem, null, 1 );
|
||||
@@ -135,19 +135,19 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
{
|
||||
return PeripheralItemFactory.create( PeripheralType.WirelessModem, null, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side )
|
||||
{
|
||||
return new Peripheral( turtle, m_advanced );
|
||||
}
|
||||
@Override
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side )
|
||||
{
|
||||
return new Peripheral( turtle, m_advanced );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing dir )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public TurtleCommandResult useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, EnumFacing dir )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly( Side.CLIENT )
|
||||
private void loadModelLocations()
|
||||
|
||||
@@ -21,14 +21,14 @@ public class TurtleShovel extends TurtleTool
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
return
|
||||
material == Material.GROUND ||
|
||||
material == Material.SAND ||
|
||||
material == Material.SNOW ||
|
||||
@@ -40,7 +40,7 @@ public class TurtleShovel extends TurtleTool
|
||||
material == Material.GOURD ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,32 +15,32 @@ import net.minecraft.world.World;
|
||||
|
||||
public class TurtleSword extends TurtleTool
|
||||
{
|
||||
public TurtleSword( ResourceLocation id, int legacyId, String adjective, Item item )
|
||||
{
|
||||
super( id, legacyId, adjective, item );
|
||||
}
|
||||
public TurtleSword( ResourceLocation id, int legacyId, String adjective, Item item )
|
||||
{
|
||||
super( id, legacyId, adjective, item );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
return
|
||||
material == Material.PLANTS ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE ||
|
||||
material == Material.CLOTH ||
|
||||
material == Material.WEB;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getDamageMultiplier()
|
||||
{
|
||||
return 9.0f;
|
||||
}
|
||||
protected float getDamageMultiplier()
|
||||
{
|
||||
return 9.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,17 +41,17 @@ import java.util.Iterator;
|
||||
public class TurtleTool implements ITurtleUpgrade
|
||||
{
|
||||
private ResourceLocation m_id;
|
||||
private int m_legacyId;
|
||||
private String m_adjective;
|
||||
protected ItemStack m_item;
|
||||
private int m_legacyId;
|
||||
private String m_adjective;
|
||||
protected ItemStack m_item;
|
||||
|
||||
public TurtleTool( ResourceLocation id, int legacyID, String adjective, Item item )
|
||||
{
|
||||
m_id = id;
|
||||
public TurtleTool( ResourceLocation id, int legacyID, String adjective, Item item )
|
||||
{
|
||||
m_id = id;
|
||||
m_legacyId = legacyID;
|
||||
m_adjective = adjective;
|
||||
m_item = new ItemStack( item, 1, 0 );
|
||||
}
|
||||
m_adjective = adjective;
|
||||
m_item = new ItemStack( item, 1, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getUpgradeID()
|
||||
@@ -60,34 +60,34 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLegacyUpgradeID()
|
||||
{
|
||||
return m_legacyId;
|
||||
}
|
||||
public int getLegacyUpgradeID()
|
||||
{
|
||||
return m_legacyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalisedAdjective()
|
||||
{
|
||||
return m_adjective;
|
||||
}
|
||||
public String getUnlocalisedAdjective()
|
||||
{
|
||||
return m_adjective;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TurtleUpgradeType getType()
|
||||
{
|
||||
return TurtleUpgradeType.Tool;
|
||||
}
|
||||
public TurtleUpgradeType getType()
|
||||
{
|
||||
return TurtleUpgradeType.Tool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingItem()
|
||||
{
|
||||
return m_item.copy();
|
||||
}
|
||||
public ItemStack getCraftingItem()
|
||||
{
|
||||
return m_item.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public IPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly( Side.CLIENT )
|
||||
@@ -133,31 +133,31 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
{
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
if( block.isAir( state, world, pos ) || block == Blocks.BEDROCK || block.getBlockHardness( state, world, pos ) <= -1.0F )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean canHarvestBlock( World world, BlockPos pos )
|
||||
{
|
||||
Block block = state.getBlock();
|
||||
if( block.isAir( state, world, pos ) || block == Blocks.BEDROCK || block.getBlockHardness( state, world, pos ) <= -1.0F )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected boolean canHarvestBlock( World world, BlockPos pos )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
TurtlePlayer turtlePlayer = new TurtlePlayer( (WorldServer)world );
|
||||
turtlePlayer.loadInventory( m_item.copy() );
|
||||
return ForgeHooks.canHarvestBlock( block, turtlePlayer, world, pos );
|
||||
}
|
||||
|
||||
protected float getDamageMultiplier()
|
||||
{
|
||||
return 3.0f;
|
||||
}
|
||||
|
||||
private TurtleCommandResult attack( final ITurtleAccess turtle, EnumFacing direction )
|
||||
{
|
||||
TurtlePlayer turtlePlayer = new TurtlePlayer( (WorldServer)world );
|
||||
turtlePlayer.loadInventory( m_item.copy() );
|
||||
return ForgeHooks.canHarvestBlock( block, turtlePlayer, world, pos );
|
||||
}
|
||||
|
||||
protected float getDamageMultiplier()
|
||||
{
|
||||
return 3.0f;
|
||||
}
|
||||
|
||||
private TurtleCommandResult attack( final ITurtleAccess turtle, EnumFacing direction )
|
||||
{
|
||||
// Create a fake player, and orient it appropriately
|
||||
final World world = turtle.getWorld();
|
||||
final BlockPos position = turtle.getPosition();
|
||||
@@ -230,13 +230,13 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
return TurtleCommandResult.failure( "Nothing to attack here" );
|
||||
}
|
||||
|
||||
private TurtleCommandResult dig( ITurtleAccess turtle, EnumFacing direction )
|
||||
{
|
||||
}
|
||||
|
||||
private TurtleCommandResult dig( ITurtleAccess turtle, EnumFacing direction )
|
||||
{
|
||||
// Get ready to dig
|
||||
World world = turtle.getWorld();
|
||||
BlockPos position = turtle.getPosition();
|
||||
World world = turtle.getWorld();
|
||||
BlockPos position = turtle.getPosition();
|
||||
BlockPos newPosition = WorldUtil.moveCoords( position, direction );
|
||||
|
||||
if( WorldUtil.isBlockInWorld( world, newPosition ) &&
|
||||
@@ -292,15 +292,15 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
brain.saveBlockChange( newPosition, previousState );
|
||||
}
|
||||
|
||||
return TurtleCommandResult.success();
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
||||
return TurtleCommandResult.failure( "Nothing to dig here" );
|
||||
}
|
||||
}
|
||||
|
||||
private java.util.List<ItemStack> getBlockDropped( World world, BlockPos pos )
|
||||
private java.util.List<ItemStack> getBlockDropped( World world, BlockPos pos )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
return block.getDrops( world, pos, world.getBlockState( pos ), 0 );
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
return block.getDrops( world, pos, world.getBlockState( pos ), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user