129 lines
3.6 KiB
Java
129 lines
3.6 KiB
Java
|
package net.minecraft.entity.passive;
|
||
|
|
||
|
import net.minecraft.block.Block;
|
||
|
import net.minecraft.entity.EntityAgeable;
|
||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||
|
import net.minecraft.entity.player.EntityPlayer;
|
||
|
import net.minecraft.init.Items;
|
||
|
import net.minecraft.item.Item;
|
||
|
import net.minecraft.item.ItemStack;
|
||
|
import net.minecraft.util.BlockPos;
|
||
|
import net.minecraft.world.World;
|
||
|
|
||
|
/**+
|
||
|
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
||
|
*
|
||
|
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
||
|
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
||
|
*
|
||
|
* EaglercraftX 1.8 patch files are (c) 2022 LAX1DUDE. All Rights Reserved.
|
||
|
*
|
||
|
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
|
||
|
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
|
||
|
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
|
||
|
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
|
||
|
*
|
||
|
* NOT FOR COMMERCIAL OR MALICIOUS USE
|
||
|
*
|
||
|
* (please read the 'LICENSE' file this repo's root directory for more info)
|
||
|
*
|
||
|
*/
|
||
|
public class EntityCow extends EntityAnimal {
|
||
|
public EntityCow(World worldIn) {
|
||
|
super(worldIn);
|
||
|
this.setSize(0.9F, 1.3F);
|
||
|
}
|
||
|
|
||
|
protected void applyEntityAttributes() {
|
||
|
super.applyEntityAttributes();
|
||
|
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
|
||
|
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D);
|
||
|
}
|
||
|
|
||
|
/**+
|
||
|
* Returns the sound this mob makes while it's alive.
|
||
|
*/
|
||
|
protected String getLivingSound() {
|
||
|
return "mob.cow.say";
|
||
|
}
|
||
|
|
||
|
/**+
|
||
|
* Returns the sound this mob makes when it is hurt.
|
||
|
*/
|
||
|
protected String getHurtSound() {
|
||
|
return "mob.cow.hurt";
|
||
|
}
|
||
|
|
||
|
/**+
|
||
|
* Returns the sound this mob makes on death.
|
||
|
*/
|
||
|
protected String getDeathSound() {
|
||
|
return "mob.cow.hurt";
|
||
|
}
|
||
|
|
||
|
protected void playStepSound(BlockPos var1, Block var2) {
|
||
|
this.playSound("mob.cow.step", 0.15F, 1.0F);
|
||
|
}
|
||
|
|
||
|
/**+
|
||
|
* Returns the volume for the sounds this mob makes.
|
||
|
*/
|
||
|
protected float getSoundVolume() {
|
||
|
return 0.4F;
|
||
|
}
|
||
|
|
||
|
protected Item getDropItem() {
|
||
|
return Items.leather;
|
||
|
}
|
||
|
|
||
|
/**+
|
||
|
* Drop 0-2 items of this living's type
|
||
|
*/
|
||
|
protected void dropFewItems(boolean var1, int i) {
|
||
|
int j = this.rand.nextInt(3) + this.rand.nextInt(1 + i);
|
||
|
|
||
|
for (int k = 0; k < j; ++k) {
|
||
|
this.dropItem(Items.leather, 1);
|
||
|
}
|
||
|
|
||
|
j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + i);
|
||
|
|
||
|
for (int l = 0; l < j; ++l) {
|
||
|
if (this.isBurning()) {
|
||
|
this.dropItem(Items.cooked_beef, 1);
|
||
|
} else {
|
||
|
this.dropItem(Items.beef, 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
/**+
|
||
|
* Called when a player interacts with a mob. e.g. gets milk
|
||
|
* from a cow, gets into the saddle on a pig.
|
||
|
*/
|
||
|
public boolean interact(EntityPlayer entityplayer) {
|
||
|
ItemStack itemstack = entityplayer.inventory.getCurrentItem();
|
||
|
if (itemstack != null && itemstack.getItem() == Items.bucket && !entityplayer.capabilities.isCreativeMode
|
||
|
&& !this.isChild()) {
|
||
|
if (itemstack.stackSize-- == 1) {
|
||
|
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem,
|
||
|
new ItemStack(Items.milk_bucket));
|
||
|
} else if (!entityplayer.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket))) {
|
||
|
entityplayer.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
} else {
|
||
|
return super.interact(entityplayer);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public EntityCow createChild(EntityAgeable var1) {
|
||
|
return new EntityCow(this.worldObj);
|
||
|
}
|
||
|
|
||
|
public float getEyeHeight() {
|
||
|
return this.height;
|
||
|
}
|
||
|
}
|