コード例 #1
0
  public void newDay(Collection<TownBuilding> buildings) {
    Set<GatheringLocation> previous = new HashSet(locations);
    locations = new HashSet();

    // Remove all previous locations
    for (GatheringLocation location : previous) {
      World world = DimensionManager.getWorld(location.dimension);
      if (world.getBlock(location.x, location.y, location.z) == location.block) {
        if (world.getBlockMetadata(location.x, location.y, location.z) == location.meta) {
          world.setBlockToAir(location.x, location.y, location.z);
        }
      }
    }

    // Create some new spawn spots based on where we have buildings
    for (TownBuilding building : buildings) {
      World world = DimensionManager.getWorld(building.dimension);
      int placed = 0;
      for (int i = 0; i < 64 && placed < 10; i++) {
        int x = building.xCoord + 32 - world.rand.nextInt(64);
        int y = building.yCoord + 4 - world.rand.nextInt(8);
        int z = building.zCoord + 32 - world.rand.nextInt(64);
        if (world.getBlock(x, y, z) == Blocks.grass
            && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z)) {
          ItemStack random = getRandomBlock();
          Block block = Block.getBlockFromItem(random.getItem());
          int meta = random.getItemDamage();
          if (world.setBlock(x, y + 1, z, block, meta, 2)) {
            locations.add(new GatheringLocation(block, meta, building.dimension, x, y + 1, z));
            placed++;
          }
        }
      }
    }
  }
コード例 #2
0
ファイル: Protection.java プロジェクト: Nerzhei/MyTown2
  /** Checking right click actions on blocks. */
  public boolean checkBlockInteraction(
      Resident res, BlockPos bp, PlayerInteractEvent.Action action) {
    Block blockType =
        DimensionManager.getWorld(bp.getDim()).getBlock(bp.getX(), bp.getY(), bp.getZ());
    for (SegmentBlock segment : segmentsBlocks) {
      if (segment.getCheckClass().isAssignableFrom(blockType.getClass())
          && (segment.getMeta() == -1
              || segment.getMeta()
                  == DimensionManager.getWorld(bp.getDim())
                      .getBlockMetadata(bp.getX(), bp.getY(), bp.getZ()))
          && (segment.getType() == BlockType.ANY_CLICK
              || segment.getType() == BlockType.RIGHT_CLICK
                  && action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK
              || segment.getType() == BlockType.LEFT_CLICK
                  && action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK)) {
        int dim = bp.getDim();
        int x = bp.getX();
        int y = bp.getY();
        int z = bp.getZ();

        if (!hasPermission(res, segment, dim, x, y, z)) {
          if (segment.hasClientUpdate())
            sendClientUpdate(
                segment.getClientUpdateCoords(), bp, (EntityPlayerMP) res.getPlayer(), null);
          return true;
        }
      }
    }

    return false;
  }
コード例 #3
0
 /** Gets the worldServer by the given dimension. */
 public WorldServer worldServerForDimension(int par1) {
   WorldServer ret = DimensionManager.getWorld(par1);
   if (ret == null) {
     DimensionManager.initDimension(par1);
     ret = DimensionManager.getWorld(par1);
   }
   return ret;
 }
コード例 #4
0
 /**
  * Return the current root directory for the world save. Accesses getSaveHandler from the
  * overworld
  *
  * @return the root directory of the save
  */
 public static File getCurrentSaveRootDirectory() {
   if (DimensionManager.getWorld(0) != null) {
     return ((SaveHandler) DimensionManager.getWorld(0).getSaveHandler()).getWorldDirectory();
   } else if (MinecraftServer.getServer() != null) {
     MinecraftServer srv = MinecraftServer.getServer();
     SaveHandler saveHandler =
         (SaveHandler) srv.getActiveAnvilConverter().getSaveLoader(srv.getFolderName(), false);
     return saveHandler.getWorldDirectory();
   } else {
     return null;
   }
 }
コード例 #5
0
  public WorldServer getWorld() {
    WorldServer world = DimensionManager.getWorld(dimension);

    if (world == null) {
      DimensionManager.initDimension(dimension);
      world = DimensionManager.getWorld(dimension);

      if (world == null) {
        return null; // How?
      }
    }

    return world;
  }
コード例 #6
0
  @Override
  public void onSpaceDimensionChanged(
      World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) {
    if (BlankPlanet.makelandingplatform) {
      int X = player.getPlayerCoordinates().posX;
      int Z = player.getPlayerCoordinates().posZ;
      if (newWorld.isAirBlock(X, 100, Z)
          && newWorld == DimensionManager.getWorld(BlankPlanet.dimensionid)) {
        for (int i = 0; i < 5; i++) {
          for (int j = 0; j < 5; j++) {
            newWorld.setBlock(X + i, 100, Z + j, Blocks.stone);
          }
        }

        for (int i = 0; i < 5; i++) {
          for (int j = 0; j < 5; j++) {
            newWorld.setBlock(X - i, 100, Z + j, Blocks.stone);
          }
        }

        for (int i = 0; i < 5; i++) {
          for (int j = 0; j < 5; j++) {
            newWorld.setBlock(X + i, 100, Z - j, Blocks.stone);
          }
        }

        for (int i = 0; i < 5; i++) {
          for (int j = 0; j < 5; j++) {
            newWorld.setBlock(X - i, 100, Z - j, Blocks.stone);
          }
        }
      }
    }
  }
コード例 #7
0
  private void serverTick(boolean doEffects) {
    World entityWorld = MinecraftServer.getServer().getEntityWorld();
    RfToolsDimensionManager dimensionManager =
        RfToolsDimensionManager.getDimensionManager(entityWorld);

    if (!dimensionManager.getDimensions().isEmpty()) {
      DimensionStorage dimensionStorage = DimensionStorage.getDimensionStorage(entityWorld);

      for (Map.Entry<Integer, DimensionDescriptor> entry :
          dimensionManager.getDimensions().entrySet()) {
        Integer id = entry.getKey();
        // If there is an activity probe we only drain power if the dimension is loaded (a player is
        // there or a chunkloader)
        DimensionInformation information = dimensionManager.getDimensionInformation(id);
        WorldServer world = DimensionManager.getWorld(id);

        // Power handling.
        if (world != null || information.getProbeCounter() == 0) {
          handlePower(doEffects, dimensionStorage, entry, id, information);
        }

        // Special effect handling.
        if (world != null && !world.playerEntities.isEmpty()) {
          handleRandomEffects(world, information);
        }
      }

      dimensionStorage.save(entityWorld);
    }
  }
コード例 #8
0
ファイル: TEC.java プロジェクト: AhmiDarrow/ThaumicExpansion
    @Override
    public void readFromNBT(NBTTagCompound tagCom) {
      TEC.idToUsername.clear();
      NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10);
      for (int i = 0; i < idUsernameTag.tagCount(); i++) {
        NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i);
        TEC.idToUsername.put(
            UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName"));
      }

      TEC.aspectBuffer.clear();
      NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10);
      for (int i = 0; i < bufferTag.tagCount(); i++) {
        NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i);
        UUID playerID = UUID.fromString(idedBuffer.getString("playerID"));
        NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10);
        for (int j = 0; j < playersBuffer.tagCount(); j++) {
          NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j);

          NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan");
          ScanResult scan =
              new ScanResult(
                  scanTag.getByte("type"),
                  scanTag.getInteger("id"),
                  scanTag.getInteger("meta"),
                  EntityList.createEntityFromNBT(
                      scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)),
                  scanTag.getString("phenomena"));

          TEC.addAspect(
              playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent"));
        }
      }
    }
コード例 #9
0
  @SubscribeEvent
  public void onClientPacket(ClientCustomPacketEvent event) {

    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
    byte packetType;
    int dimension;
    byte packetID;
    try {
      packetType = bbis.readByte();
      dimension = bbis.readInt();
      World world = DimensionManager.getWorld(dimension);
      if (packetType == 2) {
        this.handleRocketJumpHackyPacket(bbis, world);
      }
      if (packetType == 3) {
        this.handleExplodePacket(bbis, world);
      }
      //        	for (int i = 0; i < 3; i++){
      //        		player.worldObj.spawnParticle("smoke", x, y, z, -0.005D+(Math.random()*0.01D),
      // 0.025D, -0.005D+(Math.random()*0.01D));
      //        	}

      bbis.close();
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }
  }
コード例 #10
0
 public World getWorld() {
   // Cauldron start - fixes MFR proxy worlds used with grinder/slaughterhouse
   if (entity.worldObj.getWorld() == null) {
     return DimensionManager.getWorld(0).getWorld();
   }
   // Cauldron end
   return entity.worldObj.getWorld();
 }
コード例 #11
0
  public static void setSpawnPoint(int dimension, int spawnX, int spawnY, int spawnZ) {
    World dimensionWorld = DimensionManager.getWorld(dimension);
    if (dimensionWorld instanceof WorldServerMulti) {
      WorldServerMulti w = (WorldServerMulti) DimensionManager.getWorld(dimension);
      DerivedWorldInfo worldInfo = (DerivedWorldInfo) w.getWorldInfo();

      try {
        Field f = DerivedWorldInfo.class.getDeclaredField(MCPNames.field("field_76115_a"));
        f.setAccessible(true);
        WorldInfo info = (WorldInfo) f.get(worldInfo);
        info.setSpawnPosition(spawnX, spawnY, spawnZ);
      } catch (Exception e) {
        PerfectSpawn.instance.logger.log(Level.ERROR, "Couldn't set spawn position");
        e.printStackTrace();
      }
    } else {
      WorldInfo info = dimensionWorld.getWorldInfo();
      info.setSpawnPosition(spawnX, spawnY, spawnZ);
    }
  }
コード例 #12
0
  /** Checks if the block whitelist is still valid */
  public static boolean isBlockWhitelistValid(BlockWhitelist bw) {
    // Delete if the town is gone
    if (MyTownUtils.getTownAtPosition(bw.getDim(), bw.getX() >> 4, bw.getZ() >> 4) == null)
      return false;

    if (bw.getFlagType() == FlagType.ACTIVATE
        && !checkActivatedBlocks(
            DimensionManager.getWorld(bw.getDim()).getBlock(bw.getX(), bw.getY(), bw.getZ()),
            DimensionManager.getWorld(bw.getDim())
                .getBlockMetadata(bw.getX(), bw.getY(), bw.getZ()))) return false;
    if (bw.getFlagType() == FlagType.MODIFY
        || bw.getFlagType() == FlagType.ACTIVATE
        || bw.getFlagType() == FlagType.USAGE) {
      TileEntity te =
          DimensionManager.getWorld(bw.getDim()).getTileEntity(bw.getX(), bw.getY(), bw.getZ());
      if (te == null) return false;
      return getFlagsForTile(te.getClass()).contains(bw.getFlagType());
    }
    return true;
  }
コード例 #13
0
 @Override
 public void handleServerSide(EntityPlayer player) {
   World world = DimensionManager.getWorld(this.dim);
   if (world == null) return;
   TileEntity tileEntity = world.getTileEntity(this.x, this.y, this.z);
   if (tileEntity != null && tileEntity instanceof TileEntityCustomizeableDecoration) {
     TileEntityCustomizeableDecoration tile = (TileEntityCustomizeableDecoration) tileEntity;
     tile.setOrientation(rotation);
     tile.setScale(scale);
   }
 }
コード例 #14
0
  @Override
  public void fromBytes(ByteBuf buf) {
    world = DimensionManager.getWorld(buf.readInt());

    try {
      packet = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.SERVERBOUND, buf.readInt());
      packet.readPacketData(new PacketBuffer(buf));
    } catch (InstantiationException | IllegalAccessException | IOException e) {
      throw new DecoderException(e);
    }
  }
コード例 #15
0
  private void handleLowPower(Integer id, int power, boolean doEffects) {
    if (power <= 0) {
      // We ran out of power!
      WorldServer world = DimensionManager.getWorld(id);
      if (world != null) {
        List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities);
        if (DimletConfiguration.dimensionDifficulty >= 1) {
          for (EntityPlayer player : players) {
            if (!RfToolsDimensionManager.checkValidPhasedFieldGenerator(player, true)) {
              player.attackEntityFrom(new DamageSourcePowerLow("powerLow"), 1000000.0f);
            } else {
              if (doEffects && DimletConfiguration.phasedFieldGeneratorDebuf) {
                player.addPotionEffect(
                    new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
                player.addPotionEffect(
                    new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
                player.addPotionEffect(
                    new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
              }
            }
          }
        } else {
          Random random = new Random();
          for (EntityPlayer player : players) {
            if (!RfToolsDimensionManager.checkValidPhasedFieldGenerator(player, true)) {
              WorldServer worldServerForDimension =
                  MinecraftServer.getServer()
                      .worldServerForDimension(DimletConfiguration.spawnDimension);
              int x = random.nextInt(2000) - 1000;
              int z = random.nextInt(2000) - 1000;
              int y = worldServerForDimension.getTopSolidOrLiquidBlock(x, z);
              if (y == -1) {
                y = 63;
              }

              TeleportationTools.teleportToDimension(
                  player, DimletConfiguration.spawnDimension, x, y, z);
            } else {
              if (doEffects) {
                player.addPotionEffect(
                    new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
                player.addPotionEffect(
                    new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
                player.addPotionEffect(
                    new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
              }
            }
          }
        }
      }
    }
  }
コード例 #16
0
ファイル: TEC.java プロジェクト: AhmiDarrow/ThaumicExpansion
 @SubscribeEvent
 public void loadWorld(WorldEvent.Load event) {
   if (event.world.provider.dimensionId == 0 && event.world instanceof WorldServer) {
     MapStorage storage = DimensionManager.getWorld(0).mapStorage;
     if (storage != null) {
       TECData data = (TECData) storage.loadData(TECData.class, "TECData");
       if (data == null) {
         data = new TECData();
         data.markDirty();
       }
     }
   }
 }
コード例 #17
0
  public TileEntity getBlockTileEntity() {
    WorldServer world = getWorld();

    if (world == null) {
      DimensionManager.initDimension(dimension);
      world = DimensionManager.getWorld(dimension);

      if (world == null) {
        return null; // How?
      }
    }

    world.getChunkProvider().loadChunk(posX >> 4, posY >> 4);

    return world.getBlockTileEntity(posX, posY, posZ);
  }
コード例 #18
0
  /**
   * Checks to see if the situation for firing the laser exists... and changes the state accordingly
   */
  public void checkCanRun() {
    // Laser requires lense, redstone power, not be jammed, and be in orbit and energy to function
    if (!worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)
        || glassPanel == null
        || storage.getEnergyStored()
            == 0 /*|| !(this.worldObj.provider instanceof IOrbitDimension)*/) {
      if (laserSat.isAlive()) {
        laserSat.deactivateLaser();
      }

      isRunning = false;
    } else if (!laserSat.isAlive()
        && !finished
        && !laserSat.getJammed()
        && worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)
        && canMachineSeeEarth()) {

      // Laser will be on at this point
      int orbitDimId =
          0; // =
             // WorldUtil.getProviderForName(((IOrbitDimension)this.worldObj.provider).getPlanetToOrbit()).dimensionId;
      WorldServer orbitWorld = DimensionManager.getWorld(orbitDimId);

      if (ticket == null) {
        ticket =
            ForgeChunkManager.requestTicket(AdvancedRocketry.instance, this.worldObj, Type.NORMAL);
        if (ticket != null)
          ForgeChunkManager.forceChunk(
              ticket,
              new ChunkCoordIntPair(
                  this.xCoord / 16 - (this.xCoord < 0 ? 1 : 0),
                  this.zCoord / 16 - (this.zCoord < 0 ? 1 : 0)));
      }

      isRunning = laserSat.activateLaser(orbitWorld, laserX, laserZ);
    }

    if (!this.worldObj.isRemote)
      PacketHandler.sendToNearby(
          new PacketMachine(this, (byte) 2),
          this.xCoord,
          this.yCoord,
          this.zCoord,
          128,
          this.worldObj.provider.dimensionId);
  }
コード例 #19
0
 private void handleEffectsForDimension(int power, int id, DimensionInformation information) {
   WorldServer world = DimensionManager.getWorld(id);
   if (world != null) {
     Set<EffectType> effects = information.getEffectTypes();
     List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities);
     for (EntityPlayer player : players) {
       for (EffectType effect : effects) {
         Integer potionEffect = effectsMap.get(effect);
         if (potionEffect != null) {
           Integer amplifier = effectAmplifierMap.get(effect);
           if (amplifier == null) {
             amplifier = 0;
           }
           player.addPotionEffect(
               new PotionEffect(potionEffect, EFFECTS_MAX * MAXTICKS * 3, amplifier, true));
         } else if (effect == EffectType.EFFECT_FLIGHT) {
           BuffProperties.addBuff(player, PlayerBuff.BUFF_FLIGHT, EFFECTS_MAX * MAXTICKS * 2);
         }
       }
       if (power < DimletConfiguration.DIMPOWER_WARN3) {
         // We are VERY low on power. Start bad effects.
         player.addPotionEffect(
             new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
         player.addPotionEffect(
             new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true));
         player.addPotionEffect(
             new PotionEffect(Potion.poison.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
         player.addPotionEffect(
             new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
       } else if (power < DimletConfiguration.DIMPOWER_WARN2) {
         player.addPotionEffect(
             new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
         player.addPotionEffect(
             new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true));
         player.addPotionEffect(
             new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 1, true));
       } else if (power < DimletConfiguration.DIMPOWER_WARN1) {
         player.addPotionEffect(
             new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true));
         player.addPotionEffect(
             new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 0, true));
       }
     }
   }
 }
コード例 #20
0
    @Override
    public IMessage onMessage(StringPacket message, MessageContext ctx) {
      World world = DimensionManager.getWorld(message.targetPos[0]);

      if (message.targetType == Syncer.TargetType.Entity) {
        Entity target = world.getEntityByID(message.targetPos[1]);
        IStringSyncer is = (IStringSyncer) target;
        is.setStringData(message.data);
      } else if (message.targetType == Syncer.TargetType.TileEntity) {
        TileEntity target =
            world.getTileEntity(
                new BlockPos(message.targetPos[1], message.targetPos[2], message.targetPos[3]));
        IStringSyncer is = (IStringSyncer) target;
        is.setStringData(message.data);
      }

      return null;
    }
コード例 #21
0
ファイル: BukkitServer.java プロジェクト: sct/BukkitForge
	public World getWorld(int dimID) {
		if (worlds.containsKey(dimID))
			return worlds.get(dimID);
		else if (!worlds.containsKey(dimID) && Arrays.asList(DimensionManager.getIDs()).contains(dimID)) {
			// dim there but not registered with us.
			WorldServer internal = DimensionManager.getWorld(dimID);
			int dim = internal.getWorldInfo().getDimension();
				System.out.println("Registering dimension with BukkitForge: " + dim + "..." );
				WorldProvider w = internal.provider;
				
				Environment env = w.isHellWorld ? Environment.NETHER : Environment.NORMAL;
				ChunkGenerator cg = new NormalChunkGenerator(internal);//(((WorldServer)ev.world).theChunkProviderServer);
				BukkitWorld bukkit = new BukkitWorld(internal, cg, env);
				BukkitServer.instance().worlds.put(dim, bukkit);
				return bukkit;
			
		}
		return null;
	}
コード例 #22
0
ファイル: Protection.java プロジェクト: Nerzhei/MyTown2
  public void sendClientUpdate(
      Volume updateVolume, BlockPos center, EntityPlayerMP player, ForgeDirection face) {
    World world = DimensionManager.getWorld(center.getDim());
    int x, y, z;

    if (face != null) updateVolume = translateVolume(updateVolume, face);

    for (int i = updateVolume.getMinX(); i <= updateVolume.getMaxX(); i++) {
      for (int j = updateVolume.getMinY(); j <= updateVolume.getMaxY(); j++) {
        for (int k = updateVolume.getMinZ(); k <= updateVolume.getMaxZ(); k++) {
          x = center.getX() + i;
          y = center.getY() + j;
          z = center.getZ() + k;

          S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
          packet.field_148884_e = world.getBlockMetadata(x, y, z);
          FMLCommonHandler.instance()
              .getMinecraftServerInstance()
              .getConfigurationManager()
              .sendPacketToAllPlayers(packet);
        }
      }
    }
  }
コード例 #23
0
  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
  }
コード例 #24
0
  public void updateTimeLightAndEntities() {
    this.theProfiler.startSection("levels");
    int i;

    Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
    for (int x = 0; x < ids.length; x++) {
      int id = ids[x];
      long j = System.nanoTime();

      if (id == 0 || this.getAllowNether()) {
        WorldServer worldserver = DimensionManager.getWorld(id);
        this.theProfiler.startSection(worldserver.getWorldInfo().getWorldName());
        this.theProfiler.startSection("pools");
        worldserver.getWorldVec3Pool().clear();
        this.theProfiler.endSection();

        if (this.tickCounter % 20 == 0) {
          this.theProfiler.startSection("timeSync");
          this.serverConfigManager.sendPacketToAllPlayersInDimension(
              new Packet4UpdateTime(worldserver.getTotalWorldTime(), worldserver.getWorldTime()),
              worldserver.provider.dimensionId);
          this.theProfiler.endSection();
        }

        this.theProfiler.startSection("tick");
        FMLCommonHandler.instance().onPreWorldTick(worldserver);
        CrashReport crashreport;

        try {
          worldserver.tick();
        } catch (Throwable throwable) {
          crashreport = CrashReport.makeCrashReport(throwable, "Exception ticking world");
          worldserver.addWorldInfoToCrashReport(crashreport);
          throw new ReportedException(crashreport);
        }

        try {
          worldserver.updateEntities();
        } catch (Throwable throwable1) {
          crashreport = CrashReport.makeCrashReport(throwable1, "Exception ticking world entities");
          worldserver.addWorldInfoToCrashReport(crashreport);
          throw new ReportedException(crashreport);
        }

        FMLCommonHandler.instance().onPostWorldTick(worldserver);
        this.theProfiler.endSection();
        this.theProfiler.startSection("tracker");
        worldserver.getEntityTracker().updateTrackedEntities();
        this.theProfiler.endSection();
        this.theProfiler.endSection();
      }

      worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
    }

    this.theProfiler.endStartSection("dim_unloading");
    DimensionManager.unloadWorlds(worldTickTimes);
    this.theProfiler.endStartSection("connection");
    this.getNetworkThread().networkTick();
    this.theProfiler.endStartSection("players");
    this.serverConfigManager.sendPlayerInfoToAllPlayers();
    this.theProfiler.endStartSection("tickables");

    for (i = 0; i < this.tickables.size(); ++i) {
      ((IUpdatePlayerListBox) this.tickables.get(i)).update();
    }

    this.theProfiler.endSection();
  }
コード例 #25
0
ファイル: CommonProxy.java プロジェクト: dagarath/PlenaInanis
 public World getWorld() {
   return DimensionManager.getWorld(0);
 }
コード例 #26
0
 public World getPointWorld() {
   if (dimensionId != Integer.MAX_VALUE) return DimensionManager.getWorld(dimensionId);
   return null;
 }
コード例 #27
0
  private void execute(ICommandSender sender, String[] args) {
    /*
     * No world, Status update.
     */
    if (args.length == 0) {
      // Header
      String header = "--- Fillers active ---";
      sender.sendChatToPlayer(header);
      // Actual info
      for (Integer world : map.keySet()) {
        sender.sendChatToPlayer(world + ": " + map.get(world).getStatus());
      }
      // Footer
      StringBuilder footer = new StringBuilder();
      for (int i = 3; i < header.length(); i++) {
        footer.append("-");
      }
      sender.sendChatToPlayer(footer.toString());
      return;
    }

    /*
     * Get the world
     */
    WorldServer world = null;
    if (FunctionHelper.isNumeric(args[0])) {
      world = DimensionManager.getWorld(parseInt(sender, args[0]));
    } else if ((args[0].equalsIgnoreCase("here") || args[0].equalsIgnoreCase("world"))
        && sender instanceof EntityPlayer) {
      world = (WorldServer) ((EntityPlayer) sender).worldObj;
    }

    if (world == null) {
      OutputHandler.chatError(sender, args[0] + " is not an ID of a loaded world.");
      return;
    }

    if (args.length == 1) {
      if (map.containsKey(world.provider.dimensionId)) {
        OutputHandler.chatConfirmation(sender, map.get(world.provider.dimensionId).getStatus());
      } else {
        OutputHandler.chatError(sender, "There is no filler running for that world.");
      }
    } else {
      if (args[1].equalsIgnoreCase("start")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          map.put(world.provider.dimensionId, new TickTaskFill(world, sender, true));
        } else {
          OutputHandler.chatError(sender, "Filler already running for that world!");
        }
      } else if (args[1].equalsIgnoreCase("stop")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          OutputHandler.chatError(sender, "There is no filler running for that world.");
        } else {
          map.get(world.provider.dimensionId).stop();
        }
      } else if (args[1].equalsIgnoreCase("reset")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          map.put(world.provider.dimensionId, new TickTaskFill(world, sender, false));
        } else {
          OutputHandler.chatError(sender, "Filler already running for that world!");
        }
      } else if (args[1].equalsIgnoreCase("speed")) {
        if (!map.containsKey(world.provider.dimensionId)) {
          OutputHandler.chatError(sender, "There is no filler running for that world.");
        } else {
          if (args.length != 3) {
            OutputHandler.chatConfirmation(
                sender, "Current speed: " + map.get(world.provider.dimensionId));
          } else {
            map.get(world.provider.dimensionId).speed(parseIntWithMin(sender, args[2], 0));
            if (map.get(world.provider.dimensionId).source != sender) {
              OutputHandler.chatError(sender, "Changed speed to " + args[2]);
            }
          }
        }
      }
    }
  }
コード例 #28
0
  public static void transferEntityToDimension(EntityPlayerMP ent, int dim) {
    final WorldServer pass = DimensionManager.getWorld(dim);
    if (dim == 0)
      ent.mcServer
          .getConfigurationManager()
          .transferPlayerToDimension(
              ent,
              dim,
              new Teleporter(pass) {

                @Override
                public boolean placeInExistingPortal(
                    Entity ent, double par2, double par4, double par6, float par8) {
                  ChunkCoordinates c = pass.getSpawnPoint();
                  if (c == null) { // sadfaic
                    ent.setVelocity(0, 0, 0);
                    ent.setLocationAndAngles(0, pass.getHeightValue(0, 0) + 4, 0, 0, 0);
                    System.out.println("Moved to 0,0 (spawnpoint is null!)");
                  } else {
                    ent.setVelocity(0, 0, 0);
                    ent.setLocationAndAngles(
                        c.posX, pass.getHeightValue(c.posX, c.posZ) + 4, c.posZ, 0, 0);
                    System.out.println("Moved to " + c.posX + ", " + c.posY + ", " + c.posZ);
                  }
                  return true;
                }

                @Override
                public void placeInPortal(
                    Entity ent, double par2, double par4, double par6, float par8) {
                  ChunkCoordinates c = pass.getSpawnPoint();
                  if (c == null) { // sadfaic
                    ent.setVelocity(0, 0, 0);
                    ent.setLocationAndAngles(0, pass.getHeightValue(0, 0) + 4, 0, 0, 0);
                    System.out.println("Moved to 0,0 (spawnpoint is null!)");
                  } else {
                    ent.setVelocity(0, 0, 0);
                    ent.setLocationAndAngles(
                        c.posX, pass.getHeightValue(c.posX, c.posZ) + 4, c.posZ, 0, 0);
                    System.out.println("Moved to " + c.posX + ", " + c.posY + ", " + c.posZ);
                  }
                }
              }); // no idea if this will cause issues with the nether gate (creating an invalid
                  // return point)
    else
      ent.mcServer
          .getConfigurationManager()
          .transferPlayerToDimension(
              ent,
              dim,
              new Teleporter(pass) {

                @Override
                public boolean func_85188_a /*  generatePortal?  */(Entity ent) {
                  int xr = 0;
                  int yr = 40;
                  int zr = 0;

                  //                    for (int x = xr - 10; x < xr + 10; x++) {
                  //                        for (int y = yr - 10; y < yr + 10; y++) {
                  //                            for (int z = zr - 10; z < zr + 10; z++) {
                  //                                if (x == xr && y == yr - 8 && z == zr) {
                  //                                    pass.setBlock(x, y, z, 4004);
                  //                                } else {
                  //                                    pass.setBlock(x, y, z, 0);
                  //                                }
                  //                            }
                  //                        }
                  //                    }
                  //                    for (int y = yr; y < 255; y++) {
                  //                        pass.setBlock(xr, y, zr, 0);
                  //                    }
                  pass.setBlock(0, pass.getHeightValue(0, 0) + 1, 0, 4004);
                  ent.setVelocity(0, 0, 0);
                  //                    ent.setLocationAndAngles(xr, yr+1, zr, 0, 0);
                  ent.setLocationAndAngles(0, pass.getHeightValue(0, 0) + 5, 0, 0, 0);

                  return true; // finally.... no more automatic nethergate spawning
                }
              });
  }
コード例 #29
0
 @Override
 public void processCommand(final ICommandSender commandSender, List<String> arguments) {
   World world = null;
   int time_ = 30;
   boolean location = false;
   Integer x = null;
   Integer z = null;
   try {
     if ("c".equals(arguments.get(0))) {
       location = true;
       if (arguments.size() > 2) {
         x = Integer.valueOf(arguments.remove(1));
         z = Integer.valueOf(arguments.remove(1));
       }
     }
     if (arguments.size() > 1) {
       time_ = Integer.valueOf(arguments.get(1));
     }
     if (arguments.size() > 2) {
       world = DimensionManager.getWorld(Integer.valueOf(arguments.get(2)));
     } else if (location && commandSender instanceof Entity) {
       world = ((Entity) commandSender).worldObj;
     }
     if (location && x == null) {
       Entity entity = (Entity) commandSender;
       x = entity.chunkCoordX;
       z = entity.chunkCoordZ;
     }
   } catch (Exception e) {
     sendChat(
         commandSender, "Usage: /profile [e/(c [chunk x] [chunk z])] [time=30] [dimensionid=all]");
     return;
   }
   final List<World> worlds = new ArrayList<World>();
   if (world == null) {
     Collections.addAll(worlds, DimensionManager.getWorlds());
   } else {
     worlds.add(world);
   }
   final int time = time_;
   final EntityTickProfiler entityTickProfiler = EntityTickProfiler.ENTITY_TICK_PROFILER;
   if (!entityTickProfiler.startProfiling(
       new Runnable() {
         @Override
         public void run() {
           sendChat(
               commandSender,
               entityTickProfiler.writeStringData(new TableFormatter(commandSender)).toString());
         }
       },
       location ? ProfilingState.CHUNK : ProfilingState.GLOBAL,
       time,
       worlds)) {
     sendChat(commandSender, "Someone else is currently profiling.");
   }
   if (location) {
     entityTickProfiler.setLocation(x, z);
   }
   sendChat(
       commandSender,
       "Profiling for "
           + time
           + " seconds in "
           + (world == null ? "all worlds " : Log.name(world))
           + (location ? " at " + x + ',' + z : ""));
 }
コード例 #30
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();
    }
  }