use of betterwithaddons.tileentity.TileEntityRopeSideways in project BetterWithAddons by DaedalusGame.
the class BlockRopeSideways method breakBlock.
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
TileEntity te = worldIn.getTileEntity(pos);
if (te instanceof TileEntityRopeSideways) {
InvUtils.ejectStackWithOffset(worldIn, pos, ((TileEntityRopeSideways) te).getPlanks());
}
super.breakBlock(worldIn, pos, state);
}
use of betterwithaddons.tileentity.TileEntityRopeSideways in project BetterWithAddons by DaedalusGame.
the class BlockRopeSideways method removedByPlayer.
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (state.getValue(HAS_PLANKS)) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityRopeSideways && !world.isRemote) {
TileEntityRopeSideways tile = (TileEntityRopeSideways) te;
spawnAsEntity(world, pos, tile.getPlanks());
tile.setPlanks(ItemStack.EMPTY);
return false;
}
}
return super.removedByPlayer(state, world, pos, player, willHarvest);
}
use of betterwithaddons.tileentity.TileEntityRopeSideways in project BetterWithAddons by DaedalusGame.
the class BlockRopeSideways method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (playerIn == null)
return false;
TileEntity te = worldIn.getTileEntity(pos);
ItemStack stack = playerIn.getHeldItem(hand);
if (te instanceof TileEntityRopeSideways && !playerIn.isSneaking() && ItemUtil.matchesOreDict(stack, "plankWood")) {
TileEntityRopeSideways tile = (TileEntityRopeSideways) te;
if (worldIn.isRemote)
return true;
else {
if (tile.getPlanks().isEmpty()) {
tile.setPlanks(stack.splitStack(1));
}
return true;
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
use of betterwithaddons.tileentity.TileEntityRopeSideways in project BetterWithAddons by DaedalusGame.
the class BlockRopeSideways method getExtendedState.
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity te = world instanceof ChunkCache ? ((ChunkCache) world).getTileEntity(pos, Chunk.EnumCreateEntityType.CHECK) : world.getTileEntity(pos);
ItemStack planks = ItemStack.EMPTY;
if (te instanceof TileEntityRopeSideways) {
TileEntityRopeSideways tile = (TileEntityRopeSideways) te;
planks = tile.getPlanks();
}
return ((IExtendedBlockState) state).withProperty(HELD_PLANKS, planks);
}
Aggregations