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;
}
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());
}
}
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);
}
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);
}
Aggregations