2011-11-26 01:56:11 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
import java.util.List;
|
2012-01-15 10:11:21 +01:00
|
|
|
// Craftbukkit start
|
|
|
|
import org.bukkit.block.BlockState;
|
2011-11-26 01:56:11 +01:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2012-01-15 10:11:21 +01:00
|
|
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
|
|
|
// Craftbukkit end
|
2011-11-26 01:56:11 +01:00
|
|
|
|
|
|
|
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();
|
2012-01-12 23:10:13 +01:00
|
|
|
if (this.target == null && !this.E() && this.world.random.nextInt(100) == 0) {
|
2012-01-12 16:27:39 +01:00
|
|
|
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).grow(16.0D, 4.0D, 16.0D));
|
2011-11-26 01:56:11 +01:00
|
|
|
|
|
|
|
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)) {
|
2012-01-15 10:11:21 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
BlockState blockState = this.world.getWorld().getBlockAt(j, k, l).getState();
|
|
|
|
blockState.setTypeId(Block.SNOW.id);
|
|
|
|
|
|
|
|
EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if(!event.isCancelled()) {
|
|
|
|
blockState.update(true);
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2012-01-12 23:10:13 +01:00
|
|
|
double d2 = entity.locY + (double) entity.y() - 1.100000023841858D - entitysnowball.locY;
|
2011-11-26 01:56:11 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-11-30 00:17:43 +01:00
|
|
|
protected void dropDeathLoot(boolean flag, int i) {
|
2011-11-26 01:56:11 +01:00
|
|
|
// 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
|
|
|
|
}
|
2012-01-15 10:11:21 +01:00
|
|
|
}
|