本文整理匯總了Java中net.minecraft.entity.EntityAgeable類的典型用法代碼示例。如果您正苦於以下問題:Java EntityAgeable類的具體用法?Java EntityAgeable怎麽用?Java EntityAgeable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityAgeable類屬於net.minecraft.entity包,在下文中一共展示了EntityAgeable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: work
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
@Override
public float work() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
AxisAlignedBB area = getWorkingArea();
List<EntityLiving> mobs = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, area);
if (mobs.size() == 0) return 0;
FakePlayer player = IndustrialForegoing.getFakePlayer(world);
AtomicBoolean hasWorked = new AtomicBoolean(false);
mobs.stream().filter(entityLiving -> !hasAddon() || (!(entityLiving instanceof EntityAgeable) || !entityLiving.isChild())).forEach(entityLiving -> {
entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(player), Integer.MAX_VALUE);
hasWorked.set(true);
});
List<EntityItem> items = this.getWorld().getEntitiesWithinAABB(EntityItem.class, area);
for (EntityItem item : items) {
if (!item.getItem().isEmpty()) {
ItemHandlerHelper.insertItem(outItems, item.getItem(), false);
item.setDead();
}
}
return hasWorked.get() ? 1 : 0;
}
示例2: work
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
@Override
public float work() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
AxisAlignedBB area = getWorkingArea();
List<EntityAgeable> animals = this.world.getEntitiesWithinAABB(EntityAgeable.class, area);
int totalFluidAdded = 0;
for (EntityAgeable animal : animals) {
int toFill = animal.isChild() ? BlockRegistry.animalByproductRecolectorBlock.getSewageBaby() : BlockRegistry.animalByproductRecolectorBlock.getSewageAdult();
tank.fill(new FluidStack(FluidsRegistry.SEWAGE, toFill), true);
totalFluidAdded += toFill;
if (totalFluidAdded > ((AnimalByproductRecolectorBlock) this.getBlockType()).getMaxSludgeOperation()) {
break;
}
}
return 1;
}
示例3: createChild
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
public EntityRabbit createChild(EntityAgeable ageable)
{
EntityRabbit entityrabbit = new EntityRabbit(this.world);
int i = this.getRandomRabbitType();
if (this.rand.nextInt(20) != 0)
{
if (ageable instanceof EntityRabbit && this.rand.nextBoolean())
{
i = ((EntityRabbit)ageable).getRabbitType();
}
else
{
i = this.getRabbitType();
}
}
entityrabbit.setRabbitType(i);
return entityrabbit;
}
示例4: createChild
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
public EntityLlama createChild(EntityAgeable ageable)
{
EntityLlama entityllama = new EntityLlama(this.world);
this.func_190681_a(ageable, entityllama);
EntityLlama entityllama1 = (EntityLlama)ageable;
int i = this.rand.nextInt(Math.max(this.func_190707_dL(), entityllama1.func_190707_dL())) + 1;
if (this.rand.nextFloat() < 0.03F)
{
++i;
}
entityllama.func_190706_p(i);
entityllama.func_190710_o(this.rand.nextBoolean() ? this.func_190719_dM() : entityllama1.func_190719_dM());
return entityllama;
}
示例5: BabyEntitySpawnEvent
import net.minecraft.entity.EntityAgeable; //導入依賴的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;
}
示例6: createChild
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
public EntityRabbit createChild(EntityAgeable ageable)
{
EntityRabbit entityrabbit = new EntityRabbit(this.worldObj);
int i = this.getRandomRabbitType();
if (this.rand.nextInt(20) != 0)
{
if (ageable instanceof EntityRabbit && this.rand.nextBoolean())
{
i = ((EntityRabbit)ageable).getRabbitType();
}
else
{
i = this.getRabbitType();
}
}
entityrabbit.setRabbitType(i);
return entityrabbit;
}
示例7: PossessExperienceGUI
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
public PossessExperienceGUI(EntityPlayer player) {
super();
this.capability = PossessCapability.Implementation.get(player);
DifficultyInstance difficulty = player.worldObj.getDifficultyForLocation(player.getPosition());
for (Map.Entry<String, Integer> entry : this.capability.getExperience().getAllExperience().entrySet()) {
Entity entity = EntityList.createEntityByName(entry.getKey(), player.worldObj);
if (entity instanceof EntityLiving) {
EntityLiving living = (EntityLiving) entity;
living.onInitialSpawn(difficulty, null);
living.rotationYaw = 45.0F;
living.renderYawOffset = living.rotationYaw;
living.rotationYawHead = living.rotationYaw;
if (living instanceof EntityAgeable) {
((EntityAgeable) living).setGrowingAge(0);
}
this.entities.put(entry.getKey(), living);
}
}
this.maxPages = (int) Math.ceil((float) this.entities.size() / ENTITIES_PER_PAGE);
}
示例8: updateSize
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
@Override
protected void updateSize(EntityLivingBase target, float width, float height)
{
boolean isAnimalChild = this.entity instanceof EntityAgeable && this.entityData.getInteger("Age") < 0;
/* Because Minecraft is shit at syncing data!
*
* The problem is that Minecraft changes to correct size of baby
* animals on the client, but on the server it doesn't change anything
* thus I have to rely on proivded NBT data for figuring out if an
* animal entity is being a baby */
if (!target.worldObj.isRemote && isAnimalChild)
{
width *= 0.5;
height *= 0.5;
}
super.updateSize(target, width, height);
}
示例9: createChild
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
@Override
public EntityAgeable createChild(EntityAgeable ageable)
{
EntityARKCreature child = null;
try
{
Class<? extends EntityARKCreature> cl = this.getClass();
Constructor<? extends EntityARKCreature> co = cl.getConstructor(World.class);
child = co.newInstance(this.worldObj);
}
catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e)
{
e.printStackTrace();
}
child.grownUp = false;
child.updateHitbox();
return child;
}
示例10: spawnBabyAnimal
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
/**
* This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
*/
public EntityCustomTameable spawnBabyAnimal(EntityAgeable par1EntityAgeable)
{
double chance = Math.random();
if (chance < 0.5){
EntityDestroZertum var3 = new EntityDestroZertum(this.worldObj);
var3.setOwner(this.getOwnerName());
var3.setTamed(true);
return var3;
}else if (chance < 0.7){
EntityRedZertum var4 = new EntityRedZertum(this.worldObj);
var4.setOwner(this.getOwnerName());
var4.setTamed(true);
return var4;
}else{
EntityZertum var5 = new EntityZertum(this.worldObj);
var5.setOwner(this.getOwnerName());
var5.setTamed(true);
return var5;
}
}
示例11: spawnBabyAnimal
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
/**
* This function is used when two same-species animals in 'love mode' breed
* to generate the new baby animal.
*/
public EntityCustomTameable spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
double chance = Math.random();
if (chance < 0.5) {
EntityDestroZertum var3 = new EntityDestroZertum(this.worldObj);
var3.setOwnerId(this.getOwnerId());
var3.setTamed(true);
return var3;
}
else if (chance < 0.7) {
EntityZertum var4 = new EntityZertum(this.worldObj);
var4.setOwnerId(this.getOwnerId());
var4.setTamed(true);
return var4;
}
else {
EntityRedZertum var2 = new EntityRedZertum(this.worldObj);
var2.setOwnerId(this.getOwnerId());
var2.setTamed(true);
return var2;
}
}
示例12: spawnBabyAnimal
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
/**
* This function is used when two same-species animals in 'love mode' breed
* to generate the new baby animal.
*/
public EntityCustomTameable spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
double chance = Math.random();
if (chance < 0.5) {
EntityRedZertum var3 = new EntityRedZertum(this.worldObj);
var3.setOwnerId(this.getOwnerId());
var3.setTamed(true);
return var3;
}
else if (chance < 0.7) {
EntityZertum var4 = new EntityZertum(this.worldObj);
var4.setOwnerId(this.getOwnerId());
var4.setTamed(true);
return var4;
}
else {
EntityDestroZertum var2 = new EntityDestroZertum(this.worldObj);
var2.setOwnerId(this.getOwnerId());
var2.setTamed(true);
return var2;
}
}
示例13: spawnChild
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
/**
* Attempts to spawn a child when the player interacts with an entity using a custom spawn egg
* @param stack a stack containing an ItemCustomEgg item
* @param player the player interacting with the entity
* @param entity the entity that will spawn the child
* @return true if a child was spawned and the EntityInteractEvent should be canceled
*/
private boolean spawnChild(World world, ItemStack stack, EntityPlayer player, EntityAgeable entity) {
Class<? extends Entity> oclass = CustomEntityList.getClassFromID(stack.getItemDamage());
if (oclass != null && oclass == entity.getClass()) {
EntityAgeable child = entity.createChild(entity);
if (child != null) {
child.setGrowingAge(-24000);
child.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, 0.0F, 0.0F);
if (!world.isRemote) {
world.spawnEntityInWorld(child);
}
if (stack.hasDisplayName()) {
child.setCustomNameTag(stack.getDisplayName());
}
if (!player.capabilities.isCreativeMode) {
--stack.stackSize;
if (stack.stackSize <= 0) {
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
}
return true;
}
}
return false;
}
示例14: onChildEntityBred
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
private void onChildEntityBred(EntityAgeable entity) {
// Drop additional experience.
int agingSlowdown = getAgingSlowdown(entity);
int experience = (agingSlowdown - 1) * 2 + RandomUtils.getInt(3);
while (experience > 0) {
int xp = EntityXPOrb.getXPSplit(experience);
entity.worldObj.spawnEntityInWorld(new EntityXPOrb(entity.worldObj, entity.posX, entity.posY, entity.posZ, xp));
experience -= xp;
}
// Spawn additional pigs.
if (entity instanceof EntityPig) {
int num = (RandomUtils.getBoolean(1.0 / 200) ? 3 : 1);
for (int i = 0; i < num; i++) {
EntityAgeable newEntity = entity.createChild(entity);
newEntity.setGrowingAge(-23999);
newEntity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, RandomUtils.getFloat(360), 0);
entity.worldObj.spawnEntityInWorld(newEntity);
}
}
}
示例15: addInfo
import net.minecraft.entity.EntityAgeable; //導入依賴的package包/類
@Override
public void addInfo(Entity entity, List<String> curInfo) {
int growingAge = ((EntityAgeable) entity).getGrowingAge();
if (growingAge > 0) {
curInfo.add("Can breed in " + PneumaticCraftUtils.convertTicksToMinutesAndSeconds(growingAge, false));
} else if (growingAge < 0) {
curInfo.add("Becomes adult in " + PneumaticCraftUtils.convertTicksToMinutesAndSeconds(-growingAge, false));
} else {
curInfo.add("This animal can be bred");
}
}