diff options
Diffstat (limited to 'src/main/java/net')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityCreeper.java | 13 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/EntityPig.java | 95 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 40 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/WorldServer.java | 12 |
4 files changed, 151 insertions, 9 deletions
diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index e7c2bfe2..d42c4599 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -4,6 +4,7 @@ package net.minecraft.server; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.CreeperPowerEvent; // CraftBukkit end public class EntityCreeper extends EntityMonster { @@ -125,6 +126,16 @@ public class EntityCreeper extends EntityMonster { public void a(EntityWeatherStorm entityweatherstorm) { super.a(entityweatherstorm); - this.datawatcher.b(17, Byte.valueOf((byte) 1)); + // CraftBukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + org.bukkit.entity.Entity entity = this.getBukkitEntity(); + + CreeperPowerEvent event = new CreeperPowerEvent(entity, entityweatherstorm.getBukkitEntity(), CreeperPowerEvent.PowerCause.LIGHTNING); + server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.datawatcher.b(17, Byte.valueOf((byte) 1)); + } + // CraftBukkit end } } diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java new file mode 100644 index 00000000..54d93869 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -0,0 +1,95 @@ +package net.minecraft.server; + +//CraftBukkit start +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.event.entity.EntityCombustEvent; +import org.bukkit.event.entity.PigZapEvent; +// CraftBukkit end + +public class EntityPig extends EntityAnimal { + + public EntityPig(World world) { + super(world); + this.texture = "/mob/pig.png"; + this.b(0.9F, 0.9F); + } + + protected void b() { + this.datawatcher.a(16, Byte.valueOf((byte) 0)); + } + + public void b(NBTTagCompound nbttagcompound) { + super.b(nbttagcompound); + nbttagcompound.a("Saddle", this.x()); + } + + public void a(NBTTagCompound nbttagcompound) { + super.a(nbttagcompound); + this.a(nbttagcompound.m("Saddle")); + } + + protected String g() { + return "mob.pig"; + } + + protected String h() { + return "mob.pig"; + } + + protected String i() { + return "mob.pigdeath"; + } + + public boolean a(EntityHuman entityhuman) { + if (this.x() && !this.world.isStatic + && (this.passenger == null || this.passenger == entityhuman)) { + entityhuman.mount(this); + return true; + } else { + return false; + } + } + + protected int j() { + return this.fireTicks > 0 ? Item.GRILLED_PORK.id : Item.PORK.id; + } + + public boolean x() { + return (this.datawatcher.a(16) & 1) != 0; + } + + public void a(boolean flag) { + if (flag) { + this.datawatcher.b(16, Byte.valueOf((byte) 1)); + } else { + this.datawatcher.b(16, Byte.valueOf((byte) 0)); + } + } + + public void a(EntityWeatherStorm entityweatherstorm) { + EntityPigZombie entitypigzombie = new EntityPigZombie(this.world); + entitypigzombie.setPositionRotation(this.locX, this.locY, this.locZ, + this.yaw, this.pitch); + + // CraftBukkit start + CraftServer server = ((WorldServer) this.world).getServer(); + org.bukkit.entity.Entity entity = this.getBukkitEntity(); + + PigZapEvent event = new PigZapEvent(entity, entityweatherstorm.getBukkitEntity(), entitypigzombie.getBukkitEntity()); + server.getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + this.world.addEntity(entitypigzombie); + this.die(); + } + // CraftBukkit end + } + + protected void a(float f) { + super.a(f); + if (f > 5.0F && this.passenger instanceof EntityHuman) { + ((EntityHuman) this.passenger).a((Statistic) AchievementList.u); + } + } +} diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index 598d5c2e..b5327cae 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -9,11 +9,14 @@ import java.util.Set; import java.util.TreeSet; // CraftBukkit start +import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.event.block.BlockPhysicsEvent; import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.weather.WeatherChangeEvent; +import org.bukkit.event.weather.ThunderChangeEvent; // CraftBukkit end public class World implements IBlockAccess { @@ -1490,7 +1493,13 @@ public class World implements IBlockAccess { --i; this.worldData.b(i); if (i <= 0) { - this.worldData.a(!this.worldData.j()); + CraftServer server = ((WorldServer) this).getServer(); + + ThunderChangeEvent thunder = new ThunderChangeEvent(((WorldServer) this).getWorld(), !this.worldData.j()); + server.getPluginManager().callEvent(thunder); + if (!thunder.isCancelled()) { + this.worldData.a(!this.worldData.j()); + } } } @@ -1506,7 +1515,13 @@ public class World implements IBlockAccess { --j; this.worldData.c(j); if (j <= 0) { - this.worldData.b(!this.worldData.l()); + CraftServer server = ((WorldServer) this).getServer(); + + WeatherChangeEvent weather = new WeatherChangeEvent(((WorldServer) this).getWorld(), !this.worldData.l()); + server.getPluginManager().callEvent(weather); + if (!weather.isCancelled()) { + this.worldData.b(!this.worldData.l()); + } } } @@ -1543,10 +1558,23 @@ public class World implements IBlockAccess { } private void y() { - this.worldData.c(0); - this.worldData.b(false); - this.worldData.b(0); - this.worldData.a(false); + // CraftBukkit start + CraftServer server = ((WorldServer) this).getServer(); + + WeatherChangeEvent weather = new WeatherChangeEvent((org.bukkit.World) this, false); + server.getPluginManager().callEvent(weather); + + ThunderChangeEvent thunder = new ThunderChangeEvent((org.bukkit.World) this, false); + server.getPluginManager().callEvent(thunder); + if (!weather.isCancelled()) { + this.worldData.c(0); + this.worldData.b(false); + } + if (!thunder.isCancelled()) { + this.worldData.b(0); + this.worldData.a(false); + } + //CraftBukkit end } protected void j() { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 553108c5..e0c73c28 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.BlockChangeDelegate; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftWorld; +import org.bukkit.event.weather.LightningStrikeEvent; public class WorldServer extends World implements BlockChangeDelegate { // CraftBukkit end @@ -105,8 +106,15 @@ public class WorldServer extends World implements BlockChangeDelegate { public boolean a(Entity entity) { if (super.a(entity)) { - this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity)); - return true; + CraftServer server = cserver; + + LightningStrikeEvent lightning = new LightningStrikeEvent((org.bukkit.World) world, entity.getBukkitEntity()); + server.getPluginManager().callEvent(lightning); + if (!lightning.isCancelled()) { + this.server.serverConfigurationManager.a(entity.locX, entity.locY, entity.locZ, 512.0D, new Packet71Weather(entity)); + return true; + } + return false; } else { return false; } |