3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

SPIGOT-1816: Rework drop capture.

Dieser Commit ist enthalten in:
md_5 2016-03-07 19:51:42 +11:00
Ursprung ab83272e2a
Commit bf43ca62a6
6 geänderte Dateien mit 30 neuen und 113 gelöschten Zeilen

Datei anzeigen

@ -364,7 +364,7 @@
public EntityItem a(ItemStack itemstack, float f) {
if (itemstack.count != 0 && itemstack.getItem() != null) {
+ // 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));
+ return null;
+ }

Datei anzeigen

@ -11,15 +11,7 @@
public class EntityCreeper extends EntityMonster {
private static final DataWatcherObject<Integer> a = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
@@ -10,6 +15,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 @@
@@ -117,7 +122,7 @@
}
public void die(DamageSource damagesource) {
@ -28,43 +20,15 @@
if (this.world.getGameRules().getBoolean("doMobLoot")) {
if (damagesource.getEntity() instanceof EntitySkeleton) {
int i = Item.getId(Items.RECORD_13);
int j = Item.getId(Items.RECORD_WAIT);
int k = i + this.random.nextInt(j - i + 1);
- 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
@@ -130,6 +135,7 @@
this.a(new ItemStack(Items.SKULL, 1, 4), 0.0F);
}
}
+ 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) {
super.onLightningStrike(entitylightning);
@ -83,7 +47,7 @@
protected boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.FLINT_AND_STEEL) {
@@ -177,9 +213,17 @@
@@ -177,9 +193,17 @@
boolean flag = this.world.getGameRules().getBoolean("mobGriefing");
float f = this.isPowered() ? 2.0F : 1.0F;

Datei anzeigen

@ -64,28 +64,7 @@
}
public boolean d(Class<? extends EntityLiving> oclass) {
@@ -225,6 +267,7 @@
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 @@
@@ -321,11 +363,20 @@
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
@ -108,16 +87,7 @@
NBTTagList nbttaglist;
int i;
@@ -406,7 +464,7 @@
}
this.dropEquipment(flag, i);
- } else {
+ } { // CraftBukkit - remove else
super.a(flag, i, damagesource);
}
@@ -549,11 +607,11 @@
@@ -549,11 +600,11 @@
double d2 = entityhuman.locZ - this.locZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
@ -131,7 +101,7 @@
this.die();
} else if (d3 < 1024.0D) {
this.ticksFarFromPlayer = 0;
@@ -931,9 +989,21 @@
@@ -931,9 +982,21 @@
public final boolean a(EntityHuman entityhuman, ItemStack itemstack, EnumHand enumhand) {
if (this.isLeashed() && this.getLeashHolder() == entityhuman) {
@ -153,7 +123,7 @@
this.setLeashHolder(entityhuman, true);
--itemstack.count;
return true;
@@ -953,10 +1023,12 @@
@@ -953,10 +1016,12 @@
if (this.bC) {
if (!this.isAlive()) {
@ -166,7 +136,7 @@
this.unleash(true, true);
}
}
@@ -1037,6 +1109,7 @@
@@ -1037,6 +1102,7 @@
this.leashHolder = entityleash;
} else {

Datei anzeigen

@ -28,8 +28,8 @@
+ // CraftBukkit start
+ public int expToDrop;
+ public int maxAirTicks = 300;
+ ArrayList<org.bukkit.inventory.ItemStack> drops;
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
+ // CraftBukkit end
public void Q() {
@ -302,24 +302,20 @@
this.az = 0.0F;
Entity entity = damagesource.getEntity();
@@ -822,9 +956,16 @@
}
if (this.isDropExperience() && this.world.getGameRules().getBoolean("doMobLoot")) {
+ this.drops = new ArrayList<org.bukkit.inventory.ItemStack>(); // CraftBukkit - Setup drop capture
@@ -825,6 +959,12 @@
boolean flag = this.lastDamageByPlayerTime > 0;
this.a(flag, i, damagesource);
+ // CraftBukkit start - Call death event
+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
+ this.drops = null;
+ this.drops = new ArrayList<org.bukkit.inventory.ItemStack>();
+ } else {
+ CraftEventFactory.callEntityDeathEvent(this);
+ // CraftBukkit end
}
}
@@ -912,8 +1053,13 @@
@@ -912,8 +1052,13 @@
int i = MathHelper.f((f - 3.0F - f2) * f1);
if (i > 0) {
@ -334,7 +330,7 @@
int j = MathHelper.floor(this.locX);
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
int l = MathHelper.floor(this.locZ);
@@ -940,20 +1086,20 @@
@@ -940,20 +1085,20 @@
protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) {
@ -358,7 +354,7 @@
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -974,22 +1120,122 @@
@@ -974,22 +1119,122 @@
}
}
@ -488,7 +484,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1055,6 +1301,7 @@
@@ -1055,6 +1300,7 @@
public AttributeMapBase getAttributeMap() {
if (this.bp == null) {
this.bp = new AttributeMapServer();
@ -496,7 +492,7 @@
}
return this.bp;
@@ -1702,6 +1949,13 @@
@@ -1702,6 +1948,13 @@
if (!list.isEmpty()) {
for (int i = 0; i < list.size(); ++i) {
Entity entity = (Entity) list.get(i);
@ -510,7 +506,7 @@
this.C(entity);
}
@@ -1918,7 +2172,22 @@
@@ -1918,7 +2171,22 @@
protected void v() {
if (this.bm != null && this.cs()) {
this.a(this.bm, 16);

Datei anzeigen

@ -41,23 +41,15 @@
if (damagesource.i() instanceof EntityArrow && damagesource.getEntity() instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) damagesource.getEntity();
double d0 = entityhuman.locX - this.locX;
@@ -136,9 +145,14 @@
}
} else if (damagesource.getEntity() instanceof EntityCreeper && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
@@ -138,6 +147,7 @@
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
- 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
this.a(new ItemStack(Items.SKULL, 1, this.getSkeletonType() == 1 ? 1 : 0), 0.0F);
}
+ super.die(damagesource); // CraftBukkit - moved from above
+
}
protected MinecraftKey J() {
@@ -212,11 +226,30 @@
@@ -212,11 +222,30 @@
}
if (EnchantmentManager.a(Enchantments.ARROW_FIRE, (EntityLiving) this) > 0 || this.getSkeletonType() == 1) {

Datei anzeigen

@ -104,7 +104,7 @@
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);
}
@@ -514,12 +541,16 @@
@@ -514,11 +541,12 @@
}
public void die(DamageSource damagesource) {
@ -112,14 +112,9 @@
+ // super.die(damagesource); // CraftBukkit
if (damagesource.getEntity() instanceof EntityCreeper && !(this instanceof EntityPigZombie) && ((EntityCreeper) damagesource.getEntity()).isPowered() && ((EntityCreeper) damagesource.getEntity()).canCauseHeadDrop()) {
((EntityCreeper) damagesource.getEntity()).setCausedHeadDrop();
- 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
this.a(new ItemStack(Items.SKULL, 1, 2), 0.0F);
}
+ super.die(damagesource); // CraftBukkit - moved from above
}
static class SyntheticClass_1 { }