@Override public void process(double time) { energy -= powerLoad.getRpPower() * time; if (inventory.getStackInSlot(EggIncubatorContainer.EggSlotId) != null) { descriptor.setState(powerLoad, true); if (energy <= 0) { inventory.decrStackSize(EggIncubatorContainer.EggSlotId, 1); EntityChicken chicken = new EntityChicken(node.coordonate.world()); chicken.setGrowingAge(-24000); EntityLiving entityliving = (EntityLiving) chicken; entityliving.setLocationAndAngles( node.coordonate.x + 0.5, node.coordonate.y + 0.5, node.coordonate.z + 0.5, MathHelper.wrapAngleTo180_float(node.coordonate.world().rand.nextFloat() * 360.0F), 0.0F); entityliving.rotationYawHead = entityliving.rotationYaw; entityliving.renderYawOffset = entityliving.rotationYaw; entityliving.func_110161_a((EntityLivingData) null); node.coordonate.world().spawnEntityInWorld(entityliving); entityliving.playLivingSound(); // node.coordonate.world().spawnEntityInWorld()); resetEnergy(); needPublish(); } } else { descriptor.setState(powerLoad, false); resetEnergy(); } if (Math.abs(powerLoad.Uc - lastVoltagePublish) / descriptor.nominalVoltage > 0.1) needPublish(); }
private EntityLiving getTargetEntity(String entityName, EntityPlayer targetPlayer) { EntityLiving entity; try { @SuppressWarnings("unchecked") Class<? extends EntityLiving> entityClass = (Class<? extends EntityLiving>) EntityList.stringToClassMapping.get(entityName); entity = (EntityLiving) LivingHelper.instantiateEntity(entityClass, targetPlayer.worldObj); } catch (Exception exception) { throw new WrongUsageException( "commands.jascanspawnhere.cannotinstantiateentity", new Object[0]); } entity.setLocationAndAngles( targetPlayer.posX, targetPlayer.posY, targetPlayer.posZ, targetPlayer.rotationYaw, targetPlayer.rotationPitch); return entity; }
public void spawnGuildMembers(float f, float f1, float f2) { world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0); f += 0.5F; f1 += 0.0F; f2 += 0.5F; EntityLiving entityliving = new EntityGuildMaster(world); EntityLiving entityliving1 = new EntityGuildMember(world); EntityLiving entityliving2 = new EntityGuildMember(world); EntityLiving entityliving3 = new EntityGuildMember(world); EntityLiving entityliving4 = new EntityGuildMember(world); EntityLiving entityliving5 = new EntityGuildMember(world); EntityLiving entityliving6 = new EntityGuildMember(world); EntityLiving entityliving7 = new EntityGuildMember(world); EntityLiving entityliving8 = new EntityGuildMember(world); EntityLiving entityliving9 = new EntityGuildMember(world); EntityLiving entityliving10 = new EntityGuildMember(world); EntityLiving entityliving11 = new EntityGuildMember(world); EntityLiving entityliving12 = new EntityGuildMember(world); EntityLiving entityliving13 = new EntityGuildMember(world); EntityLiving entityliving14 = new EntityGuildMember(world); EntityLiving entityliving15 = new EntityGuildMember(world); EntityLiving entityliving16 = new EntityGuildMember(world); EntityLiving entityliving17 = new EntityGuildMember(world); EntityLiving entityliving18 = new EntityGuildMember(world); EntityLiving entityliving19 = new EntityGuildMember(world); EntityLiving entityliving20 = new EntityGuildMember(world); EntityLiving entityliving21 = new EntityGuildMember(world); EntityLiving entityliving22 = new EntityGuildMember(world); EntityLiving entityliving23 = new EntityGuildMember(world); EntityLiving entityliving24 = new EntityGuildMember(world); EntityLiving entityliving25 = new EntityGuildMember(world); EntityLiving entityliving26 = new EntityGuildMember(world); EntityLiving entityliving27 = new EntityGuildMember(world); EntityLiving entityliving28 = new EntityGuildMember(world); EntityLiving entityliving29 = new EntityGuildMember(world); EntityLiving entityliving30 = new EntityFarmerKeeper(world); EntityLiving entityliving31 = new EntityWeaponKeeper(world); EntityList.createEntityByName("GuildMaster", world); entityliving.setLocationAndAngles(f + 34F, f1 + 16F, f2 + 66F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving); EntityList.createEntityByName("GuildMember", world); entityliving1.setLocationAndAngles((double) f + 12.5D, f1 + 11F, f2 + 68F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving1); EntityList.createEntityByName("GuildMember", world); entityliving2.setLocationAndAngles(f + 12F, f1 + 11F, f2 + 40F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving2); EntityList.createEntityByName("GuildMember", world); entityliving3.setLocationAndAngles(f + 28F, f1 + 2.0F, f2 + 42F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving3); EntityList.createEntityByName("GuildMember", world); entityliving4.setLocationAndAngles(f + 10F, f1 + 11F, f2 + 60F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving4); EntityList.createEntityByName("GuildMember", world); entityliving5.setLocationAndAngles(f + 11F, f1 + 18F, f2 + 52F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving5); EntityList.createEntityByName("GuildMember", world); entityliving6.setLocationAndAngles(f + 11F, f1 + 18F, f2 + 57F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving6); EntityList.createEntityByName("GuildMember", world); entityliving7.setLocationAndAngles(f + 16F, f1 + 11F, f2 + 48F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving7); EntityList.createEntityByName("GuildMember", world); entityliving8.setLocationAndAngles(f + 16F, f1 + 18F, f2 + 43F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving8); EntityList.createEntityByName("GuildMember", world); entityliving9.setLocationAndAngles(f + 16F, f1 + 18F, f2 + 61F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving9); EntityList.createEntityByName("GuildMember", world); entityliving10.setLocationAndAngles(f + 19F, f1 + 11F, f2 + 46F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving10); EntityList.createEntityByName("GuildMember", world); entityliving11.setLocationAndAngles(f + 19F, f1 + 11F, f2 + 66F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving11); EntityList.createEntityByName("GuildMember", world); entityliving12.setLocationAndAngles(f + 20F, f1 + 10F, f2 + 26F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving12); EntityList.createEntityByName("GuildMember", world); entityliving13.setLocationAndAngles(f + 20F, f1 + 11F, f2 + 56F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving13); EntityList.createEntityByName("GuildMember", world); entityliving14.setLocationAndAngles(f + 20F, f1 + 18F, f2 + 40F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving14); EntityList.createEntityByName("GuildMember", world); entityliving15.setLocationAndAngles(f + 24F, f1 + 8F, f2 + 66F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving15); EntityList.createEntityByName("GuildMember", world); entityliving16.setLocationAndAngles(f + 25F, f1 + 10F, f2 + 15F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving16); EntityList.createEntityByName("GuildMember", world); entityliving17.setLocationAndAngles(f + 28F, f1 + 8F, f2 + 66F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving17); EntityList.createEntityByName("GuildMember", world); entityliving18.setLocationAndAngles(f + 31F, f1 + 2.0F, f2 + 32F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving18); EntityList.createEntityByName("GuildMember", world); entityliving19.setLocationAndAngles(f + 32F, f1 + 9F, f2 + 38F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving19); EntityList.createEntityByName("GuildMember", world); entityliving20.setLocationAndAngles(f + 34F, f1 + 8F, f2 + 66F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving20); EntityList.createEntityByName("GuildMember", world); entityliving21.setLocationAndAngles(f + 41F, f1 + 9F, f2 + 41F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving21); EntityList.createEntityByName("GuildMember", world); entityliving22.setLocationAndAngles(f + 41F, f1 + 9F, f2 + 59F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving22); EntityList.createEntityByName("GuildMember", world); entityliving23.setLocationAndAngles(f + 42F, f1 + 2.0F, f2 + 23F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving23); EntityList.createEntityByName("GuildMember", world); entityliving24.setLocationAndAngles(f + 43F, f1 + 10F, f2 + 13F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving24); EntityList.createEntityByName("GuildMember", world); entityliving25.setLocationAndAngles(f + 50F, f1 + 2.0F, f2 + 36F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving25); EntityList.createEntityByName("GuildMember", world); entityliving26.setLocationAndAngles(f + 50F, f1 + 3F, f2 + 54F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving26); EntityList.createEntityByName("GuildMember", world); entityliving27.setLocationAndAngles(f + 57F, f1 + 12F, f2 + 39F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving27); EntityList.createEntityByName("GuildMember", world); entityliving28.setLocationAndAngles(f + 70F, f1 + 17F, f2 + 48F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving28); EntityList.createEntityByName("GuildMember", world); entityliving29.setLocationAndAngles(f + 70F, f1 + 25F, f2 + 45F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving29); EntityList.createEntityByName("Farmer", world); entityliving30.setLocationAndAngles(f + 54F, f1 + 2.0F, f2 + 50F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving30); EntityList.createEntityByName("WeaponKeeper", world); entityliving31.setLocationAndAngles(f + 49F, f1 + 3F, f2 + 25F, 0.0F, 0.0F); world.spawnEntityInWorld(entityliving31); }
private void HandleHatching() { String MsgHeadTmp; float light = getBrightness(1.0F); BiomeGenBase LocationBiome; EntityPlayer PlayerNearby = null; if (this.ParentOwner != "" && worldObj.getPlayerEntityByName(this.ParentOwner) != null) { // PlayerNearby = ParentOwner; } else if (worldObj.getClosestPlayerToEntity(this, 16D) != null) { PlayerNearby = worldObj.getClosestPlayerToEntity(this, 16D); } if (this.DinoInside == EnumDinoType.Mosasaurus) { if (this.inWater) { this.BirthTick++; } else { this.BirthTick--; } } else { if (light >= 0.5) { this.BirthTick++; } else { if (!worldObj.canBlockSeeTheSky( MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ))) { this.BirthTick--; } } } if (this.BirthTick <= -HatchingNeedTime) { String TailTmp; if (this.DinoInside == EnumDinoType.Mosasaurus) { TailTmp = mod_Fossil.GetLangTextByKey(HEAD + DRY + MSGTAIL); } else { TailTmp = mod_Fossil.GetLangTextByKey(HEAD + COLD + MSGTAIL); } MsgHeadTmp = mod_Fossil.GetLangTextByKey(MSGHEAD); mod_Fossil.ShowMessage( MsgHeadTmp + EntityDinosaurce.GetNameByEnum(DinoInside, false) + TailTmp, PlayerNearby); this.setDead(); return; } if (this.BirthTick >= HatchingNeedTime) { if (worldObj.isRemote) { return; } LocationBiome = worldObj.provider.worldChunkMgr.getBiomeGenAt( (int) Math.floor(posX), (int) Math.floor(posZ)); EntityLiving entityliving = null; switch (DinoInside) { case Triceratops: entityliving = (EntityAnimal) new EntityTriceratops(worldObj); ((EntityTriceratops) entityliving).setSubSpecies(worldObj.rand.nextInt(3) + 1); if (PlayerNearby != null) { ((EntityDinosaurce) entityliving).setOwner(PlayerNearby.username); ((EntityDinosaurce) entityliving).setTamed(true); } else { ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; } break; case Raptor: entityliving = (EntityAnimal) new EntityRaptor(worldObj); if (LocationBiome instanceof BiomeGenForest) { ((EntityRaptor) entityliving).ChangeSubType(2); } if (LocationBiome instanceof BiomeGenSnow || LocationBiome instanceof BiomeGenTaiga) { ((EntityRaptor) entityliving).ChangeSubType(1); } if (PlayerNearby != null) { ((EntityDinosaurce) entityliving).setOwner(PlayerNearby.username); ((EntityDinosaurce) entityliving).setTamed(true); } else { ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; } break; case TRex: entityliving = (EntityAnimal) new EntityTRex(worldObj); ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; // ((EntityTRex)entityliving).setSelfOwner(entityplayer.username); // ((EntityTRex)entityliving).setSelfTamed(true); break; case Pterosaur: // mod_Fossil.ShowMessage("Pterosaur not ready yet."); entityliving = (EntityAnimal) new EntityPterosaur(worldObj); if (PlayerNearby != null) { ((EntityDinosaurce) entityliving).setOwner(PlayerNearby.username); ((EntityDinosaurce) entityliving).setTamed(true); } else { ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; } break; case Plesiosaur: entityliving = (EntityAnimal) new EntityPlesiosaur(worldObj); if (PlayerNearby != null) { ((EntityDinosaurce) entityliving).setOwner(PlayerNearby.username); ((EntityDinosaurce) entityliving).setTamed(true); } break; case Mosasaurus: entityliving = (EntityAnimal) new EntityMosasaurus(worldObj); ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; break; case Stegosaurus: entityliving = (EntityAnimal) new EntityStegosaurus(worldObj); if (PlayerNearby != null) { ((EntityDinosaurce) entityliving).setOwner(PlayerNearby.username); ((EntityDinosaurce) entityliving).setTamed(true); } else { ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; } break; case dilphosaur: entityliving = (EntityAnimal) new Entitydil(worldObj); ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; break; case Brachiosaurus: entityliving = (EntityAnimal) new EntityBrachiosaurus(worldObj); if (PlayerNearby != null) { ((EntityDinosaurce) entityliving).setOwner(PlayerNearby.username); ((EntityDinosaurce) entityliving).setTamed(true); } else { ((EntityDinosaurce) entityliving).OrderStatus = EnumOrderType.FreeMove; } break; default: mod_Fossil.ShowMessage("Bug:Impossible result.", PlayerNearby); this.setDead(); return; } entityliving.setLocationAndAngles( (int) Math.floor(this.posX), (int) Math.floor(this.posY) + 1, (int) Math.floor(this.posZ), worldObj.rand.nextFloat() * 360F, 0.0F); if (worldObj.checkIfAABBIsClear(entityliving.boundingBox) && worldObj.getCollidingBoundingBoxes(entityliving, entityliving.boundingBox).size() == 0 && (!worldObj.isAnyLiquid(entityliving.boundingBox) ^ (DinoInside == EnumDinoType.Mosasaurus))) { if (!worldObj.isRemote) { worldObj.spawnEntityInWorld(entityliving); } if (PlayerNearby != null) { mod_Fossil.ShowMessage(mod_Fossil.GetLangTextByKey(HEAD + "Hatched"), PlayerNearby); } this.setDead(); } else { mod_Fossil.ShowMessage(mod_Fossil.GetLangTextByKey(HEAD + "NoSpace"), PlayerNearby); this.BirthTick -= 500; } } }