Archiviert
13
0

Added EntityIronGolem and EntityOcelot for diff visibility.

Dieser Commit ist enthalten in:
aPunch 2012-03-05 16:23:13 -06:00 committet von EvilSeph
Ursprung a029f32ccd
Commit 1c641ed982
2 geänderte Dateien mit 373 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,168 @@
package net.minecraft.server;
public class EntityIronGolem extends EntityGolem {
private int b = 0;
Village a = null;
private int c;
private int g;
public EntityIronGolem(World world) {
super(world);
this.texture = "/mob/villager_golem.png";
this.b(1.4F, 2.9F);
this.ak().a(true);
this.goalSelector.a(1, new PathfinderGoalMeleeAttack(this, 0.25F, true));
this.goalSelector.a(2, new PathfinderGoalMoveTowardsTarget(this, 0.22F, 32.0F));
this.goalSelector.a(3, new PathfinderGoalMoveThroughVillage(this, 0.16F, true));
this.goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(this, 0.16F));
this.goalSelector.a(5, new PathfinderGoalOfferFlower(this));
this.goalSelector.a(6, new PathfinderGoalRandomStroll(this, 0.16F));
this.goalSelector.a(7, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalDefendVillage(this));
this.targetSelector.a(2, new PathfinderGoalHurtByTarget(this, false));
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget(this, EntityMonster.class, 16.0F, 0, false, true));
}
protected void b() {
super.b();
this.datawatcher.a(16, Byte.valueOf((byte) 0));
}
public boolean c_() {
return true;
}
protected void g() {
if (--this.b <= 0) {
this.b = 70 + this.random.nextInt(50);
this.a = this.world.villages.getClosestVillage(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ), 32);
if (this.a == null) {
this.aw();
} else {
ChunkCoordinates chunkcoordinates = this.a.getCenter();
this.b(chunkcoordinates.x, chunkcoordinates.y, chunkcoordinates.z, this.a.getSize());
}
}
super.g();
}
public int getMaxHealth() {
return 100;
}
protected int b_(int i) {
return i;
}
public void e() {
super.e();
if (this.c > 0) {
--this.c;
}
if (this.g > 0) {
--this.g;
}
if (this.motX * this.motX + this.motZ * this.motZ > 2.500000277905201E-7D && this.random.nextInt(5) == 0) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.locY - 0.20000000298023224D - (double) this.height);
int k = MathHelper.floor(this.locZ);
int l = this.world.getTypeId(i, j, k);
if (l > 0) {
this.world.a("tilecrack_" + l, this.locX + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, this.boundingBox.b + 0.1D, this.locZ + ((double) this.random.nextFloat() - 0.5D) * (double) this.width, 4.0D * ((double) this.random.nextFloat() - 0.5D), 0.5D, ((double) this.random.nextFloat() - 0.5D) * 4.0D);
}
}
}
public boolean a(Class oclass) {
return this.n_() && EntityHuman.class.isAssignableFrom(oclass) ? false : super.a(oclass);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setBoolean("PlayerCreated", this.n_());
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.b(nbttagcompound.getBoolean("PlayerCreated"));
}
public boolean a(Entity entity) {
this.c = 10;
this.world.broadcastEntityEffect(this, (byte) 4);
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), 7 + this.random.nextInt(15));
if (flag) {
entity.motY += 0.4000000059604645D;
}
this.world.makeSound(this, "mob.irongolem.throw", 1.0F, 1.0F);
return flag;
}
public Village l_() {
return this.a;
}
public void a(boolean flag) {
this.g = flag ? 400 : 0;
this.world.broadcastEntityEffect(this, (byte) 11);
}
protected String i() {
return "none";
}
protected String j() {
return "mob.irongolem.hit";
}
protected String k() {
return "mob.irongolem.death";
}
protected void a(int i, int j, int k, int l) {
this.world.makeSound(this, "mob.irongolem.walk", 1.0F, 1.0F);
}
protected void dropDeathLoot(boolean flag, int i) {
int j = this.random.nextInt(3);
int k;
for (k = 0; k < j; ++k) {
this.b(Block.RED_ROSE.id, 1);
}
k = 3 + this.random.nextInt(3);
for (int l = 0; l < k; ++l) {
this.b(Item.IRON_INGOT.id, 1);
}
}
public int m_() {
return this.g;
}
public boolean n_() {
return (this.datawatcher.getByte(16) & 1) != 0;
}
public void b(boolean flag) {
byte b0 = this.datawatcher.getByte(16);
if (flag) {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 1)));
} else {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -2)));
}
}
}

Datei anzeigen

@ -0,0 +1,205 @@
package net.minecraft.server;
public class EntityOcelot extends EntityTameableAnimal {
private PathfinderGoalTempt b;
public EntityOcelot(World world) {
super(world);
this.texture = "/mob/ozelot.png";
this.b(0.6F, 0.8F);
this.ak().a(true);
this.goalSelector.a(1, new PathfinderGoalFloat(this));
this.goalSelector.a(2, this.a);
this.goalSelector.a(3, this.b = new PathfinderGoalTempt(this, 0.18F, Item.RAW_FISH.id, true));
this.goalSelector.a(4, new PathfinderGoalAvoidPlayer(this, EntityHuman.class, 16.0F, 0.23F, 0.4F));
this.goalSelector.a(5, new PathfinderGoalFollowOwner(this, 0.3F, 10.0F, 5.0F));
this.goalSelector.a(6, new PathfinderGoalLeapAtTarget(this, 0.3F));
this.goalSelector.a(7, new PathfinderGoalOzelotAttack(this));
this.goalSelector.a(8, new PathfinderGoalBreed(this, 0.23F));
this.goalSelector.a(9, new PathfinderGoalRandomStroll(this, 0.23F));
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 10.0F));
this.targetSelector.a(1, new PathfinderGoalRandomTargetNonTamed(this, EntityChicken.class, 14.0F, 750, false));
}
protected void b() {
super.b();
this.datawatcher.a(18, Byte.valueOf((byte) 0));
}
public void g() {
if (!this.getControllerMove().a()) {
this.setSneak(false);
this.setSprinting(false);
} else {
float f = this.getControllerMove().b();
if (f == 0.18F) {
this.setSneak(true);
this.setSprinting(false);
} else if (f == 0.4F) {
this.setSneak(false);
this.setSprinting(true);
} else {
this.setSneak(false);
this.setSprinting(false);
}
}
}
protected boolean n() {
return !this.isTamed();
}
public boolean c_() {
return true;
}
public int getMaxHealth() {
return 10;
}
protected void a(float f) {}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setInt("CatType", this.getCatType());
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setCatType(nbttagcompound.getInt("CatType"));
}
protected String i() {
return this.isTamed() ? (this.r_() ? "mob.cat.purr" : (this.random.nextInt(4) == 0 ? "mob.cat.purreow" : "mob.cat.meow")) : "";
}
protected String j() {
return "mob.cat.hitt";
}
protected String k() {
return "mob.cat.hitt";
}
protected float p() {
return 0.4F;
}
protected int getLootId() {
return Item.LEATHER.id;
}
public boolean a(Entity entity) {
return entity.damageEntity(DamageSource.mobAttack(this), 3);
}
public boolean damageEntity(DamageSource damagesource, int i) {
this.a.a(false);
return super.damageEntity(damagesource, i);
}
protected void dropDeathLoot(boolean flag, int i) {}
public boolean b(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (!this.isTamed()) {
if (this.b.f() && itemstack != null && itemstack.id == Item.RAW_FISH.id && entityhuman.j(this) < 9.0D) {
--itemstack.count;
if (itemstack.count <= 0) {
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
}
if (!this.world.isStatic) {
if (this.random.nextInt(3) == 0) {
this.setTamed(true);
this.setCatType(1 + this.world.random.nextInt(3));
this.setOwnerName(entityhuman.name);
this.a(true);
this.a.a(true);
this.world.broadcastEntityEffect(this, (byte) 7);
} else {
this.a(false);
this.world.broadcastEntityEffect(this, (byte) 6);
}
}
}
return true;
} else {
if (entityhuman.name.equalsIgnoreCase(this.getOwnerName()) && !this.world.isStatic && !this.a(itemstack)) {
this.a.a(!this.isSitting());
}
return super.b(entityhuman);
}
}
public EntityAnimal createChild(EntityAnimal entityanimal) {
EntityOcelot entityocelot = new EntityOcelot(this.world);
if (this.isTamed()) {
entityocelot.setOwnerName(this.getOwnerName());
entityocelot.setTamed(true);
entityocelot.setCatType(this.getCatType());
}
return entityocelot;
}
public boolean a(ItemStack itemstack) {
return itemstack != null && itemstack.id == Item.RAW_FISH.id;
}
public boolean mate(EntityAnimal entityanimal) {
if (entityanimal == this) {
return false;
} else if (!this.isTamed()) {
return false;
} else if (!(entityanimal instanceof EntityOcelot)) {
return false;
} else {
EntityOcelot entityocelot = (EntityOcelot) entityanimal;
return !entityocelot.isTamed() ? false : this.r_() && entityocelot.r_();
}
}
public int getCatType() {
return this.datawatcher.getByte(18);
}
public void setCatType(int i) {
this.datawatcher.watch(18, Byte.valueOf((byte) i));
}
public boolean canSpawn() {
if (this.world.random.nextInt(3) == 0) {
return false;
} else {
if (this.world.containsEntity(this.boundingBox) && this.world.getCubes(this, this.boundingBox).size() == 0 && !this.world.containsLiquid(this.boundingBox)) {
int i = MathHelper.floor(this.locX);
int j = MathHelper.floor(this.boundingBox.b);
int k = MathHelper.floor(this.locZ);
if (j < 63) {
return false;
}
int l = this.world.getTypeId(i, j - 1, k);
if (l == Block.GRASS.id || l == Block.LEAVES.id) {
return true;
}
}
return false;
}
}
public String getLocalizedName() {
return this.isTamed() ? "entity.Cat.name" : super.getLocalizedName();
}
}