Search in sources :

Example 1 with TileEntityRopeSideways

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRopeSideways(betterwithaddons.tileentity.TileEntityRopeSideways)

Example 2 with TileEntityRopeSideways

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRopeSideways(betterwithaddons.tileentity.TileEntityRopeSideways)

Example 3 with TileEntityRopeSideways

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRopeSideways(betterwithaddons.tileentity.TileEntityRopeSideways) ItemStack(net.minecraft.item.ItemStack)

Example 4 with TileEntityRopeSideways

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);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityRopeSideways(betterwithaddons.tileentity.TileEntityRopeSideways) ChunkCache(net.minecraft.world.ChunkCache) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) ItemStack(net.minecraft.item.ItemStack)

Aggregations

TileEntityRopeSideways (betterwithaddons.tileentity.TileEntityRopeSideways)4 TileEntity (net.minecraft.tileentity.TileEntity)4 ItemStack (net.minecraft.item.ItemStack)2 ChunkCache (net.minecraft.world.ChunkCache)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1