Search in sources :

Example 1 with TileEntityCustomWorkbench

use of lumien.randomthings.tileentity.TileEntityCustomWorkbench in project Random-Things by lumien231.

the class BlockCustomWorkbench method getPickBlock.

@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
    TileEntityCustomWorkbench te = (TileEntityCustomWorkbench) world.getTileEntity(pos);
    String woodName = te.getWoodMaterial().getRegistryName().toString();
    int meta = te.getWoodMeta();
    ItemStack pickedWorkbench = new ItemStack(this);
    NBTTagCompound compound;
    pickedWorkbench.setTagCompound(compound = new NBTTagCompound());
    compound.setString("woodName", woodName);
    compound.setInteger("woodMeta", meta);
    return pickedWorkbench;
}
Also used : TileEntityCustomWorkbench(lumien.randomthings.tileentity.TileEntityCustomWorkbench) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 2 with TileEntityCustomWorkbench

use of lumien.randomthings.tileentity.TileEntityCustomWorkbench in project Random-Things by lumien231.

the class BlockCustomWorkbench method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    TileEntityCustomWorkbench te = (TileEntityCustomWorkbench) worldIn.getTileEntity(pos);
    IExtendedBlockState actualState = (IExtendedBlockState) state;
    if (te != null && te.getWoodState() != null) {
        return actualState.withProperty(WOOD_STATE, te.getWoodState());
    } else {
        return actualState.withProperty(WOOD_STATE, Blocks.PLANKS.getDefaultState());
    }
}
Also used : TileEntityCustomWorkbench(lumien.randomthings.tileentity.TileEntityCustomWorkbench) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState)

Example 3 with TileEntityCustomWorkbench

use of lumien.randomthings.tileentity.TileEntityCustomWorkbench in project Random-Things by lumien231.

the class BlockCustomWorkbench method breakBlock.

@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    TileEntityCustomWorkbench te = (TileEntityCustomWorkbench) worldIn.getTileEntity(pos);
    String woodName = te.getWoodMaterial().getRegistryName().toString();
    int meta = te.getWoodMeta();
    ItemStack droppedWorkbench = new ItemStack(this);
    NBTTagCompound compound;
    droppedWorkbench.setTagCompound(compound = new NBTTagCompound());
    compound.setString("woodName", woodName);
    compound.setInteger("woodMeta", meta);
    WorldUtil.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), droppedWorkbench);
    super.breakBlock(worldIn, pos, state);
}
Also used : TileEntityCustomWorkbench(lumien.randomthings.tileentity.TileEntityCustomWorkbench) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 4 with TileEntityCustomWorkbench

use of lumien.randomthings.tileentity.TileEntityCustomWorkbench in project Random-Things by lumien231.

the class BlockCustomWorkbench method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    NBTTagCompound compound;
    String woodName;
    int meta;
    if ((compound = stack.getTagCompound()) != null) {
        woodName = compound.getString("woodName");
        meta = compound.getInteger("woodMeta");
    } else {
        woodName = "minecraft:planks";
        meta = 0;
    }
    TileEntityCustomWorkbench te = (TileEntityCustomWorkbench) worldIn.getTileEntity(pos);
    Block woodBlock = Block.getBlockFromName(woodName);
    if (woodBlock == null) {
        woodBlock = Blocks.PLANKS;
        meta = 0;
    }
    te.setWood(woodBlock, meta);
}
Also used : TileEntityCustomWorkbench(lumien.randomthings.tileentity.TileEntityCustomWorkbench) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Block(net.minecraft.block.Block)

Aggregations

TileEntityCustomWorkbench (lumien.randomthings.tileentity.TileEntityCustomWorkbench)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 ItemStack (net.minecraft.item.ItemStack)2 Block (net.minecraft.block.Block)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1