當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityAnimal.isInLove方法代碼示例

本文整理匯總了Java中net.minecraft.entity.passive.EntityAnimal.isInLove方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityAnimal.isInLove方法的具體用法?Java EntityAnimal.isInLove怎麽用?Java EntityAnimal.isInLove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.passive.EntityAnimal的用法示例。


在下文中一共展示了EntityAnimal.isInLove方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:26,代碼來源:BlockPureLove.java

示例2: 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];
}
 
開發者ID:austinv11,項目名稱:PeripheralsPlusPlus,代碼行數:26,代碼來源:PeripheralFeeder.java

示例3: 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;
}
 
開發者ID:theoriginalbit,項目名稱:MoarPeripherals,代碼行數:20,代碼來源:UpgradeFeeder.java

示例4: findAnimalToFeed

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
protected EntityAnimal findAnimalToFeed(int n) {
    Point3I point = getPoint(n);
    boundCheck = new AxisAlignedBB(point.getX(), point.getY()-1, point.getZ(), 
            point.getX()+1, point.getY()+2, point.getZ()+1);
    List<EntityAnimal> entities = world.getEntitiesWithinAABB(EntityAnimal.class, boundCheck);
    if (!entities.isEmpty()) {
        for (EntityAnimal animal: entities) {
            if ( (!slots[SLOT_FOOD].isEmpty()) && (animal.isBreedingItem(slots[SLOT_FOOD])) ) {
                if (animal.getGrowingAge() == 0 && !animal.isInLove()) {
                    return animal;
                }
            }
        }
    }
    return null;
}
 
開發者ID:Vanhal,項目名稱:ProgressiveAutomation,代碼行數:17,代碼來源:TileFarmer.java

示例5: work

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;

    AxisAlignedBB area = getWorkingArea();
    List<EntityAnimal> animals = this.world.getEntitiesWithinAABB(EntityAnimal.class, area);
    if (animals.size() == 0 || animals.size() > 35) return 0;
    EntityAnimal animal1 = animals.get(0);
    while ((animal1.isChild() || animal1.getGrowingAge() != 0 || getFirstBreedingItem(animal1).isEmpty() || animal1.isInLove()) && animals.indexOf(animal1) + 1 < animals.size())
        animal1 = animals.get(animals.indexOf(animal1) + 1);
    if (animal1.isChild() || animal1.getGrowingAge() != 0) return 0;
    EntityAnimal animal2 = animals.get(0);
    while ((animal2.equals(animal1) || animal2.isChild() || animal2.getGrowingAge() != 0 || getFirstBreedingItem(animal2).isEmpty() || animal1.isInLove()) && animals.indexOf(animal2) + 1 < animals.size())
        animal2 = animals.get(animals.indexOf(animal2) + 1);
    if (animal2.equals(animal1) || animal2.isChild() || animal2.getGrowingAge() != 0) return 0;
    if (animal1.getClass() != animal2.getClass()) return 0;
    ItemStack stack = getFirstBreedingItem(animal1);
    Item item = stack.getItem();
    stack.setCount(stack.getCount() - 1);
    stack = getFirstBreedingItem(animal2);
    if (stack.isEmpty()) {
        ItemHandlerHelper.insertItem(inFeedItems, new ItemStack(item, 1), false);
        return 0;
    }
    stack.setCount(stack.getCount() - 1);
    animal1.setInLove(null);
    animal2.setInLove(null);

    return 1;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:31,代碼來源:AnimalStockIncreaserTile.java

示例6: 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);
    }
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:9,代碼來源:ServerEventHandler.java

示例7: 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);
            }
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:29,代碼來源:TileEntityGeneratorPink.java

示例8: getAnimals

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
public ArrayList getAnimals( final World world ) {
    final List list = world.getEntitiesWithinAABB( EntityAnimal.class, fairy.boundingBox.expand( 5D, 5D, 5D ) );

    if ( list.size() < 2 ) {
        return null;
    }

    final ArrayList list2 = new ArrayList();

    for ( int i = 0; i < list.size(); i++ ) {
        final EntityAnimal entity1 = (EntityAnimal) list.get( i );

        final int fleeingTick = ReflectionHelper.getPrivateValue(EntityCreature.class, entity1, MCP_FLEEINGTICK);
        if ( fairy.peacefulAnimal( entity1 ) && fairy.canEntityBeSeen( entity1 ) && entity1.getHealth() > 0
                && entity1.getEntityToAttack() == null && fleeingTick <= 0 && !entity1.isInLove()
                && entity1.getGrowingAge() == 0 ) {
            for ( int j = 0; j < list.size(); j++ ) {
                final EntityAnimal entity2 = (EntityAnimal) list.get( j );

                if ( entity1 != entity2 && entity1.getClass() == entity2.getClass()
                        && entity2.getGrowingAge() == 0 ) {
                    list2.add( entity1 );
                }
            }
        }
    }

    if ( list2.size() <= 0 ) {
        return null;
    } else {
        return list2;
    }
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:34,代碼來源:FairyJob.java

示例9: canMateWith

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal mob)
{
    if(hasGenders()){
        if( this.getGender() == 0 && ((EntityIatMob) mob).getGender() == 1){
           	return true;
           }if(this.getGender() == 1 && ((EntityIatMob) mob).getGender() == 0){
           	return true;
           }	
    }
    return mob == this ? false : (mob.getClass() != this.getClass() ? false : this.isInLove() && mob.isInLove());
}
 
開發者ID:Alex-the-666,項目名稱:It-s-About-Time-Minecraft-Mod,代碼行數:15,代碼來源:EntityIatMob.java

示例10: onEntityUpdate

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public void onEntityUpdate() {
    super.onEntityUpdate();
    if (!worldObj.isRemote && worldObj.getTotalWorldTime() % 3 == 0) {
        List<EntityAnimal> nearbyEntities = worldObj.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(posX - 1, posY - 1, posZ - 1, posX + 1, posY + 1, posZ + 1));
        for (EntityAnimal entity : nearbyEntities) {
            if (!entity.isInLove() && entity.getGrowingAge() == 0) {
                entity.setInLove(player);
                AuraCascade.proxy.networkWrapper.sendToAllAround(new PacketBurst(5, entity.posX, entity.posY, entity.posZ), new NetworkRegistry.TargetPoint(entity.worldObj.provider.getDimension(), entity.posX, entity.posY, entity.posZ, 32));
                break;

            }
        }
    }
}
 
開發者ID:AdlyTempleton,項目名稱:Aura-Cascade,代碼行數:16,代碼來源:EntityBreederFairy.java

示例11: 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;
}
 
開發者ID:copygirl,項目名稱:PocketBags,代碼行數:31,代碼來源:ItemPouch.java

示例12: checkEntityImmunities

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity)
{
    // quick checks.
    if ( entity.inWater /* isInWater */ || entity.fire > 0 )
    {
        return true;
    }
    if ( !( entity instanceof EntityArrow ) )
    {
        if ( !entity.onGround || entity.riddenByEntity != null
                || entity.ridingEntity != null )
        {
            return true;
        }
    } else if ( !( (EntityArrow) entity ).inGround )
    {
        return true;
    }
    // special cases.
    if ( entity instanceof EntityLiving )
    {
        EntityLiving living = (EntityLiving) entity;
        if ( living.attackTime > 0 || living.hurtTime > 0 || living.activePotionsMap.size() > 0 )
        {
            return true;
        }
        if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).entityToAttack != null )
        {
            return true;
        }
        if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isMating() /* Getter for first boolean */ )
        {
            return true;
        }
        if ( entity instanceof EntityAnimal )
        {
            EntityAnimal animal = (EntityAnimal) entity;
            if ( animal.isChild() || animal.isInLove() /*love*/ )
            {
                return true;
            }
            if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).getSheared() )
            {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:57,代碼來源:ActivationRange.java

示例13: scanForAnimals

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
private void scanForAnimals(List<EntityAnimal> animals,
        List<EntityPair> targets, int maxCount) {
    EntityAnimal animal1;
    EntityAnimal animal2;
    EntityPair breedingPair;

    int age;

    for (int i = 0; i < animals.size(); i++) {
        animal1 = animals.get(i);
        age = animal1.getGrowingAge();

        if (age != 0 || animal1.isInLove()) {
            continue;
        }// unbreedable first-target, skip
        while (i + 1 < animals.size())// loop through remaining animals to
                                        // find a breeding partner
        {
            i++;
            animal2 = animals.get(i);
            age = animal2.getGrowingAge();
            if (age == 0 && !animal2.isInLove())// found a second breedable
                                                // animal, add breeding
                                                // pair, exit to outer loop
            {
                breedingPair = new EntityPair(animal1, animal2);
                targets.add(breedingPair);
                break;
            }
        }
    }

    int grownCount = 0;
    for (EntityAnimal animal : animals) {
        if (animal.getGrowingAge() >= 0) {
            grownCount++;
        }
    }

    if (grownCount > maxCount) {
        for (int i = 0, cullCount = grownCount - maxCount; i < animals
                .size() && cullCount > 0; i++) {
            if (animals.get(i).getGrowingAge() >= 0) {
                entitiesToCull.add(animals.get(i).getEntityId());
                cullCount--;
            }
        }
    }
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:50,代碼來源:WorksiteAnimalFarm.java

示例14: breedable

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
@Override
public boolean breedable() {
    EntityAnimal animal = this.getAnimal();
    return ((animal != null) && !animal.isInLove() && !animal.isChild() && (animal.getGrowingAge() == 0));
}
 
開發者ID:faceofcat,項目名稱:Mekfarm,代碼行數:6,代碼來源:VanillaGenericAnimal.java

示例15: canBreed

import net.minecraft.entity.passive.EntityAnimal; //導入方法依賴的package包/類
protected boolean canBreed(final EntityAnimal animal, final EntityPlayerMP player) {
    if(animal.getGrowingAge() != 0 || animal.isInLove())
        return false;
    
    return !(animal instanceof EntityHorse);
}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:7,代碼來源:BreedingItemManager.java


注:本文中的net.minecraft.entity.passive.EntityAnimal.isInLove方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。