2011-11-26 01:56:11 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-01-28 00:23:16 +01:00
|
|
|
// CraftBukkit start
|
2012-01-15 10:11:21 +01:00
|
|
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
2012-03-14 06:26:23 +01:00
|
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
2012-01-28 00:23:16 +01:00
|
|
|
// CraftBukkit end
|
2011-11-26 01:56:11 +01:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public class EntitySnowman extends EntityGolem implements IRangedEntity {
|
2011-11-26 01:56:11 +01:00
|
|
|
|
|
|
|
public EntitySnowman(World world) {
|
|
|
|
super(world);
|
|
|
|
this.texture = "/mob/snowman.png";
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.4F, 1.8F);
|
|
|
|
this.getNavigation().a(true);
|
2012-10-25 05:53:23 +02:00
|
|
|
this.goalSelector.a(1, new PathfinderGoalArrowAttack(this, 0.25F, 20, 10.0F));
|
2012-03-01 11:49:23 +01:00
|
|
|
this.goalSelector.a(2, new PathfinderGoalRandomStroll(this, 0.2F));
|
|
|
|
this.goalSelector.a(3, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
|
|
|
|
this.goalSelector.a(4, new PathfinderGoalRandomLookaround(this));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityLiving.class, 16.0F, 0, true, false, IMonster.a));
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public boolean bb() {
|
2012-03-01 11:49:23 +01:00
|
|
|
return true;
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxHealth() {
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public void c() {
|
|
|
|
super.c();
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.G()) {
|
2012-07-01 12:04:06 +02:00
|
|
|
// CraftBukkit start
|
2012-03-14 06:29:02 +01:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1);
|
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
2012-07-01 12:04:06 +02:00
|
|
|
event.getEntity().setLastDamageCause(event);
|
2012-03-14 06:29:02 +01:00
|
|
|
this.damageEntity(DamageSource.DROWN, event.getDamage());
|
|
|
|
}
|
2012-07-01 12:04:06 +02:00
|
|
|
// CraftBukkit end
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int i = MathHelper.floor(this.locX);
|
2012-03-01 11:49:23 +01:00
|
|
|
int j = MathHelper.floor(this.locZ);
|
2011-11-26 01:56:11 +01:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.world.getBiome(i, j).j() > 1.0F) {
|
2012-07-01 12:04:06 +02:00
|
|
|
// CraftBukkit start
|
2012-03-22 22:33:33 +01:00
|
|
|
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.MELTING, 1);
|
2012-03-14 06:26:23 +01:00
|
|
|
this.world.getServer().getPluginManager().callEvent(event);
|
|
|
|
|
|
|
|
if (!event.isCancelled()) {
|
2012-07-01 12:04:06 +02:00
|
|
|
event.getEntity().setLastDamageCause(event);
|
2012-03-14 06:26:23 +01:00
|
|
|
this.damageEntity(DamageSource.BURN, event.getDamage());
|
|
|
|
}
|
2012-07-01 12:04:06 +02:00
|
|
|
// CraftBukkit end
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 4; ++i) {
|
|
|
|
j = MathHelper.floor(this.locX + (double) ((float) (i % 2 * 2 - 1) * 0.25F));
|
2012-03-01 11:49:23 +01:00
|
|
|
int k = MathHelper.floor(this.locY);
|
2011-11-26 01:56:11 +01:00
|
|
|
int l = MathHelper.floor(this.locZ + (double) ((float) (i / 2 % 2 * 2 - 1) * 0.25F));
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
if (this.world.getTypeId(j, k, l) == 0 && this.world.getBiome(j, l).j() < 0.8F && Block.SNOW.canPlace(this.world, j, k, l)) {
|
2012-01-15 10:11:21 +01:00
|
|
|
// CraftBukkit start
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(j, k, l).getState();
|
2012-01-15 10:11:21 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-14 21:03:48 +01:00
|
|
|
protected int getLootId() {
|
2011-11-26 01:56:11 +01:00
|
|
|
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
|
2012-07-29 09:33:13 +02:00
|
|
|
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
2011-11-26 01:56:11 +01:00
|
|
|
int j = this.random.nextInt(16);
|
|
|
|
|
|
|
|
if (j > 0) {
|
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(Item.SNOW_BALL.id, j));
|
|
|
|
}
|
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
|
2011-11-26 01:56:11 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
public void d(EntityLiving entityliving) {
|
|
|
|
EntitySnowball entitysnowball = new EntitySnowball(this.world, this);
|
|
|
|
double d0 = entityliving.locX - this.locX;
|
|
|
|
double d1 = entityliving.locY + (double) entityliving.getHeadHeight() - 1.100000023841858D - entitysnowball.locY;
|
|
|
|
double d2 = entityliving.locZ - this.locZ;
|
|
|
|
float f = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F;
|
|
|
|
|
|
|
|
entitysnowball.shoot(d0, d1 + (double) f, d2, 1.6F, 12.0F);
|
|
|
|
this.world.makeSound(this, "random.bow", 1.0F, 1.0F / (this.aA().nextFloat() * 0.4F + 0.8F));
|
|
|
|
this.world.addEntity(entitysnowball);
|
|
|
|
}
|
2012-02-29 22:31:04 +01:00
|
|
|
}
|