Archiviert
13
0

Trigger EntityBlockChangeEvent for Silverfish. Adds BUKKIT-1560 and BUKKIT-1593

Dieser Commit ist enthalten in:
feildmaster 2012-04-28 12:26:07 -05:00
Ursprung 23d5922bbf
Commit 568fae2e86
2 geänderte Dateien mit 19 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -1,5 +1,7 @@
package net.minecraft.server; package net.minecraft.server;
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
public class EntitySilverfish extends EntityMonster { public class EntitySilverfish extends EntityMonster {
private int a; private int a;
@ -96,6 +98,11 @@ public class EntitySilverfish extends EntityMonster {
int k1 = this.world.getTypeId(i + i1, j + l, k + j1); int k1 = this.world.getTypeId(i + i1, j + l, k + j1);
if (k1 == Block.MONSTER_EGGS.id) { if (k1 == Block.MONSTER_EGGS.id) {
// CraftBukkit start
if (CraftEventFactory.callEntityChangeBlockEvent(this, i + i1, j + l, k + j1, 0).isCancelled()) {
continue;
}
// CraftBukkit end
this.world.triggerEffect(2001, i + i1, j + l, k + j1, Block.MONSTER_EGGS.id + (this.world.getData(i + i1, j + l, k + j1) << 12)); this.world.triggerEffect(2001, i + i1, j + l, k + j1, Block.MONSTER_EGGS.id + (this.world.getData(i + i1, j + l, k + j1) << 12));
this.world.setTypeId(i + i1, j + l, k + j1, 0); this.world.setTypeId(i + i1, j + l, k + j1, 0);
Block.MONSTER_EGGS.postBreak(this.world, i + i1, j + l, k + j1, 0); Block.MONSTER_EGGS.postBreak(this.world, i + i1, j + l, k + j1, 0);
@ -118,6 +125,11 @@ public class EntitySilverfish extends EntityMonster {
l = this.world.getTypeId(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1]); l = this.world.getTypeId(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1]);
if (BlockMonsterEggs.d(l)) { if (BlockMonsterEggs.d(l)) {
// CraftBukkit start
if (CraftEventFactory.callEntityChangeBlockEvent(this, i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id).isCancelled()) {
return;
}
// CraftBukkit end
this.world.setTypeIdAndData(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.e(l)); this.world.setTypeIdAndData(i + Facing.b[l1], j + Facing.c[l1], k + Facing.d[l1], Block.MONSTER_EGGS.id, BlockMonsterEggs.e(l));
this.aC(); this.aC();
this.die(); this.die();

Datei anzeigen

@ -441,6 +441,13 @@ public class CraftEventFactory {
return event; return event;
} }
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, int x, int y, int z, int type) {
Block block = entity.world.getWorld().getBlockAt(x, y, z);
Material material = Material.getMaterial(type);
return callEntityChangeBlockEvent(entity, block, material);
}
public static CreeperPowerEvent callCreeperPowerEvent(Entity creeper, Entity lightning, CreeperPowerEvent.PowerCause cause) { public static CreeperPowerEvent callCreeperPowerEvent(Entity creeper, Entity lightning, CreeperPowerEvent.PowerCause cause) {
CreeperPowerEvent event = new CreeperPowerEvent((Creeper) creeper.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), cause); CreeperPowerEvent event = new CreeperPowerEvent((Creeper) creeper.getBukkitEntity(), (LightningStrike) lightning.getBukkitEntity(), cause);
creeper.getBukkitEntity().getServer().getPluginManager().callEvent(event); creeper.getBukkitEntity().getServer().getPluginManager().callEvent(event);