SPIGOT-7248: Bone mealing grass triggers piston block update detector

This commit is contained in:
md_5 2023-01-31 19:44:37 +11:00
parent 7cd3244d3d
commit 39462a8985
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11

View File

@ -123,16 +123,16 @@
+ Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()); + Location location = new Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
+ TreeType treeType = BlockSapling.treeType; + TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null; + BlockSapling.treeType = null;
+ List<BlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); + List<CraftBlockState> blocks = new java.util.ArrayList<>(world.capturedBlockStates.values());
+ world.capturedBlockStates.clear(); + world.capturedBlockStates.clear();
+ StructureGrowEvent structureEvent = null; + StructureGrowEvent structureEvent = null;
+ if (treeType != null) { + if (treeType != null) {
+ boolean isBonemeal = getItem() == Items.BONE_MEAL; + boolean isBonemeal = getItem() == Items.BONE_MEAL;
+ structureEvent = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), blocks); + structureEvent = new StructureGrowEvent(location, treeType, isBonemeal, (Player) entityhuman.getBukkitEntity(), (List< BlockState>) (List<? extends BlockState>) blocks);
+ org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); + org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent);
+ } + }
+ +
+ BlockFertilizeEvent fertilizeEvent = new BlockFertilizeEvent(CraftBlock.at(world, blockposition), (Player) entityhuman.getBukkitEntity(), blocks); + BlockFertilizeEvent fertilizeEvent = new BlockFertilizeEvent(CraftBlock.at(world, blockposition), (Player) entityhuman.getBukkitEntity(), (List< BlockState>) (List<? extends BlockState>) blocks);
+ fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled()); + fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled());
+ org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); + org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent);
+ +
@ -142,8 +142,8 @@
+ this.setTag(newData); + this.setTag(newData);
+ this.setCount(newCount); + this.setCount(newCount);
+ } + }
+ for (BlockState blockstate : blocks) { + for (CraftBlockState blockstate : blocks) {
+ blockstate.update(true); + world.setBlock(blockstate.getPosition(),blockstate.getHandle(), blockstate.getFlag()); // SPIGOT-7248 - manual update to avoid physics where appropriate
+ } + }
+ entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); // SPIGOT-7236 - award stat + entityhuman.awardStat(StatisticList.ITEM_USED.get(item)); // SPIGOT-7236 - award stat
+ } + }