Added missing craftbukkit files.

This commit is contained in:
Jonathan Williams 2013-08-30 20:57:46 -07:00
parent 81f8503180
commit 0f7828092c
4 changed files with 955 additions and 0 deletions

View File

@ -0,0 +1,161 @@
package net.minecraft.server.v1_6_R2;
public class EntityBlaze extends EntityMonster {
private float bp = 0.5F;
private int bq;
private int br;
public EntityBlaze(World world) {
super(world);
this.fireProof = true;
this.b = 10;
}
protected void ay() {
super.ay();
this.getAttributeInstance(GenericAttributes.e).setValue(6.0D);
}
protected void a() {
super.a();
this.datawatcher.a(16, new Byte((byte) 0));
}
protected String r() {
return "mob.blaze.breathe";
}
protected String aN() {
return "mob.blaze.hit";
}
protected String aO() {
return "mob.blaze.death";
}
public float d(float f) {
return 1.0F;
}
public void c() {
if (!this.world.isStatic) {
if (this.F()) {
this.damageEntity(DamageSource.DROWN, 1.0F);
}
--this.bq;
if (this.bq <= 0) {
this.bq = 100;
this.bp = 0.5F + (float) this.random.nextGaussian() * 3.0F;
}
if (this.bN() != null && this.bN().locY + (double) this.bN().getHeadHeight() > this.locY + (double) this.getHeadHeight() + (double) this.bp) {
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 (!Vegetated && !this.onGround && this.motY < 0.0D) {
this.motY *= 0.6D;
}
for (int i = 0; i < 2; ++i) {
this.world.addParticle("largesmoke", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, 0.0D, 0.0D, 0.0D);
}
super.c();
}
protected void a(Entity entity, float f) {
if (Vegetated)
return;
if (this.attackTicks <= 0 && f < 2.0F && entity.boundingBox.e > this.boundingBox.b && entity.boundingBox.b < this.boundingBox.e) {
this.attackTicks = 20;
this.m(entity);
} else if (f < 30.0F) {
double d0 = entity.locX - this.locX;
double d1 = entity.boundingBox.b + (double) (entity.length / 2.0F) - (this.locY + (double) (this.length / 2.0F));
double d2 = entity.locZ - this.locZ;
if (this.attackTicks == 0) {
++this.br;
if (this.br == 1) {
this.attackTicks = 60;
this.a(true);
} else if (this.br <= 4) {
this.attackTicks = 6;
} else {
this.attackTicks = 100;
this.br = 0;
this.a(false);
}
if (this.br > 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.length / 2.0F) + 0.5D;
this.world.addEntity(entitysmallfireball);
}
}
}
this.yaw = (float) (Math.atan2(d2, d0) * 180.0D / 3.1415927410125732D) - 90.0F;
this.bn = true;
}
}
protected void b(float f) {}
protected int getLootId() {
return Item.BLAZE_ROD.id;
}
public boolean isBurning() {
return this.bT();
}
protected void dropDeathLoot(boolean flag, int i) {
if (flag) {
// CraftBukkit start
java.util.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));
}
org.bukkit.craftbukkit.v1_6_R2.event.CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
}
public boolean bT() {
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 i_() {
return true;
}
}

View File

@ -0,0 +1,390 @@
package net.minecraft.server.v1_6_R2;
import java.util.UUID;
// CraftBukkit start
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_6_R2.event.CraftEventFactory;
import org.bukkit.event.entity.EntityTeleportEvent;
// CraftBukkit end
public class EntityEnderman extends EntityMonster {
private static final UUID bp = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
private static final AttributeModifier bq = (new AttributeModifier(bp, "Attacking speed boost", 6.199999809265137D, 0)).a(false);
private static boolean[] br = new boolean[256];
private int bs;
private int bt;
private Entity bu;
private boolean bv;
public EntityEnderman(World world) {
super(world);
this.a(0.6F, 2.9F);
this.Y = 1.0F;
}
protected void ay() {
super.ay();
this.getAttributeInstance(GenericAttributes.a).setValue(40.0D);
this.getAttributeInstance(GenericAttributes.d).setValue(0.30000001192092896D);
this.getAttributeInstance(GenericAttributes.e).setValue(7.0D);
}
protected void a() {
super.a();
this.datawatcher.a(16, new Byte((byte) 0));
this.datawatcher.a(17, new Byte((byte) 0));
this.datawatcher.a(18, new Byte((byte) 0));
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setShort("carried", (short) this.getCarriedId());
nbttagcompound.setShort("carriedData", (short) this.getCarriedData());
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setCarriedId(nbttagcompound.getShort("carried"));
this.setCarriedData(nbttagcompound.getShort("carriedData"));
}
protected Entity findTarget() {
if (Vegetated)
return null;
EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 64.0D);
if (entityhuman != null) {
if (this.f(entityhuman)) {
this.bv = true;
if (this.bt == 0) {
this.world.makeSound(entityhuman, "mob.endermen.stare", 1.0F, 1.0F);
}
if (this.bt++ == 5) {
this.bt = 0;
this.a(true);
return entityhuman;
}
} else {
this.bt = 0;
}
}
return null;
}
private boolean f(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.armor[3];
if (itemstack != null && itemstack.id == Block.PUMPKIN.id) {
return false;
} else {
Vec3D vec3d = entityhuman.j(1.0F).a();
Vec3D vec3d1 = this.world.getVec3DPool().create(this.locX - entityhuman.locX, this.boundingBox.b + (double) (this.length / 2.0F) - (entityhuman.locY + (double) entityhuman.getHeadHeight()), this.locZ - entityhuman.locZ);
double d0 = vec3d1.b();
vec3d1 = vec3d1.a();
double d1 = vec3d.b(vec3d1);
return d1 > 1.0D - 0.025D / d0 ? entityhuman.o(this) : false;
}
}
public void c() {
if (this.F()) {
this.damageEntity(DamageSource.DROWN, 1.0F);
}
if (this.bu != this.target) {
AttributeInstance attributeinstance = this.getAttributeInstance(GenericAttributes.d);
attributeinstance.b(bq);
if (this.target != null) {
attributeinstance.a(bq);
}
}
this.bu = this.target;
int i;
if (!this.world.isStatic && this.world.getGameRules().getBoolean("mobGriefing")) {
int j;
int k;
int l;
if (this.getCarriedId() == 0) {
if (this.random.nextInt(20) == 0) {
i = MathHelper.floor(this.locX - 2.0D + this.random.nextDouble() * 4.0D);
j = MathHelper.floor(this.locY + this.random.nextDouble() * 3.0D);
k = MathHelper.floor(this.locZ - 2.0D + this.random.nextDouble() * 4.0D);
l = this.world.getTypeId(i, j, k);
if (br[l]) {
// CraftBukkit start - Pickup event
if (!CraftEventFactory.callEntityChangeBlockEvent(this, this.world.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) {
this.setCarriedId(this.world.getTypeId(i, j, k));
this.setCarriedData(this.world.getData(i, j, k));
this.world.setTypeIdUpdate(i, j, k, 0);
}
// CraftBukkit end
}
}
} else if (this.random.nextInt(2000) == 0) {
i = MathHelper.floor(this.locX - 1.0D + this.random.nextDouble() * 2.0D);
j = MathHelper.floor(this.locY + this.random.nextDouble() * 2.0D);
k = MathHelper.floor(this.locZ - 1.0D + this.random.nextDouble() * 2.0D);
l = this.world.getTypeId(i, j, k);
int i1 = this.world.getTypeId(i, j - 1, k);
if (l == 0 && i1 > 0 && Block.byId[i1].b()) {
// CraftBukkit start - Place event
if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.getCarriedId(), this.getCarriedData()).isCancelled()) {
this.world.setTypeIdAndData(i, j, k, this.getCarriedId(), this.getCarriedData(), 3);
this.setCarriedId(0);
}
// CraftBukkit end
}
}
}
for (i = 0; i < 2; ++i) {
this.world.addParticle("portal", this.locX + (this.random.nextDouble() - 0.5D) * (double) this.width, this.locY + this.random.nextDouble() * (double) this.length - 0.25D, this.locZ + (this.random.nextDouble() - 0.5D) * (double) this.width, (this.random.nextDouble() - 0.5D) * 2.0D, -this.random.nextDouble(), (this.random.nextDouble() - 0.5D) * 2.0D);
}
if (this.world.v() && !this.world.isStatic) {
float f = this.d(1.0F);
if (f > 0.5F && this.world.l(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) && this.random.nextFloat() * 30.0F < (f - 0.4F) * 2.0F) {
this.target = null;
this.a(false);
this.bv = false;
this.bT();
}
}
if (this.F() || this.isBurning()) {
this.target = null;
this.a(false);
this.bv = false;
this.bT();
}
if (this.bX() && !this.bv && this.random.nextInt(100) == 0) {
this.a(false);
}
this.bd = false;
if (this.target != null) {
this.a(this.target, 100.0F, 100.0F);
}
if (!this.world.isStatic && this.isAlive()) {
if (this.target != null) {
if (this.target instanceof EntityHuman && this.f((EntityHuman) this.target)) {
if (this.target.e((Entity) this) < 16.0D) {
this.bT();
}
this.bs = 0;
} else if (this.target.e((Entity) this) > 256.0D && this.bs++ >= 30 && this.c(this.target)) {
this.bs = 0;
}
} else {
this.a(false);
this.bs = 0;
}
}
super.c();
}
protected boolean bT() {
double d0 = this.locX + (this.random.nextDouble() - 0.5D) * 64.0D;
double d1 = this.locY + (double) (this.random.nextInt(64) - 32);
double d2 = this.locZ + (this.random.nextDouble() - 0.5D) * 64.0D;
return this.j(d0, d1, d2);
}
protected boolean c(Entity entity) {
Vec3D vec3d = this.world.getVec3DPool().create(this.locX - entity.locX, this.boundingBox.b + (double) (this.length / 2.0F) - entity.locY + (double) entity.getHeadHeight(), this.locZ - entity.locZ);
vec3d = vec3d.a();
double d0 = 16.0D;
double d1 = this.locX + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.c * d0;
double d2 = this.locY + (double) (this.random.nextInt(16) - 8) - vec3d.d * d0;
double d3 = this.locZ + (this.random.nextDouble() - 0.5D) * 8.0D - vec3d.e * d0;
return this.j(d1, d2, d3);
}
protected boolean j(double d0, double d1, double d2) {
double d3 = this.locX;
double d4 = this.locY;
double d5 = this.locZ;
this.locX = d0;
this.locY = d1;
this.locZ = d2;
boolean flag = false;
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY);
int k = MathHelper.floor(this.locZ);
int l;
if (this.world.isLoaded(i, j, k)) {
boolean flag1 = false;
while (!flag1 && j > 0) {
l = this.world.getTypeId(i, j - 1, k);
if (l != 0 && Block.byId[l].material.isSolid()) {
flag1 = true;
} else {
--this.locY;
--j;
}
}
if (flag1) {
// CraftBukkit start - Teleport event
EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ));
this.world.getServer().getPluginManager().callEvent(teleport);
if (teleport.isCancelled()) {
return false;
}
Location to = teleport.getTo();
this.setPosition(to.getX(), to.getY(), to.getZ());
// CraftBukkit end
if (this.world.getCubes(this, this.boundingBox).isEmpty() && !this.world.containsLiquid(this.boundingBox)) {
flag = true;
}
}
}
if (!flag) {
this.setPosition(d3, d4, d5);
return false;
} else {
short short1 = 128;
for (l = 0; l < short1; ++l) {
double d6 = (double) l / ((double) short1 - 1.0D);
float f = (this.random.nextFloat() - 0.5F) * 0.2F;
float f1 = (this.random.nextFloat() - 0.5F) * 0.2F;
float f2 = (this.random.nextFloat() - 0.5F) * 0.2F;
double d7 = d3 + (this.locX - d3) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D;
double d8 = d4 + (this.locY - d4) * d6 + this.random.nextDouble() * (double) this.length;
double d9 = d5 + (this.locZ - d5) * d6 + (this.random.nextDouble() - 0.5D) * (double) this.width * 2.0D;
this.world.addParticle("portal", d7, d8, d9, (double) f, (double) f1, (double) f2);
}
this.world.makeSound(d3, d4, d5, "mob.endermen.portal", 1.0F, 1.0F);
this.makeSound("mob.endermen.portal", 1.0F, 1.0F);
return true;
}
}
protected String r() {
return this.bX() ? "mob.endermen.scream" : "mob.endermen.idle";
}
protected String aN() {
return "mob.endermen.hit";
}
protected String aO() {
return "mob.endermen.death";
}
protected int getLootId() {
return Item.ENDER_PEARL.id;
}
protected void dropDeathLoot(boolean flag, int i) {
int j = this.getLootId();
if (j > 0) {
// CraftBukkit start - Whole method
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int count = this.random.nextInt(2 + i);
if ((j > 0) && (count > 0)) {
loot.add(new org.bukkit.inventory.ItemStack(j, count));
}
CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
}
public void setCarriedId(int i) {
this.datawatcher.watch(16, Byte.valueOf((byte) (i & 255)));
}
public int getCarriedId() {
return this.datawatcher.getByte(16);
}
public void setCarriedData(int i) {
this.datawatcher.watch(17, Byte.valueOf((byte) (i & 255)));
}
public int getCarriedData() {
return this.datawatcher.getByte(17);
}
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else {
this.a(true);
if (damagesource instanceof EntityDamageSource && damagesource.getEntity() instanceof EntityHuman) {
this.bv = true;
}
if (damagesource instanceof EntityDamageSourceIndirect) {
this.bv = false;
for (int i = 0; i < 64; ++i) {
if (this.bT()) {
return true;
}
}
return false;
} else {
return super.damageEntity(damagesource, f);
}
}
}
public boolean bX() {
return this.datawatcher.getByte(18) > 0;
}
public void a(boolean flag) {
this.datawatcher.watch(18, Byte.valueOf((byte) (flag ? 1 : 0)));
}
static {
br[Block.GRASS.id] = true;
br[Block.DIRT.id] = true;
br[Block.SAND.id] = true;
br[Block.GRAVEL.id] = true;
br[Block.YELLOW_FLOWER.id] = true;
br[Block.RED_ROSE.id] = true;
br[Block.BROWN_MUSHROOM.id] = true;
br[Block.RED_MUSHROOM.id] = true;
br[Block.TNT.id] = true;
br[Block.CACTUS.id] = true;
br[Block.CLAY.id] = true;
br[Block.PUMPKIN.id] = true;
br[Block.MELON.id] = true;
br[Block.MYCEL.id] = true;
}
}

View File

@ -0,0 +1,145 @@
package net.minecraft.server.v1_6_R2;
import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
public abstract class EntityMonster extends EntityCreature implements IMonster {
public boolean Vegetated;
public EntityMonster(World world) {
super(world);
this.b = 5;
}
public void c() {
this.aV();
float f = this.d(1.0F);
if (f > 0.5F) {
this.aV += 2;
}
super.c();
}
public void l_() {
super.l_();
if (!this.world.isStatic && this.world.difficulty == 0) {
this.die();
}
}
protected Entity findTarget() {
EntityHuman entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D);
return entityhuman != null && this.o(entityhuman) ? entityhuman : null;
}
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable()) {
return false;
} else if (super.damageEntity(damagesource, f)) {
Entity entity = damagesource.getEntity();
if (this.passenger != entity && this.vehicle != entity) {
if (entity != this) {
// CraftBukkit start - We still need to call events for entities without goals
if (entity != this.target && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish)) {
EntityTargetEvent event = org.bukkit.craftbukkit.v1_6_R2.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
if (!event.isCancelled()) {
if (event.getTarget() == null) {
this.target = null;
} else {
this.target = ((org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity) event.getTarget()).getHandle();
}
}
} else {
this.target = entity;
}
// CraftBukkit end
}
return true;
} else {
return true;
}
} else {
return false;
}
}
public boolean m(Entity entity) {
float f = (float) this.getAttributeInstance(GenericAttributes.e).getValue();
int i = 0;
if (entity instanceof EntityLiving) {
f += EnchantmentManager.a((EntityLiving) this, (EntityLiving) entity);
i += EnchantmentManager.getKnockbackEnchantmentLevel(this, (EntityLiving) entity);
}
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
if (flag) {
if (i > 0) {
entity.g((double) (-MathHelper.sin(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F), 0.1D, (double) (MathHelper.cos(this.yaw * 3.1415927F / 180.0F) * (float) i * 0.5F));
this.motX *= 0.6D;
this.motZ *= 0.6D;
}
int j = EnchantmentManager.getFireAspectEnchantmentLevel(this);
if (j > 0) {
entity.setOnFire(j * 4);
}
if (entity instanceof EntityLiving) {
EnchantmentThorns.a(this, (EntityLiving) entity, this.random);
}
}
return flag;
}
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.m(entity);
}
}
public float a(int i, int j, int k) {
return 0.5F - this.world.q(i, j, k);
}
protected boolean i_() {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.floor(this.locZ);
if (this.world.b(EnumSkyBlock.SKY, i, j, k) > this.random.nextInt(32)) {
return false;
} else {
int l = this.world.getLightLevel(i, j, k);
if (this.world.P()) {
int i1 = this.world.j;
this.world.j = 10;
l = this.world.getLightLevel(i, j, k);
this.world.j = i1;
}
return l <= this.random.nextInt(8);
}
}
public boolean canSpawn() {
return this.world.difficulty > 0 && this.i_() && super.canSpawn();
}
protected void ay() {
super.ay();
this.aW().b(GenericAttributes.e);
}
}

View File

@ -0,0 +1,259 @@
package net.minecraft.server.v1_6_R2;
// CraftBukkit start
import org.bukkit.craftbukkit.v1_6_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_6_R2.event.CraftEventFactory;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.SlimeSplitEvent;
// CraftBukkit end
public class EntitySlime extends EntityInsentient implements IMonster {
public float h;
public float i;
public float j;
private int jumpDelay;
private Entity lastTarget; // CraftBukkit
public EntitySlime(World world) {
super(world);
int i = 1 << this.random.nextInt(3);
this.height = 0.0F;
this.jumpDelay = this.random.nextInt(20) + 10;
this.setSize(i);
}
protected void a() {
super.a();
this.datawatcher.a(16, new Byte((byte) 1));
}
// CraftBukkit - protected -> public
public void setSize(int i) {
this.datawatcher.watch(16, new Byte((byte) i));
this.a(0.6F * (float) i, 0.6F * (float) i);
this.setPosition(this.locX, this.locY, this.locZ);
this.getAttributeInstance(GenericAttributes.a).setValue((double) (i * i));
this.setHealth(this.getMaxHealth());
this.b = i;
}
public int getSize() {
return this.datawatcher.getByte(16);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setInt("Size", this.getSize() - 1);
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setSize(nbttagcompound.getInt("Size") + 1);
}
protected String bJ() {
return "slime";
}
protected String bP() {
return "mob.slime." + (this.getSize() > 1 ? "big" : "small");
}
public void l_() {
if (!this.world.isStatic && this.world.difficulty == 0 && this.getSize() > 0) {
this.dead = true;
}
this.i += (this.h - this.i) * 0.5F;
this.j = this.i;
boolean flag = this.onGround;
super.l_();
int i;
if (this.onGround && !flag) {
i = this.getSize();
for (int j = 0; j < i * 8; ++j) {
float f = this.random.nextFloat() * 3.1415927F * 2.0F;
float f1 = this.random.nextFloat() * 0.5F + 0.5F;
float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1;
float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1;
this.world.addParticle(this.bJ(), this.locX + (double) f2, this.boundingBox.b, this.locZ + (double) f3, 0.0D, 0.0D, 0.0D);
}
if (this.bQ()) {
this.makeSound(this.bP(), this.aZ(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) / 0.8F);
}
this.h = -0.5F;
} else if (!this.onGround && flag) {
this.h = 1.0F;
}
this.bM();
if (this.world.isStatic) {
i = this.getSize();
this.a(0.6F * (float) i, 0.6F * (float) i);
}
}
protected void bk() {
this.bo();
// CraftBukkit start
Entity entityhuman = this.world.findNearbyVulnerablePlayer(this, 16.0D); // EntityHuman -> Entity
EntityTargetEvent event = null;
if (entityhuman != null && !entityhuman.equals(lastTarget)) {
event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
} else if (lastTarget != null && entityhuman == null) {
event = CraftEventFactory.callEntityTargetEvent(this, entityhuman, EntityTargetEvent.TargetReason.FORGOT_TARGET);
}
if (event != null && !event.isCancelled()) {
entityhuman = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle();
}
this.lastTarget = entityhuman;
// CraftBukkit end
if (entityhuman != null) {
this.a(entityhuman, 10.0F, 20.0F);
}
if (this.onGround && this.jumpDelay-- <= 0) {
this.jumpDelay = this.bL();
if (entityhuman != null) {
this.jumpDelay /= 3;
}
this.bd = true;
if (this.bS()) {
this.makeSound(this.bP(), this.aZ(), ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F) * 0.8F);
}
this.be = 1.0F - this.random.nextFloat() * 2.0F;
this.bf = (float) (1 * this.getSize());
} else {
this.bd = false;
if (this.onGround) {
this.be = this.bf = 0.0F;
}
}
}
protected void bM() {
this.h *= 0.6F;
}
protected int bL() {
return this.random.nextInt(20) + 10;
}
protected EntitySlime bK() {
return new EntitySlime(this.world);
}
public void die() {
int i = this.getSize();
if (!this.world.isStatic && i > 1 && this.getHealth() <= 0.0F) {
int j = 2 + this.random.nextInt(3);
// CraftBukkit start
SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
this.world.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled() && event.getCount() > 0) {
j = event.getCount();
} else {
super.die();
return;
}
// CraftBukkit end
for (int k = 0; k < j; ++k) {
float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
EntitySlime entityslime = this.bK();
entityslime.setSize(i / 2);
entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
}
}
super.die();
}
public void b_(EntityHuman entityhuman) {
if (this.bN()) {
int i = this.getSize();
if (this.o(entityhuman) && this.e(entityhuman) < 0.6D * (double) i * 0.6D * (double) i && entityhuman.damageEntity(DamageSource.mobAttack(this), (float) this.bO())) {
this.makeSound("mob.attack", 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
}
}
}
protected boolean bN() {
return this.getSize() > 1;
}
protected int bO() {
return this.getSize();
}
protected String aN() {
return "mob.slime." + (this.getSize() > 1 ? "big" : "small");
}
protected String aO() {
return "mob.slime." + (this.getSize() > 1 ? "big" : "small");
}
protected int getLootId() {
return this.getSize() == 1 ? Item.SLIME_BALL.id : 0;
}
public boolean canSpawn() {
Chunk chunk = this.world.getChunkAtWorldCoords(MathHelper.floor(this.locX), MathHelper.floor(this.locZ));
if (this.world.getWorldData().getType() == WorldType.FLAT && this.random.nextInt(4) != 1) {
return false;
} else {
if (this.getSize() == 1 || this.world.difficulty > 0) {
BiomeBase biomebase = this.world.getBiome(MathHelper.floor(this.locX), MathHelper.floor(this.locZ));
if (biomebase == BiomeBase.SWAMPLAND && this.locY > 50.0D && this.locY < 70.0D && this.random.nextFloat() < 0.5F && this.random.nextFloat() < this.world.x() && this.world.getLightLevel(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ)) <= this.random.nextInt(8)) {
return super.canSpawn();
}
if (this.random.nextInt(10) == 0 && chunk.a(987234911L).nextInt(10) == 0 && this.locY < 40.0D) {
return super.canSpawn();
}
}
return false;
}
}
protected float aZ() {
return 0.4F * (float) this.getSize();
}
public int bp() {
return 0;
}
protected boolean bS() {
return this.getSize() > 0;
}
protected boolean bQ() {
return this.getSize() > 2;
}
}