Use CraftEventFactory for BlockFormEvent

This commit is contained in:
md_5
2016-12-09 12:45:21 +11:00
parent 521b64741e
commit caf86c88a9
4 changed files with 45 additions and 65 deletions

View File

@@ -21,22 +21,12 @@
}
if (!this.world.getGameRules().getBoolean("mobGriefing")) {
@@ -73,7 +78,17 @@
@@ -73,7 +78,7 @@
BlockPosition blockposition = new BlockPosition(i, j, k);
if (this.world.getType(blockposition).getMaterial() == Material.AIR && this.world.getBiome(blockposition).a(blockposition) < 0.8F && Blocks.SNOW_LAYER.canPlace(this.world, blockposition)) {
- this.world.setTypeUpdate(blockposition, Blocks.SNOW_LAYER.getBlockData());
+ // CraftBukkit start
+ org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.SNOW_LAYER));
+
+ EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if(!event.isCancelled()) {
+ blockState.update(true);
+ }
+ // CraftBukkit end
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, Blocks.SNOW_LAYER, this); // CraftBukkit
}
}
}