3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-17 21:40:08 +01:00
Paper/src/main/java/net/minecraft/server/EntitySheep.java

131 Zeilen
4.1 KiB
Java

package net.minecraft.server;
import java.util.Random;
import org.bukkit.craftbukkit.event.CraftEventFactory;
public class EntitySheep extends EntityAnimal {
public static final float[][] a = new float[][] { { 1.0F, 1.0F, 1.0F}, { 0.95F, 0.7F, 0.2F}, { 0.9F, 0.5F, 0.85F}, { 0.6F, 0.7F, 0.95F}, { 0.9F, 0.9F, 0.2F}, { 0.5F, 0.8F, 0.1F}, { 0.95F, 0.7F, 0.8F}, { 0.3F, 0.3F, 0.3F}, { 0.6F, 0.6F, 0.6F}, { 0.3F, 0.6F, 0.7F}, { 0.7F, 0.4F, 0.9F}, { 0.2F, 0.4F, 0.8F}, { 0.5F, 0.4F, 0.3F}, { 0.4F, 0.5F, 0.2F}, { 0.8F, 0.3F, 0.3F}, { 0.1F, 0.1F, 0.1F}};
public EntitySheep(World world) {
super(world);
this.texture = "/mob/sheep.png";
this.b(0.9F, 1.3F);
}
2011-11-20 09:01:14 +01:00
public int getMaxHealth() {
return 8;
}
protected void b() {
super.b();
this.datawatcher.a(16, new Byte((byte) 0));
}
protected void dropDeathLoot(boolean flag, int i) {
// CraftBukkit start - whole method
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
if (!this.isSheared()) {
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.WOOL, 1, (short) 0, (byte) this.getColor()));
}
CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
2011-11-20 09:01:14 +01:00
protected int e() {
return Block.WOOL.id;
}
2011-09-15 02:23:52 +02:00
public boolean b(EntityHuman entityhuman) {
ItemStack itemstack = entityhuman.inventory.getItemInHand();
if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared()) {
if (!this.world.isStatic) {
this.setSheared(true);
int i = 2 + this.random.nextInt(3);
for (int j = 0; j < i; ++j) {
EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);
entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
}
}
itemstack.damage(1, entityhuman);
}
2011-11-20 09:01:14 +01:00
return super.b(entityhuman);
}
public void b(NBTTagCompound nbttagcompound) {
super.b(nbttagcompound);
nbttagcompound.setBoolean("Sheared", this.isSheared());
nbttagcompound.setByte("Color", (byte) this.getColor());
}
public void a(NBTTagCompound nbttagcompound) {
super.a(nbttagcompound);
this.setSheared(nbttagcompound.getBoolean("Sheared"));
this.setColor(nbttagcompound.getByte("Color"));
}
2011-11-20 09:01:14 +01:00
protected String c_() {
return "mob.sheep";
}
2011-11-20 09:01:14 +01:00
protected String m() {
return "mob.sheep";
}
2011-11-20 09:01:14 +01:00
protected String n() {
return "mob.sheep";
}
public int getColor() {
return this.datawatcher.getByte(16) & 15;
}
public void setColor(int i) {
byte b0 = this.datawatcher.getByte(16);
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & 240 | i & 15)));
}
public boolean isSheared() {
return (this.datawatcher.getByte(16) & 16) != 0;
}
public void setSheared(boolean flag) {
byte b0 = this.datawatcher.getByte(16);
if (flag) {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 | 16)));
} else {
this.datawatcher.watch(16, Byte.valueOf((byte) (b0 & -17)));
}
}
public static int a(Random random) {
int i = random.nextInt(100);
return i < 5 ? 15 : (i < 10 ? 7 : (i < 15 ? 8 : (i < 18 ? 12 : (random.nextInt(500) == 0 ? 6 : 0))));
}
2011-11-20 09:01:14 +01:00
protected EntityAnimal createChild(EntityAnimal entityanimal) {
EntitySheep entitysheep = (EntitySheep) entityanimal;
EntitySheep entitysheep1 = new EntitySheep(this.world);
if (this.random.nextBoolean()) {
entitysheep1.setColor(this.getColor());
} else {
entitysheep1.setColor(entitysheep.getColor());
}
return entitysheep1;
}
}