2011-11-26 01:56:11 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-01-28 00:23:16 +01:00
|
|
|
// CraftBukkit start
|
2013-04-10 05:25:06 +02:00
|
|
|
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
2013-11-04 14:07:38 +01:00
|
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
2012-01-15 10:11:21 +01:00
|
|
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
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);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(0.4F, 1.8F);
|
|
|
|
this.getNavigation().a(true);
|
2013-07-01 13:03:00 +02:00
|
|
|
this.goalSelector.a(1, new PathfinderGoalArrowAttack(this, 1.25D, 20, 10.0F));
|
|
|
|
this.goalSelector.a(2, new PathfinderGoalRandomStroll(this, 1.0D));
|
2012-03-01 11:49:23 +01:00
|
|
|
this.goalSelector.a(3, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
|
|
|
|
this.goalSelector.a(4, new PathfinderGoalRandomLookaround(this));
|
2013-07-01 13:03:00 +02:00
|
|
|
this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityInsentient.class, 0, true, false, IMonster.a));
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public boolean bk() {
|
2012-03-01 11:49:23 +01:00
|
|
|
return true;
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected void aD() {
|
|
|
|
super.aD();
|
2013-07-09 01:43:37 +02:00
|
|
|
this.getAttributeInstance(GenericAttributes.a).setValue(4.0D);
|
|
|
|
this.getAttributeInstance(GenericAttributes.d).setValue(0.20000000298023224D);
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
public void e() {
|
|
|
|
super.e();
|
|
|
|
int i = MathHelper.floor(this.locX);
|
|
|
|
int j = MathHelper.floor(this.locY);
|
|
|
|
int k = MathHelper.floor(this.locZ);
|
|
|
|
|
|
|
|
if (this.L()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.damageEntity(DamageSource.DROWN, 1.0F);
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
if (this.world.getBiome(i, k).a(i, j, k) > 1.0F) {
|
2013-07-01 13:03:00 +02:00
|
|
|
this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
for (int l = 0; l < 4; ++l) {
|
|
|
|
i = MathHelper.floor(this.locX + (double) ((float) (l % 2 * 2 - 1) * 0.25F));
|
|
|
|
j = MathHelper.floor(this.locY);
|
|
|
|
k = MathHelper.floor(this.locZ + (double) ((float) (l / 2 % 2 * 2 - 1) * 0.25F));
|
|
|
|
if (this.world.getType(i, j, k).getMaterial() == Material.AIR && this.world.getBiome(i, k).a(i, j, k) < 0.8F && Blocks.SNOW.canPlace(this.world, i, j, k)) {
|
2012-01-15 10:11:21 +01:00
|
|
|
// CraftBukkit start
|
2013-12-04 21:10:54 +01:00
|
|
|
org.bukkit.block.BlockState blockState = this.world.getWorld().getBlockAt(i, j, k).getState();
|
2013-11-04 14:07:38 +01:00
|
|
|
blockState.setType(CraftMagicNumbers.getMaterial(Blocks.SNOW));
|
2012-01-15 10:11:21 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
protected Item getLoot() {
|
|
|
|
return Items.SNOW_BALL;
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
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) {
|
2013-11-04 14:07:38 +01:00
|
|
|
loot.add(new org.bukkit.inventory.ItemStack(CraftMagicNumbers.getMaterial(Items.SNOW_BALL), j));
|
2011-11-26 01:56:11 +01:00
|
|
|
}
|
|
|
|
|
2013-04-10 05:25:06 +02:00
|
|
|
CraftEventFactory.callEntityDeathEvent(this, loot);
|
2011-11-26 01:56:11 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
}
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void a(EntityLiving entityliving, float f) {
|
2012-10-25 05:53:23 +02:00
|
|
|
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;
|
2013-03-13 23:33:27 +01:00
|
|
|
float f1 = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F;
|
2012-10-25 05:53:23 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
entitysnowball.shoot(d0, d1 + (double) f1, d2, 1.6F, 12.0F);
|
2013-11-04 14:07:38 +01:00
|
|
|
this.makeSound("random.bow", 1.0F, 1.0F / (this.aI().nextFloat() * 0.4F + 0.8F));
|
2012-10-25 05:53:23 +02:00
|
|
|
this.world.addEntity(entitysnowball);
|
|
|
|
}
|
2012-02-29 22:31:04 +01:00
|
|
|
}
|