Files
CatServer/patches/net/minecraft/block/BlockMushroom.java.patch
2019-02-24 22:29:41 +08:00

64 lines
2.6 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockMushroom.java
+++ ../src-work/minecraft/net/minecraft/block/BlockMushroom.java
@@ -9,6 +9,9 @@
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import net.minecraft.world.gen.feature.WorldGenerator;
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
+import org.bukkit.event.block.BlockSpreadEvent;
public class BlockMushroom extends BlockBush implements IGrowable
{
@@ -26,7 +29,8 @@
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
- if (rand.nextInt(25) == 0)
+ final int sourceX = pos.getX(), sourceY = pos.getY(), sourceZ = pos.getZ();
+ if (rand.nextInt(Math.max(1, (int) (100.0F / worldIn.spigotConfig.mushroomModifier) * 25)) == 0) // Spigot
{
int i = 5;
int j = 4;
@@ -58,7 +62,17 @@
if (worldIn.isAirBlock(blockpos1) && this.canBlockStay(worldIn, blockpos1, this.getDefaultState()))
{
- worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
+// worldIn.setBlockState(blockpos1, this.getDefaultState(), 2);
+ org.bukkit.World bworld = worldIn.getWorld();
+ BlockState blockState = bworld.getBlockAt(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ()).getState();
+ blockState.setType(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(this)); // nms: this.id, 0, 2
+
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(sourceX, sourceY, sourceZ), blockState);
+ worldIn.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ blockState.update(true);
+ }
}
}
}
@@ -89,7 +103,7 @@
}
else
{
- return worldIn.getLight(pos) < 13 && this.canSustainBush(iblockstate);
+ return worldIn.getLight(pos) < 13 && iblockstate.getBlock().canSustainPlant(iblockstate, worldIn, pos.down(), net.minecraft.util.EnumFacing.UP, this);
}
}
else
@@ -105,10 +119,12 @@
if (this == Blocks.BROWN_MUSHROOM)
{
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM;
worldgenerator = new WorldGenBigMushroom(Blocks.BROWN_MUSHROOM_BLOCK);
}
else if (this == Blocks.RED_MUSHROOM)
{
+ BlockSapling.treeType = TreeType.RED_MUSHROOM;
worldgenerator = new WorldGenBigMushroom(Blocks.RED_MUSHROOM_BLOCK);
}