Files
CatServer/patches/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java.patch
2019-02-24 22:29:41 +08:00

61 lines
2.7 KiB
Diff

--- ../src-base/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java
+++ ../src-work/minecraft/net/minecraft/world/gen/feature/WorldGenMegaPineTree.java
@@ -41,32 +41,25 @@
for (int j = 0; j < i; ++j)
{
- IBlockState iblockstate = worldIn.getBlockState(position.up(j));
-
- if (iblockstate.getMaterial() == Material.AIR || iblockstate.getMaterial() == Material.LEAVES)
+ if (isAirLeaves(worldIn, position.up(j)))
{
this.setBlockAndNotifyAdequately(worldIn, position.up(j), this.woodMetadata);
}
if (j < i - 1)
{
- iblockstate = worldIn.getBlockState(position.add(1, j, 0));
-
- if (iblockstate.getMaterial() == Material.AIR || iblockstate.getMaterial() == Material.LEAVES)
+ if (isAirLeaves(worldIn, position.add(1, j, 0)))
{
this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 0), this.woodMetadata);
}
- iblockstate = worldIn.getBlockState(position.add(1, j, 1));
-
- if (iblockstate.getMaterial() == Material.AIR || iblockstate.getMaterial() == Material.LEAVES)
+ if (isAirLeaves(worldIn, position.add(1, j, 1)))
{
this.setBlockAndNotifyAdequately(worldIn, position.add(1, j, 1), this.woodMetadata);
}
- iblockstate = worldIn.getBlockState(position.add(0, j, 1));
- if (iblockstate.getMaterial() == Material.AIR || iblockstate.getMaterial() == Material.LEAVES)
+ if (isAirLeaves(worldIn, position.add(0, j, 1)))
{
this.setBlockAndNotifyAdequately(worldIn, position.add(0, j, 1), this.woodMetadata);
}
@@ -133,7 +126,7 @@
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Block block = iblockstate.getBlock();
- if (block == Blocks.GRASS || block == Blocks.DIRT)
+ if (block.canSustainPlant(iblockstate, worldIn, blockpos, net.minecraft.util.EnumFacing.UP, ((net.minecraft.block.BlockSapling)Blocks.SAPLING)))
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, PODZOL);
break;
@@ -145,4 +138,11 @@
}
}
}
+
+ //Helper macro
+ private boolean isAirLeaves(World world, BlockPos pos)
+ {
+ IBlockState state = world.getBlockState(pos);
+ return state.getBlock().isAir(state, world, pos) || state.getBlock().isLeaves(state, world, pos);
+ }
}