Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RubberLeaves extends BlockLeaves {
- public RubberLeaves() {
- this.setTickRandomly(true);
- this.setCreativeTab(TechExpansion.TechExpansion);
- this.setHardness(0.2F);
- this.setLightOpacity(1);
- this.setSoundType(SoundType.PLANT);
- this.setUnlocalizedName("rubber_leaves");
- this.setDefaultState(this.blockState.getBaseState().withProperty(CHECK_DECAY, Boolean.valueOf(true)).withProperty(DECAYABLE, Boolean.valueOf(true)));
- GameRegistry.register(this.setRegistryName("rubber_leaves"));
- GameRegistry.register(new ItemBlock(this).setRegistryName(this.getRegistryName()));
- }
- @Override
- public Item getItemDropped(IBlockState state, Random rand, int fortune)
- {
- return Item.getItemFromBlock(ModBlocks.RubberSapling);
- }
- protected void dropRubber(World worldIn, BlockPos pos, IBlockState state, int chance)
- {
- spawnAsEntity(worldIn, pos, new ItemStack(ModItems.RawRubber, 1));
- }
- @Override
- protected int getSaplingDropChance(IBlockState state)
- {
- return 20;
- }
- @Override
- public boolean isOpaqueCube(IBlockState state)
- {
- return false;
- }
- @Override
- @SideOnly(Side.CLIENT)
- public BlockRenderLayer getBlockLayer()
- {
- return BlockRenderLayer.CUTOUT_MIPPED;
- }
- @Override
- public BlockPlanks.EnumType getWoodType(int meta) {
- return null;
- }
- @Override public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos){
- return true;
- }
- @Override
- public List<ItemStack> onSheared(@Nonnull ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
- List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
- ret.add(new ItemStack(ModBlocks.RubberLeaves, 1));
- return ret;
- }
- @Override
- public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) {
- return true;
- }
- @Override
- public java.util.List<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune)
- {
- java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
- Random rand = world instanceof World ? ((World)world).rand : new Random();
- int chance = this.getSaplingDropChance(state);
- if (fortune > 0)
- {
- chance -= 2 << fortune;
- if (chance < 10) chance = 10;
- }
- if (rand.nextInt(chance) == 0)
- {
- ItemStack drop = new ItemStack(getItemDropped(state, rand, fortune), 1, damageDropped(state));
- if (!drop.isEmpty())
- ret.add(drop);
- }
- chance = 200;
- if (fortune > 0)
- {
- chance -= 10 << fortune;
- if (chance < 40) chance = 40;
- }
- this.captureDrops(true);
- if (world instanceof World)
- this.dropRubber((World)world, pos, state, chance);
- ret.addAll(this.captureDrops(false));
- return ret;
- }
- @Override
- protected BlockStateContainer createBlockState() {
- return new BlockStateContainer(this, new IProperty[]{DECAYABLE, CHECK_DECAY});
- }
- @Override
- public int getMetaFromState(IBlockState state) {
- int i = 0;
- if (!state.getValue(DECAYABLE).booleanValue()) {
- i |= 4;
- }
- if (state.getValue(CHECK_DECAY).booleanValue()) {
- i |= 8;
- }
- return i;
- }
- @Override
- public IBlockState getStateFromMeta(int meta) {
- return this.getDefaultState().withProperty(DECAYABLE, Boolean.valueOf((meta & 4) == 0)).withProperty(CHECK_DECAY, Boolean.valueOf((meta & 8) > 0));
- }
- }
Add Comment
Please, Sign In to add comment