protected boolean spawnMob(IBeeGenome genome, IBeeHousing housing) {
    boolean flag = false;

    World w = housing.getWorld();
    int roll = 0;

    for (int i = 0; i < this.spawnChance.length && !flag; ++i) {
      roll = 100 - w.rand.nextInt(100) + 1;
      if (roll < this.spawnChance[i]) {
        flag = true;
        Entity mob = EntityList.createEntityByName(this.entityNames[i], w);
        // .createEntityByName method returns null when spawning a ghast in the overworld
        if (mob == null) return false;
        double[] coords = this.randomMobSpawnCoords(w, genome, housing);

        mob.setPositionAndRotation(coords[0], coords[1], coords[2], w.rand.nextFloat() * 360f, 0f);
        if (mob instanceof EntityLiving) {
          if (((EntityLiving) mob).getCanSpawnHere()) {
            w.spawnEntityInWorld(mob);
          }
        } else {
          w.spawnEntityInWorld(mob);
        }
      }
    }

    return flag;
  }
  public Entity func_98281_h() {
    if (this.field_98291_j == null) {
      Entity var1 = EntityList.createEntityByName(this.getEntityNameToSpawn(), (World) null);
      var1 = this.func_98265_a(var1);
      this.field_98291_j = var1;
    }

    return this.field_98291_j;
  }
 @Override
 public void handlePlacement(World world, int turns, int x, int y, int z) {
   Entity e = EntityList.createEntityByName(mobID, world);
   float x1 = BlockTools.rotateFloatX(xOffset, zOffset, turns);
   float z1 = BlockTools.rotateFloatZ(xOffset, zOffset, turns);
   float yaw = (rotation + 90.f * turns) % 360.f;
   e.setPosition(x + x1, y + yOffset, z + z1);
   e.rotationYaw = yaw;
   world.spawnEntityInWorld(e);
 }
  public Entity func_98265_a(Entity p_98265_1_) {
    if (this.getRandomMinecart() != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      p_98265_1_.writeToNBTOptional(var2);
      Iterator var3 = this.getRandomMinecart().field_98222_b.func_150296_c().iterator();

      while (var3.hasNext()) {
        String var4 = (String) var3.next();
        NBTBase var5 = this.getRandomMinecart().field_98222_b.getTag(var4);
        var2.setTag(var4, var5.copy());
      }

      p_98265_1_.readFromNBT(var2);

      if (p_98265_1_.worldObj != null) {
        p_98265_1_.worldObj.spawnEntityInWorld(p_98265_1_);
      }

      NBTTagCompound var11;

      for (Entity var10 = p_98265_1_; var2.func_150297_b("Riding", 10); var2 = var11) {
        var11 = var2.getCompoundTag("Riding");
        Entity var12 = EntityList.createEntityByName(var11.getString("id"), p_98265_1_.worldObj);

        if (var12 != null) {
          NBTTagCompound var6 = new NBTTagCompound();
          var12.writeToNBTOptional(var6);
          Iterator var7 = var11.func_150296_c().iterator();

          while (var7.hasNext()) {
            String var8 = (String) var7.next();
            NBTBase var9 = var11.getTag(var8);
            var6.setTag(var8, var9.copy());
          }

          var12.readFromNBT(var6);
          var12.setLocationAndAngles(
              var10.posX, var10.posY, var10.posZ, var10.rotationYaw, var10.rotationPitch);

          if (p_98265_1_.worldObj != null) {
            p_98265_1_.worldObj.spawnEntityInWorld(var12);
          }

          var10.mountEntity(var12);
        }

        var10 = var12;
      }
    } else if (p_98265_1_ instanceof EntityLivingBase && p_98265_1_.worldObj != null) {
      ((EntityLiving) p_98265_1_).onSpawnWithEgg((IEntityLivingData) null);
      this.getSpawnerWorld().spawnEntityInWorld(p_98265_1_);
    }

    return p_98265_1_;
  }
  @SideOnly(Side.CLIENT)
  public Entity getEntityForRenderer() {
    if (this.renderedEntity == null) {
      Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), getSpawnerWorld());
      entity = this.spawnEntity(entity);
      if (entity instanceof EntitySkeleton) ((EntitySkeleton) entity).setSkeletonType(skeletonType);
      this.renderedEntity = entity;
    }

    return this.renderedEntity;
  }
  /** Teleports the entity to another dimension. Params: Dimension number to teleport to */
  public static void travelEntityToDimension(Entity entity, int dimensionId, int x, int y, int z) {
    if (!entity.worldObj.isRemote && !entity.isDead) {
      entity.worldObj.theProfiler.startSection("changeDimension");
      MinecraftServer minecraftserver = MinecraftServer.getServer();
      int j = entity.dimension;
      WorldServer worldserver = minecraftserver.worldServerForDimension(j);
      WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
      entity.dimension = dimensionId;

      if (j == 1 && dimensionId == 1) {
        worldserver1 = minecraftserver.worldServerForDimension(0);
        entity.dimension = 0;
      }

      entity.worldObj.removeEntity(entity);
      entity.isDead = false;
      entity.worldObj.theProfiler.startSection("reposition");
      minecraftserver
          .getConfigurationManager()
          .transferEntityToWorld(entity, j, worldserver, worldserver1);
      entity.worldObj.theProfiler.endStartSection("reloading");
      Entity newEntity =
          EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

      if (newEntity != null) {
        newEntity.copyDataFrom(entity, true);

        if (j == 1 && dimensionId == 1) {
          ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint();
          chunkcoordinates.posY =
              entity.worldObj.getTopSolidOrLiquidBlock(
                  chunkcoordinates.posX, chunkcoordinates.posZ);
          newEntity.setLocationAndAngles(
              (double) chunkcoordinates.posX,
              (double) chunkcoordinates.posY,
              (double) chunkcoordinates.posZ,
              newEntity.rotationYaw,
              newEntity.rotationPitch);
        }

        worldserver1.spawnEntityInWorld(newEntity);
        newEntity.setPosition(x + 0.5D, y, z + 0.5D);
      }

      entity.isDead = true;
      entity.worldObj.theProfiler.endSection();
      worldserver.resetUpdateEntityTick();
      worldserver1.resetUpdateEntityTick();
      entity.worldObj.theProfiler.endSection();
    }
  }
Example #7
0
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {

    if (world.isRemote) {
      return true;
    }
    if (!containsSoul(itemstack)) {
      return false;
    }
    if (player == null) {
      return false;
    }

    Entity mob;
    NBTTagCompound root = itemstack.stackTagCompound;
    if (root.hasKey("isStub")) {
      String entityId = root.getString("id");
      mob = EntityList.createEntityByName(entityId, world);
    } else {
      mob = EntityList.createEntityFromNBT(root, world);
    }
    if (mob == null) {
      return true;
    }
    mob.readFromNBT(root);

    Block blk = world.getBlock(x, y, z);
    double spawnX = x + Facing.offsetsXForSide[side] + 0.5;
    double spawnY = y + Facing.offsetsYForSide[side];
    double spawnZ = z + Facing.offsetsZForSide[side] + 0.5;
    if (side == ForgeDirection.UP.ordinal()
        && (blk instanceof BlockFence || blk instanceof BlockWall)) {
      spawnY += 0.5;
    }
    mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);

    boolean spaceClear =
        world.checkNoEntityCollision(mob.boundingBox)
            && world.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty();
    if (!spaceClear) {
      return false;
    }

    if (itemstack.hasDisplayName() && mob instanceof EntityLiving) {
      ((EntityLiving) mob).setCustomNameTag(itemstack.getDisplayName());
    }

    world.spawnEntityInWorld(mob);
    if (mob instanceof EntityLiving) {
      ((EntityLiving) mob).playLivingSound();
    }

    Entity riddenByEntity = mob.riddenByEntity;
    while (riddenByEntity != null) {
      riddenByEntity.setLocationAndAngles(
          spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
      world.spawnEntityInWorld(riddenByEntity);
      if (riddenByEntity instanceof EntityLiving) {
        ((EntityLiving) riddenByEntity).playLivingSound();
      }
      riddenByEntity = riddenByEntity.riddenByEntity;
    }

    if (!player.capabilities.isCreativeMode) {
      if (itemstack.stackSize > 1) {
        itemstack.stackSize--;
        player.inventory.addItemStackToInventory(new ItemStack(this));
        player.inventoryContainer.detectAndSendChanges();
      } else {
        itemstack.setTagCompound(null);
      }
    }

    return true;
  }
  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);
  }
Example #9
0
  @Override
  public void processCommand(ICommandSender var1, String[] var2) {

    try {
      if (var1 instanceof EntityPlayerMP) {
        EntityPlayer player = getCommandSenderAsPlayer(var1);

        String prefix = "HostileWorlds.";
        String mobToSpawn = "InvaderZombieMiner";

        if (var2.length > 0) {
          if (var2[0].equalsIgnoreCase("spawn")) {
            if (var2[1].equalsIgnoreCase("miner")) {
              mobToSpawn = "InvaderZombieMiner";
            } else if (var2[1].equalsIgnoreCase("zombie")) {
              mobToSpawn = "InvaderZombie";
            } else if (var2[1].equalsIgnoreCase("fireworm")) {
              mobToSpawn = "EntityWormFire";
            } else if (var2[1].equalsIgnoreCase("sandworm")) {
              mobToSpawn = "EntityWormSand";
            } else if (var2[1].equalsIgnoreCase("boss")) {
              mobToSpawn = "BlockWielderZombie";
            } else {
              mobToSpawn = var2[1];
              prefix = "";
            }

            int count = 1;

            if (var2.length > 2) {
              count = Integer.valueOf(var2[2]);
            }

            for (int i = 0; i < count; i++) {
              Entity ent = EntityList.createEntityByName(prefix + mobToSpawn, player.worldObj);

              if (ent == null) ent = EntityList.createEntityByName(mobToSpawn, player.worldObj);

              if (ent != null) {

                double dist = 4D;

                double finalX = player.posX - (Math.sin(player.rotationYaw * 0.01745329F) * dist);
                double finalZ = player.posZ + (Math.cos(player.rotationYaw * 0.01745329F) * dist);

                double finalY = player.posY;

                ent.setPosition(finalX, finalY, finalZ);

                if (ent instanceof EntityInvader
                    && ((ICoroAI) ent).getAIAgent().jobMan.priJob instanceof JobGroupHorde) {
                  ((JobGroupHorde) ((ICoroAI) ent).getAIAgent().jobMan.priJob).attackCoord =
                      new ChunkCoordinates(
                          (int) player.posX, (int) player.boundingBox.minY, (int) player.posZ);
                }

                if (ent instanceof ICoroAI) ((ICoroAI) ent).getAIAgent().spawnedOrNBTReloadedInit();

                // temp
                // ent.setPosition(69, player.worldObj.getHeightValue(69, 301), 301);
                // ((JobGroupHorde)((ICoroAI) ent).getAIAgent().jobMan.priJob).attackCoord = new
                // ChunkCoordinates(44, player.worldObj.getHeightValue(44, 301), 301);

                player.worldObj.spawnEntityInWorld(ent);
                if (ent instanceof EntityLiving) {
                  ((EntityLiving) ent).onSpawnWithEgg(null);
                }
                System.out.println("Spawned: " + mobToSpawn);
              } else {
                System.out.println("failed to spawn");
                break;
              }
            }

          } else if (var2[0].equalsIgnoreCase("invasion")) {
            if (var2[1].equalsIgnoreCase("start")) {
              if (ModConfigFields.timeBasedInvasionsInstead) {
                WorldDirectorMultiDim.getPlayerNBT(CoroUtilEntity.getName(player))
                    .setInteger("HWInvasionCooldown", 20);
              } else {
                WorldDirectorMultiDim.getPlayerNBT(CoroUtilEntity.getName(player))
                    .setFloat(
                        "harvested_Rating",
                        WorldDirectorMultiDim.getHarvestRatingInvadeThreshold());
              }
            } else if (var2[1].equalsIgnoreCase("stop") || var2[1].equalsIgnoreCase("end")) {
              for (int i = 0;
                  i < WorldDirectorMultiDim.curInvasions.get(player.dimension).size();
                  i++) {
                WorldEvent we = WorldDirectorMultiDim.curInvasions.get(player.dimension).get(i);
                if (we.mainPlayerName.equals(CoroUtilEntity.getName(player))) {
                  WorldDirectorMultiDim.curInvasions.get(player.dimension).remove(i);
                  break;
                }
              }
            } else if (var2[1].equalsIgnoreCase("next")) {
              for (int i = 0;
                  i < WorldDirectorMultiDim.curInvasions.get(player.dimension).size();
                  i++) {
                WorldEvent we = WorldDirectorMultiDim.curInvasions.get(player.dimension).get(i);
                if (we.mainPlayerName.equals(CoroUtilEntity.getName(player))) {
                  we.curCooldown = 20;
                }
              }
              // if (WorldDirector.curInvasions.get(player.dimension).size() > 0)
              // WorldDirector.curInvasions.get(player.dimension).remove(0);
            }
          } else if (var2[0].equalsIgnoreCase("waveCount")) {
            String username = CoroUtilEntity.getName(player);
            int val = 0;
            if (var2.length > 3) {
              username = var2[2];
              val = Integer.valueOf(var2[3]);
            } else if (var2.length > 2) {
              val = Integer.valueOf(var2[2]);
            }
            if (var2[1].equalsIgnoreCase("reset")) {

            } else if (var2[1].equalsIgnoreCase("set")) {

            }
            WorldDirectorMultiDim.getPlayerNBT(username).setInteger("numOfWavesSpawned", val);
            CoroUtil.sendPlayerMsg((EntityPlayerMP) player, username + "s waveCount set to " + val);
            /*} else if (var2[0].equalsIgnoreCase("boss")) {
            if (var2[1].equalsIgnoreCase("reset")) {
            	if (player.dimension != 0) {
            		TileEntity tEnt = player.worldObj.getBlockTileEntity(HWTeleporter.portalCoord.posX, HWTeleporter.portalCoord.posY, HWTeleporter.portalCoord.posZ);
            		if (tEnt instanceof TileEntityHWPortal) {
            			((TileEntityHWPortal) tEnt).bossEventOccurred = false;
            		}
            	}
            }*/
          } else if (var2[0].equalsIgnoreCase("get")) {
            if (var2.length > 1) {
              Object obj = ConfigMod.getField(getCommandName(), var2[1]);
              if (obj != null) {
                CoroUtil.sendPlayerMsg((EntityPlayerMP) player, var2[1] + " = " + obj);
              } else {
                CoroUtil.sendPlayerMsg((EntityPlayerMP) player, "failed to get " + var2[1]);
              }
            }
          } else if (var2[0].equalsIgnoreCase("set")) {
            if (var2.length > 2) {

              String val = "";
              for (int i = 2; i < var2.length; i++)
                val += var2[i] + (i != var2.length - 1 ? " " : "");
              if (ConfigMod.updateField(getCommandName(), var2[1], val)) {
                CoroUtil.sendPlayerMsg((EntityPlayerMP) player, "set " + var2[1] + " to " + val);
              } else {
                CoroUtil.sendPlayerMsg((EntityPlayerMP) player, "failed to set " + var2[1]);
              }
            } else {
              CoroUtil.sendPlayerMsg((EntityPlayerMP) player, "set requires 3 parameters");
            }
          } else if (var2[0].equalsIgnoreCase("derp")) {

            EntityMeteorite.genBuilding(
                player.worldObj,
                MathHelper.floor_double(player.posX),
                MathHelper.floor_double(player.posY + 2),
                MathHelper.floor_double(player.posZ),
                22);

          } else if (var2[0].equalsIgnoreCase("derp2")) {

            int size = 22;
            int origSize = size;
            int startX = 0;
            int startZ = 0;

            int x = 0;
            int y = 0;
            int z = 0;

            for (y = 0; y < 50; y++) {
              for (x = startX; x <= size; x++) {
                for (z = startZ; z <= size; z++) {
                  player.worldObj.setBlock(
                      (int) (player.posX + x - origSize / 2),
                      (int) (player.posY + y + 5),
                      (int) (player.posZ + z - origSize / 2),
                      HostileWorlds.blockBloodyCobblestone);
                }
              }
              startX += 1;
              startZ += 1;
              size -= 1;

              if (size - startX < 5) {
                break;
              }
            }
          } else if (var2[0].equals("stronghold")) {

            // for now, to speed up production, use CoroUtil world director for its managed
            // locations, and HW multi dimensional WorldDirector for ... for what?

            int x = MathHelper.floor_double(player.posX);
            int z = MathHelper.floor_double(player.posZ);
            int y = player.worldObj.getHeightValue(x, z);
            Stronghold village = new Stronghold();

            WorldDirector wd =
                WorldDirectorManager.instance().getCoroUtilWorldDirector(player.worldObj);
            // questionable ID setting
            int newID = wd.lookupTickingManagedLocations.size();
            village.initData(
                newID, player.worldObj.provider.dimensionId, new ChunkCoordinates(x, y, z));
            village.initFirstTime();
            wd.addTickingLocation(village);
            // StructureObject bb = StructureMapping.newTown(player.worldObj.provider.dimensionId,
            // "command", new ChunkCoordinates(x, y, z));
            // bb.init();
            // bb.location.initFirstTime();
          } else if (var2[0].equals("regen")) {
            WorldDirector wd =
                WorldDirectorManager.instance().getCoroUtilWorldDirector(player.worldObj);
            Iterator it = wd.lookupTickingManagedLocations.values().iterator();
            while (it.hasNext()) {
              ManagedLocation ml = (ManagedLocation) it.next();
              ml.initFirstTime();
            }
          } else if (var2[0].equals("infotest")) {
            Chunk chunk =
                player.worldObj.getChunkFromBlockCoords(
                    MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posZ));

            System.out.println("inhabited time: " + chunk.inhabitedTime);
          } else if (var2[0].equals("testdig")) {
            TaskDigTowardsTarget task = new TaskDigTowardsTarget();

            System.out.println("ENHANCE!");
            BehaviorModifier.enhanceZombiesToDig(
                DimensionManager.getWorld(0),
                Vec3.createVectorHelper(player.posX, player.posY, player.posZ),
                new Class[] {TaskDigTowardsTarget.class, TaskCallForHelp.class},
                5);
          }

          /* else if (var2[0].equalsIgnoreCase("rts")) {
          	if (var2[1].equalsIgnoreCase("new")) {
          		RtsEngine.teams.teamNew(player.worldObj.provider.dimensionId, new ChunkCoordinates((int)(player.posX), (int)(player.posY), (int)(player.posZ)));
          	} else if (var2[1].equalsIgnoreCase("reset") || var2[1].equalsIgnoreCase("clear") ) {
          		RtsEngine.teams.teamRemoveAll();
          	}
          }*/

        }
      }
    } catch (Exception ex) {
      System.out.println("Exception handling Hostile Worlds command");
      ex.printStackTrace();
    }
  }
  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();
        }
      }
    }
  }
Example #11
0
  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();
        }
      }
    }
  }
  private static Entity sendEntityToWorld(
      Entity entity, int newDimension, Vector3 newPos, Facing3 newLook) {
    MinecraftServer server = MinecraftServer.getServer();
    Entity currentEntity = entity;
    if (entity.dimension != newDimension) {
      if (entity instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        ServerConfigurationManager scm = server.getConfigurationManager();
        int oldDimension = player.dimension;
        player.dimension = newDimension;
        WorldServer oldWorld = server.worldServerForDimension(oldDimension);
        WorldServer newWorld = server.worldServerForDimension(newDimension);

        DimensionRegisterMessage packet =
            new DimensionRegisterMessage(
                newDimension, DimensionManager.getProviderType(newDimension));
        LCRuntime.runtime.network().getPreferredPipe().sendForgeMessageTo(packet, player);

        player.closeScreen();
        player.playerNetServerHandler.sendPacket(
            new S07PacketRespawn(
                player.dimension,
                player.worldObj.difficultySetting,
                newWorld.getWorldInfo().getTerrainType(),
                player.theItemInWorldManager.getGameType()));
        oldWorld.removePlayerEntityDangerously(player);
        player.isDead = false;
        player.setLocationAndAngles(
            newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
        newWorld.spawnEntityInWorld(player);
        player.setWorld(newWorld);
        scm.func_72375_a(player, oldWorld);
        player.playerNetServerHandler.setPlayerLocation(
            newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
        player.theItemInWorldManager.setWorld(newWorld);
        scm.updateTimeAndWeatherForPlayer(player, newWorld);
        scm.syncPlayerInventory(player);
        Iterator<?> var6 = player.getActivePotionEffects().iterator();
        while (var6.hasNext())
          player.playerNetServerHandler.sendPacket(
              new S1DPacketEntityEffect(player.getEntityId(), (PotionEffect) var6.next()));
        player.playerNetServerHandler.sendPacket(
            new S1FPacketSetExperience(
                player.experience, player.experienceTotal, player.experienceLevel));
      } else {
        int oldDimension = entity.dimension;
        WorldServer oldWorld = server.worldServerForDimension(oldDimension);
        WorldServer newWorld = server.worldServerForDimension(newDimension);
        entity.dimension = newDimension;

        entity.worldObj.removeEntity(entity);
        entity.isDead = false;
        server
            .getConfigurationManager()
            .transferEntityToWorld(entity, oldDimension, oldWorld, newWorld);
        currentEntity = EntityList.createEntityByName(EntityList.getEntityString(entity), newWorld);

        if (currentEntity != null) {
          currentEntity.copyDataFrom(entity, true);
          currentEntity.setLocationAndAngles(
              newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
          newWorld.spawnEntityInWorld(currentEntity);
        }

        entity.isDead = true;
        oldWorld.resetUpdateEntityTick();
        newWorld.resetUpdateEntityTick();
      }
    } else {
      currentEntity.setLocationAndAngles(
          newPos.x, newPos.y, newPos.z, (float) newLook.yaw, (float) newLook.pitch);
      if (currentEntity instanceof EntityPlayerMP) {
        EntityPlayerMP mpEnt = (EntityPlayerMP) currentEntity;
        mpEnt.rotationYaw = (float) newLook.yaw;
        mpEnt.setPositionAndUpdate(newPos.x, newPos.y, newPos.z);
        mpEnt.worldObj.updateEntityWithOptionalForce(entity, false);
      }
    }
    return currentEntity;
  }