From 1a6a828156ceea6ac404006851790cf6af18fb95 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Fri, 30 Nov 2012 11:53:31 -0600 Subject: Add data values to EntityChangeBlockEvent. Adds BUKKIT-3077, BUKKIT-3076 This change affects Endermen and Silverfish, adding a data value for the block change event. --- .../java/net/minecraft/server/EntityEnderman.java | 4 +--- .../net/minecraft/server/EntitySilverfish.java | 4 ++-- .../craftbukkit/event/CraftEventFactory.java | 24 ++++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityEnderman.java b/src/main/java/net/minecraft/server/EntityEnderman.java index db88142f..eb331932 100644 --- a/src/main/java/net/minecraft/server/EntityEnderman.java +++ b/src/main/java/net/minecraft/server/EntityEnderman.java @@ -120,9 +120,7 @@ public class EntityEnderman extends EntityMonster { if (l == 0 && i1 > 0 && Block.byId[i1].b()) { // CraftBukkit start - place event - org.bukkit.block.Block bblock = this.world.getWorld().getBlockAt(i, j, k); - - if (!CraftEventFactory.callEntityChangeBlockEvent(this, bblock, this.getCarriedId()).isCancelled()) { + if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.getCarriedId(), this.getCarriedData()).isCancelled()) { this.world.setTypeIdAndData(i, j, k, this.getCarriedId(), this.getCarriedData()); this.setCarriedId(0); } diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java index 1dab71b6..5ccb3ab6 100644 --- a/src/main/java/net/minecraft/server/EntitySilverfish.java +++ b/src/main/java/net/minecraft/server/EntitySilverfish.java @@ -94,7 +94,7 @@ public class EntitySilverfish extends EntityMonster { if (k1 == Block.MONSTER_EGGS.id) { // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, i + i1, j + l, k + j1, 0).isCancelled()) { + if (CraftEventFactory.callEntityChangeBlockEvent(this, i + i1, j + l, k + j1, 0, 0).isCancelled()) { continue; } // CraftBukkit end @@ -122,7 +122,7 @@ public class EntitySilverfish extends EntityMonster { l = this.world.getTypeId(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1]); if (BlockMonsterEggs.e(l)) { // CraftBukkit start - if (CraftEventFactory.callEntityChangeBlockEvent(this, i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id).isCancelled()) { + if (CraftEventFactory.callEntityChangeBlockEvent(this, i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.f(l)).isCancelled()) { return; } // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 73945848..a840111f 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -441,29 +441,31 @@ public class CraftEventFactory { return event; } - public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material) { - EntityChangeBlockEvent event = new EntityChangeBlockEvent((LivingEntity) entity, block, material); - entity.getServer().getPluginManager().callEvent(event); - return event; - } - public static PigZapEvent callPigZapEvent(Entity pig, Entity lightning, Entity pigzombie) { PigZapEvent event = new PigZapEvent((Pig) pig.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), (PigZombie) pigzombie.getBukkitEntity()); pig.getBukkitEntity().getServer().getPluginManager().callEvent(event); return event; } + public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material) { + return callEntityChangeBlockEvent(entity, block, material, 0); + } + public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, Block block, Material material) { - EntityChangeBlockEvent event = new EntityChangeBlockEvent((LivingEntity) entity.getBukkitEntity(), block, material); - entity.getBukkitEntity().getServer().getPluginManager().callEvent(event); - return event; + return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, 0); } - public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, int x, int y, int z, int type) { + public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, int x, int y, int z, int type, int data) { Block block = entity.world.getWorld().getBlockAt(x, y, z); Material material = Material.getMaterial(type); - return callEntityChangeBlockEvent(entity, block, material); + return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, data); + } + + public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material, int data) { + EntityChangeBlockEvent event = new EntityChangeBlockEvent((LivingEntity) entity, block, material, (byte) data); + entity.getServer().getPluginManager().callEvent(event); + return event; } public static CreeperPowerEvent callCreeperPowerEvent(Entity creeper, Entity lightning, CreeperPowerEvent.PowerCause cause) { -- cgit v1.2.3