3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 22:10:10 +01:00
Paper/src/main/java/net/minecraft/server/EntitySnowman.java

97 Zeilen
3.6 KiB
Java

package net.minecraft.server;
2012-01-28 00:23:16 +01:00
// CraftBukkit start
import org.bukkit.event.block.EntityBlockFormEvent;
import org.bukkit.event.entity.EntityDamageEvent;
2012-01-28 00:23:16 +01:00
// CraftBukkit end
public class EntitySnowman extends EntityGolem {
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-03-01 11:49:23 +01:00
this.goalSelector.a(1, new PathfinderGoalArrowAttack(this, 0.25F, 2, 20));
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));
this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget(this, EntityMonster.class, 16.0F, 0, true));
}
2012-07-29 09:33:13 +02:00
public boolean aV() {
2012-03-01 11:49:23 +01:00
return true;
}
public int getMaxHealth() {
return 4;
}
2012-07-29 09:33:13 +02:00
public void d() {
super.d();
if (this.G()) {
// CraftBukkit start
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.DROWNING, 1);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
this.damageEntity(DamageSource.DROWN, event.getDamage());
}
// CraftBukkit end
}
int i = MathHelper.floor(this.locX);
2012-03-01 11:49:23 +01:00
int j = MathHelper.floor(this.locZ);
2012-07-29 09:33:13 +02:00
if (this.world.getBiome(i, j).j() > 1.0F) {
// CraftBukkit start
EntityDamageEvent event = new EntityDamageEvent(this.getBukkitEntity(), EntityDamageEvent.DamageCause.MELTING, 1);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
this.damageEntity(DamageSource.BURN, event.getDamage());
}
// CraftBukkit end
}
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);
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)) {
// CraftBukkit start
org.bukkit.block.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
}
}
}
protected int getLootId() {
return Item.SNOW_BALL.id;
}
protected void dropDeathLoot(boolean flag, int i) {
// 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>();
int j = this.random.nextInt(16);
if (j > 0) {
loot.add(new org.bukkit.inventory.ItemStack(Item.SNOW_BALL.id, j));
}
org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
2012-02-29 22:31:04 +01:00
}