本文整理汇总了Java中net.minecraft.entity.passive.EntityAnimal.func_146082_f方法的典型用法代码示例。如果您正苦于以下问题:Java EntityAnimal.func_146082_f方法的具体用法?Java EntityAnimal.func_146082_f怎么用?Java EntityAnimal.func_146082_f使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.passive.EntityAnimal
的用法示例。
在下文中一共展示了EntityAnimal.func_146082_f方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityCollidedWithBlock
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entity) {
if (this.rand.nextInt(5) > 0) {
return;
}
if (entity instanceof EntityAnimal) {
final EntityAnimal animal = (EntityAnimal)entity;
if (animal.getGrowingAge() < 0) {
animal.addGrowth(this.rand.nextInt(40));
}
else if (animal.getGrowingAge() > 0) {
int j = animal.getGrowingAge();
j -= this.rand.nextInt(40);
if (j < 0) {
j = 0;
}
animal.setGrowingAge(j);
}
else if (!animal.isInLove()) {
if (world.getEntitiesWithinAABB((Class)entity.getClass(), entity.boundingBox.expand(8.0, 8.0, 8.0)).size() > 32) {
return;
}
animal.func_146082_f((EntityPlayer)null);
}
}
}
示例2: entityInteract
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = false)
public void entityInteract(final EntityInteractEvent event) {
if(event.entityPlayer instanceof EntityPlayerMP && event.target instanceof EntityAnimal) {
final EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
final ItemStack heldItem = player.getCurrentEquippedItem();
if(heldItem != null) {
final EntityAnimal animal = (EntityAnimal)event.target;
if(canBreed(animal, player)) {
final Set<ItemStackKey> possibleFood = foodItems.get(event.target.getClass());
if(possibleFood != null && possibleFood.contains(ItemStackKey.getCachedKey(heldItem))) {
if (!event.entityPlayer.capabilities.isCreativeMode) {
heldItem.stackSize--;
if (heldItem.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
animal.func_146082_f(player);
}
}
}
}
}
示例3: callMethod
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
if (!Config.enableFeederTurtle)
throw new LuaException("Feeder Turtles have been disabled");
if (method == 0) {
ItemStack curItem = turtle.getInventory().getStackInSlot(turtle.getSelectedSlot());
if (curItem == null || curItem.stackSize <= 0)
return new Object[] {false};
ChunkCoordinates pos = turtle.getPosition();
for (EntityAnimal animal : (List<EntityAnimal>)turtle.getWorld().getEntitiesWithinAABB(EntityAnimal.class, AxisAlignedBB.getBoundingBox(pos.posX - 1.5D, pos.posY - 1.5D, pos.posZ - 1.5D, pos.posX + 1.5D, pos.posY + 1.5D, pos.posZ + 1.5D))) {
if (animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(curItem)) {
animal.setTarget(null);
animal.func_146082_f(null);//setting inLove to 600
curItem.stackSize--;
if (curItem.stackSize <= 0)
turtle.getInventory().setInventorySlotContents(turtle.getSelectedSlot(), null);
else
turtle.getInventory().setInventorySlotContents(turtle.getSelectedSlot(), curItem);
return new Object[]{true};
}
}
return new Object[]{false};
}
return new Object[0];
}
示例4: attackEntity
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
protected ArrayList<ItemStack> attackEntity(ITurtleAccess turtle, Entity entity) throws TurtleFailureAttack {
final IInventory inv = turtle.getInventory();
final int selected = turtle.getSelectedSlot();
final ItemStack currStack = inv.getStackInSlot(selected);
if (currStack == null || currStack.stackSize <= 0) {
throw new TurtleFailureAttack("selected slot empty");
}
final EntityAnimal animal = (EntityAnimal) entity;
if (animal.getGrowingAge() == 0 && !animal.isInLove() && animal.isBreedingItem(currStack)) {
animal.setTarget(null); // remove anything they're following
animal.func_146082_f(null); // set it in love
--currStack.stackSize;
if (currStack.stackSize == 0) {
inv.setInventorySlotContents(selected, null);
}
}
return null;
}
示例5: setAnimalInLove
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private void setAnimalInLove(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
if (!animal.isInLove()) {
animal.func_146082_f(player);
if (!player.capabilities.isCreativeMode)
if (--stack.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
示例6: doSpecial
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
public void doSpecial() {
if (this.coolDown > 0.0 && this.rand.nextInt(40) == 0) {
for (final Object entity : this.worldObj.getEntitiesWithinAABB((Class)EntityAnimal.class, AxisAlignedBB.getBoundingBox((double)this.x(), (double)this.y(), (double)this.z(), (double)(this.x() + 1), (double)(this.y() + 1), (double)(this.z() + 1)).expand(10.0, 10.0, 10.0))) {
final EntityAnimal animal = (EntityAnimal)entity;
if (animal.getGrowingAge() < 0) {
animal.addGrowth(this.rand.nextInt(40));
}
else if (animal.getGrowingAge() > 0) {
int j = animal.getGrowingAge();
j -= this.rand.nextInt(40);
if (j < 0) {
j = 0;
}
animal.setGrowingAge(j);
}
else {
if (animal.isInLove() || this.rand.nextInt(40) != 0) {
continue;
}
if (animal.worldObj.getEntitiesWithinAABB((Class)entity.getClass(), animal.boundingBox.expand(8.0, 8.0, 8.0)).size() > 32) {
return;
}
animal.func_146082_f((EntityPlayer)null);
}
}
}
}
示例7: onApply
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
public void onApply(EntityLivingBase player) {
if (player instanceof EntityAnimal) {
EntityAnimal animal = (EntityAnimal) player;
animal.func_146082_f(null);
}
}
示例8: itemInteractionForEntity
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target) {
if (player.worldObj.isRemote || player.isSneaking() ||
!(target instanceof EntityAnimal))
return false;
InventoryPouch pouch = InventoryPouch.getOrCreate(player, player.inventory.currentItem);
ItemStack item = getNextItem(pouch, null);
if ((item == null) || !PouchAPI.getEntry(item).isFood ||
!((EntityAnimal)target).isBreedingItem(item))
return false;
boolean used = false;
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
target.posX - 2, target.posY - 1, target.posZ - 2,
target.posX + 2, target.posY + 1, target.posZ + 2);
List<EntityAnimal> entities = target.worldObj.getEntitiesWithinAABB(target.getClass(), aabb);
for (EntityAnimal entity : entities) {
if ((item = getNextItem(pouch, item)) == null) break;
if ((entity.getGrowingAge() == 0) && !entity.isInLove() &&
entity.isBreedingItem(item)) {
entity.func_146082_f(player);
item.stackSize--;
item = setLastPouchItem(pouch, item);
used = true;
}
}
return used;
}
示例9: impactLove
import net.minecraft.entity.passive.EntityAnimal; //导入方法依赖的package包/类
private void impactLove(MovingObjectPosition mop, boolean enhanced) {
double RADIUS = enhanced?5.0D:4.0D;
AxisAlignedBB axisalignedbb = super.boundingBox.expand(RADIUS, 2.0D, RADIUS);
List list1 = super.worldObj.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
if(list1 != null && !list1.isEmpty() && !super.worldObj.isRemote) {
EntityLivingBase entityThrower = this.getThrower();
EntityPlayer thrower = entityThrower != null && entityThrower instanceof EntityPlayer?(EntityPlayer)entityThrower:null;
Iterator iterator = list1.iterator();
ArrayList villagers = new ArrayList();
ArrayList zombies = new ArrayList();
while(iterator.hasNext()) {
EntityLiving limit = (EntityLiving)iterator.next();
double zombie = limit.getDistanceSq(super.posX, super.posY, super.posZ);
if(zombie < RADIUS * RADIUS) {
double baby = 1.0D - Math.sqrt(zombie) / RADIUS;
if(limit == mop.entityHit) {
baby = 1.0D;
}
int j = (int)(baby * 400.0D + 0.5D);
if(limit instanceof EntityAnimal) {
EntityAnimal zombie1 = (EntityAnimal)limit;
if(zombie1.getGrowingAge() >= 0) {
zombie1.setGrowingAge(0);
zombie1.func_146082_f((EntityPlayer)null);
}
} else if(limit instanceof EntityVillager) {
EntityVillager var26 = (EntityVillager)limit;
if(var26.getGrowingAge() >= 0) {
villagers.add(var26);
}
} else if(limit instanceof EntityZombie) {
EntityZombie var25 = (EntityZombie)limit;
if(!var25.isChild() && thrower != null) {
NBTTagCompound nbt = var25.getEntityData();
if(PotionEnslaved.isMobEnslavedBy(var25, thrower)) {
zombies.add(var25);
}
}
}
}
}
int var20 = 10;
while(villagers.size() > 1 && var20-- > 0) {
EntityVillager var22 = (EntityVillager)villagers.get(0);
EntityVillager mate = (EntityVillager)villagers.get(1);
var22.setPosition(mate.posX, mate.posY, mate.posZ);
ParticleEffect.HEART.send(SoundEffect.NONE, mate, 1.0D, 2.0D, 8);
this.giveBirth(var22, mate);
villagers.remove(0);
villagers.remove(0);
}
var20 = 10;
while(zombies.size() > 1 && var20-- > 0) {
EntityZombie var21 = (EntityZombie)zombies.get(0);
EntityZombie var23 = (EntityZombie)zombies.get(1);
var21.setPosition(var23.posX, var23.posY, var23.posZ);
ParticleEffect.HEART.send(SoundEffect.NONE, var23, 1.0D, 2.0D, 8);
var21.setVillager(true);
var23.setVillager(true);
EntityZombie var24 = new EntityZombie(super.worldObj);
var24.setLocationAndAngles(var23.posX, var23.posY, var23.posZ, 0.0F, 0.0F);
var24.setChild(true);
super.worldObj.spawnEntityInWorld(var24);
zombies.remove(0);
zombies.remove(0);
}
}
}