本文整理匯總了Java中net.minecraft.entity.passive.EntityAnimal類的典型用法代碼示例。如果您正苦於以下問題:Java EntityAnimal類的具體用法?Java EntityAnimal怎麽用?Java EntityAnimal使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityAnimal類屬於net.minecraft.entity.passive包,在下文中一共展示了EntityAnimal類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: affectChunk
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
@Override
public void affectChunk(World world) {
Chunk chunk = world.getChunkFromChunkCoords(chunkPos.x, chunkPos.z);
for (int i = 0; i < chunk.getEntityLists().length; i++) {
if (chunk.getEntityLists()[i] != null) {
for (EntityAnimal e : chunk.getEntityLists()[i].getByClass(EntityAnimal.class)) {
if (world.rand.nextInt(3) == 0) {
e.addTag(TAG);
}
}
}
}
}
示例2: getNearbyMate
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
* Loops through nearby animals and finds another animal of the same type that can be mated with. Returns the first
* valid mate found.
*/
private EntityAnimal getNearbyMate()
{
float f = 8.0F;
List<EntityAnimal> list = this.theWorld.<EntityAnimal>getEntitiesWithinAABB(this.theAnimal.getClass(), this.theAnimal.getEntityBoundingBox().expand((double)f, (double)f, (double)f));
double d0 = Double.MAX_VALUE;
EntityAnimal entityanimal = null;
for (EntityAnimal entityanimal1 : list)
{
if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0)
{
entityanimal = entityanimal1;
d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1);
}
}
return entityanimal;
}
示例3: checkValidity
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private boolean checkValidity(final EntityLivingBase entity) {
if (entity == this.mc.thePlayer) {
return false;
}
if (!entity.isEntityAlive()) {
return false;
}
if (this.mc.thePlayer.getDistanceToEntity(entity) > this.range) {
return false;
}
if (!(entity instanceof EntityPlayer)) {
return (this.monsters && entity instanceof EntityMob) || (this.animals && (entity instanceof EntityAnimal || entity instanceof EntitySquid)) || (this.bats && entity instanceof EntityBat);
}
if (this.players) {
final EntityPlayer player = (EntityPlayer)entity;
return (this.friend && FriendManager.isFriend(player.getName())) || (!FriendManager.isFriend(player.getName()) && (!this.noArmor || this.hasArmor(player)));
}
return false;
}
示例4: interactEntityEvent
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
if (stack == null)
return;
if (!(event.target instanceof EntityAnimal))
return;
EntityAnimal animal = (EntityAnimal) event.target;
if (!animal.isChild()) {
if (animal instanceof EntityPig) {
if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
setAnimalInLove(animal, event.entityPlayer, stack);
} else if (animal instanceof EntityChicken)
if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
setAnimalInLove(animal, event.entityPlayer, stack);
} else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
feedBaby(animal, event.entityPlayer, stack);
}
示例5: feedBaby
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private void feedBaby(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
int currentAge = animal.getGrowingAge();
int age = (int) (-currentAge * 0.1F);
animal.setGrowingAge(currentAge + age);
player.swingItem();
Random itemRand = animal.worldObj.rand;
for (int i = 0; i < 3; i++) {
double d0 = itemRand.nextGaussian() * 0.02D;
double d1 = itemRand.nextGaussian() * 0.02D;
double d2 = itemRand.nextGaussian() * 0.02D;
animal.worldObj.spawnParticle("happyVillager", animal.posX + itemRand.nextFloat() * 0.5, animal.posY + 0.5 + itemRand.nextFloat() * 0.5, animal.posZ + itemRand.nextFloat() * 0.5, d0, d1, d2);
}
if (!player.capabilities.isCreativeMode)
if (--stack.stackSize <= 0)
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
示例6: getEntityColor
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
public Color getEntityColor() {
if ((entity instanceof EntityAnimal)) {
return Color.white;
}
if ((entity instanceof EntityMob)) {
return Color.red;
}
if ((entity instanceof EntitySlime)) {
return Color.green;
}
if ((entity instanceof EntityVillager)) {
return new Color(245, 245, 220);
}
if ((entity instanceof EntityBat)) {
return Color.BLACK;
}
if ((entity instanceof EntitySquid)) {
return Color.PINK;
}
return Color.white;
}
示例7: getNearbyMate
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
* Loops through nearby animals and finds another animal of the same type that can be mated with. Returns the first
* valid mate found.
*/
private EntityAnimal getNearbyMate()
{
List<EntityAnimal> list = this.theWorld.<EntityAnimal>getEntitiesWithinAABB(this.field_190857_e, this.theAnimal.getEntityBoundingBox().expandXyz(8.0D));
double d0 = Double.MAX_VALUE;
EntityAnimal entityanimal = null;
for (EntityAnimal entityanimal1 : list)
{
if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0)
{
entityanimal = entityanimal1;
d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1);
}
}
return entityanimal;
}
示例8: BabyEntitySpawnEvent
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
public BabyEntitySpawnEvent(EntityLiving parentA, EntityLiving parentB, @Nullable EntityAgeable proposedChild)
{
//causedByPlayer calculated here to simplify the patch.
EntityPlayer causedByPlayer = null;
if (parentA instanceof EntityAnimal) {
causedByPlayer = ((EntityAnimal)parentA).getPlayerInLove();
}
if (causedByPlayer == null && parentB instanceof EntityAnimal)
{
causedByPlayer = ((EntityAnimal)parentB).getPlayerInLove();
}
this.parentA = parentA;
this.parentB = parentB;
this.causedByPlayer = causedByPlayer;
this.child = proposedChild;
}
示例9: getNearbyMate
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
* Loops through nearby animals and finds another animal of the same type that can be mated with. Returns the first
* valid mate found.
*/
private EntityAnimal getNearbyMate()
{
List<EntityAnimal> list = this.theWorld.<EntityAnimal>getEntitiesWithinAABB(this.theAnimal.getClass(), this.theAnimal.getEntityBoundingBox().expandXyz(8.0D));
double d0 = Double.MAX_VALUE;
EntityAnimal entityanimal = null;
for (EntityAnimal entityanimal1 : list)
{
if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0)
{
entityanimal = entityanimal1;
d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1);
}
}
return entityanimal;
}
示例10: 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);
}
}
}
示例11: canMateWith
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
@Override
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
if (par1EntityAnimal == this)
{
return false;
}
else if (!this.isTamed())
{
return false;
}
else if (!(par1EntityAnimal instanceof EntitySlimeling))
{
return false;
}
else
{
EntitySlimeling slimeling = (EntitySlimeling) par1EntityAnimal;
return slimeling.isTamed() && !slimeling.isSitting() && this.isInLove() && slimeling.isInLove();
}
}
示例12: isEntityValidToAttack
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
public boolean isEntityValidToAttack(EntityMinionWarrior minion, EntityLivingBase entity)
{
if(entity == minion || entity == minion.getRidingEntity() || !EntityAITarget.isSuitableTarget(minion, entity, false, false) || entity.getClass() == EntityCreeper.class) return false;
if (entity instanceof EntityMob &&
(getTargetBehavior() == EnumCombatBehaviors.TARGET_HOSTILE_MOBS ||
getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS))
{
return true;
}
else if (entity instanceof EntityAnimal &&
(getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_MOBS ||
getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS))
{
return true;
}
else
{
return false;
}
}
示例13: tryBreeding
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private boolean tryBreeding(List<EntityPair> targets) {
Entity animalA;
Entity animalB;
EntityPair pair;
if (!targets.isEmpty()) {
pair = targets.remove(0);
animalA = pair.getEntityA(getWorld());
animalB = pair.getEntityB(getWorld());
if (!(animalA instanceof EntityAnimal)
|| !(animalB instanceof EntityAnimal)) {
return false;
}
if (!hasBreedingItem((EntityAnimal) animalA))
return false;
((EntityAnimal) animalA).setInLove(null);// setInLove(EntityPlayer
// breeder)
((EntityAnimal) animalB).setInLove(null);// setInLove(EntityPlayer
// breeder)
return true;
}
return false;
}
示例14: 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 p_70878_1_)
{
if (p_70878_1_ == this)
{
return false;
}
else if (!this.isTamed())
{
return false;
}
else if (!(p_70878_1_ instanceof EntityStymph))
{
return false;
}
else
{
EntityStymph entityocelot = (EntityStymph)p_70878_1_;
return !entityocelot.isTamed() ? false : this.isInLove() && entityocelot.isInLove();
}
}
示例15: isValidTarget
import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private boolean isValidTarget(Entity e)
{
if (e == null) return false;
else if (e instanceof EntityPlayer)
{
EntityPlayer p = ((EntityPlayer) e);
if (p.capabilities.isCreativeMode) return false;
else
{
if (kPlayers) return true;
else if (!kTeam) return false;
RivalRebelsPlayer rrp = RivalRebels.round.rrplayerlist.getForName(((EntityPlayer) e).getCommandSenderName());
if (rrp == null) return kTeam;
if (rrp.rrteam == RivalRebelsTeam.NONE) return !p.getCommandSenderName().equals(username);
if (rrp.rrteam != team) return kTeam;
else return false;
}
}
else return (kMobs && (e instanceof EntityRhodes || (e instanceof EntityMob && !(e instanceof EntityAnimal) && !(e instanceof EntityBat) && !(e instanceof EntityVillager) && !(e instanceof EntitySquid)) || e instanceof EntityGhast));
}