@Override public void process(ICommandSender commandSender, String[] stringArgs) { if (stringArgs.length >= 3) { throw new WrongUsageException("commands.jaslocate.usage", new Object[0]); } EntityPlayerMP targetPlayer; if (stringArgs.length == 2) { targetPlayer = getPlayer(commandSender, stringArgs[0]); } else { targetPlayer = getPlayer(commandSender, commandSender.getCommandSenderName()); } String entityTarget = stringArgs.length == 0 ? "*" : stringArgs.length == 1 ? stringArgs[0] : stringArgs[1]; StringBuilder countedContents = new StringBuilder(); countedContents.append("Locations: "); boolean foundMatch = false; Iterator<Entity> iterator = CustomSpawner.getLoadedEntities(targetPlayer.worldObj).iterator(); while (iterator.hasNext()) { Entity entity = iterator.next(); LivingGroupRegistry groupRegistry = TAGProfile.worldSettings().livingGroupRegistry(); ImmutableCollection<String> groupIDs = groupRegistry.getGroupsWithEntity( groupRegistry.EntityClasstoJASName.get(entity.getClass())); for (String groupID : groupIDs) { LivingHandler handler = TAGProfile.worldSettings().livingHandlerRegistry().getLivingHandler(groupID); if (handler != null && (entityTarget.equals("*") || handler.creatureTypeID.equals(entityTarget)) || entityTarget.equals(EntityList.classToStringMapping.get(entity.getClass()))) { foundMatch = true; boolean canDespawn = handler.canDespawn((EntityLiving) entity); countedContents .append(canDespawn ? "\u00A7a" : "\u00A7c") .append(EntityList.classToStringMapping.get(entity.getClass())) .append("\u00A7r["); countedContents.append("\u00A79").append((int) entity.posX).append("\u00A7r").append(","); countedContents.append("\u00A79").append((int) entity.posY).append("\u00A7r").append(","); countedContents.append("\u00A79").append((int) entity.posZ).append("\u00A7r"); if (iterator.hasNext()) { countedContents.append("] "); } break; } } } if (!foundMatch) { throw new WrongUsageException("commands.jaslocate.typenotfound", new Object[0]); } else { commandSender.addChatMessage(new ChatComponentText(countedContents.toString())); } }
/** Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (this.dino instanceof EntityNewPrehistoric) { EntityNewPrehistoric prehistoric = (EntityNewPrehistoric) dino; if (prehistoric.aiResponseType() != Response.TERRITORIAL) { return false; } } if (this.dino.preyBlacklist().contains(targetEntityClass)) { return false; } if (closestLivingEntity != null) { if (targetEntityClass == closestLivingEntity.getClass() && targetEntityClass != dino.getClass()) { if (closestLivingEntity.boundingBox.maxX * 1.5F < dino.boundingBox.maxX && closestLivingEntity.boundingBox.minX * 1.5F > dino.boundingBox.minX && closestLivingEntity.boundingBox.minZ * 1.5F < dino.boundingBox.minZ && closestLivingEntity.boundingBox.minZ * 1.5F > dino.boundingBox.minZ) { return false; } } } if (this.targetEntityClass == EntityPlayer.class) { if (this.dino instanceof EntityTameable && ((EntityTameable) this.dino).isTamed()) { return false; } this.closestLivingEntity = this.dino.worldObj.getClosestPlayerToEntity(this.dino, (double) this.distanceFromEntity); if (this.closestLivingEntity == null) { return false; } } else { List list = this.dino.worldObj.selectEntitiesWithinAABB( this.targetEntityClass, this.dino.boundingBox.expand( (double) this.distanceFromEntity, 3.0D, (double) this.distanceFromEntity), this.selector); if (list.isEmpty()) { return false; } this.closestLivingEntity = (Entity) list.get(0); } if (closestLivingEntity.getClass() == targetEntityClass) { return true; } else { return false; } }
/** Checking item usage for right click on entity */ public boolean checkEntityRightClick(ItemStack item, Resident res, Entity entity) { for (Iterator<SegmentEntity> it = segmentsEntities.iterator(); it.hasNext(); ) { SegmentEntity segment = it.next(); if (segment.getType() == EntityType.PROTECT && segment.getCheckClass().isAssignableFrom(entity.getClass())) { int dim = entity.dimension; int x = (int) Math.floor(entity.posX); int y = (int) Math.floor(entity.posY); int z = (int) Math.floor(entity.posZ); if (!hasPermission(res, segment, dim, x, y, z)) { return true; } } } if (item == null) return false; for (Iterator<SegmentItem> it = segmentsItems.iterator(); it.hasNext(); ) { SegmentItem segment = it.next(); if (segment.getType() == ItemType.RIGHT_CLICK_ENTITY && segment.getCheckClass().isAssignableFrom(item.getItem().getClass())) { try { if (segment.checkCondition(item)) { int range = segment.getRange(item); int dim = entity.dimension; int x = (int) Math.floor(entity.posX); int y = (int) Math.floor(entity.posY); int z = (int) Math.floor(entity.posZ); if (range == 0) { if (!hasPermission(res, segment, dim, x, y, z)) { return true; } } else { Volume rangeBox = new Volume(x - range, y - range, z - range, x + range, y + range, z + range); if (!hasPermission(res, segment, dim, rangeBox)) { return true; } } } } catch (Exception ex) { MyTown.instance.LOG.error( "Failed to check item use on {} at the player {} ({}, {}, {} | Dim: {})", item.getDisplayName(), res.getPlayerName(), entity.posX, entity.posY, entity.posZ, entity.dimension); MyTown.instance.LOG.error(ExceptionUtils.getStackTrace(ex)); if (ex instanceof GetterException || ex instanceof ConditionException) { this.disableSegment(it, segment, ex.getMessage()); } } } } return false; }
// TODO: Add condition check public boolean checkEntity(Entity entity) { for (SegmentEntity segment : segmentsEntities) { if (segment.getCheckClass().isAssignableFrom(entity.getClass())) { if (segment.getType() == EntityType.TRACKED) { if (segment.checkCondition(entity)) { int range = segment.getRange(entity); Resident owner = segment.getOwner(entity); int dim = entity.dimension; int x = (int) Math.floor(entity.posX); int y = (int) Math.floor(entity.posY); int z = (int) Math.floor(entity.posZ); if (range == 0) { if (!hasPermission(owner, segment, dim, x, y, z)) { return true; } } else { Volume rangeBox = new Volume(x - range, y - range, z - range, x + range, y + range, z + range); if (!hasPermission(owner, segment, dim, rangeBox)) { return true; } } } } } } return false; }
@Override public List<String> getWailaBody( Entity entity, List<String> currenttip, IWailaEntityAccessor accessor, IWailaConfigHandler config) { Entity currentEntity = accessor.getEntity(); Class currentEntityClass = currentEntity.getClass(); if (EntityList.classToStringMapping.containsKey(currentEntityClass)) { NBTTagCompound n = accessor.getNBTData(); // LogHelper.info(n.toString()); EntityPlayer player = accessor.getPlayer(); ItemStack holdItemReal = player.getHeldItem(); String holdItemNameReal = ""; if (holdItemReal != null) { holdItemNameReal = Item.itemRegistry.getNameForObject(holdItemReal.getItem()); } NBTHandler.flag = 1; NBTHandler.id = EntityList.getEntityString(currentEntity); // currenttip.add(NBTHandler.id); List<String> tips = NBTHandler.getTipsFromNBT(n, holdItemNameReal); currenttip.addAll(tips); } return currenttip; }
private Modchu_Render renderMapGet(Entity entity) { Object entity2 = Modchu_Main.getModchuCharacteristicObjectMaster(entity); // Modchu_Debug.mDebug("renderMapGet entity2.getClass()="+(entity2 != null ? entity2.getClass() // : null)); Class c = entity2 != null ? entity2.getClass() : entity.getClass(); // Modchu_Debug.mDebug("renderMapGet c="+c); return renderMap.get(c); }
public boolean tryTrackingEntity(EntityTracker entityTracker, Entity entity) { EntityRegistration er = lookupModSpawn(entity.getClass(), true); if (er != null) { entityTracker.addEntityToTracker(entity, er.getTrackingRange(), er.getUpdateFrequency(), er.sendsVelocityUpdates()); return true; } return false; }
public static void checkPVP(Entity entity, Resident res, Event event) { if (!event.isCancelable()) { return; } for (SegmentEntity segment : segmentsEntity.get(entity.getClass())) { if (!segment.shouldAttack(entity, res)) { event.setCanceled(true); } } }
@Override public void doRender(Entity entity, double d, double d1, double d2, float d3, float d4) { Modchu_Debug.mDebug("Modchu_AllRender doRender"); Modchu_Render render = renderMapGet(entity); if (render != null) { setShadowSize(Modchu_AS.getFloat("Render", "shadowSize", render)); // setShadowSize(0.0F); // render.setShadowSize(0.0F); render.doRender(entity, d, d1, d2, d3, d4); } else { Modchu_Debug.mDebug( "Modchu_AllRender doRender render == null !! entity=" + entity + " entity.getClass()=" + (entity != null ? entity.getClass() : null)); } }
public static boolean check(Entity entity) { if (entity instanceof EntityLiving) { if (!getFlagValueAtLocation( FlagType.ENTITIES, entity.dimension, (int) Math.floor(entity.posX), (int) Math.floor(entity.posY), (int) Math.floor(entity.posZ))) { entity.setDead(); return true; } } for (SegmentEntity segment : segmentsEntity.get(entity.getClass())) { if (!segment.shouldExist(entity)) { entity.setDead(); return true; } } return false; }
public Render getEntityRenderObject(Entity par1Entity) { return this.getEntityClassRenderObject(par1Entity.getClass()); }
public static CraftEntity getEntity(CraftServer server, net.minecraft.entity.Entity entity) { /** Order is *EXTREMELY* important -- keep it right! =D */ if (entity instanceof net.minecraft.entity.EntityLivingBase) { // Players if (entity instanceof net.minecraft.entity.player.EntityPlayer) { if (entity instanceof net.minecraft.entity.player.EntityPlayerMP) { return new CraftPlayer(server, (net.minecraft.entity.player.EntityPlayerMP) entity); } // Cauldron start - support fake player classes from mods // This case is never hit in vanilla // else { return new CraftHumanEntity(server, (net.minecraft.entity.player.EntityPlayer) // entity); } else { return new CraftPlayer( server, FakePlayerFactory.get( DimensionManager.getWorld(entity.worldObj.provider.dimensionId), ((net.minecraft.entity.player.EntityPlayer) entity).getGameProfile())); } // Cauldron end } else if (entity instanceof net.minecraft.entity.EntityCreature) { // Animals if (entity instanceof net.minecraft.entity.passive.EntityAnimal) { if (entity instanceof net.minecraft.entity.passive.EntityChicken) { return new CraftChicken(server, (net.minecraft.entity.passive.EntityChicken) entity); } else if (entity instanceof net.minecraft.entity.passive.EntityCow) { if (entity instanceof net.minecraft.entity.passive.EntityMooshroom) { return new CraftMushroomCow( server, (net.minecraft.entity.passive.EntityMooshroom) entity); } else { return new CraftCow(server, (net.minecraft.entity.passive.EntityCow) entity); } } else if (entity instanceof net.minecraft.entity.passive.EntityPig) { return new CraftPig(server, (net.minecraft.entity.passive.EntityPig) entity); } else if (entity instanceof net.minecraft.entity.passive.EntityTameable) { if (entity instanceof net.minecraft.entity.passive.EntityWolf) { return new CraftWolf(server, (net.minecraft.entity.passive.EntityWolf) entity); } else if (entity instanceof net.minecraft.entity.passive.EntityOcelot) { return new CraftOcelot(server, (net.minecraft.entity.passive.EntityOcelot) entity); } // Cauldron else { return new CraftTameableAnimal( server, (net.minecraft.entity.passive.EntityTameable) entity); } // Cauldron } else if (entity instanceof net.minecraft.entity.passive.EntitySheep) { return new CraftSheep(server, (net.minecraft.entity.passive.EntitySheep) entity); } else if (entity instanceof net.minecraft.entity.passive.EntityHorse) { return new CraftHorse(server, (net.minecraft.entity.passive.EntityHorse) entity); } else { return new CraftAnimals(server, (net.minecraft.entity.passive.EntityAnimal) entity); } } // Monsters else if (entity instanceof net.minecraft.entity.monster.EntityMob) { if (entity instanceof net.minecraft.entity.monster.EntityZombie) { if (entity instanceof net.minecraft.entity.monster.EntityPigZombie) { return new CraftPigZombie( server, (net.minecraft.entity.monster.EntityPigZombie) entity); } else { return new CraftZombie(server, (net.minecraft.entity.monster.EntityZombie) entity); } } else if (entity instanceof net.minecraft.entity.monster.EntityCreeper) { return new CraftCreeper(server, (net.minecraft.entity.monster.EntityCreeper) entity); } else if (entity instanceof net.minecraft.entity.monster.EntityEnderman) { return new CraftEnderman(server, (net.minecraft.entity.monster.EntityEnderman) entity); } else if (entity instanceof net.minecraft.entity.monster.EntitySilverfish) { return new CraftSilverfish( server, (net.minecraft.entity.monster.EntitySilverfish) entity); } else if (entity instanceof net.minecraft.entity.monster.EntityGiantZombie) { return new CraftGiant(server, (net.minecraft.entity.monster.EntityGiantZombie) entity); } else if (entity instanceof net.minecraft.entity.monster.EntitySkeleton) { return new CraftSkeleton(server, (net.minecraft.entity.monster.EntitySkeleton) entity); } else if (entity instanceof net.minecraft.entity.monster.EntityBlaze) { return new CraftBlaze(server, (net.minecraft.entity.monster.EntityBlaze) entity); } else if (entity instanceof net.minecraft.entity.monster.EntityWitch) { return new CraftWitch(server, (net.minecraft.entity.monster.EntityWitch) entity); } else if (entity instanceof net.minecraft.entity.boss.EntityWither) { return new CraftWither(server, (net.minecraft.entity.boss.EntityWither) entity); } else if (entity instanceof net.minecraft.entity.monster.EntitySpider) { if (entity instanceof net.minecraft.entity.monster.EntityCaveSpider) { return new CraftCaveSpider( server, (net.minecraft.entity.monster.EntityCaveSpider) entity); } else { return new CraftSpider(server, (net.minecraft.entity.monster.EntitySpider) entity); } } else { return new CraftMonster(server, (net.minecraft.entity.monster.EntityMob) entity); } } // Water Animals else if (entity instanceof net.minecraft.entity.passive.EntityWaterMob) { if (entity instanceof net.minecraft.entity.passive.EntitySquid) { return new CraftSquid(server, (net.minecraft.entity.passive.EntitySquid) entity); } else { return new CraftWaterMob(server, (net.minecraft.entity.passive.EntityWaterMob) entity); } } else if (entity instanceof net.minecraft.entity.monster.EntityGolem) { if (entity instanceof net.minecraft.entity.monster.EntitySnowman) { return new CraftSnowman(server, (net.minecraft.entity.monster.EntitySnowman) entity); } else if (entity instanceof net.minecraft.entity.monster.EntityIronGolem) { return new CraftIronGolem( server, (net.minecraft.entity.monster.EntityIronGolem) entity); } else { return new CraftLivingEntity(server, (net.minecraft.entity.EntityLivingBase) entity); } // Cauldron } else if (entity instanceof net.minecraft.entity.passive.EntityVillager) { return new CraftVillager(server, (net.minecraft.entity.passive.EntityVillager) entity); } else { return new CraftCreature(server, (net.minecraft.entity.EntityCreature) entity); } } // Slimes are a special (and broken) case else if (entity instanceof net.minecraft.entity.monster.EntitySlime) { if (entity instanceof net.minecraft.entity.monster.EntityMagmaCube) { return new CraftMagmaCube(server, (net.minecraft.entity.monster.EntityMagmaCube) entity); } else { return new CraftSlime(server, (net.minecraft.entity.monster.EntitySlime) entity); } } // Flying else if (entity instanceof net.minecraft.entity.EntityFlying) { if (entity instanceof net.minecraft.entity.monster.EntityGhast) { return new CraftGhast(server, (net.minecraft.entity.monster.EntityGhast) entity); } else { return new CraftFlying(server, (net.minecraft.entity.EntityFlying) entity); } } else if (entity instanceof net.minecraft.entity.boss.EntityDragon) { return new CraftEnderDragon(server, (net.minecraft.entity.boss.EntityDragon) entity); } // Ambient else if (entity instanceof net.minecraft.entity.passive.EntityAmbientCreature) { if (entity instanceof net.minecraft.entity.passive.EntityBat) { return new CraftBat(server, (net.minecraft.entity.passive.EntityBat) entity); } else { return new CraftAmbient( server, (net.minecraft.entity.passive.EntityAmbientCreature) entity); } } else { return new CraftLivingEntity(server, (net.minecraft.entity.EntityLivingBase) entity); } } else if (entity instanceof net.minecraft.entity.boss.EntityDragonPart) { net.minecraft.entity.boss.EntityDragonPart part = (net.minecraft.entity.boss.EntityDragonPart) entity; if (part.entityDragonObj instanceof net.minecraft.entity.boss.EntityDragon) { return new CraftEnderDragonPart( server, (net.minecraft.entity.boss.EntityDragonPart) entity); } else { return new CraftComplexPart(server, (net.minecraft.entity.boss.EntityDragonPart) entity); } } else if (entity instanceof net.minecraft.entity.item.EntityXPOrb) { return new CraftExperienceOrb(server, (net.minecraft.entity.item.EntityXPOrb) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityArrow) { return new CraftArrow(server, (net.minecraft.entity.projectile.EntityArrow) entity); } else if (entity instanceof net.minecraft.entity.item.EntityBoat) { return new CraftBoat(server, (net.minecraft.entity.item.EntityBoat) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityThrowable) { if (entity instanceof net.minecraft.entity.projectile.EntityEgg) { return new CraftEgg(server, (net.minecraft.entity.projectile.EntityEgg) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntitySnowball) { return new CraftSnowball(server, (net.minecraft.entity.projectile.EntitySnowball) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityPotion) { return new CraftThrownPotion(server, (net.minecraft.entity.projectile.EntityPotion) entity); } else if (entity instanceof net.minecraft.entity.item.EntityEnderPearl) { return new CraftEnderPearl(server, (net.minecraft.entity.item.EntityEnderPearl) entity); } else if (entity instanceof net.minecraft.entity.item.EntityExpBottle) { return new CraftThrownExpBottle(server, (net.minecraft.entity.item.EntityExpBottle) entity); } else { return new CraftProjectile( server, (net.minecraft.entity.projectile.EntityThrowable) entity); } // Cauldron } else if (entity instanceof net.minecraft.entity.item.EntityFallingBlock) { return new CraftFallingSand(server, (net.minecraft.entity.item.EntityFallingBlock) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityFireball) { if (entity instanceof net.minecraft.entity.projectile.EntitySmallFireball) { return new CraftSmallFireball( server, (net.minecraft.entity.projectile.EntitySmallFireball) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityLargeFireball) { return new CraftLargeFireball( server, (net.minecraft.entity.projectile.EntityLargeFireball) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityWitherSkull) { return new CraftWitherSkull( server, (net.minecraft.entity.projectile.EntityWitherSkull) entity); } else { return new CraftFireball(server, (net.minecraft.entity.projectile.EntityFireball) entity); } } else if (entity instanceof net.minecraft.entity.item.EntityEnderEye) { return new CraftEnderSignal(server, (net.minecraft.entity.item.EntityEnderEye) entity); } else if (entity instanceof net.minecraft.entity.item.EntityEnderCrystal) { return new CraftEnderCrystal(server, (net.minecraft.entity.item.EntityEnderCrystal) entity); } else if (entity instanceof net.minecraft.entity.projectile.EntityFishHook) { return new CraftFish(server, (net.minecraft.entity.projectile.EntityFishHook) entity); } else if (entity instanceof net.minecraft.entity.item.EntityItem) { return new CraftItem(server, (net.minecraft.entity.item.EntityItem) entity); } else if (entity instanceof net.minecraft.entity.effect.EntityWeatherEffect) { if (entity instanceof net.minecraft.entity.effect.EntityLightningBolt) { return new CraftLightningStrike( server, (net.minecraft.entity.effect.EntityLightningBolt) entity); } else { return new CraftWeather(server, (net.minecraft.entity.effect.EntityWeatherEffect) entity); } } else if (entity instanceof net.minecraft.entity.item.EntityMinecart) { if (entity instanceof net.minecraft.entity.item.EntityMinecartFurnace) { return new CraftMinecartFurnace( server, (net.minecraft.entity.item.EntityMinecartFurnace) entity); } else if (entity instanceof net.minecraft.entity.item.EntityMinecartChest) { return new CraftMinecartChest( server, (net.minecraft.entity.item.EntityMinecartChest) entity); } else if (entity instanceof net.minecraft.entity.item.EntityMinecartTNT) { return new CraftMinecartTNT(server, (net.minecraft.entity.item.EntityMinecartTNT) entity); } else if (entity instanceof net.minecraft.entity.item.EntityMinecartHopper) { return new CraftMinecartHopper( server, (net.minecraft.entity.item.EntityMinecartHopper) entity); } else if (entity instanceof net.minecraft.entity.ai.EntityMinecartMobSpawner) { return new CraftMinecartMobSpawner( server, (net.minecraft.entity.ai.EntityMinecartMobSpawner) entity); } else if (entity instanceof net.minecraft.entity.item.EntityMinecartEmpty) { return new CraftMinecartRideable( server, (net.minecraft.entity.item.EntityMinecartEmpty) entity); } else if (entity instanceof net.minecraft.entity.EntityMinecartCommandBlock) { return new CraftMinecartCommand( server, (net.minecraft.entity.EntityMinecartCommandBlock) entity); } else { return new CraftMinecart(server, (net.minecraft.entity.item.EntityMinecart) entity); } // Cauldron - other minecarts (Steve's Carts) } else if (entity instanceof net.minecraft.entity.EntityHanging) { if (entity instanceof net.minecraft.entity.item.EntityPainting) { return new CraftPainting(server, (net.minecraft.entity.item.EntityPainting) entity); } else if (entity instanceof net.minecraft.entity.item.EntityItemFrame) { return new CraftItemFrame(server, (net.minecraft.entity.item.EntityItemFrame) entity); } else if (entity instanceof net.minecraft.entity.EntityLeashKnot) { return new CraftLeash(server, (net.minecraft.entity.EntityLeashKnot) entity); } else { return new CraftHanging(server, (net.minecraft.entity.EntityHanging) entity); } } else if (entity instanceof net.minecraft.entity.item.EntityTNTPrimed) { return new CraftTNTPrimed(server, (net.minecraft.entity.item.EntityTNTPrimed) entity); } else if (entity instanceof net.minecraft.entity.item.EntityFireworkRocket) { return new CraftFirework(server, (net.minecraft.entity.item.EntityFireworkRocket) entity); } // Cauldron - used for custom entities that extend Entity directly else if (entity instanceof net.minecraft.entity.Entity) { return new CraftCustomEntity(server, (net.minecraft.entity.Entity) entity); } throw new AssertionError( "Unknown entity " + entity == null ? null : entity.getClass() + ": " + entity); // Cauldron - show the entity that caused exception }
public void updateSpawner() { if (isActivated() && !powered) { double d2; if (this.getSpawnerWorld().isRemote) { double d0 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat()); double d1 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat()); d2 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat()); this.getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); this.getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); if (this.spawnDelay > 0) { --this.spawnDelay; } this.renderRotation1 = this.renderRotation0; this.renderRotation0 = (this.renderRotation0 + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; } else { if (this.spawnDelay == -1) { this.resetTimer(); } if (this.spawnDelay > 0) { --this.spawnDelay; return; } boolean flag = false; for (int i = 0; i < this.spawnCount; ++i) { Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld()); if (entity == null) { return; } int j = this.getSpawnerWorld() .getEntitiesWithinAABB( entity.getClass(), AxisAlignedBB.getBoundingBox( (double) this.getSpawnerX(), (double) this.getSpawnerY(), (double) this.getSpawnerZ(), (double) (this.getSpawnerX() + 1), (double) (this.getSpawnerY() + 1), (double) (this.getSpawnerZ() + 1)) .expand( (double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))) .size(); if (j >= this.maxNearbyEntities) { this.resetTimer(); return; } int x = this.getSpawnerX() + (int) ((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); int y = this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1; int z = this.getSpawnerZ() + (int) ((this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange); EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; entity.setLocationAndAngles( x + 0.5, y + 0.5, z + 0.5, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); if (entityliving == null || (entityliving.getCanSpawnHere() || ignoreSpawnRequirements && getSpawnerWorld().getBlock(x, y, z) == Blocks.air)) { this.spawnEntity(entity); this.getSpawnerWorld() .playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0); if (entityliving != null) { entityliving.spawnExplosionParticle(); } flag = true; } } if (flag) { this.resetTimer(); } } } }
public void updateSpawner() { if (this.canRun()) { double var5; if (this.getSpawnerWorld().isClient) { double var1 = (double) ((float) this.getSpawnerX() + this.getSpawnerWorld().rand.nextFloat()); double var3 = (double) ((float) this.getSpawnerY() + this.getSpawnerWorld().rand.nextFloat()); var5 = (double) ((float) this.getSpawnerZ() + this.getSpawnerWorld().rand.nextFloat()); this.getSpawnerWorld().spawnParticle("smoke", var1, var3, var5, 0.0D, 0.0D, 0.0D); this.getSpawnerWorld().spawnParticle("flame", var1, var3, var5, 0.0D, 0.0D, 0.0D); if (this.spawnDelay > 0) { --this.spawnDelay; } this.field_98284_d = this.field_98287_c; this.field_98287_c = (this.field_98287_c + (double) (1000.0F / ((float) this.spawnDelay + 200.0F))) % 360.0D; } else { if (this.spawnDelay == -1) { this.resetTimer(); } if (this.spawnDelay > 0) { --this.spawnDelay; return; } boolean var12 = false; for (int var2 = 0; var2 < this.spawnCount; ++var2) { Entity var13 = EntityList.createEntityByName(this.getEntityNameToSpawn(), this.getSpawnerWorld()); if (var13 == null) { return; } int var4 = this.getSpawnerWorld() .getEntitiesWithinAABB( var13.getClass(), AxisAlignedBB.getBoundingBox( (double) this.getSpawnerX(), (double) this.getSpawnerY(), (double) this.getSpawnerZ(), (double) (this.getSpawnerX() + 1), (double) (this.getSpawnerY() + 1), (double) (this.getSpawnerZ() + 1)) .expand( (double) (this.spawnRange * 2), 4.0D, (double) (this.spawnRange * 2))) .size(); if (var4 >= this.maxNearbyEntities) { this.resetTimer(); return; } var5 = (double) this.getSpawnerX() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange; double var7 = (double) (this.getSpawnerY() + this.getSpawnerWorld().rand.nextInt(3) - 1); double var9 = (double) this.getSpawnerZ() + (this.getSpawnerWorld().rand.nextDouble() - this.getSpawnerWorld().rand.nextDouble()) * (double) this.spawnRange; EntityLiving var11 = var13 instanceof EntityLiving ? (EntityLiving) var13 : null; var13.setLocationAndAngles( var5, var7, var9, this.getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); if (var11 == null || var11.getCanSpawnHere()) { this.func_98265_a(var13); this.getSpawnerWorld() .playAuxSFX(2004, this.getSpawnerX(), this.getSpawnerY(), this.getSpawnerZ(), 0); if (var11 != null) { var11.spawnExplosionParticle(); } var12 = true; } } if (var12) { this.resetTimer(); } } } }
public static Resident getOwner(Entity entity) { for (SegmentEntity segment : segmentsEntity.get(entity.getClass())) { return segment.getOwner(entity); } return null; }
@SuppressWarnings("unchecked") @Override public void update() { super.update(); if (this.roomCoords == null) { return; } if (!this.worldObj.isRemote) { if (this.lastKillTime > 0 && MinecraftServer.getCurrentTimeMillis() - lastKillTime > 900000) // 15 minutes { this.lastKillTime = 0; this.isBossDefeated = false; } final Vector3 thisVec = new Vector3(this); final List<E> l = this.worldObj.getEntitiesWithinAABB( bossClass, AxisAlignedBB.fromBounds( thisVec.x - 15, thisVec.y - 15, thisVec.z - 15, thisVec.x + 15, thisVec.y + 15, thisVec.z + 15)); for (final Entity e : l) { if (!e.isDead) { this.boss = (IBoss) e; this.boss.setRoom(this.roomCoords, this.roomSize); this.spawned = true; this.isBossDefeated = false; } } List<EntityMob> entitiesWithin = this.worldObj.getEntitiesWithinAABB( EntityMob.class, AxisAlignedBB.fromBounds( this.roomCoords.intX() - 3, this.roomCoords.intY() - 3, this.roomCoords.intZ() - 3, this.roomCoords.intX() + this.roomSize.intX() + 3, this.roomCoords.intY() + this.roomSize.intY() + 3, this.roomCoords.intZ() + this.roomSize.intZ() + 3)); for (Entity mob : entitiesWithin) { if (this.getDisabledCreatures().contains(mob.getClass())) { mob.setDead(); } } List<EntityPlayer> playersWithin = this.worldObj.getEntitiesWithinAABB( EntityPlayer.class, AxisAlignedBB.fromBounds( this.roomCoords.intX(), this.roomCoords.intY(), this.roomCoords.intZ(), this.roomCoords.intX() + this.roomSize.intX(), this.roomCoords.intY() + this.roomSize.intY(), this.roomCoords.intZ() + this.roomSize.intZ())); if (this.boss == null && !this.isBossDefeated && !playersWithin.isEmpty()) { try { Constructor<?> c = this.bossClass.getConstructor(new Class[] {World.class}); this.boss = (IBoss) c.newInstance(new Object[] {this.worldObj}); ((Entity) this.boss) .setPosition( this.getPos().getX() + 0.5, this.getPos().getY() + 1.0, this.getPos().getZ() + 0.5); this.boss.setRoom(this.roomCoords, this.roomSize); } catch (Exception e) { e.printStackTrace(); } } if (this.playerCheated) { if (!playersWithin.isEmpty()) { this.isBossDefeated = false; this.spawned = false; this.lastPlayerInRange = false; this.playerCheated = false; } } else if (playersWithin.size() == 0) { this.spawned = false; this.lastPlayerInRange = false; this.playerCheated = false; } this.playerInRange = !playersWithin.isEmpty(); if (this.playerInRange && !this.lastPlayerInRange) { if (this.boss != null && !this.spawned) { if (this.boss instanceof EntityLiving) { EntityLiving bossLiving = (EntityLiving) this.boss; bossLiving.onInitialSpawn( this.worldObj.getDifficultyForLocation(new BlockPos(bossLiving)), null); this.worldObj.spawnEntityInWorld(bossLiving); this.playSpawnSound(bossLiving); this.spawned = true; this.boss.onBossSpawned(this); this.boss.setRoom(this.roomCoords, this.roomSize); } } } if (this.boss != null && ((EntityLiving) this.boss).isDead) { this.isBossDefeated = false; this.spawned = false; this.lastPlayerInRange = false; this.playerCheated = false; this.boss = null; } this.lastPlayerInRange = this.playerInRange; } }