mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-24 09:04:49 +00:00
ComputerCraft 1.80pr0
Updated the source code to the version shipped as the 1.80pr0 alpha release. Also removed some unnecessary files from the LuaJ subfolder which were bulking up the repository.
This commit is contained in:
@@ -478,7 +478,7 @@ public class TurtleAPI implements ILuaAPI
|
||||
if( stack != null && stack.stackSize > 0 )
|
||||
{
|
||||
Item item = stack.getItem();
|
||||
String name = ((ResourceLocation)Item.itemRegistry.getNameForObject( item )).toString();
|
||||
String name = ((ResourceLocation)Item.REGISTRY.getNameForObject( item )).toString();
|
||||
int damage = stack.getItemDamage();
|
||||
int count = stack.stackSize;
|
||||
|
||||
|
||||
@@ -16,12 +16,13 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.properties.PropertyDirection;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockState;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -33,7 +34,7 @@ public class BlockTurtle extends BlockComputerBase
|
||||
public static class Properties
|
||||
{
|
||||
public static final PropertyDirection FACING = PropertyDirection.create( "facing", EnumFacing.Plane.HORIZONTAL );
|
||||
public static final PropertyEnum DYE = PropertyEnum.create( "dye", BlockTurtleDyeVariant.class );
|
||||
public static final PropertyEnum<BlockTurtleDyeVariant> DYE = PropertyEnum.<BlockTurtleDyeVariant>create( "dye", BlockTurtleDyeVariant.class );
|
||||
}
|
||||
|
||||
public static BlockTurtle createTurtleBlock()
|
||||
@@ -45,7 +46,7 @@ public class BlockTurtle extends BlockComputerBase
|
||||
|
||||
public BlockTurtle()
|
||||
{
|
||||
super( Material.iron );
|
||||
super( Material.IRON );
|
||||
setHardness( 2.5f );
|
||||
setUnlocalizedName( "computercraft:turtle" );
|
||||
setCreativeTab( ComputerCraft.mainCreativeTab );
|
||||
@@ -56,27 +57,27 @@ public class BlockTurtle extends BlockComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType()
|
||||
public EnumBlockRenderType getRenderType( IBlockState state )
|
||||
{
|
||||
return -1;
|
||||
return EnumBlockRenderType.INVISIBLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube()
|
||||
public boolean isOpaqueCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullCube()
|
||||
public boolean isFullCube( IBlockState state )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BlockState createBlockState()
|
||||
protected BlockStateContainer createBlockState()
|
||||
{
|
||||
return new BlockState(this, new IProperty[] {
|
||||
return new BlockStateContainer(this, new IProperty[] {
|
||||
Properties.FACING,
|
||||
Properties.DYE
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.common.IDirectionalTile;
|
||||
import dan200.computercraft.shared.computer.blocks.IComputerTile;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public interface ITurtleTile extends IComputerTile, IDirectionalTile
|
||||
{
|
||||
@@ -22,7 +22,7 @@ public interface ITurtleTile extends IComputerTile, IDirectionalTile
|
||||
public ITurtleUpgrade getUpgrade( TurtleSide side );
|
||||
public ITurtleAccess getAccess();
|
||||
|
||||
public Vec3 getRenderOffset( float f );
|
||||
public Vec3d getRenderOffset( float f );
|
||||
public float getRenderYaw( float f );
|
||||
public float getToolRenderAngle( TurtleSide side, float f );
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import java.util.List;
|
||||
@@ -135,7 +137,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getDroppedItems( List<ItemStack> drops, int fortune, boolean creative, boolean silkTouch )
|
||||
public void getDroppedItems( List<ItemStack> drops, boolean creative )
|
||||
{
|
||||
IComputer computer = getComputer();
|
||||
if( !creative || (computer != null && computer.getLabel() != null) )
|
||||
@@ -157,10 +159,10 @@ public class TileTurtle extends TileComputerBase
|
||||
requestTileEntityUpdate();
|
||||
|
||||
// Apply dye
|
||||
ItemStack currentItem = player.getCurrentEquippedItem();
|
||||
ItemStack currentItem = player.getHeldItem( EnumHand.MAIN_HAND );
|
||||
if( currentItem != null )
|
||||
{
|
||||
if( currentItem.getItem() == Items.dye )
|
||||
if( currentItem.getItem() == Items.DYE )
|
||||
{
|
||||
// Dye to change turtle colour
|
||||
if( !worldObj.isRemote )
|
||||
@@ -177,7 +179,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if( currentItem.getItem() == Items.water_bucket && m_brain.getDyeColour() != -1 )
|
||||
else if( currentItem.getItem() == Items.WATER_BUCKET && m_brain.getDyeColour() != -1 )
|
||||
{
|
||||
// Water to remove turtle colour
|
||||
if( !worldObj.isRemote )
|
||||
@@ -187,7 +189,7 @@ public class TileTurtle extends TileComputerBase
|
||||
m_brain.setDyeColour( -1 );
|
||||
if( !player.capabilities.isCreativeMode )
|
||||
{
|
||||
currentItem.setItem( Items.bucket );
|
||||
currentItem.setItem( Items.BUCKET );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +239,7 @@ public class TileTurtle extends TileComputerBase
|
||||
@Override
|
||||
public AxisAlignedBB getBounds()
|
||||
{
|
||||
Vec3 offset = getRenderOffset( 1.0f );
|
||||
Vec3d offset = getRenderOffset( 1.0f );
|
||||
return new AxisAlignedBB(
|
||||
offset.xCoord + 0.125, offset.yCoord + 0.125, offset.zCoord + 0.125,
|
||||
offset.xCoord + 0.875, offset.yCoord + 0.875, offset.zCoord + 0.875
|
||||
@@ -299,9 +301,9 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
super.writeToNBT( nbttagcompound );
|
||||
nbttagcompound = super.writeToNBT( nbttagcompound );
|
||||
|
||||
// Write inventory
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
@@ -318,7 +320,9 @@ public class TileTurtle extends TileComputerBase
|
||||
nbttagcompound.setTag( "Items", nbttaglist );
|
||||
|
||||
// Write brain
|
||||
m_brain.writeToNBT( nbttagcompound );
|
||||
nbttagcompound = m_brain.writeToNBT( nbttagcompound );
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -379,7 +383,7 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getRenderOffset( float f )
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
return m_brain.getRenderOffset( f );
|
||||
}
|
||||
@@ -524,15 +528,15 @@ public class TileTurtle extends TileComputerBase
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
if( hasCustomName() )
|
||||
{
|
||||
return new ChatComponentText( getName() );
|
||||
return new TextComponentString( getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ChatComponentTranslation( getName() );
|
||||
return new TextComponentTranslation( getName() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.text.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
@@ -297,7 +299,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToNBT( NBTTagCompound nbttagcompound )
|
||||
public NBTTagCompound writeToNBT( NBTTagCompound nbttagcompound )
|
||||
{
|
||||
// Write state
|
||||
nbttagcompound.setInteger( "dir", m_direction.getIndex() );
|
||||
@@ -338,6 +340,8 @@ public class TurtleBrain implements ITurtleAccess
|
||||
{
|
||||
nbttagcompound.setTag( "rightUpgradeNBT", (NBTTagCompound) getUpgradeNBTData( TurtleSide.Right ).copy() );
|
||||
}
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
private String getUpgradeID( ITurtleUpgrade upgrade )
|
||||
@@ -535,11 +539,11 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 getVisualPosition( float f )
|
||||
public Vec3d getVisualPosition( float f )
|
||||
{
|
||||
Vec3 offset = getRenderOffset( f );
|
||||
Vec3d offset = getRenderOffset( f );
|
||||
BlockPos pos = m_owner.getPos();
|
||||
return new Vec3(
|
||||
return new Vec3d(
|
||||
pos.getX() + 0.5 + offset.xCoord,
|
||||
pos.getY() + 0.5 + offset.yCoord,
|
||||
pos.getZ() + 0.5 + offset.zCoord
|
||||
@@ -856,7 +860,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
public Vec3 getRenderOffset( float f )
|
||||
public Vec3d getRenderOffset( float f )
|
||||
{
|
||||
switch( m_animation )
|
||||
{
|
||||
@@ -893,7 +897,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
|
||||
double distance = -1.0 + (double)getAnimationFraction( f );
|
||||
return new Vec3(
|
||||
return new Vec3d(
|
||||
distance * (double)dir.getFrontOffsetX(),
|
||||
distance * (double)dir.getFrontOffsetY(),
|
||||
distance * (double)dir.getFrontOffsetZ()
|
||||
@@ -901,7 +905,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
default:
|
||||
{
|
||||
return new Vec3( 0.0, 0.0, 0.0 );
|
||||
return new Vec3d( 0.0, 0.0, 0.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1140,7 +1144,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
Holiday currentHoliday = HolidayUtil.getCurrentHoliday();
|
||||
if( currentHoliday == Holiday.Valentines )
|
||||
{
|
||||
Vec3 position = getVisualPosition( 1.0f );
|
||||
Vec3d position = getVisualPosition( 1.0f );
|
||||
if( position != null )
|
||||
{
|
||||
double x = position.xCoord + world.rand.nextGaussian() * 0.1;
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.ReflectionHelper;
|
||||
@@ -50,11 +50,11 @@ public class TurtleCompareCommand implements ITurtleCommand
|
||||
{
|
||||
if( !world.isAirBlock( newPosition ) )
|
||||
{
|
||||
Block lookAtBlock = world.getBlockState( newPosition ).getBlock();
|
||||
if( lookAtBlock != null && !lookAtBlock.isAir( world, newPosition ) )
|
||||
IBlockState lookAtState = world.getBlockState( newPosition );
|
||||
Block lookAtBlock = lookAtState.getBlock();
|
||||
if( !lookAtBlock.isAir( lookAtState, world, newPosition ) )
|
||||
{
|
||||
// Try createStackedBlock first
|
||||
IBlockState lookAtState = world.getBlockState( newPosition );
|
||||
if( !lookAtBlock.hasTileEntity( lookAtState ) )
|
||||
{
|
||||
try
|
||||
|
||||
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.turtle.upgrades.TurtleInventoryCrafting;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.api.turtle.ITurtleCommand;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
@@ -12,9 +12,12 @@ import dan200.computercraft.api.turtle.TurtleAnimation;
|
||||
import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -81,7 +84,7 @@ public class TurtleDropCommand implements ITurtleCommand
|
||||
{
|
||||
// Drop the item into the world
|
||||
WorldUtil.dropItemStack( stack, world, oldPosition, direction );
|
||||
world.playSoundEffect( newPosition.getX() + 0.5, newPosition.getY() + 0.5, newPosition.getZ() + 0.5, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 2.0f );
|
||||
world.playBroadcastSound( 1000, newPosition, 0 );
|
||||
turtle.playAnimation( TurtleAnimation.Wait );
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.util.InventoryUtil;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class TurtleEquipCommand implements ITurtleCommand
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -49,7 +49,7 @@ public class TurtleInspectCommand implements ITurtleCommand
|
||||
{
|
||||
IBlockState state = world.getBlockState( newPosition );
|
||||
Block block = state.getBlock();
|
||||
String name = ((ResourceLocation)Block.blockRegistry.getNameForObject( block )).toString();
|
||||
String name = ((ResourceLocation)Block.REGISTRY.getNameForObject( block )).toString();
|
||||
int metadata = block.getMetaFromState( state );
|
||||
|
||||
Map<Object, Object> table = new HashMap<Object, Object>();
|
||||
|
||||
@@ -14,8 +14,8 @@ import dan200.computercraft.api.turtle.TurtleCommandResult;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -88,7 +88,7 @@ public class TurtleMoveCommand implements ITurtleCommand
|
||||
(double) direction.getFrontOffsetY(),
|
||||
(double) direction.getFrontOffsetZ()
|
||||
);
|
||||
if( !oldWorld.func_147461_a( pushedBB ).isEmpty() ) // getCollidingBlockBoundingBoxes
|
||||
if( !oldWorld.getCollisionBoxes( pushedBB ).isEmpty() )
|
||||
{
|
||||
return TurtleCommandResult.failure( "Movement obstructed" );
|
||||
}
|
||||
|
||||
@@ -22,10 +22,13 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -200,10 +203,10 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
// See if there is an entity present
|
||||
final World world = turtle.getWorld();
|
||||
final BlockPos position = turtle.getPosition();
|
||||
Vec3 turtlePos = new Vec3( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3 rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3 rayStart = turtlePos;
|
||||
Pair<Entity, Vec3> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
Vec3d turtlePos = new Vec3d( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3d rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3d rayStart = turtlePos;
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
if( hit == null )
|
||||
{
|
||||
return stack;
|
||||
@@ -216,7 +219,7 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Start claiming entity drops
|
||||
Entity hitEntity = hit.getKey();
|
||||
Vec3 hitPos = hit.getValue();
|
||||
Vec3d hitPos = hit.getValue();
|
||||
ComputerCraft.setEntityDropConsumer( hitEntity, new IEntityDropConsumer()
|
||||
{
|
||||
@Override
|
||||
@@ -232,21 +235,18 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Place on the entity
|
||||
boolean placed = false;
|
||||
if( hitEntity.interactFirst( turtlePlayer ) )
|
||||
if( hitEntity.applyPlayerInteraction( turtlePlayer, hitPos, stackCopy, EnumHand.MAIN_HAND ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( hitEntity instanceof EntityLivingBase )
|
||||
{
|
||||
placed = item.itemInteractionForEntity( stackCopy, turtlePlayer, (EntityLivingBase)hitEntity );
|
||||
placed = item.itemInteractionForEntity( stackCopy, turtlePlayer, (EntityLivingBase)hitEntity, EnumHand.MAIN_HAND );
|
||||
if( placed )
|
||||
{
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( hitEntity.interactAt( turtlePlayer, hitPos ) ) // interact
|
||||
{
|
||||
placed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop claiming drops
|
||||
@@ -346,19 +346,23 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
|
||||
// Do the deploying (put everything in the players inventory)
|
||||
boolean placed = false;
|
||||
if( item.onItemUseFirst( stackCopy, turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ ) ||
|
||||
item.onItemUse( stackCopy, turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ ) )
|
||||
if( item.onItemUseFirst( stackCopy, turtlePlayer, turtle.getWorld(), position, side, hitX, hitY, hitZ, EnumHand.MAIN_HAND ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( item.onItemUse( stackCopy, turtlePlayer, turtle.getWorld(), position, EnumHand.MAIN_HAND, side, hitX, hitY, hitZ ) == EnumActionResult.SUCCESS )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( stackCopy );
|
||||
}
|
||||
else if( item instanceof ItemBucket || item instanceof ItemBoat || item instanceof ItemLilyPad || item instanceof ItemGlassBottle )
|
||||
{
|
||||
ItemStack result = item.onItemRightClick( stackCopy, turtle.getWorld(), turtlePlayer );
|
||||
if( !ItemStack.areItemStacksEqual( stack, result ) )
|
||||
ActionResult<ItemStack> result = item.onItemRightClick( stackCopy, turtle.getWorld(), turtlePlayer, EnumHand.MAIN_HAND );
|
||||
if( result.getType() == EnumActionResult.SUCCESS && !ItemStack.areItemStacksEqual( stack, result.getResult() ) )
|
||||
{
|
||||
placed = true;
|
||||
turtlePlayer.loadInventory( result );
|
||||
turtlePlayer.loadInventory( result.getResult() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,20 +390,20 @@ public class TurtlePlaceCommand implements ITurtleCommand
|
||||
{
|
||||
if( split[ i - firstLine ].length() > 15 )
|
||||
{
|
||||
signTile.signText[ i ] = new ChatComponentText( split[ i - firstLine ].substring( 0, 15 ) );
|
||||
signTile.signText[ i ] = new TextComponentString( split[ i - firstLine ].substring( 0, 15 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.signText[ i ] = new ChatComponentText( split[ i - firstLine ] );
|
||||
signTile.signText[ i ] = new TextComponentString( split[ i - firstLine ] );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
signTile.signText[i] = new ChatComponentText( "" );
|
||||
signTile.signText[i] = new TextComponentString( "" );
|
||||
}
|
||||
}
|
||||
signTile.markDirty();
|
||||
world.markBlockForUpdate( signTile.getPos() );
|
||||
world.markBlockRangeForRenderUpdate( signTile.getPos(), signTile.getPos() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
@@ -78,7 +78,7 @@ public class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mountEntity( Entity entity )
|
||||
public void mountEntityAndWakeUp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class TurtleSuckCommand implements ITurtleCommand
|
||||
if( storedItems )
|
||||
{
|
||||
// Play fx
|
||||
world.playSoundEffect( oldPosition.getX() + 0.5, oldPosition.getY() + 0.5, oldPosition.getZ() + 0.5, "random.pop", 0.2f, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7f + 1.0f) * 2.0f );
|
||||
world.playBroadcastSound( 1000, oldPosition, 0 );
|
||||
turtle.playAnimation( TurtleAnimation.Wait );
|
||||
return TurtleCommandResult.success();
|
||||
}
|
||||
|
||||
@@ -9,20 +9,25 @@ package dan200.computercraft.shared.turtle.entity;
|
||||
import dan200.computercraft.api.turtle.ITurtleAccess;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.EnumHandSide;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TurtleVisionCamera extends EntityLivingBase
|
||||
{
|
||||
private ITurtleAccess m_turtle;
|
||||
private ItemStack[] m_inventory;
|
||||
private ArrayList<ItemStack> m_armor;
|
||||
|
||||
public TurtleVisionCamera( World world, ITurtleAccess turtle )
|
||||
{
|
||||
super( world );
|
||||
m_turtle = turtle;
|
||||
m_inventory = new ItemStack[0];
|
||||
m_armor = new ArrayList<ItemStack>();
|
||||
applyPos();
|
||||
}
|
||||
|
||||
@@ -37,6 +42,12 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHandSide getPrimaryHand()
|
||||
{
|
||||
return EnumHandSide.RIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
@@ -46,7 +57,7 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
|
||||
private void applyPos()
|
||||
{
|
||||
Vec3 prevPos = m_turtle.getVisualPosition( 0.0f );
|
||||
Vec3d prevPos = m_turtle.getVisualPosition( 0.0f );
|
||||
this.lastTickPosX = this.prevPosX = prevPos.xCoord;
|
||||
this.lastTickPosY = this.prevPosY = prevPos.yCoord;
|
||||
this.lastTickPosZ = this.prevPosZ = prevPos.zCoord;
|
||||
@@ -54,7 +65,7 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
this.prevRotationYaw = m_turtle.getVisualYaw( 0.0f );
|
||||
this.prevCameraPitch = 0.0f;
|
||||
|
||||
Vec3 pos = m_turtle.getVisualPosition( 1.0f );
|
||||
Vec3d pos = m_turtle.getVisualPosition( 1.0f );
|
||||
this.posX = pos.xCoord;
|
||||
this.posY = pos.yCoord;
|
||||
this.posZ = pos.zCoord;
|
||||
@@ -76,31 +87,25 @@ public class TurtleVisionCamera extends EntityLivingBase
|
||||
// EntityLivingBase overrides:
|
||||
|
||||
@Override
|
||||
public ItemStack getHeldItem()
|
||||
public ItemStack getHeldItem( EnumHand hand )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getEquipmentInSlot( int slot )
|
||||
public void setItemStackToSlot(EntityEquipmentSlot slot, ItemStack stack)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStackFromSlot(EntityEquipmentSlot slot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCurrentArmor( int slotIn )
|
||||
public Iterable<ItemStack> getArmorInventoryList()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentItemOrArmor( int slot, ItemStack stack )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getInventory()
|
||||
{
|
||||
return m_inventory;
|
||||
return m_armor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.IContainerListener;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -76,16 +76,16 @@ public class ContainerTurtle extends Container
|
||||
return m_selectedSlot;
|
||||
}
|
||||
|
||||
private void sendStateToPlayer( ICrafting icrafting )
|
||||
private void sendStateToPlayer( IContainerListener icrafting )
|
||||
{
|
||||
int selectedSlot = m_turtle.getSelectedSlot();
|
||||
icrafting.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftGuiOpened( ICrafting crafting )
|
||||
public void addListener( IContainerListener crafting )
|
||||
{
|
||||
super.onCraftGuiOpened( crafting );
|
||||
super.addListener( crafting );
|
||||
sendStateToPlayer( crafting );
|
||||
}
|
||||
|
||||
@@ -95,9 +95,9 @@ public class ContainerTurtle extends Container
|
||||
super.detectAndSendChanges();
|
||||
|
||||
int selectedSlot = m_turtle.getSelectedSlot();
|
||||
for( int i=0; i<crafters.size(); ++i )
|
||||
for( int i=0; i<listeners.size(); ++i )
|
||||
{
|
||||
ICrafting icrafting = (ICrafting)crafters.get(i);
|
||||
IContainerListener icrafting = (IContainerListener)listeners.get(i);
|
||||
if( m_selectedSlot != selectedSlot )
|
||||
{
|
||||
icrafting.sendProgressBarUpdate( this, PROGRESS_ID_SELECTED_SLOT, selectedSlot );
|
||||
|
||||
@@ -21,10 +21,10 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.text.translation.I18n;;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -142,29 +142,29 @@ public abstract class ItemTurtleBase extends ItemComputerBase implements ITurtle
|
||||
ITurtleUpgrade right = getUpgrade( stack, TurtleSide.Right );
|
||||
if( left != null && right != null )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded_twice.name",
|
||||
StatCollector.translateToLocal( right.getUnlocalisedAdjective() ),
|
||||
StatCollector.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
I18n.translateToLocal( right.getUnlocalisedAdjective() ),
|
||||
I18n.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else if( left != null )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded.name",
|
||||
StatCollector.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
I18n.translateToLocal( left.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else if( right != null )
|
||||
{
|
||||
return StatCollector.translateToLocalFormatted(
|
||||
return I18n.translateToLocalFormatted(
|
||||
baseString + ".upgraded.name",
|
||||
StatCollector.translateToLocal( right.getUnlocalisedAdjective() )
|
||||
I18n.translateToLocal( right.getUnlocalisedAdjective() )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return StatCollector.translateToLocal( baseString + ".name" );
|
||||
return I18n.translateToLocal( baseString + ".name" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ package dan200.computercraft.shared.turtle.upgrades;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.api.turtle.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -38,7 +38,7 @@ public class TurtleCraftingTable implements ITurtleUpgrade
|
||||
{
|
||||
m_id = new ResourceLocation( "minecraft", "crafting_table" );
|
||||
m_legacyID = legacyId;
|
||||
m_item = new ItemStack( Blocks.crafting_table, 1, 0 );
|
||||
m_item = new ItemStack( Blocks.CRAFTING_TABLE, 1, 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,9 +13,10 @@ import dan200.computercraft.api.turtle.TurtleVerb;
|
||||
import dan200.computercraft.shared.turtle.core.TurtlePlaceCommand;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
@@ -32,13 +33,15 @@ public class TurtleHoe extends TurtleTool
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
block.getMaterial() == Material.plants ||
|
||||
block.getMaterial() == Material.cactus ||
|
||||
block.getMaterial() == Material.gourd ||
|
||||
block.getMaterial() == Material.leaves ||
|
||||
block.getMaterial() == Material.vine;
|
||||
material == Material.PLANTS ||
|
||||
material == Material.CACTUS ||
|
||||
material == Material.GOURD ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
@@ -120,7 +120,7 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
results.add( result );
|
||||
|
||||
// Consume resources from the inventory
|
||||
ItemStack[] remainingItems = CraftingManager.getInstance().func_180303_b( this, world ); // getRemainingItems
|
||||
ItemStack[] remainingItems = CraftingManager.getInstance().getRemainingItems( this, world );
|
||||
for( int n=0; n<size; ++n )
|
||||
{
|
||||
ItemStack stack = getStackInSlot( n );
|
||||
@@ -214,9 +214,9 @@ public class TurtleInventoryCrafting extends InventoryCrafting
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatComponent getDisplayName()
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return new ChatComponentText( "" );
|
||||
return new TextComponentString( "" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,15 +12,15 @@ import dan200.computercraft.shared.peripheral.PeripheralType;
|
||||
import dan200.computercraft.shared.peripheral.common.PeripheralItemFactory;
|
||||
import dan200.computercraft.shared.peripheral.modem.WirelessModemPeripheral;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.resources.model.ModelManager;
|
||||
import net.minecraft.client.resources.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelManager;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
@@ -48,10 +48,10 @@ public class TurtleModem implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Vec3 getPosition()
|
||||
protected Vec3d getPosition()
|
||||
{
|
||||
BlockPos turtlePos = m_turtle.getPosition();
|
||||
return new Vec3(
|
||||
return new Vec3d(
|
||||
(double)turtlePos.getX(),
|
||||
(double)turtlePos.getY(),
|
||||
(double)turtlePos.getZ()
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -24,19 +25,21 @@ public class TurtleShovel extends TurtleTool
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
return
|
||||
block.getMaterial() == Material.ground ||
|
||||
block.getMaterial() == Material.sand ||
|
||||
block.getMaterial() == Material.snow ||
|
||||
block.getMaterial() == Material.clay ||
|
||||
block.getMaterial() == Material.craftedSnow ||
|
||||
block.getMaterial() == Material.grass ||
|
||||
block.getMaterial() == Material.plants ||
|
||||
block.getMaterial() == Material.cactus ||
|
||||
block.getMaterial() == Material.gourd ||
|
||||
block.getMaterial() == Material.leaves ||
|
||||
block.getMaterial() == Material.vine;
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
material == Material.GROUND ||
|
||||
material == Material.SAND ||
|
||||
material == Material.SNOW ||
|
||||
material == Material.CLAY ||
|
||||
material == Material.CRAFTED_SNOW ||
|
||||
material == Material.GRASS ||
|
||||
material == Material.PLANTS ||
|
||||
material == Material.CACTUS ||
|
||||
material == Material.GOURD ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
package dan200.computercraft.shared.turtle.upgrades;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -24,13 +25,15 @@ public class TurtleSword extends TurtleTool
|
||||
{
|
||||
if( super.canBreakBlock( world, pos ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
return
|
||||
block.getMaterial() == Material.plants ||
|
||||
block.getMaterial() == Material.leaves ||
|
||||
block.getMaterial() == Material.vine ||
|
||||
block.getMaterial() == Material.cloth ||
|
||||
block.getMaterial() == Material.web;
|
||||
IBlockState state = world.getBlockState( pos );
|
||||
Block block = state.getBlock();
|
||||
Material material = block.getMaterial( state );
|
||||
return
|
||||
material == Material.PLANTS ||
|
||||
material == Material.LEAVES ||
|
||||
material == Material.VINE ||
|
||||
material == Material.CLOTH ||
|
||||
material == Material.WEB;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.SharedMonsterAttributes;
|
||||
import net.minecraft.entity.item.EntityArmorStand;
|
||||
@@ -26,6 +27,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
@@ -132,8 +134,9 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
|
||||
protected boolean canBreakBlock( World world, BlockPos pos )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
if( block.isAir( world, pos ) || block == Blocks.bedrock || block.getBlockHardness( world, pos ) <= -1.0F )
|
||||
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;
|
||||
}
|
||||
@@ -161,10 +164,10 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
final TurtlePlayer turtlePlayer = TurtlePlaceCommand.createPlayer( turtle, position, direction );
|
||||
|
||||
// See if there is an entity present
|
||||
Vec3 turtlePos = new Vec3( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3 rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3 rayStart = turtlePos;
|
||||
Pair<Entity, Vec3> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
Vec3d turtlePos = new Vec3d( turtlePlayer.posX, turtlePlayer.posY, turtlePlayer.posZ );
|
||||
Vec3d rayDir = turtlePlayer.getLook( 1.0f );
|
||||
Vec3d rayStart = turtlePos;
|
||||
Pair<Entity, Vec3d> hit = WorldUtil.rayTraceEntities( world, rayStart, rayDir, 1.5 );
|
||||
if( hit != null )
|
||||
{
|
||||
// Load up the turtle's inventory
|
||||
@@ -188,9 +191,9 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
|
||||
// Place on the entity
|
||||
boolean placed = false;
|
||||
if( hitEntity.canAttackWithItem() && !hitEntity.hitByEntity( turtlePlayer ) )
|
||||
if( hitEntity.canBeAttackedWithItem() && !hitEntity.hitByEntity( turtlePlayer ) )
|
||||
{
|
||||
float damage = (float)turtlePlayer.getEntityAttribute( SharedMonsterAttributes.attackDamage ).getAttributeValue();
|
||||
float damage = (float)turtlePlayer.getEntityAttribute( SharedMonsterAttributes.ATTACK_DAMAGE ).getAttributeValue();
|
||||
damage *= getDamageMultiplier();
|
||||
if( damage > 0.0f )
|
||||
{
|
||||
@@ -277,16 +280,13 @@ public class TurtleTool implements ITurtleUpgrade
|
||||
}
|
||||
|
||||
// Destroy the block
|
||||
Block previousBlock = world.getBlockState( newPosition ).getBlock();
|
||||
IBlockState previousState = world.getBlockState( newPosition );
|
||||
if( previousBlock != null )
|
||||
{
|
||||
world.playSoundEffect( newPosition.getX() + 0.5, newPosition.getY() + 0.5, newPosition.getZ() + 0.5, previousBlock.stepSound.getBreakSound(), (previousBlock.stepSound.getVolume() + 1.0F) / 2.0F, previousBlock.stepSound.getFrequency() * 0.8F);
|
||||
}
|
||||
Block previousBlock = previousState.getBlock();
|
||||
world.playSound( null, newPosition, previousBlock.getSoundType().getBreakSound(), SoundCategory.BLOCKS, (previousBlock.getSoundType().getVolume() + 1.0F) / 2.0F, previousBlock.getSoundType().getPitch() * 0.8F );
|
||||
world.setBlockToAir( newPosition );
|
||||
|
||||
// Remember the previous block
|
||||
if( turtle instanceof TurtleBrain && previousBlock != null )
|
||||
if( turtle instanceof TurtleBrain )
|
||||
{
|
||||
TurtleBrain brain = (TurtleBrain)turtle;
|
||||
brain.saveBlockChange( newPosition, previousState );
|
||||
|
||||
Reference in New Issue
Block a user