2012-01-15 10:41:41 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
public class ItemMonsterEgg extends Item {
|
|
|
|
|
|
|
|
public ItemMonsterEgg(int i) {
|
|
|
|
super(i);
|
|
|
|
this.a(true);
|
2012-07-29 09:33:13 +02:00
|
|
|
this.a(CreativeModeTab.f);
|
2012-01-15 10:41:41 +01:00
|
|
|
}
|
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public String l(ItemStack itemstack) {
|
2012-10-25 05:53:23 +02:00
|
|
|
String s = ("" + LocaleI18n.get(this.getName() + ".name")).trim();
|
2012-11-06 13:05:28 +01:00
|
|
|
String s1 = EntityTypes.b(itemstack.getData());
|
2012-10-25 05:53:23 +02:00
|
|
|
|
|
|
|
if (s1 != null) {
|
|
|
|
s = s + " " + LocaleI18n.get("entity." + s1 + ".name");
|
|
|
|
}
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public boolean interactWith(ItemStack itemstack, EntityHuman entityhuman, World world, int i, int j, int k, int l, float f, float f1, float f2) {
|
2012-10-25 05:53:23 +02:00
|
|
|
if (world.isStatic || itemstack.getData() == 48 || itemstack.getData() == 49 || itemstack.getData() == 63 || itemstack.getData() == 64) { // CraftBukkit
|
2012-01-15 10:41:41 +01:00
|
|
|
return true;
|
|
|
|
} else {
|
2012-03-01 11:49:23 +01:00
|
|
|
int i1 = world.getTypeId(i, j, k);
|
|
|
|
|
2012-01-15 10:41:41 +01:00
|
|
|
i += Facing.b[l];
|
|
|
|
j += Facing.c[l];
|
|
|
|
k += Facing.d[l];
|
2012-03-01 11:49:23 +01:00
|
|
|
double d0 = 0.0D;
|
2012-01-15 10:41:41 +01:00
|
|
|
|
2012-11-06 13:05:28 +01:00
|
|
|
if (l == 1 && Block.byId[i1] != null && Block.byId[i1].d() == 11) {
|
2012-03-01 11:49:23 +01:00
|
|
|
d0 = 0.5D;
|
|
|
|
}
|
2012-01-15 10:41:41 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
Entity entity = a(world, itemstack.getData(), (double) i + 0.5D, (double) j + d0, (double) k + 0.5D);
|
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
if (entity instanceof EntityLiving && itemstack.hasName()) {
|
2013-07-01 13:03:00 +02:00
|
|
|
((EntityInsentient) entity).setCustomName(itemstack.getName());
|
2013-03-13 23:33:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
2012-01-15 10:41:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
|
2013-07-01 13:03:00 +02:00
|
|
|
public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
|
|
|
|
if (world.isStatic) {
|
|
|
|
return itemstack;
|
|
|
|
} else {
|
|
|
|
MovingObjectPosition movingobjectposition = this.a(world, entityhuman, true);
|
|
|
|
|
|
|
|
if (movingobjectposition == null) {
|
|
|
|
return itemstack;
|
|
|
|
} else {
|
|
|
|
if (movingobjectposition.type == EnumMovingObjectType.TILE) {
|
|
|
|
int i = movingobjectposition.b;
|
|
|
|
int j = movingobjectposition.c;
|
|
|
|
int k = movingobjectposition.d;
|
|
|
|
|
|
|
|
if (!world.a(entityhuman, i, j, k)) {
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!entityhuman.a(i, j, k, movingobjectposition.face, itemstack)) {
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (world.getMaterial(i, j, k) == Material.WATER) {
|
|
|
|
Entity entity = a(world, itemstack.getData(), (double) i, (double) j, (double) k);
|
|
|
|
|
|
|
|
if (entity != null) {
|
|
|
|
if (entity instanceof EntityLiving && itemstack.hasName()) {
|
|
|
|
((EntityInsentient) entity).setCustomName(itemstack.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
|
|
|
--itemstack.count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
public static Entity a(World world, int i, double d0, double d1, double d2) {
|
2012-03-01 11:49:23 +01:00
|
|
|
if (!EntityTypes.a.containsKey(Integer.valueOf(i))) {
|
2012-10-25 05:53:23 +02:00
|
|
|
return null;
|
2012-03-01 11:49:23 +01:00
|
|
|
} else {
|
2012-10-25 05:53:23 +02:00
|
|
|
Entity entity = null;
|
2012-07-29 09:33:13 +02:00
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
for (int j = 0; j < 1; ++j) {
|
|
|
|
entity = EntityTypes.a(i, world);
|
2012-12-20 05:03:52 +01:00
|
|
|
if (entity != null && entity instanceof EntityLiving) {
|
2013-07-01 13:03:00 +02:00
|
|
|
EntityInsentient entityinsentient = (EntityInsentient) entity;
|
2012-12-20 05:03:52 +01:00
|
|
|
|
|
|
|
entity.setPositionRotation(d0, d1, d2, MathHelper.g(world.random.nextFloat() * 360.0F), 0.0F);
|
2013-07-01 13:03:00 +02:00
|
|
|
entityinsentient.aP = entityinsentient.yaw;
|
|
|
|
entityinsentient.aN = entityinsentient.yaw;
|
|
|
|
entityinsentient.a((GroupDataEntity) null);
|
2012-10-25 05:53:23 +02:00
|
|
|
world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
|
2013-07-01 13:03:00 +02:00
|
|
|
entityinsentient.p();
|
2012-07-29 09:33:13 +02:00
|
|
|
}
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
|
2012-10-25 05:53:23 +02:00
|
|
|
return entity;
|
2012-03-01 11:49:23 +01:00
|
|
|
}
|
|
|
|
}
|
2012-02-29 22:31:04 +01:00
|
|
|
}
|