diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedLeaves.java b/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedLeaves.java index a63ec2964..82d85d28f 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedLeaves.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedLeaves.java @@ -304,7 +304,10 @@ public class BlockBOPColorizedLeaves extends BlockLeavesBase implements IShearab private static int getTypeFromMeta(int meta) { - return meta & 7; + meta = meta & 7; + if (meta < 0 || meta >= leaves.length) + meta = 0; + return meta; } @SideOnly(Side.CLIENT) diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedSapling.java b/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedSapling.java index 3f54bcef6..93c66fd4f 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedSapling.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPColorizedSapling.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.ForgeDirection; import biomesoplenty.BiomesOPlenty; import biomesoplenty.worldgen.WorldGenAcacia; import biomesoplenty.worldgen.WorldGenMangrove; @@ -91,6 +92,18 @@ public class BlockBOPColorizedSapling extends BlockSapling return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID; } + @Override + public boolean canBlockStay(World par1World, int par2, int par3, int par4) + { + Block soil = blocksList[par1World.getBlockId(par2, par3 - 1, par4)]; + if (par1World.getBlockMetadata(par2, par3, par4) != 1) + return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && + (soil != null && soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this)); + else + return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && + (soil != null && (soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this) || soil.blockID == Block.sand.blockID)); + } + @Override public void updateTick(World world, int x, int y, int z, Random random) { diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPLeaves.java b/src/minecraft/biomesoplenty/blocks/BlockBOPLeaves.java index 7694c1fa3..a6c984e24 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPLeaves.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPLeaves.java @@ -303,7 +303,10 @@ public class BlockBOPLeaves extends BlockLeavesBase implements IShearable private static int getTypeFromMeta(int meta) { - return meta & 7; + meta = meta & 7; + if (meta < 0 || meta >= leaves.length) + meta = 0; + return meta; } @SideOnly(Side.CLIENT) diff --git a/src/minecraft/biomesoplenty/blocks/BlockBOPSapling.java b/src/minecraft/biomesoplenty/blocks/BlockBOPSapling.java index e3e70c092..a1616c1f7 100644 --- a/src/minecraft/biomesoplenty/blocks/BlockBOPSapling.java +++ b/src/minecraft/biomesoplenty/blocks/BlockBOPSapling.java @@ -11,6 +11,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; +import net.minecraftforge.common.ForgeDirection; import biomesoplenty.BiomesOPlenty; import biomesoplenty.api.Blocks; import biomesoplenty.worldgen.WorldGenApple; @@ -98,6 +99,18 @@ public class BlockBOPSapling extends BlockSapling return blockID == Block.grass.blockID || blockID == Block.dirt.blockID || blockID == Block.tilledField.blockID; } + @Override + public boolean canBlockStay(World par1World, int par2, int par3, int par4) + { + Block soil = blocksList[par1World.getBlockId(par2, par3 - 1, par4)]; + if (par1World.getBlockMetadata(par2, par3, par4) != 7) + return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && + (soil != null && soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this)); + else + return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && + (soil != null && (soil.canSustainPlant(par1World, par2, par3 - 1, par4, ForgeDirection.UP, this) || soil.blockID == Blocks.holyGrass.get().blockID)); + } + @Override public void updateTick(World world, int x, int y, int z, Random random) {