Archiviert
13
0

SPIGOT-1831: Chicken / sheep not dropping items correctly.

Dieser Commit ist enthalten in:
md_5 2016-03-08 17:58:52 +11:00
Ursprung bf43ca62a6
Commit 3b375b354e
4 geänderte Dateien mit 42 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -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) { + if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
+ ((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;
+ } + }

Datei anzeigen

@ -12,3 +12,13 @@
super.n(); super.n();
this.bz = this.bv; this.bz = this.bv;
this.bx = this.bw; this.bx = this.bw;
@@ -60,7 +65,9 @@
this.bv += this.bA * 2.0F;
if (!this.world.isClientSide && !this.isBaby() && !this.isChickenJockey() && --this.bB <= 0) {
this.a(SoundEffects.aa, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
this.a(Items.EGG, 1);
+ this.forceDrops = false; // CraftBukkit
this.bB = this.random.nextInt(6000) + 6000;
}

Datei anzeigen

@ -21,20 +21,21 @@
public abstract class EntityLiving extends Entity { public abstract class EntityLiving extends Entity {
private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D"); private static final UUID a = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
@@ -80,6 +94,12 @@ @@ -80,6 +94,13 @@
protected int bn; protected int bn;
protected int bo; protected int bo;
private BlockPosition bC; private BlockPosition bC;
+ // CraftBukkit start + // CraftBukkit start
+ public int expToDrop; + public int expToDrop;
+ public int maxAirTicks = 300; + public int maxAirTicks = 300;
+ boolean forceDrops;
+ ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>(); + 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
public void Q() { public void Q() {
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE); this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
@@ -88,7 +108,8 @@ @@ -88,7 +109,8 @@
public EntityLiving(World world) { public EntityLiving(World world) {
super(world); super(world);
this.initAttributes(); this.initAttributes();
@ -44,7 +45,7 @@
this.i = true; this.i = true;
this.aL = (float) ((Math.random() + 1.0D) * 0.009999999776482582D); this.aL = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.setPosition(this.locX, this.locY, this.locZ); this.setPosition(this.locX, this.locY, this.locZ);
@@ -125,7 +146,13 @@ @@ -125,7 +147,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D); double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1); int i = (int) (150.0D * d1);
@ -59,7 +60,7 @@
} }
} }
@@ -183,7 +210,11 @@ @@ -183,7 +211,11 @@
this.stopRiding(); this.stopRiding();
} }
} else { } else {
@ -72,7 +73,7 @@
} }
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
@@ -240,6 +271,18 @@ @@ -240,6 +272,18 @@
this.world.methodProfiler.b(); this.world.methodProfiler.b();
} }
@ -91,7 +92,7 @@
protected void b(BlockPosition blockposition) { protected void b(BlockPosition blockposition) {
int i = EnchantmentManager.a(Enchantments.j, this); int i = EnchantmentManager.a(Enchantments.j, this);
@@ -255,19 +298,19 @@ @@ -255,19 +299,19 @@
protected void bC() { protected void bC() {
++this.deathTicks; ++this.deathTicks;
@ -120,7 +121,7 @@
this.die(); this.die();
@@ -421,6 +464,17 @@ @@ -421,6 +465,17 @@
} }
} }
@ -138,7 +139,7 @@
if (nbttagcompound.hasKeyOfType("Health", 99)) { if (nbttagcompound.hasKeyOfType("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health")); this.setHealth(nbttagcompound.getFloat("Health"));
} }
@@ -436,9 +490,15 @@ @@ -436,9 +491,15 @@
} }
@ -154,7 +155,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next(); MobEffectList mobeffectlist = (MobEffectList) iterator.next();
MobEffect mobeffect = (MobEffect) this.effects.get(mobeffectlist); MobEffect mobeffect = (MobEffect) this.effects.get(mobeffectlist);
@@ -452,6 +512,16 @@ @@ -452,6 +513,16 @@
this.a(mobeffect, false); this.a(mobeffect, false);
} }
} }
@ -171,7 +172,7 @@
if (this.updateEffects) { if (this.updateEffects) {
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
@@ -548,6 +618,12 @@ @@ -548,6 +619,12 @@
} }
public void addEffect(MobEffect mobeffect) { public void addEffect(MobEffect mobeffect) {
@ -184,7 +185,7 @@
if (this.d(mobeffect)) { if (this.d(mobeffect)) {
MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect()); MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
@@ -579,6 +655,12 @@ @@ -579,6 +656,12 @@
} }
public MobEffect c(MobEffectList mobeffectlist) { public MobEffect c(MobEffectList mobeffectlist) {
@ -197,7 +198,7 @@
return (MobEffect) this.effects.remove(mobeffectlist); return (MobEffect) this.effects.remove(mobeffectlist);
} }
@@ -618,20 +700,52 @@ @@ -618,20 +701,52 @@
} }
@ -251,7 +252,7 @@
this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth()))); this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
} }
@@ -647,7 +761,8 @@ @@ -647,7 +762,8 @@
} else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { } else if (damagesource.o() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false; return false;
} else { } else {
@ -261,7 +262,7 @@
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this); this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this);
f *= 0.75F; f *= 0.75F;
} }
@@ -673,19 +788,38 @@ @@ -673,19 +789,38 @@
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
if (f <= this.lastDamage) { if (f <= this.lastDamage) {
@ -302,7 +303,7 @@
this.az = 0.0F; this.az = 0.0F;
Entity entity = damagesource.getEntity(); Entity entity = damagesource.getEntity();
@@ -825,6 +959,12 @@ @@ -825,6 +960,12 @@
boolean flag = this.lastDamageByPlayerTime > 0; boolean flag = this.lastDamageByPlayerTime > 0;
this.a(flag, i, damagesource); this.a(flag, i, damagesource);
@ -315,7 +316,7 @@
} }
} }
@@ -912,8 +1052,13 @@ @@ -912,8 +1053,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) {
@ -330,7 +331,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 +1085,20 @@ @@ -940,20 +1086,20 @@
protected float applyArmorModifier(DamageSource damagesource, float f) { protected float applyArmorModifier(DamageSource damagesource, float f) {
if (!damagesource.ignoresArmor()) { if (!damagesource.ignoresArmor()) {
@ -354,7 +355,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 +1119,122 @@ @@ -974,22 +1120,122 @@
} }
} }
@ -484,7 +485,7 @@
} }
public CombatTracker getCombatTracker() { public CombatTracker getCombatTracker() {
@@ -1055,6 +1300,7 @@ @@ -1055,6 +1301,7 @@
public AttributeMapBase getAttributeMap() { public AttributeMapBase getAttributeMap() {
if (this.bp == null) { if (this.bp == null) {
this.bp = new AttributeMapServer(); this.bp = new AttributeMapServer();
@ -492,7 +493,7 @@
} }
return this.bp; return this.bp;
@@ -1702,6 +1948,13 @@ @@ -1702,6 +1949,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);
@ -506,7 +507,7 @@
this.C(entity); this.C(entity);
} }
@@ -1918,7 +2171,22 @@ @@ -1918,7 +2172,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);

Datei anzeigen

@ -35,7 +35,7 @@
} }
protected void r() { protected void r() {
@@ -123,6 +137,15 @@ @@ -123,11 +137,22 @@
public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) { public boolean a(EntityHuman entityhuman, EnumHand enumhand, ItemStack itemstack) {
if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) { if (itemstack != null && itemstack.getItem() == Items.SHEARS && !this.isSheared() && !this.isBaby()) {
if (!this.world.isClientSide) { if (!this.world.isClientSide) {
@ -51,7 +51,14 @@
this.setSheared(true); this.setSheared(true);
int i = 1 + this.random.nextInt(3); int i = 1 + this.random.nextInt(3);
@@ -210,6 +233,12 @@ for (int j = 0; j < i; ++j) {
+ this.forceDrops = true; // CraftBukkit
EntityItem entityitem = this.a(new ItemStack(Item.getItemOf(Blocks.WOOL), 1, this.getColor().getColorIndex()), 1.0F);
+ this.forceDrops = false; // CraftBukkit
entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
@@ -210,6 +235,12 @@
} }
public void B() { public void B() {