public Entity spawnEntity(Entity par1Entity) {

    if (par1Entity instanceof EntityLivingBase && par1Entity.worldObj != null) {
      if (par1Entity instanceof EntitySkeleton) {
        ((EntitySkeleton) par1Entity).setSkeletonType(skeletonType);
        if (skeletonType == 1) {
          par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.stone_sword));
          ((EntitySkeleton) par1Entity).setEquipmentDropChance(0, 0f);
        } else {
          par1Entity.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
        }
      } else ((EntityLiving) par1Entity).onSpawnWithEgg(null);

      if (!requiresPlayer) {
        ((EntityLiving) par1Entity).func_110163_bv();
        par1Entity
            .getEntityData()
            .setLong("SpawnedByDESpawner", getSpawnerWorld().getTotalWorldTime());
      }

      this.getSpawnerWorld().spawnEntityInWorld(par1Entity);
    }

    return par1Entity;
  }
  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_;
  }
Exemple #3
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1) {
      String var3 = par2ArrayOfStr[0];
      double var4 = (double) par1ICommandSender.getCommandSenderPosition().posX + 0.5D;
      double var6 = (double) par1ICommandSender.getCommandSenderPosition().posY;
      double var8 = (double) par1ICommandSender.getCommandSenderPosition().posZ + 0.5D;

      if (par2ArrayOfStr.length >= 4) {
        var4 = func_110666_a(par1ICommandSender, var4, par2ArrayOfStr[1]);
        var6 = func_110666_a(par1ICommandSender, var6, par2ArrayOfStr[2]);
        var8 = func_110666_a(par1ICommandSender, var8, par2ArrayOfStr[3]);
      }

      World var10 = par1ICommandSender.getEntityWorld();

      if (!var10.blockExists((int) var4, (int) var6, (int) var8)) {
        notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]);
      } else {
        NBTTagCompound var11 = new NBTTagCompound();
        boolean var12 = false;

        if (par2ArrayOfStr.length >= 5) {
          IChatComponent var13 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4);

          try {
            NBTBase var14 = JsonToNBT.func_150315_a(var13.getUnformattedText());

            if (!(var14 instanceof NBTTagCompound)) {
              notifyAdmins(
                  par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"});
              return;
            }

            var11 = (NBTTagCompound) var14;
            var12 = true;
          } catch (NBTException var17) {
            notifyAdmins(
                par1ICommandSender, "commands.summon.tagError", new Object[] {var17.getMessage()});
            return;
          }
        }

        var11.setString("id", var3);
        Entity var18 = EntityList.createEntityFromNBT(var11, var10);

        if (var18 != null) {
          var18.setLocationAndAngles(var4, var6, var8, var18.rotationYaw, var18.rotationPitch);

          if (!var12 && var18 instanceof EntityLiving) {
            ((EntityLiving) var18).onSpawnWithEgg((IEntityLivingData) null);
          }

          var10.spawnEntityInWorld(var18);
          Entity var19 = var18;

          for (NBTTagCompound var15 = var11;
              var15.func_150297_b("Riding", 10);
              var15 = var15.getCompoundTag("Riding")) {
            Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), var10);

            if (var16 != null) {
              var16.setLocationAndAngles(var4, var6, var8, var16.rotationYaw, var16.rotationPitch);
              var10.spawnEntityInWorld(var16);
              var19.mountEntity(var16);
            }

            var19 = var16;
          }

          notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]);
        } else {
          notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]);
        }
      }
    } else {
      throw new WrongUsageException("commands.summon.usage", new Object[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();
    }
  }