@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; }
@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; }
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; }
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; }
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; }
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; }
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); }
@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); }
@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; }
/** * 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; } }
/** * 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; } }
/** * 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; } }
/** * 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; }
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); } } }
@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"); } }
@Override public EntityAIBase getWidgetAI(IDroneBase drone, IProgWidget widget) { return new DroneEntityBase<IProgWidget, EntityLivingBase>(drone, widget) { private final List<Entity> visitedEntities = new ArrayList<Entity>(); @Override protected boolean isEntityValid(Entity entity) { return entity instanceof EntityLivingBase && !visitedEntities.contains(entity); } @Override protected boolean doAction() { visitedEntities.add(targetedEntity); boolean activated = false; ItemStack stack = drone.getInv().getStackInSlot(0); if (stack.getItem().itemInteractionForEntity(stack, drone.getFakePlayer(), targetedEntity, EnumHand.MAIN_HAND)) { activated = true; } if (!activated && targetedEntity instanceof EntityAgeable && ((EntityAgeable) targetedEntity).processInteract(drone.getFakePlayer(), EnumHand.MAIN_HAND)) { activated = true; } DroneAIBlockInteract.transferToDroneFromFakePlayer(drone); return false;//return activated; <-- will right click as long as it's sucessfully activated. } }; }
private static boolean isEntityValidForModifier(String modifier, String value, Entity entity) throws IllegalArgumentException { if (modifier.equalsIgnoreCase("age")) { if (entity instanceof EntityAgeable) { if (value.equalsIgnoreCase("adult")) { return ((EntityAgeable) entity).getGrowingAge() >= 0; } else if (value.equalsIgnoreCase("baby")) { return ((EntityAgeable) entity).getGrowingAge() < 0; } else { throw new IllegalArgumentException(value + " doesn't match 'adult'/'baby'."); } } else { throw new IllegalArgumentException("This modifier can't be applied to this entity."); } } else if (modifier.equalsIgnoreCase("breedable")) { if (entity instanceof EntityAgeable) { if (value.equalsIgnoreCase("yes")) { return ((EntityAgeable) entity).getGrowingAge() == 0; } else if (value.equalsIgnoreCase("no")) { return ((EntityAgeable) entity).getGrowingAge() != 0; } else { throw new IllegalArgumentException(value + " doesn't match 'yes'/'no'."); } } else { throw new IllegalArgumentException("This modifier can't be applied to this entity."); } } throw new IllegalArgumentException(modifier + " is not a valid modifier"); }
@Override public float work() { world.getEntitiesWithinAABB(EntityAnimal.class, getWorkingArea()).stream().filter(EntityAgeable::isChild).forEach(entityAnimal -> { for (int i = 0; i < items.getSlots(); ++i) { if (entityAnimal.isBreedingItem(items.getStackInSlot(i))) { entityAnimal.ageUp(30, true); items.getStackInSlot(i).shrink(1); break; } } }); return 1; }
@Override public float work() { if (WorkUtils.isDisabled(this.getBlockType())) return 0; AxisAlignedBB area = getWorkingArea(); List<EntityAgeable> animals = this.world.getEntitiesWithinAABB(EntityAgeable.class, area); if (animals.size() == 0) return 0; EntityAgeable animal = animals.get(0); while (animal.isChild() == this.hasAddon(AdultFilterAddonItem.class) && animals.indexOf(animal) + 1 < animals.size()) animal = animals.get(animals.indexOf(animal) + 1); if (animal.isChild() == this.hasAddon(AdultFilterAddonItem.class)) return 0; BlockPos pos = this.getPos().offset(this.getFacing(), 1); animal.setPositionAndUpdate(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); return 1; }
public EntityRabbit createChild(EntityAgeable ageable) { EntityRabbit entityrabbit = new EntityRabbit(this.worldObj); if (ageable instanceof EntityRabbit) { entityrabbit.setRabbitType(this.rand.nextBoolean() ? this.getRabbitType() : ((EntityRabbit)ageable).getRabbitType()); } return entityrabbit; }
public EntityWolf createChild(EntityAgeable ageable) { EntityWolf entitywolf = new EntityWolf(this.worldObj); String s = this.getOwnerId(); if (s != null && s.trim().length() > 0) { entitywolf.setOwnerId(s); entitywolf.setTamed(true); } return entitywolf; }
public EntitySheep createChild(EntityAgeable ageable) { EntitySheep entitysheep = (EntitySheep)ageable; EntitySheep entitysheep1 = new EntitySheep(this.worldObj); entitysheep1.setFleeceColor(this.getDyeColorMixFromParents(this, entitysheep)); return entitysheep1; }
public EntityOcelot createChild(EntityAgeable ageable) { EntityOcelot entityocelot = new EntityOcelot(this.worldObj); if (this.isTamed()) { entityocelot.setOwnerId(this.getOwnerId()); entityocelot.setTamed(true); entityocelot.setTameSkin(this.getTameSkin()); } return entityocelot; }
@Override public EntityAgeable createChild(EntityAgeable mate) { EntityRabbit baby = new EntityRabbit(worldObj); if (mate instanceof EntityRabbit) baby.setRabbitType(rand.nextBoolean() ? getRabbitType() : ((EntityRabbit) mate).getRabbitType()); return baby; }
public boolean instanceOf(EntityType e) { // Generic types and players if (e.equals(EntityType.ENTITY_PLAYER_SP)) { return entity instanceof EntityPlayerSP; } else if (e.equals(EntityType.ENTITY_PLAYER)) { return entity instanceof EntityPlayer; } else if (e.equals(EntityType.ENTITY_LIVING_BASE)) { return entity instanceof EntityLivingBase; } else if (e.equals(EntityType.ENTITY_LIVING)) { return entity instanceof EntityLiving; } // Mobs if (e.equals(EntityType.ENTITY_WOLF)) { return entity instanceof EntityWolf; } else if (e.equals(EntityType.Entity_Ageable)) { return entity instanceof EntityAgeable; } else if (e.equals(EntityType.EntityAmbientCreature)) { return entity instanceof EntityAmbientCreature; } else if (e.equals(EntityType.EntityWaterMob)) { return entity instanceof EntityWaterMob; } else if (e.equals(EntityType.EntityMob)) { return entity instanceof EntityMob; } else if (e.equals(EntityType.EntitySlime)) { return entity instanceof EntitySlime; } else if (e.equals(EntityType.EntityFlying)) { return entity instanceof EntityFlying; } else if (e.equals(EntityType.EntityGolem)) { return entity instanceof EntityGolem; } else if (e.equals(EntityType.ENTITY_SPIDER)) { return entity instanceof EntitySpider; } else if (e.equals(EntityType.ENTITY_SPIDER)) { return entity instanceof EntitySpider; } else if (e.equals(EntityType.ENTITY_ZOMBIE_PIGMAN)) { return entity instanceof EntityZombie; } else if (e.equals(EntityType.ENTITY_ENDERMAN)) { return entity instanceof EntityEnderman; } return false; }
protected void func_190681_a(EntityAgeable p_190681_1_, AbstractHorse p_190681_2_) { double d0 = this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() + p_190681_1_.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() + (double)this.getModifiedMaxHealth(); p_190681_2_.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(d0 / 3.0D); double d1 = this.getEntityAttribute(JUMP_STRENGTH).getBaseValue() + p_190681_1_.getEntityAttribute(JUMP_STRENGTH).getBaseValue() + this.getModifiedJumpStrength(); p_190681_2_.getEntityAttribute(JUMP_STRENGTH).setBaseValue(d1 / 3.0D); double d2 = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue() + p_190681_1_.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getBaseValue() + this.getModifiedMovementSpeed(); p_190681_2_.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(d2 / 3.0D); }
public EntityWolf createChild(EntityAgeable ageable) { EntityWolf entitywolf = new EntityWolf(this.world); UUID uuid = this.getOwnerId(); if (uuid != null) { entitywolf.setOwnerId(uuid); entitywolf.setTamed(true); } return entitywolf; }
public EntitySheep createChild(EntityAgeable ageable) { EntitySheep entitysheep = (EntitySheep)ageable; EntitySheep entitysheep1 = new EntitySheep(this.world); entitysheep1.setFleeceColor(this.getDyeColorMixFromParents(this, entitysheep)); return entitysheep1; }