Files
2019-02-24 22:29:41 +08:00

81 lines
4.1 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockBush.java
+++ ../src-work/minecraft/net/minecraft/block/BlockBush.java
@@ -17,7 +17,7 @@
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-public class BlockBush extends Block
+public class BlockBush extends Block implements net.minecraftforge.common.IPlantable
{
protected static final AxisAlignedBB BUSH_AABB = new AxisAlignedBB(0.30000001192092896D, 0.0D, 0.30000001192092896D, 0.699999988079071D, 0.6000000238418579D, 0.699999988079071D);
@@ -40,7 +40,8 @@
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
- return super.canPlaceBlockAt(worldIn, pos) && this.canSustainBush(worldIn.getBlockState(pos.down()));
+ IBlockState soil = worldIn.getBlockState(pos.down());
+ return super.canPlaceBlockAt(worldIn, pos) && soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), EnumFacing.UP, this);
}
protected boolean canSustainBush(IBlockState state)
@@ -63,6 +64,9 @@
{
if (!this.canBlockStay(worldIn, pos, state))
{
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(worldIn, pos).isCancelled()) {
+ return;
+ }
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
}
@@ -70,6 +74,11 @@
public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
{
+ if (state.getBlock() == this) //Forge: This function is called during world gen and placement, before this block is set, so if we are not 'here' then assume it's the pre-check.
+ {
+ IBlockState soil = worldIn.getBlockState(pos.down());
+ return soil.getBlock().canSustainPlant(soil, worldIn, pos.down(), EnumFacing.UP, this);
+ }
return this.canSustainBush(worldIn.getBlockState(pos.down()));
}
@@ -94,6 +103,36 @@
return false;
}
+ @Override
+ public net.minecraftforge.common.EnumPlantType getPlantType(net.minecraft.world.IBlockAccess world, BlockPos pos)
+ {
+ if (this == Blocks.WHEAT) return net.minecraftforge.common.EnumPlantType.Crop;
+ if (this == Blocks.CARROTS) return net.minecraftforge.common.EnumPlantType.Crop;
+ if (this == Blocks.POTATOES) return net.minecraftforge.common.EnumPlantType.Crop;
+ if (this == Blocks.BEETROOTS) return net.minecraftforge.common.EnumPlantType.Crop;
+ if (this == Blocks.MELON_STEM) return net.minecraftforge.common.EnumPlantType.Crop;
+ if (this == Blocks.PUMPKIN_STEM) return net.minecraftforge.common.EnumPlantType.Crop;
+ if (this == Blocks.DEADBUSH) return net.minecraftforge.common.EnumPlantType.Desert;
+ if (this == Blocks.WATERLILY) return net.minecraftforge.common.EnumPlantType.Water;
+ if (this == Blocks.RED_MUSHROOM) return net.minecraftforge.common.EnumPlantType.Cave;
+ if (this == Blocks.BROWN_MUSHROOM) return net.minecraftforge.common.EnumPlantType.Cave;
+ if (this == Blocks.NETHER_WART) return net.minecraftforge.common.EnumPlantType.Nether;
+ if (this == Blocks.SAPLING) return net.minecraftforge.common.EnumPlantType.Plains;
+ if (this == Blocks.TALLGRASS) return net.minecraftforge.common.EnumPlantType.Plains;
+ if (this == Blocks.DOUBLE_PLANT) return net.minecraftforge.common.EnumPlantType.Plains;
+ if (this == Blocks.RED_FLOWER) return net.minecraftforge.common.EnumPlantType.Plains;
+ if (this == Blocks.YELLOW_FLOWER) return net.minecraftforge.common.EnumPlantType.Plains;
+ return net.minecraftforge.common.EnumPlantType.Plains;
+ }
+
+ @Override
+ public IBlockState getPlant(net.minecraft.world.IBlockAccess world, BlockPos pos)
+ {
+ IBlockState state = world.getBlockState(pos);
+ if (state.getBlock() != this) return getDefaultState();
+ return state;
+ }
+
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer()
{