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

Added death events for blaze and snowman, fixed reported loot for chickens

Dieser Commit ist enthalten in:
Nathan Adams 2011-11-26 00:56:11 +00:00
Ursprung b9aaf3977c
Commit 8062d5c7be
3 geänderte Dateien mit 272 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,178 @@
package net.minecraft.server;
import java.util.List;
import org.bukkit.craftbukkit.event.CraftEventFactory;
public class EntityBlaze extends EntityMonster {
private float a = 0.5F;
private int b;
private int g;
public EntityBlaze(World world) {
super(world);
this.texture = "/mob/fire.png";
this.fireProof = true;
this.damage = 6;
this.az = 10;
}
public int getMaxHealth() {
return 20;
}
protected void b() {
super.b();
this.datawatcher.a(16, new Byte((byte) 0));
}
protected String c_() {
return "mob.blaze.breathe";
}
protected String m() {
return "mob.blaze.hit";
}
protected String n() {
return "mob.blaze.death";
}
public boolean damageEntity(DamageSource damagesource, int i) {
return super.damageEntity(damagesource, i);
}
public void die(DamageSource damagesource) {
super.die(damagesource);
}
public float a(float f) {
return 1.0F;
}
public void d() {
if (!this.world.isStatic) {
if (this.ay()) {
this.damageEntity(DamageSource.DROWN, 1);
}
--this.b;
if (this.b <= 0) {
this.b = 100;
this.a = 0.5F + (float) this.random.nextGaussian() * 3.0F;
}
if (this.E() != null && this.E().locY + (double) this.E().x() > this.locY + (double) this.x() + (double) this.a) {
this.motY += (0.30000001192092896D - this.motY) * 0.30000001192092896D;
}
}
if (this.random.nextInt(24) == 0) {
this.world.makeSound(this.locX + 0.5D, this.locY + 0.5D, this.locZ + 0.5D, "fire.fire", 1.0F + this.random.nextFloat(), this.random.nextFloat() * 0.7F + 0.3F);
}
if (!this.onGround && this.motY < 0.0D) {
this.motY *= 0.6D;
}
for (int i = 0; i < 2; ++i) {
this.world.a("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.length, this.locY + this.random.nextDouble() * (double) this.width, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.length, 0.0D, 0.0D, 0.0D);
}
super.d();
}
protected void a(Entity entity, float f) {
if (this.attackTicks <= 0 && f < 2.0F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
this.attackTicks = 20;
this.d(entity);
} else if (f < 30.0F) {
double d0 = entity.locX - this.locX;
double d1 = entity.boundingBox.b + (double) (entity.width / 2.0F) - (this.locY + (double) (this.width / 2.0F));
double d2 = entity.locZ - this.locZ;
if (this.attackTicks == 0) {
++this.g;
if (this.g == 1) {
this.attackTicks = 60;
this.a(true);
} else if (this.g <= 4) {
this.attackTicks = 6;
} else {
this.attackTicks = 100;
this.g = 0;
this.a(false);
}
if (this.g > 1) {
float f1 = MathHelper.c(f) * 0.5F;
this.world.a((EntityHuman) null, 1009, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
for (int i = 0; i < 1; ++i) {
EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.world, this, d0 + this.random.nextGaussian() * (double) f1, d1, d2 + this.random.nextGaussian() * (double) f1);
entitysmallfireball.locY = this.locY + (double) (this.width / 2.0F) + 0.5D;
this.world.addEntity(entitysmallfireball);
}
}
}
this.yaw = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
this.e = true;
}
}
protected void b(float f) {}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
}
protected int e() {
return Item.BLAZE_ROD.id;
}
public boolean z() {
return this.A();
}
protected void a(boolean flag, int i) {
if (flag) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(2 + i);
if (j > 0) {
loot.add(new org.bukkit.inventory.ItemStack(Item.BLAZE_ROD.id, j));
}
CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
}
public boolean A() {
return (this.datawatcher.getByte(16) & 1) != 0;
}
public void a(boolean flag) {
byte b0 = this.datawatcher.getByte(16);
if (flag) {
b0 = (byte) (b0 | 1);
} else {
b0 &= -2;
}
this.datawatcher.watch(16, Byte.valueOf(b0));
}
protected boolean y() {
return true;
}
}

Datei anzeigen

@ -92,9 +92,9 @@ public class EntityChicken extends EntityAnimal {
}
if (this.z()) {
this.b(Item.COOKED_CHICKEN.id, 1);
loot.add(new org.bukkit.inventory.ItemStack(Item.COOKED_CHICKEN.id, 1));
} else {
this.b(Item.RAW_CHICKEN.id, 1);
loot.add(new org.bukkit.inventory.ItemStack(Item.RAW_CHICKEN.id, 1));
}
CraftEventFactory.callEntityDeathEvent(this, loot);

Datei anzeigen

@ -0,0 +1,92 @@
package net.minecraft.server;
import java.util.List;
import org.bukkit.craftbukkit.event.CraftEventFactory;
public class EntitySnowman extends EntityGolem {
public EntitySnowman(World world) {
super(world);
this.texture = "/mob/snowman.png";
this.b(0.4F, 1.8F);
}
public int getMaxHealth() {
return 4;
}
public void d() {
super.d();
if (this.target == null && !this.D() && this.world.random.nextInt(100) == 0) {
List list = this.world.a(EntityMonster.class, AxisAlignedBB.b(this.locX, this.locY, this.locZ, this.locX + 1.0D, this.locY + 1.0D, this.locZ + 1.0D).b(16.0D, 4.0D, 16.0D));
if (!list.isEmpty()) {
this.setTarget((Entity) list.get(this.world.random.nextInt(list.size())));
}
}
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
if (this.world.getWorldChunkManager().a(i, j, k) > 1.0F) {
this.damageEntity(DamageSource.BURN, 1);
}
for (i = 0; i < 4; ++i) {
j = MathHelper.floor(this.locX + (double) ((float) (i % 2 * 2 - 1) * 0.25F));
k = MathHelper.floor(this.locY);
int l = MathHelper.floor(this.locZ + (double) ((float) (i / 2 % 2 * 2 - 1) * 0.25F));
if (this.world.getTypeId(j, k, l) == 0 && this.world.getWorldChunkManager().a(j, k, l) < 0.8F && Block.SNOW.canPlace(this.world, j, k, l)) {
this.world.setTypeId(j, k, l, Block.SNOW.id);
}
}
}
protected void a(Entity entity, float f) {
if (f < 10.0F) {
double d0 = entity.locX - this.locX;
double d1 = entity.locZ - this.locZ;
if (this.attackTicks == 0) {
EntitySnowball entitysnowball = new EntitySnowball(this.world, this);
double d2 = entity.locY + (double) entity.x() - 1.100000023841858D - entitysnowball.locY;
float f1 = MathHelper.a(d0 * d0 + d1 * d1) * 0.2F;
this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.random.nextFloat() * 0.4F + 0.8F));
this.world.addEntity(entitysnowball);
entitysnowball.a(d0, d2 + (double) f1, d1, 1.6F, 12.0F);
this.attackTicks = 10;
}
this.yaw = (float) (Math.atan2(d1, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
this.e = true;
}
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
}
protected int e() {
return Item.SNOW_BALL.id;
}
protected void a(boolean flag, int i) {
// CraftBukkit start
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(16);
if (j > 0) {
loot.add(new org.bukkit.inventory.ItemStack(Item.SNOW_BALL.id, j));
}
CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
}