diff --git a/src/main/java/com/progwml6/natura/common/block/base/BlockLeavesBase.java b/src/main/java/com/progwml6/natura/common/block/base/BlockLeavesBase.java index c9db9247..182f8f4a 100644 --- a/src/main/java/com/progwml6/natura/common/block/base/BlockLeavesBase.java +++ b/src/main/java/com/progwml6/natura/common/block/base/BlockLeavesBase.java @@ -1,305 +1,19 @@ package com.progwml6.natura.common.block.base; -import java.util.Random; +import net.minecraft.block.BlockLeaves; +import net.minecraft.block.BlockPlanks.EnumType; -import net.minecraft.block.Block; -import net.minecraft.block.SoundType; -import net.minecraft.block.material.Material; -import net.minecraft.block.properties.PropertyBool; -import net.minecraft.block.state.IBlockState; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.EnumParticleTypes; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.IShearable; -import net.minecraftforge.fml.relauncher.Side; -import net.minecraftforge.fml.relauncher.SideOnly; - -public abstract class BlockLeavesBase extends Block implements IShearable +public abstract class BlockLeavesBase extends BlockLeaves { - public static final PropertyBool DECAYABLE = PropertyBool.create("decayable"); - - public static final PropertyBool CHECK_DECAY = PropertyBool.create("check_decay"); - - int[] surroundings; - public BlockLeavesBase() { - super(Material.LEAVES); - - this.setTickRandomly(true); - this.setCreativeTab(CreativeTabs.DECORATIONS); - this.setHardness(0.2F); - this.setLightOpacity(1); - this.setSoundType(SoundType.PLANT); - } - - /** - * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated - */ - @Override - public void breakBlock(World worldIn, BlockPos pos, IBlockState state) - { - int k = pos.getX(); - int l = pos.getY(); - int i1 = pos.getZ(); - - if (worldIn.isAreaLoaded(new BlockPos(k - 2, l - 2, i1 - 2), new BlockPos(k + 2, l + 2, i1 + 2))) - { - for (int j1 = -1; j1 <= 1; ++j1) - { - for (int k1 = -1; k1 <= 1; ++k1) - { - for (int l1 = -1; l1 <= 1; ++l1) - { - BlockPos blockpos = pos.add(j1, k1, l1); - IBlockState iblockstate = worldIn.getBlockState(blockpos); - - if (iblockstate.getBlock().isLeaves(iblockstate, worldIn, blockpos)) - { - iblockstate.getBlock().beginLeavesDecay(iblockstate, worldIn, blockpos); - } - } - } - } - } - } - - @Override - public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) - { - if (!worldIn.isRemote) - { - if (state.getValue(CHECK_DECAY).booleanValue() && state.getValue(DECAYABLE).booleanValue()) - { - int k = pos.getX(); - int l = pos.getY(); - int i1 = pos.getZ(); - - if (this.surroundings == null) - { - this.surroundings = new int[32768]; - } - - if (worldIn.isAreaLoaded(new BlockPos(k - 5, l - 5, i1 - 5), new BlockPos(k + 5, l + 5, i1 + 5))) - { - BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); - - for (int i2 = -4; i2 <= 4; ++i2) - { - for (int j2 = -4; j2 <= 4; ++j2) - { - for (int k2 = -4; k2 <= 4; ++k2) - { - IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos.setPos(k + i2, l + j2, i1 + k2)); - Block block = iblockstate.getBlock(); - - if (!block.canSustainLeaves(iblockstate, worldIn, blockpos$mutableblockpos.setPos(k + i2, l + j2, i1 + k2))) - { - if (block.isLeaves(iblockstate, worldIn, blockpos$mutableblockpos.setPos(k + i2, l + j2, i1 + k2))) - { - this.surroundings[(i2 + 16) * 1024 + (j2 + 16) * 32 + k2 + 16] = -2; - } - else - { - this.surroundings[(i2 + 16) * 1024 + (j2 + 16) * 32 + k2 + 16] = -1; - } - } - else - { - this.surroundings[(i2 + 16) * 1024 + (j2 + 16) * 32 + k2 + 16] = 0; - } - } - } - } - - for (int i3 = 1; i3 <= 4; ++i3) - { - for (int j3 = -4; j3 <= 4; ++j3) - { - for (int k3 = -4; k3 <= 4; ++k3) - { - for (int l3 = -4; l3 <= 4; ++l3) - { - if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + l3 + 16] == i3 - 1) - { - if (this.surroundings[(j3 + 16 - 1) * 1024 + (k3 + 16) * 32 + l3 + 16] == -2) - { - this.surroundings[(j3 + 16 - 1) * 1024 + (k3 + 16) * 32 + l3 + 16] = i3; - } - - if (this.surroundings[(j3 + 16 + 1) * 1024 + (k3 + 16) * 32 + l3 + 16] == -2) - { - this.surroundings[(j3 + 16 + 1) * 1024 + (k3 + 16) * 32 + l3 + 16] = i3; - } - - if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16 - 1) * 32 + l3 + 16] == -2) - { - this.surroundings[(j3 + 16) * 1024 + (k3 + 16 - 1) * 32 + l3 + 16] = i3; - } - - if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16 + 1) * 32 + l3 + 16] == -2) - { - this.surroundings[(j3 + 16) * 1024 + (k3 + 16 + 1) * 32 + l3 + 16] = i3; - } - - if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + (l3 + 16 - 1)] == -2) - { - this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + (l3 + 16 - 1)] = i3; - } - - if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + l3 + 16 + 1] == -2) - { - this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + l3 + 16 + 1] = i3; - } - } - } - } - } - } - } - - int l2 = this.surroundings[16912]; - - if (l2 >= 0) - { - worldIn.setBlockState(pos, state.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4); - } - else - { - this.destroy(worldIn, pos); - } - } - } - } - - private void destroy(World worldIn, BlockPos pos) - { - this.dropBlockAsItem(worldIn, pos, worldIn.getBlockState(pos), 0); - worldIn.setBlockToAir(pos); - } - - @SuppressWarnings("deprecation") - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand) - { - if (worldIn.isRainingAt(pos.up()) && !worldIn.getBlockState(pos.down()).isTopSolid() && rand.nextInt(15) == 1) - { - double d0 = pos.getX() + rand.nextFloat(); - double d1 = pos.getY() - 0.05D; - double d2 = pos.getZ() + rand.nextFloat(); - worldIn.spawnParticle(EnumParticleTypes.DRIP_WATER, d0, d1, d2, 0.0D, 0.0D, 0.0D); - } - } - - /** - * Returns the quantity of items to drop on block destruction. - */ - @Override - public int quantityDropped(Random random) - { - return random.nextInt(20) == 0 ? 1 : 0; + super(); } - /** - * Get the Item that this Block should drop when harvested. - */ @Override - public Item getItemDropped(IBlockState state, Random rand, int fortune) + public EnumType getWoodType(int meta) { - return Item.getItemFromBlock(Blocks.SAPLING); + throw new UnsupportedOperationException(); } - /** - * Spawns this Block's drops into the World as EntityItems. - */ - @Override - public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune) - { - super.dropBlockAsItemWithChance(worldIn, pos, state, chance, fortune); - } - - protected void dropApple(World worldIn, BlockPos pos, IBlockState state, int chance) - { - } - - protected int getSaplingDropChance(IBlockState state) - { - return 20; - } - - @Override - public boolean causesSuffocation(IBlockState state) - { - return false; - } - - @Override - public boolean isShearable(ItemStack item, IBlockAccess world, BlockPos pos) - { - return true; - } - - @Override - public boolean isLeaves(IBlockState state, IBlockAccess world, BlockPos pos) - { - return true; - } - - @Override - public void beginLeavesDecay(IBlockState state, World world, BlockPos pos) - { - if (!(Boolean) state.getValue(CHECK_DECAY)) - { - world.setBlockState(pos, state.withProperty(CHECK_DECAY, true), 4); - } - } - - @Override - public void getDrops(net.minecraft.util.NonNullList drops, IBlockAccess world, BlockPos pos, IBlockState state, int fortune) - { - 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()) - drops.add(drop); - } - - chance = 200; - if (fortune > 0) - { - chance -= 10 << fortune; - if (chance < 40) - chance = 40; - } - - this.captureDrops(true); - if (world instanceof World) - this.dropApple((World) world, pos, state, chance); // Dammet mojang - drops.addAll(this.captureDrops(false)); - } - - @SuppressWarnings("deprecation") - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) - { - return super.shouldSideBeRendered(blockState, blockAccess, pos, side); - } } diff --git a/src/main/java/com/progwml6/natura/nether/NetherClientProxy.java b/src/main/java/com/progwml6/natura/nether/NetherClientProxy.java index a2e68fad..e4046e34 100644 --- a/src/main/java/com/progwml6/natura/nether/NetherClientProxy.java +++ b/src/main/java/com/progwml6/natura/nether/NetherClientProxy.java @@ -7,7 +7,6 @@ import com.progwml6.natura.common.ClientProxy; import com.progwml6.natura.common.block.BlockEnumBerryBush; -import com.progwml6.natura.common.block.base.BlockLeavesBase; import com.progwml6.natura.common.client.LeavesColorizer; import com.progwml6.natura.library.Util; import com.progwml6.natura.library.client.state.CustomStateMap; @@ -22,6 +21,7 @@ import net.minecraft.block.BlockDoor; import net.minecraft.block.BlockHopper; +import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -89,8 +89,8 @@ public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) protected void registerModels() { // blocks - ModelLoader.setCustomStateMapper(NaturaNether.netherLeaves, (new StateMap.Builder()).ignore(BlockLeavesBase.CHECK_DECAY, BlockLeavesBase.DECAYABLE).build()); - ModelLoader.setCustomStateMapper(NaturaNether.netherLeaves2, (new StateMap.Builder()).ignore(BlockLeavesBase.CHECK_DECAY, BlockLeavesBase.DECAYABLE).build()); + ModelLoader.setCustomStateMapper(NaturaNether.netherLeaves, (new StateMap.Builder()).ignore(BlockLeaves.CHECK_DECAY, BlockLeaves.DECAYABLE).build()); + ModelLoader.setCustomStateMapper(NaturaNether.netherLeaves2, (new StateMap.Builder()).ignore(BlockLeaves.CHECK_DECAY, BlockLeaves.DECAYABLE).build()); ModelLoader.setCustomStateMapper(NaturaNether.netherSapling, (new StateMap.Builder()).ignore(BlockNetherSapling.STAGE, BlockSapling.TYPE).build()); ModelLoader.setCustomStateMapper(NaturaNether.netherSapling2, (new StateMap.Builder()).ignore(BlockNetherSapling2.STAGE, BlockSapling.TYPE).build()); diff --git a/src/main/java/com/progwml6/natura/overworld/OverworldClientProxy.java b/src/main/java/com/progwml6/natura/overworld/OverworldClientProxy.java index 9df569b2..c2aea54e 100644 --- a/src/main/java/com/progwml6/natura/overworld/OverworldClientProxy.java +++ b/src/main/java/com/progwml6/natura/overworld/OverworldClientProxy.java @@ -8,7 +8,6 @@ import com.progwml6.natura.common.ClientProxy; import com.progwml6.natura.common.block.BlockEnumBerryBush; import com.progwml6.natura.common.block.BlockGrassStairs; -import com.progwml6.natura.common.block.base.BlockLeavesBase; import com.progwml6.natura.common.client.GrassColorizer; import com.progwml6.natura.common.client.LeavesColorizer; import com.progwml6.natura.overworld.block.crops.BlockNaturaBarley; @@ -23,6 +22,7 @@ import com.progwml6.natura.overworld.block.saplings.BlockRedwoodSapling; import net.minecraft.block.BlockDoor; +import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockSapling; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; @@ -155,9 +155,9 @@ public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) protected void registerModels() { // blocks - ModelLoader.setCustomStateMapper(NaturaOverworld.overworldLeaves, (new StateMap.Builder()).ignore(BlockLeavesBase.CHECK_DECAY, BlockLeavesBase.DECAYABLE).build()); - ModelLoader.setCustomStateMapper(NaturaOverworld.overworldLeaves2, (new StateMap.Builder()).ignore(BlockLeavesBase.CHECK_DECAY, BlockLeavesBase.DECAYABLE).build()); - ModelLoader.setCustomStateMapper(NaturaOverworld.redwoodLeaves, (new StateMap.Builder()).ignore(BlockLeavesBase.CHECK_DECAY, BlockLeavesBase.DECAYABLE).build()); + ModelLoader.setCustomStateMapper(NaturaOverworld.overworldLeaves, (new StateMap.Builder()).ignore(BlockLeaves.CHECK_DECAY, BlockLeaves.DECAYABLE).build()); + ModelLoader.setCustomStateMapper(NaturaOverworld.overworldLeaves2, (new StateMap.Builder()).ignore(BlockLeaves.CHECK_DECAY, BlockLeaves.DECAYABLE).build()); + ModelLoader.setCustomStateMapper(NaturaOverworld.redwoodLeaves, (new StateMap.Builder()).ignore(BlockLeaves.CHECK_DECAY, BlockLeaves.DECAYABLE).build()); ModelLoader.setCustomStateMapper(NaturaOverworld.overworldSapling, (new StateMap.Builder()).ignore(BlockOverworldSapling.STAGE, BlockSapling.TYPE).build()); ModelLoader.setCustomStateMapper(NaturaOverworld.overworldSapling2, (new StateMap.Builder()).ignore(BlockOverworldSapling2.STAGE, BlockSapling.TYPE).build());