
net.minecraft.server.EntityCow Maven / Gradle / Ivy
package net.minecraft.server;
// CraftBukkit start
import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Cow;
import org.jetbrains.annotations.NotNull;
// CraftBukkit end
public class EntityCow extends EntityAnimal {
public EntityCow(World world) {
super(world);
this.setSize(0.9F, 1.3F);
((Navigation) this.getNavigation()).a(true);
this.goalSelector.addTask(0, new PathfinderGoalFloat(this));
this.goalSelector.addTask(1, new PathfinderGoalPanic(this, 2.0D));
this.goalSelector.addTask(2, new PathfinderGoalBreed(this, 1.0D));
this.goalSelector.addTask(3, new PathfinderGoalTempt(this, 1.25D, Items.WHEAT, false));
this.goalSelector.addTask(4, new PathfinderGoalFollowParent(this, 1.25D));
this.goalSelector.addTask(5, new PathfinderGoalRandomStroll(this, 1.0D));
this.goalSelector.addTask(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
this.goalSelector.addTask(7, new PathfinderGoalRandomLookaround(this));
}
protected void initAttributes() {
super.initAttributes();
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(10.0D);
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(0.20000000298023224D);
}
protected String getLivingSound() {
return "mob.cow.say";
}
protected String getHurtSound() {
return "mob.cow.hurt";
}
@NotNull
@Override
public Cow getEntityBukkit() {
return (Cow) super.getEntityBukkit();
}
protected String getDeathSound() {
return "mob.cow.hurt";
}
protected void playStepSound(BlockPosition pos, Block block) {
this.playSound("mob.cow.step", 0.15F, 1.0F);
}
protected float getSoundVolume() {
return 0.4F;
}
protected Item getLoot() {
return Items.LEATHER;
}
protected void dropDeathLoot(boolean wasRecentlyHit, int lootingModifier) {
int j = this.random.nextInt(3) + this.random.nextInt(1 + lootingModifier);
int k;
for (k = 0; k < j; ++k) {
this.dropItem(Items.LEATHER, 1);
}
j = this.random.nextInt(3) + 1 + this.random.nextInt(1 + lootingModifier);
for (k = 0; k < j; ++k) {
if (this.isBurning()) {
this.dropItem(Items.COOKED_BEEF, 1);
} else {
this.dropItem(Items.BEEF, 1);
}
}
}
public boolean interact(EntityHuman player) {
ItemStack itemstack = player.inventory.getItemInHand();
if (itemstack != null && itemstack.getItem() == Items.BUCKET && !player.abilities.canInstantlyBuild && !this.isBaby()) {
// CraftBukkit start - Got milk?
org.bukkit.Location loc = this.getBukkitEntity().getLocation();
org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, itemstack, Items.MILK_BUCKET);
if (event.isCancelled()) {
return false;
}
ItemStack result = CraftItemStack.asNMSCopy(event.getItemStack());
if (--itemstack.count <= 0) {
player.inventory.setItem(player.inventory.itemInHandIndex, result);
} else if (!player.inventory.pickup(result)) {
player.drop(result, false);
}
// CraftBukkit end
return true;
} else {
return super.interact(player);
}
}
public EntityCow b(EntityAgeable entityageable) {
return new EntityCow(this.world);
}
public float getHeadHeight() {
return this.length;
}
public EntityAgeable createChild(EntityAgeable entityageable) {
return this.b(entityageable);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy