From ddc30dd6e3da3fa4a5b27b40ba0d15854e6fb12e Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 18 Jan 2011 10:48:02 +1100 Subject: [PATCH 1/4] Fixing some entity damage events --- .../java/net/minecraft/server/EntityMobs.java | 8 ++++- .../net/minecraft/server/EntityPlayer.java | 9 +++-- .../java/net/minecraft/server/Explosion.java | 34 ++++++++++++------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/main/java/net/minecraft/server/EntityMobs.java b/src/main/java/net/minecraft/server/EntityMobs.java index 8b1da90eaf..e55b488289 100644 --- a/src/main/java/net/minecraft/server/EntityMobs.java +++ b/src/main/java/net/minecraft/server/EntityMobs.java @@ -8,9 +8,11 @@ import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftMinecart; import org.bukkit.craftbukkit.entity.CraftMonster; import org.bukkit.craftbukkit.CraftServer; + import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; //CraftBukkit end public class EntityMobs extends EntityCreature implements IMobs { @@ -73,8 +75,12 @@ public class EntityMobs extends EntityCreature implements IMobs { // CraftBukkit start if(entity instanceof EntityLiving) { CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.entity.Entity damager = this.getBukkitEntity(); + org.bukkit.entity.Entity damagee = entity.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK; + int damageDone = c; - EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, c); + EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone); server.getPluginManager().callEvent(edbee); if (!edbee.isCancelled()){ diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 39b6eef2e0..99a189143d 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -8,6 +8,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; // CraftBukkit end +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; public abstract class EntityPlayer extends EntityLiving { @@ -340,8 +341,12 @@ public abstract class EntityPlayer extends EntityLiving { // CraftBukkit start if(entity instanceof EntityLiving) { CraftServer server = ((WorldServer) l).getServer(); - - EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(entity.getBukkitEntity(), this.getBukkitEntity(), EntityDamageEvent.DamageCause.ENTITY_ATTACK, i); + org.bukkit.entity.Entity damager = this.getBukkitEntity(); + org.bukkit.entity.Entity damagee = entity.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK; + int damageDone = i; + + EntityDamageByEntityEvent edbee = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone); server.getPluginManager().callEvent(edbee); if (!edbee.isCancelled()){ diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java index d48e3bc31f..68879d8a19 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -8,9 +8,13 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; + import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.block.CraftBlock; + +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; + // CraftBukkit end import java.util.*; @@ -115,32 +119,36 @@ public class Explosion { double d14 = (1.0D - d11) * d13; // CraftBukkit start - explosion damage hook - int damage = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D); - CraftServer servr = ((WorldServer) i).getServer(); - CraftEntity damagee = null; - if (entity instanceof EntityPlayerMP) { - damagee = new CraftPlayer(servr, (EntityPlayerMP) entity); - } else if (entity instanceof EntityLiving) { - damagee = new CraftLivingEntity(servr, (EntityLiving) entity); + CraftServer server = ((WorldServer) i).getServer(); + org.bukkit.entity.Entity damagee = null; + DamageCause damageType; + int damageDone = (int) (((d14 * d14 + d14) / 2D) * 8D * (double) f + 1.0D); + + if(entity instanceof EntityLiving) { + damagee = entity.getBukkitEntity(); } if (e == null) { // Block explosion // Craftbukkit TODO: get the x/y/z of the tnt block? - EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, EntityDamageEvent.DamageCause.BLOCK_EXPLOSION, damage); - servr.getPluginManager().callEvent(edbbe); + damageType = EntityDamageEvent.DamageCause.BLOCK_EXPLOSION; + EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone); + server.getPluginManager().callEvent(edbbe); if (!edbbe.isCancelled()) { entity.a(e, edbbe.getDamage()); } } else { CraftEntity damager = null; + //TODO org.bukkit.entity.Entity damager = e.getBukkitEntity(); if (e instanceof EntityPlayerMP) { // not possible in normal operations - damager = new CraftPlayer(servr, (EntityPlayerMP) e); + damager = new CraftPlayer(server, (EntityPlayerMP) e); } else if (e instanceof EntityLiving) { - damager = new CraftLivingEntity(servr, (EntityLiving) e); + damager = new CraftLivingEntity(server, (EntityLiving) e); } - EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, EntityDamageEvent.DamageCause.ENTITY_EXPLOSION, damage); - servr.getPluginManager().callEvent(edbbe); + damageType = EntityDamageEvent.DamageCause.ENTITY_ATTACK; + + EntityDamageByEntityEvent edbbe = new EntityDamageByEntityEvent(damager, damagee, damageType, damageDone); + server.getPluginManager().callEvent(edbbe); if (!edbbe.isCancelled()) { entity.a(e, edbbe.getDamage()); From d7d7a68f911591ae5cf5a4a519f94235826bf427 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 18 Jan 2011 16:30:01 +1100 Subject: [PATCH 2/4] fixes to combust event so that it is raised only once on combustion. minor fixes to imports --- .../java/net/minecraft/server/Entity.java | 58 ++++++++++++++----- .../net/minecraft/server/EntityArrow.java | 3 - .../java/net/minecraft/server/EntityBoat.java | 1 - .../net/minecraft/server/EntityFireball.java | 4 -- .../net/minecraft/server/EntityGhast.java | 1 - .../java/net/minecraft/server/EntityItem.java | 1 - .../net/minecraft/server/EntityLiving.java | 1 - .../net/minecraft/server/EntityMinecart.java | 1 - 8 files changed, 44 insertions(+), 26 deletions(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index 9de175cb2c..a05206b01a 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1,14 +1,12 @@ package net.minecraft.server; -// CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.Event.Type; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; // CraftBukkit end import java.util.List; @@ -221,9 +219,12 @@ public abstract class Entity { if (Z % 20 == 0) { // CraftBukkit start if(this instanceof EntityLiving) { - CraftServer server = ((WorldServer)l).getServer(); + CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.DROWNING; + int damageDone = 1; - EntityDamageEvent ede = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1); + EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone); server.getPluginManager().callEvent(ede); if (!ede.isCancelled()){ @@ -254,19 +255,30 @@ public abstract class Entity { if (!ae) { // CraftBukkit start if(this instanceof EntityLiving) { - CraftServer server = ((WorldServer)l).getServer(); + CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.LAVA; + int damageDone = 4; - EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, this.getBukkitEntity(), EntityDamageEvent.DamageCause.LAVA, 4); + EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone); server.getPluginManager().callEvent(ede); if (!ede.isCancelled()){ a(((Entity) (null)), ede.getDamage()); } - EntityCombustEvent ece = new EntityCombustEvent(Type.ENTITY_COMBUST, this.getBukkitEntity()); - server.getPluginManager().callEvent(ece); - if (!ece.isCancelled()){ + if(Z <= 0){ + // not on fire yet + Type eventType = Type.ENTITY_COMBUST; + EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee); + server.getPluginManager().callEvent(ece); + if (!ece.isCancelled()){ + Z = 600; + } + } else { + // reset fire level back to max Z = 600; } + } else { a(((Entity) (null)), 4); Z = 600; @@ -473,9 +485,24 @@ public abstract class Entity { b(1); if (!flag2) { Z++; - if (Z == 0) { + //CraftBukkit start + if(Z <= 0){ + // not on fire yet + CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + Type eventType = Type.ENTITY_COMBUST; + + EntityCombustEvent ece = new EntityCombustEvent(eventType, damagee); + server.getPluginManager().callEvent(ece); + + if (!ece.isCancelled()){ + Z = 300; + } + } else { + // reset fire level back to max Z = 300; } + //CraftBukkit end } } else if (Z <= 0) { Z = -Y; @@ -505,9 +532,12 @@ public abstract class Entity { if (!ae) { // CraftBukkit start if(this instanceof EntityLiving) { - CraftServer server = ((WorldServer)l).getServer(); + CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.FIRE; + int damageDone = i1; - EntityDamageEvent ede = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.FIRE, i1); + EntityDamageEvent ede = new EntityDamageEvent(damagee, damageType, damageDone); server.getPluginManager().callEvent(ede); if (!ede.isCancelled()){ diff --git a/src/main/java/net/minecraft/server/EntityArrow.java b/src/main/java/net/minecraft/server/EntityArrow.java index 1940349d90..d05f3d4f07 100644 --- a/src/main/java/net/minecraft/server/EntityArrow.java +++ b/src/main/java/net/minecraft/server/EntityArrow.java @@ -1,12 +1,9 @@ package net.minecraft.server; import java.util.List; -import java.util.Random; //CraftBukkit start import org.bukkit.craftbukkit.entity.CraftArrow; -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; diff --git a/src/main/java/net/minecraft/server/EntityBoat.java b/src/main/java/net/minecraft/server/EntityBoat.java index 1cc034709e..9fbb132b7f 100644 --- a/src/main/java/net/minecraft/server/EntityBoat.java +++ b/src/main/java/net/minecraft/server/EntityBoat.java @@ -5,7 +5,6 @@ import java.util.Random; // CraftBukkit start import org.bukkit.Location; -import org.bukkit.craftbukkit.entity.CraftArrow; import org.bukkit.craftbukkit.entity.CraftBoat; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.CraftMappable; diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index fbb7061e6d..610e0e8dd5 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -3,11 +3,7 @@ package net.minecraft.server; import java.util.List; import java.util.Random; -//CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEgg; -import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftFireball; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index 532a7e671f..df26fd88a0 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Random; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftAnimals; import org.bukkit.craftbukkit.entity.CraftGhast; public class EntityGhast extends EntityFlying implements IMobs { diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index f2a7e9d38f..0221012782 100644 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ b/src/main/java/net/minecraft/server/EntityItem.java @@ -3,7 +3,6 @@ package net.minecraft.server; import java.util.Random; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftAnimals; import org.bukkit.craftbukkit.entity.CraftItem; public class EntityItem extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index f9e8025718..30bd0ccd43 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Random; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftAnimals; import org.bukkit.craftbukkit.entity.CraftLivingEntity; public abstract class EntityLiving extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityMinecart.java b/src/main/java/net/minecraft/server/EntityMinecart.java index f78bb2aa80..ef239f550d 100644 --- a/src/main/java/net/minecraft/server/EntityMinecart.java +++ b/src/main/java/net/minecraft/server/EntityMinecart.java @@ -5,7 +5,6 @@ import java.util.Random; // CraftBukkit start import org.bukkit.Location; -import org.bukkit.craftbukkit.entity.CraftEgg; import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftPoweredMinecart; import org.bukkit.craftbukkit.entity.CraftStorageMinecart; From 26a590f03018f011c29d17053219106929052a3b Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 18 Jan 2011 17:16:05 +1100 Subject: [PATCH 3/4] fixed imports on all Entities --- src/main/java/net/minecraft/server/Entity.java | 4 ++-- src/main/java/net/minecraft/server/EntityAnimals.java | 2 ++ src/main/java/net/minecraft/server/EntityChicken.java | 3 ++- src/main/java/net/minecraft/server/EntityCow.java | 2 ++ src/main/java/net/minecraft/server/EntityCreature.java | 2 ++ src/main/java/net/minecraft/server/EntityCreeper.java | 2 ++ src/main/java/net/minecraft/server/EntityEgg.java | 4 ---- src/main/java/net/minecraft/server/EntityFallingSand.java | 2 ++ src/main/java/net/minecraft/server/EntityFireball.java | 1 + src/main/java/net/minecraft/server/EntityFish.java | 4 ---- src/main/java/net/minecraft/server/EntityFlying.java | 2 ++ src/main/java/net/minecraft/server/EntityGhast.java | 2 ++ src/main/java/net/minecraft/server/EntityItem.java | 2 ++ src/main/java/net/minecraft/server/EntityLiving.java | 2 ++ src/main/java/net/minecraft/server/EntityMobs.java | 4 ---- src/main/java/net/minecraft/server/EntityPainting.java | 2 ++ src/main/java/net/minecraft/server/EntityPig.java | 2 ++ src/main/java/net/minecraft/server/EntityPigZombie.java | 2 ++ src/main/java/net/minecraft/server/EntityPlayer.java | 3 ++- src/main/java/net/minecraft/server/EntitySheep.java | 2 ++ src/main/java/net/minecraft/server/EntitySkeleton.java | 1 + src/main/java/net/minecraft/server/EntitySlime.java | 3 ++- src/main/java/net/minecraft/server/EntitySnowball.java | 2 -- src/main/java/net/minecraft/server/EntitySpider.java | 2 ++ src/main/java/net/minecraft/server/EntitySquid.java | 2 ++ src/main/java/net/minecraft/server/EntityTNTPrimed.java | 3 ++- src/main/java/net/minecraft/server/EntityWaterMob.java | 2 ++ src/main/java/net/minecraft/server/EntityZombie.java | 1 + src/main/java/net/minecraft/server/EntityZombieSimple.java | 2 ++ 29 files changed, 47 insertions(+), 20 deletions(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index a05206b01a..d56f1de977 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -1,13 +1,13 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.Event.Type; import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageByBlockEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -// CraftBukkit end +//CraftBukkit end import java.util.List; import java.util.Random; diff --git a/src/main/java/net/minecraft/server/EntityAnimals.java b/src/main/java/net/minecraft/server/EntityAnimals.java index 31a5e86b61..09df7f6f25 100644 --- a/src/main/java/net/minecraft/server/EntityAnimals.java +++ b/src/main/java/net/minecraft/server/EntityAnimals.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftAnimals; +//CraftBukkit end public abstract class EntityAnimals extends EntityCreature implements IAnimals { diff --git a/src/main/java/net/minecraft/server/EntityChicken.java b/src/main/java/net/minecraft/server/EntityChicken.java index 4ae15dafc6..64dfced3d6 100644 --- a/src/main/java/net/minecraft/server/EntityChicken.java +++ b/src/main/java/net/minecraft/server/EntityChicken.java @@ -2,9 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftAnimals; import org.bukkit.craftbukkit.entity.CraftChicken; +//CraftBukkit end public class EntityChicken extends EntityAnimals { diff --git a/src/main/java/net/minecraft/server/EntityCow.java b/src/main/java/net/minecraft/server/EntityCow.java index b98f37ea0b..d19d40d13d 100644 --- a/src/main/java/net/minecraft/server/EntityCow.java +++ b/src/main/java/net/minecraft/server/EntityCow.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftCow; +//CraftBukkit end public class EntityCow extends EntityAnimals { diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java index 8beaf876c2..35f6da6fe3 100644 --- a/src/main/java/net/minecraft/server/EntityCreature.java +++ b/src/main/java/net/minecraft/server/EntityCreature.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftCreature; +//CraftBukkit end public class EntityCreature extends EntityLiving { diff --git a/src/main/java/net/minecraft/server/EntityCreeper.java b/src/main/java/net/minecraft/server/EntityCreeper.java index 589a92dc49..c6b7f2e684 100644 --- a/src/main/java/net/minecraft/server/EntityCreeper.java +++ b/src/main/java/net/minecraft/server/EntityCreeper.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftCreeper; +//CraftBukkit end public class EntityCreeper extends EntityMobs { diff --git a/src/main/java/net/minecraft/server/EntityEgg.java b/src/main/java/net/minecraft/server/EntityEgg.java index 690701c7f3..1feff62969 100644 --- a/src/main/java/net/minecraft/server/EntityEgg.java +++ b/src/main/java/net/minecraft/server/EntityEgg.java @@ -6,11 +6,7 @@ import java.util.Random; // CraftBukkit start import org.bukkit.entity.MobType; import org.bukkit.entity.Player; -import org.bukkit.craftbukkit.entity.CraftArrow; import org.bukkit.craftbukkit.entity.CraftEgg; -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.Event.Type; import org.bukkit.event.entity.EntityDamageByProjectileEvent; diff --git a/src/main/java/net/minecraft/server/EntityFallingSand.java b/src/main/java/net/minecraft/server/EntityFallingSand.java index bc0a106a6c..41ab39760b 100644 --- a/src/main/java/net/minecraft/server/EntityFallingSand.java +++ b/src/main/java/net/minecraft/server/EntityFallingSand.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftFallingSand; +//CraftBukkit end public class EntityFallingSand extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityFireball.java b/src/main/java/net/minecraft/server/EntityFireball.java index 610e0e8dd5..27f28da98b 100644 --- a/src/main/java/net/minecraft/server/EntityFireball.java +++ b/src/main/java/net/minecraft/server/EntityFireball.java @@ -3,6 +3,7 @@ package net.minecraft.server; import java.util.List; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.entity.CraftFireball; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByProjectileEvent; diff --git a/src/main/java/net/minecraft/server/EntityFish.java b/src/main/java/net/minecraft/server/EntityFish.java index cc6893ae57..09a73dbe0f 100644 --- a/src/main/java/net/minecraft/server/EntityFish.java +++ b/src/main/java/net/minecraft/server/EntityFish.java @@ -4,11 +4,7 @@ import java.util.List; import java.util.Random; // CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEgg; -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftFireball; import org.bukkit.craftbukkit.entity.CraftFish; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByProjectileEvent; import org.bukkit.event.entity.EntityDamageEvent; diff --git a/src/main/java/net/minecraft/server/EntityFlying.java b/src/main/java/net/minecraft/server/EntityFlying.java index ea36e28e58..8df4b9a18e 100644 --- a/src/main/java/net/minecraft/server/EntityFlying.java +++ b/src/main/java/net/minecraft/server/EntityFlying.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftFlying; +//CraftBukkit end public class EntityFlying extends EntityLiving { diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java index df26fd88a0..e7dcd822e8 100644 --- a/src/main/java/net/minecraft/server/EntityGhast.java +++ b/src/main/java/net/minecraft/server/EntityGhast.java @@ -3,8 +3,10 @@ package net.minecraft.server; import java.util.List; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftGhast; +//CraftBukkit end public class EntityGhast extends EntityFlying implements IMobs { diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index 0221012782..b6e5a4ead2 100644 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ b/src/main/java/net/minecraft/server/EntityItem.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftItem; +//CraftBukkit end public class EntityItem extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 30bd0ccd43..678debc03e 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -3,8 +3,10 @@ package net.minecraft.server; import java.util.List; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftLivingEntity; +//CraftBukkit end public abstract class EntityLiving extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityMobs.java b/src/main/java/net/minecraft/server/EntityMobs.java index e55b488289..9085af9a64 100644 --- a/src/main/java/net/minecraft/server/EntityMobs.java +++ b/src/main/java/net/minecraft/server/EntityMobs.java @@ -3,13 +3,9 @@ package net.minecraft.server; import java.util.Random; //CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; -import org.bukkit.craftbukkit.entity.CraftMinecart; import org.bukkit.craftbukkit.entity.CraftMonster; import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; diff --git a/src/main/java/net/minecraft/server/EntityPainting.java b/src/main/java/net/minecraft/server/EntityPainting.java index fbe12e01fd..4373395f22 100644 --- a/src/main/java/net/minecraft/server/EntityPainting.java +++ b/src/main/java/net/minecraft/server/EntityPainting.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.*; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftPainting; +//CraftBukkit end public class EntityPainting extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityPig.java b/src/main/java/net/minecraft/server/EntityPig.java index b51e3e95ed..2b67d72cab 100644 --- a/src/main/java/net/minecraft/server/EntityPig.java +++ b/src/main/java/net/minecraft/server/EntityPig.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftPig; +//CraftBukkit end public class EntityPig extends EntityAnimals { diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java index a26a2a5d7e..f0451a0762 100644 --- a/src/main/java/net/minecraft/server/EntityPigZombie.java +++ b/src/main/java/net/minecraft/server/EntityPigZombie.java @@ -3,8 +3,10 @@ package net.minecraft.server; import java.util.List; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftPigZombie; +//CraftBukkit end public class EntityPigZombie extends EntityZombie { diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index 99a189143d..aa8a9ed347 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -3,12 +3,13 @@ package net.minecraft.server; import java.util.List; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.entity.CraftHumanEntity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; -// CraftBukkit end import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +//CraftBukkit end public abstract class EntityPlayer extends EntityLiving { diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java index 4cdd79cfef..5e51fa985f 100644 --- a/src/main/java/net/minecraft/server/EntitySheep.java +++ b/src/main/java/net/minecraft/server/EntitySheep.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftSheep; +//CraftBukkit end public class EntitySheep extends EntityAnimals { diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java index b4c789bbc5..b18ef99f31 100644 --- a/src/main/java/net/minecraft/server/EntitySkeleton.java +++ b/src/main/java/net/minecraft/server/EntitySkeleton.java @@ -2,6 +2,7 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.entity.CraftSkeleton; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.Event.Type; diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java index 6a08eaa146..c18e70a810 100644 --- a/src/main/java/net/minecraft/server/EntitySlime.java +++ b/src/main/java/net/minecraft/server/EntitySlime.java @@ -2,9 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftSkeleton; import org.bukkit.craftbukkit.entity.CraftSlime; +//CraftBukkit stop public class EntitySlime extends EntityLiving implements IMobs { diff --git a/src/main/java/net/minecraft/server/EntitySnowball.java b/src/main/java/net/minecraft/server/EntitySnowball.java index 7107d6e7f6..ff07e80753 100644 --- a/src/main/java/net/minecraft/server/EntitySnowball.java +++ b/src/main/java/net/minecraft/server/EntitySnowball.java @@ -4,8 +4,6 @@ import java.util.List; import java.util.Random; //CraftBukkit start -import org.bukkit.craftbukkit.entity.CraftEntity; -import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftSnowball; import org.bukkit.event.entity.EntityDamageByProjectileEvent; diff --git a/src/main/java/net/minecraft/server/EntitySpider.java b/src/main/java/net/minecraft/server/EntitySpider.java index f9a639dc81..ee01de3133 100644 --- a/src/main/java/net/minecraft/server/EntitySpider.java +++ b/src/main/java/net/minecraft/server/EntitySpider.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftSpider; +//CraftBukkit stop public class EntitySpider extends EntityMobs { diff --git a/src/main/java/net/minecraft/server/EntitySquid.java b/src/main/java/net/minecraft/server/EntitySquid.java index 5e48e4466d..e6b02ffa50 100644 --- a/src/main/java/net/minecraft/server/EntitySquid.java +++ b/src/main/java/net/minecraft/server/EntitySquid.java @@ -2,8 +2,10 @@ package net.minecraft.server; import java.util.Random; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftSquid; +//CraftBukkit stop public class EntitySquid extends EntityWaterMob { diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java index 1705ba6ebd..4f228f58ab 100644 --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java @@ -1,8 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; -import org.bukkit.craftbukkit.entity.CraftSkeleton; import org.bukkit.craftbukkit.entity.CraftTNTPrimed; +//CraftBukkit stop public class EntityTNTPrimed extends Entity { diff --git a/src/main/java/net/minecraft/server/EntityWaterMob.java b/src/main/java/net/minecraft/server/EntityWaterMob.java index c37eac5bdc..e83d9c5c19 100644 --- a/src/main/java/net/minecraft/server/EntityWaterMob.java +++ b/src/main/java/net/minecraft/server/EntityWaterMob.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftWaterMob; +//CraftBukkit stop public class EntityWaterMob extends EntityCreature implements IAnimals { diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java index 9304781560..e717f89283 100644 --- a/src/main/java/net/minecraft/server/EntityZombie.java +++ b/src/main/java/net/minecraft/server/EntityZombie.java @@ -1,5 +1,6 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.entity.CraftZombie; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.Event.Type; diff --git a/src/main/java/net/minecraft/server/EntityZombieSimple.java b/src/main/java/net/minecraft/server/EntityZombieSimple.java index 4e9118ee28..0b76a3bfbe 100644 --- a/src/main/java/net/minecraft/server/EntityZombieSimple.java +++ b/src/main/java/net/minecraft/server/EntityZombieSimple.java @@ -1,7 +1,9 @@ package net.minecraft.server; +//CraftBukkit start import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.entity.CraftGiant; +//CraftBukkit stop public class EntityZombieSimple extends EntityMobs { From e275f727d035f86ef44127460d4e217d340dd543 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Tue, 18 Jan 2011 18:29:41 +1100 Subject: [PATCH 4/4] small change to block event with lava and cactus, to improve readability and consistency --- .../java/net/minecraft/server/BlockCactus.java | 14 ++++++++++---- src/main/java/net/minecraft/server/Entity.java | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minecraft/server/BlockCactus.java b/src/main/java/net/minecraft/server/BlockCactus.java index 2f0aa35f12..1d28821750 100644 --- a/src/main/java/net/minecraft/server/BlockCactus.java +++ b/src/main/java/net/minecraft/server/BlockCactus.java @@ -9,6 +9,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.event.entity.EntityDamageByBlockEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; // CraftBukkit end import java.util.Random; @@ -100,16 +101,21 @@ public class BlockCactus extends Block { if(entity instanceof EntityLiving) { CraftServer server = ((WorldServer) world).getServer(); - CraftEntity toPassIn = new CraftLivingEntity(server, (EntityLiving) entity); - EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(((WorldServer) world).getWorld().getBlockAt(i, j, k), toPassIn, EntityDamageEvent.DamageCause.CONTACT, 1); + org.bukkit.block.Block damager = ((WorldServer) world).getWorld().getBlockAt(i, j, k); + org.bukkit.entity.Entity damagee = entity.getBukkitEntity(); + DamageCause damageType = EntityDamageEvent.DamageCause.CONTACT; + int damageDone = 1; + + EntityDamageByBlockEvent edbbe = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); server.getPluginManager().callEvent(edbbe); if (!edbbe.isCancelled()){ entity.a(((Entity) (null)), edbbe.getDamage()); } return; + } else { + entity.a(((Entity) (null)), 1); } - // CraftBukkit end - entity.a(((Entity) (null)), 1); + // CraftBukkit end } } diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index d56f1de977..69c619dc3d 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -256,11 +256,12 @@ public abstract class Entity { // CraftBukkit start if(this instanceof EntityLiving) { CraftServer server = ((WorldServer) l).getServer(); + org.bukkit.block.Block damager = null;//((WorldServer) l).getWorld().getBlockAt(i, j, k); org.bukkit.entity.Entity damagee = this.getBukkitEntity(); DamageCause damageType = EntityDamageEvent.DamageCause.LAVA; int damageDone = 4; - EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(null, damagee, damageType, damageDone); + EntityDamageByBlockEvent ede = new EntityDamageByBlockEvent(damager, damagee, damageType, damageDone); server.getPluginManager().callEvent(ede); if (!ede.isCancelled()){ a(((Entity) (null)), ede.getDamage());