SPIGOT-1816: Rework drop capture.
This commit is contained in:
parent
ab83272e2a
commit
bf43ca62a6
@ -364,7 +364,7 @@
|
|||||||
public EntityItem a(ItemStack itemstack, float f) {
|
public EntityItem a(ItemStack itemstack, float f) {
|
||||||
if (itemstack.count != 0 && itemstack.getItem() != null) {
|
if (itemstack.count != 0 && itemstack.getItem() != null) {
|
||||||
+ // CraftBukkit start - Capture drops for death event
|
+ // CraftBukkit start - Capture drops for death event
|
||||||
+ if (this instanceof EntityLiving && ((EntityLiving) this).drops != null) {
|
+ if (this instanceof EntityLiving) {
|
||||||
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
||||||
+ return null;
|
+ return null;
|
||||||
+ }
|
+ }
|
||||||
|
@ -11,15 +11,7 @@
|
|||||||
public class EntityCreeper extends EntityMonster {
|
public class EntityCreeper extends EntityMonster {
|
||||||
|
|
||||||
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
|
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
|
||||||
@@ -10,6 +15,7 @@
|
@@ -117,7 +122,7 @@
|
||||||
private int maxFuseTicks = 30;
|
|
||||||
private int explosionRadius = 3;
|
|
||||||
private int bz = 0;
|
|
||||||
+ private int record = -1; // CraftBukkit
|
|
||||||
|
|
||||||
public EntityCreeper(World world) {
|
|
||||||
super(world);
|
|
||||||
@@ -117,21 +123,41 @@
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void die(DamageSource damagesource) {
|
public void die(DamageSource damagesource) {
|
||||||
@ -28,43 +20,15 @@
|
|||||||
if (this.world.getGameRules().getBoolean("doMobLoot")) {
|
if (this.world.getGameRules().getBoolean("doMobLoot")) {
|
||||||
if (damagesource.getEntity() instanceof EntitySkeleton) {
|
if (damagesource.getEntity() instanceof EntitySkeleton) {
|
||||||
int i = Item.getId(Items.RECORD_13);
|
int i = Item.getId(Items.RECORD_13);
|
||||||
int j = Item.getId(Items.RECORD_WAIT);
|
@@ -130,6 +135,7 @@
|
||||||
int k = i + this.random.nextInt(j - i + 1);
|
this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
||||||
|
|
||||||
- this.a(Item.getById(k), 1);
|
|
||||||
+ // CraftBukkit start - Store record for now, drop in dropDeathLoot
|
|
||||||
+ // this.a(Item.getById(k), 1);
|
|
||||||
+ this.record = k;
|
|
||||||
+ // CraftBukkit end
|
|
||||||
} else if (damagesource.getEntity() instanceof EntityCreeper && damagesource.getEntity() != this && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
|
|
||||||
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
|
|
||||||
- this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ // this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
|
||||||
+ headDrop = new ItemStack(Items.SKULL, 1, 4);
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
+ super.die(damagesource); // CraftBukkit - Moved from above
|
+ super.die(damagesource); // CraftBukkit - Moved from above
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // CraftBukkit start - Whole method
|
|
||||||
+ @Override
|
|
||||||
+ protected void dropDeathLoot(boolean flag, int i) {
|
|
||||||
+ super.dropDeathLoot(flag, i);
|
|
||||||
+
|
|
||||||
+ // Drop a music disc?
|
|
||||||
+ if (this.record != -1) {
|
|
||||||
+ this.a(Item.getById(this.record), 1);
|
|
||||||
+ this.record = -1;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
+ // CraftBukkit end
|
|
||||||
|
|
||||||
public boolean B(Entity entity) {
|
}
|
||||||
return true;
|
|
||||||
@@ -155,8 +181,18 @@
|
@@ -155,8 +161,18 @@
|
||||||
|
|
||||||
public void onLightningStrike(EntityLightning entitylightning) {
|
public void onLightningStrike(EntityLightning entitylightning) {
|
||||||
super.onLightningStrike(entitylightning);
|
super.onLightningStrike(entitylightning);
|
||||||
@ -83,7 +47,7 @@
|
|||||||
|
|
||||||
protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
|
protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
|
||||||
if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) {
|
if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) {
|
||||||
@@ -177,9 +213,17 @@
|
@@ -177,9 +193,17 @@
|
||||||
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
|
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
|
||||||
float f = this.isPowered() ? 2.0F : 1.0F;
|
float f = this.isPowered() ? 2.0F : 1.0F;
|
||||||
|
|
||||||
|
@ -64,28 +64,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean d(Class<? extends EntityLiving> oclass) {
|
public boolean d(Class<? extends EntityLiving> oclass) {
|
||||||
@@ -225,6 +267,7 @@
|
@@ -321,11 +363,20 @@
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ protected ItemStack headDrop = null; // CraftBukkit
|
|
||||||
protected void dropDeathLoot(boolean flag, int i) {
|
|
||||||
Item item = this.getLoot();
|
|
||||||
|
|
||||||
@@ -240,6 +283,12 @@
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // CraftBukkit start
|
|
||||||
+ if (headDrop != null) {
|
|
||||||
+ this.a(headDrop, 0.0F);
|
|
||||||
+ headDrop = null;
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
|
||||||
|
|
||||||
public void b(NBTTagCompound nbttagcompound) {
|
|
||||||
@@ -321,11 +370,20 @@
|
|
||||||
|
|
||||||
public void a(NBTTagCompound nbttagcompound) {
|
public void a(NBTTagCompound nbttagcompound) {
|
||||||
super.a(nbttagcompound);
|
super.a(nbttagcompound);
|
||||||
@ -108,16 +87,7 @@
|
|||||||
NBTTagList nbttaglist;
|
NBTTagList nbttaglist;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -406,7 +464,7 @@
|
@@ -549,11 +600,11 @@
|
||||||
}
|
|
||||||
|
|
||||||
this.dropEquipment(flag, i);
|
|
||||||
- } else {
|
|
||||||
+ } { // CraftBukkit - remove else
|
|
||||||
super.a(flag, i, damagesource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -549,11 +607,11 @@
|
|
||||||
double d2 = entityhuman.locZ - this.locZ;
|
double d2 = entityhuman.locZ - this.locZ;
|
||||||
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
|
||||||
|
|
||||||
@ -131,7 +101,7 @@
|
|||||||
this.die();
|
this.die();
|
||||||
} else if (d3 < 1024.0D) {
|
} else if (d3 < 1024.0D) {
|
||||||
this.ticksFarFromPlayer = 0;
|
this.ticksFarFromPlayer = 0;
|
||||||
@@ -931,9 +989,21 @@
|
@@ -931,9 +982,21 @@
|
||||||
|
|
||||||
public final boolean a(EntityHuman entityhuman, ItemStack itemstack, EnumHand enumhand) {
|
public final boolean a(EntityHuman entityhuman, ItemStack itemstack, EnumHand enumhand) {
|
||||||
if (this.isLeashed() && this.getLeashHolder() == entityhuman) {
|
if (this.isLeashed() && this.getLeashHolder() == entityhuman) {
|
||||||
@ -153,7 +123,7 @@
|
|||||||
this.setLeashHolder(entityhuman, true);
|
this.setLeashHolder(entityhuman, true);
|
||||||
--itemstack.count;
|
--itemstack.count;
|
||||||
return true;
|
return true;
|
||||||
@@ -953,10 +1023,12 @@
|
@@ -953,10 +1016,12 @@
|
||||||
|
|
||||||
if (this.bC) {
|
if (this.bC) {
|
||||||
if (!this.isAlive()) {
|
if (!this.isAlive()) {
|
||||||
@ -166,7 +136,7 @@
|
|||||||
this.unleash(true, true);
|
this.unleash(true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1037,6 +1109,7 @@
|
@@ -1037,6 +1102,7 @@
|
||||||
|
|
||||||
this.leashHolder = entityleash;
|
this.leashHolder = entityleash;
|
||||||
} else {
|
} else {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ public int expToDrop;
|
+ public int expToDrop;
|
||||||
+ public int maxAirTicks = 300;
|
+ public int maxAirTicks = 300;
|
||||||
+ ArrayList<org.bukkit.inventory.ItemStack> drops;
|
+ ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||||
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
@ -302,24 +302,20 @@
|
|||||||
this.az = 0.0F;
|
this.az = 0.0F;
|
||||||
Entity entity = damagesource.getEntity();
|
Entity entity = damagesource.getEntity();
|
||||||
|
|
||||||
@@ -822,9 +956,16 @@
|
@@ -825,6 +959,12 @@
|
||||||
}
|
|
||||||
|
|
||||||
if (this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot")) {
|
|
||||||
+ this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); // CraftBukkit - Setup drop capture
|
|
||||||
boolean flag = this.lastDamageByPlayerTime > 0;
|
boolean flag = this.lastDamageByPlayerTime > 0;
|
||||||
|
|
||||||
this.a(flag, i, damagesource);
|
this.a(flag, i, damagesource);
|
||||||
+ // CraftBukkit start - Call death event
|
+ // CraftBukkit start - Call death event
|
||||||
+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
|
+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
|
||||||
+ this.drops = null;
|
+ this.drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||||
+ } else {
|
+ } else {
|
||||||
+ CraftEventFactory.callEntityDeathEvent(this);
|
+ CraftEventFactory.callEntityDeathEvent(this);
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,8 +1053,13 @@
|
@@ -912,8 +1052,13 @@
|
||||||
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -334,7 +330,7 @@
|
|||||||
int j = MathHelper.floor(this.locX);
|
int j = MathHelper.floor(this.locX);
|
||||||
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
||||||
int l = MathHelper.floor(this.locZ);
|
int l = MathHelper.floor(this.locZ);
|
||||||
@@ -940,20 +1086,20 @@
|
@@ -940,20 +1085,20 @@
|
||||||
|
|
||||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||||
if (!damagesource.ignoresArmor()) {
|
if (!damagesource.ignoresArmor()) {
|
||||||
@ -358,7 +354,7 @@
|
|||||||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||||
int j = 25 - i;
|
int j = 25 - i;
|
||||||
float f1 = f * (float) j;
|
float f1 = f * (float) j;
|
||||||
@@ -974,22 +1120,122 @@
|
@@ -974,22 +1119,122 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +484,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CombatTracker getCombatTracker() {
|
public CombatTracker getCombatTracker() {
|
||||||
@@ -1055,6 +1301,7 @@
|
@@ -1055,6 +1300,7 @@
|
||||||
public AttributeMapBase getAttributeMap() {
|
public AttributeMapBase getAttributeMap() {
|
||||||
if (this.bp == null) {
|
if (this.bp == null) {
|
||||||
this.bp = new AttributeMapServer();
|
this.bp = new AttributeMapServer();
|
||||||
@ -496,7 +492,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.bp;
|
return this.bp;
|
||||||
@@ -1702,6 +1949,13 @@
|
@@ -1702,6 +1948,13 @@
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
Entity entity = (Entity) list.get(i);
|
Entity entity = (Entity) list.get(i);
|
||||||
@ -510,7 +506,7 @@
|
|||||||
|
|
||||||
this.C(entity);
|
this.C(entity);
|
||||||
}
|
}
|
||||||
@@ -1918,7 +2172,22 @@
|
@@ -1918,7 +2171,22 @@
|
||||||
protected void v() {
|
protected void v() {
|
||||||
if (this.bm != null && this.cs()) {
|
if (this.bm != null && this.cs()) {
|
||||||
this.a(this.bm, 16);
|
this.a(this.bm, 16);
|
||||||
|
@ -41,23 +41,15 @@
|
|||||||
if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
|
if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
|
||||||
EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
|
EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
|
||||||
double d0 = entityhuman.locX - this.locX;
|
double d0 = entityhuman.locX - this.locX;
|
||||||
@@ -136,9 +145,14 @@
|
@@ -138,6 +147,7 @@
|
||||||
}
|
|
||||||
} else if (damagesource.getEntity() instanceof EntityCreeper && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
|
|
||||||
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
|
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
|
||||||
- this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
|
this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
|
||||||
+ // CraftBukkit start
|
|
||||||
+ // this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
|
|
||||||
+ headDrop = new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0);
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ super.die(damagesource); // CraftBukkit - moved from above
|
+ super.die(damagesource); // CraftBukkit - moved from above
|
||||||
+
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MinecraftKey J() {
|
@@ -212,11 +222,30 @@
|
||||||
@@ -212,11 +226,30 @@
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, (EntityLiving) this) > 0 || this.getSkeletonType() == 1) {
|
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, (EntityLiving) this) > 0 || this.getSkeletonType() == 1) {
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
|
entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
|
||||||
this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
|
this.world.a((EntityHuman) null, 1027, new BlockPosition((int) this.locX, (int) this.locY, (int) this.locZ), 0);
|
||||||
}
|
}
|
||||||
@@ -514,12 +541,16 @@
|
@@ -514,11 +541,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void die(DamageSource damagesource) {
|
public void die(DamageSource damagesource) {
|
||||||
@ -112,14 +112,9 @@
|
|||||||
+ // super.die(damagesource); // CraftBukkit
|
+ // super.die(damagesource); // CraftBukkit
|
||||||
if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
|
if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
|
||||||
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
|
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
|
||||||
- this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
|
this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
|
||||||
+ // CraftBukkit start
|
|
||||||
+ // this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
|
|
||||||
+ headDrop = new ItemStack(Items.SKULL, 1, 2);
|
|
||||||
+ // CraftBukkit end
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ super.die(damagesource); // CraftBukkit - moved from above
|
+ super.die(damagesource); // CraftBukkit - moved from above
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SyntheticClass_1 { }
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user