3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00

[Bleeding] Fix for creeper getDrops() not reporting the music disk if it was killed by a skeleton. Addresses BUKKIT-1133

Dieser Commit ist enthalten in:
Celtic Minstrel 2012-03-10 23:19:09 -05:00 committet von EvilSeph
Ursprung 5ba8928041
Commit 1c95413f49

Datei anzeigen

@ -1,11 +1,17 @@
package net.minecraft.server;
import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
// CraftBukkit start
import java.util.List;
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.event.entity.ExplosionPrimeEvent;
// CraftBukkit end
public class EntityCreeper extends EntityMonster {
int fuseTicks;
int b;
private int record = -1; // CraftBukkit
public EntityCreeper(World world) {
super(world);
@ -91,12 +97,43 @@ public class EntityCreeper extends EntityMonster {
}
public void die(DamageSource damagesource) {
super.die(damagesource);
// CraftBukkit start - rearranged the method (super call to end, drop to dropDeathLoot)
if (damagesource.getEntity() instanceof EntitySkeleton) {
this.b(Item.RECORD_1.id + this.random.nextInt(10), 1);
// this.b(Item.RECORD_1.id + this.random.nextInt(10), 1); // CraftBukkit
this.record = Item.RECORD_1.id + this.random.nextInt(10);
}
super.die(damagesource);
// CraftBukkit end
}
// CraftBukkit start - whole method
protected void dropDeathLoot(boolean flag, int i) {
int j = this.getLootId();
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
if (j > 0) {
int k = this.random.nextInt(3);
if (i > 0) {
k += this.random.nextInt(i + 1);
}
if (k > 0) {
loot.add(new org.bukkit.inventory.ItemStack(j, k));
}
}
// Drop a music disc?
if (this.record != -1) {
loot.add(new org.bukkit.inventory.ItemStack(this.record, 1));
this.record = -1;
}
CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot
}
// CraftBukkit end
public boolean a(Entity entity) {
return true;
}
@ -131,8 +168,9 @@ public class EntityCreeper extends EntityMonster {
public void setPowered(boolean powered) {
if (!powered) {
this.datawatcher.watch(17, Byte.valueOf((byte) 0));
} else
} else {
this.datawatcher.watch(17, Byte.valueOf((byte) 1));
}
// CraftBukkit end
this.datawatcher.watch(17, Byte.valueOf((byte) 1));
}
}