Пример #1
0
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    MinecraftServer server = MinecraftServer.getServer();
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != TFCBlocks.Ore
                && id != TFCBlocks.Ore2
                && id != TFCBlocks.Ore3
                && id != Blocks.bedrock)
              world.setBlock(
                  x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords(
                  (int) player.posX + (i * 16), (int) player.posZ + (k * 16));
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != TFCBlocks.Ore
                    && id != TFCBlocks.Ore2
                    && id != TFCBlocks.Ore3
                    && id != Blocks.bedrock)
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
Пример #2
0
  @Override
  public void processCommand(ICommandSender sender, String[] params) {
    EntityPlayerMP player = getCommandSenderAsPlayer(sender);

    if (!TFCOptions.enableDebugMode) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Debug Mode Required"));
      return;
    }

    MinecraftServer server = MinecraftServer.getServer();
    WorldServer world =
        server.worldServerForDimension(player.getEntityWorld().provider.dimensionId);
    if (params.length == 0) {
      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk"));
      Chunk chunk = world.getChunkFromBlockCoords((int) player.posX, (int) player.posZ);
      for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
          for (int y = 0; y < 256; y++) {
            Block id = chunk.getBlock(x, y, z);
            if (id != Blocks.air
                && id != TFCBlocks.ore
                && id != TFCBlocks.ore2
                && id != TFCBlocks.ore3
                && id != Blocks.bedrock) {
              if (TFC_Core.isGround(
                  id)) // Automatically replace ground blocks to help with performance
              {
                world.setBlock(
                    x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
              } else {
                Boolean isOre = false;
                Iterator iter = WorldGenOre.oreList.values().iterator();
                while (iter.hasNext()) {
                  OreSpawnData osd = (OreSpawnData) iter.next();
                  if (osd != null && id == osd.block) {
                    isOre = true;
                    break;
                  }
                }

                if (!isOre) {
                  world.setBlock(
                      x + (chunk.xPosition * 16), y, z + (chunk.zPosition * 16), Blocks.air, 0, 2);
                }
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    } else if (params.length == 1) {
      TFC_Core.sendInfoMessage(
          player,
          new ChatComponentText(
              "Stripping Chunks Within a Radius of " + Integer.parseInt(params[0])));
      int radius = Integer.parseInt(params[0]);
      for (int i = -radius; i <= radius; i++) {
        for (int k = -radius; k <= radius; k++) {
          Chunk chunk =
              world.getChunkFromBlockCoords((int) player.posX + i * 16, (int) player.posZ + k * 16);
          for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
              for (int y = 0; y < 256; y++) {
                Block id = chunk.getBlock(x, y, z);
                if (id != Blocks.air
                    && id != TFCBlocks.ore
                    && id != TFCBlocks.ore2
                    && id != TFCBlocks.ore3
                    && id != Blocks.bedrock) {
                  if (TFC_Core.isGround(
                      id)) // Automatically replace ground blocks to help with performance
                  {
                    world.setBlock(
                        x + (chunk.xPosition * 16),
                        y,
                        z + (chunk.zPosition * 16),
                        Blocks.air,
                        0,
                        2);
                  } else {
                    Boolean isOre = false;
                    Iterator iter = WorldGenOre.oreList.values().iterator();
                    while (iter.hasNext()) {
                      OreSpawnData osd = (OreSpawnData) iter.next();
                      if (osd != null && id == osd.block) {
                        isOre = true;
                        break;
                      }
                    }

                    if (!isOre) {
                      world.setBlock(
                          x + (chunk.xPosition * 16),
                          y,
                          z + (chunk.zPosition * 16),
                          Blocks.air,
                          0,
                          2);
                    }
                  }
                }
              }
            }
          }
        }
      }

      TFC_Core.sendInfoMessage(player, new ChatComponentText("Stripping Chunk Complete"));
    }
  }
Пример #3
0
  /** Called upon block activation (right click on the block.) */
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (world.isRemote) {
      return true;
    } else {
      int i1 = world.getBlockMetadata(x, y, z);

      if (!isBlockHeadOfBed(i1)) {
        int j1 = getDirection(i1);
        x += footBlockToHeadBlockMap[j1][0];
        z += footBlockToHeadBlockMap[j1][1];

        if (world.getBlock(x, y, z) != this) return true;

        i1 = world.getBlockMetadata(x, y, z);
      }

      if (world.provider.canRespawnHere() && world.getBiomeGenForCoords(x, z) != TFCBiome.hell) {
        if (isBedOccupied(i1)) {
          EntityPlayer entityplayer1 = null;
          Iterator iterator = world.playerEntities.iterator();

          while (iterator.hasNext()) {
            EntityPlayer entityplayer2 = (EntityPlayer) iterator.next();

            if (entityplayer2.isPlayerSleeping()) {
              ChunkCoordinates chunkcoordinates = entityplayer2.playerLocation;

              if (chunkcoordinates.posX == x
                  && chunkcoordinates.posY == y
                  && chunkcoordinates.posZ == z) {
                entityplayer1 = entityplayer2;
              }
            }
          }

          if (entityplayer1 != null) {
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.occupied"));
            return true;
          }

          setBedOccupied(world, x, y, z, false);
        }

        EnumStatus enumstatus = player.sleepInBedAt(x, y, z);

        if (enumstatus == EnumStatus.OK) {
          TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.customBed.sleep"));
          setBedOccupied(world, x, y, z, true);
          return true;
        } else {
          if (enumstatus == EnumStatus.NOT_POSSIBLE_NOW)
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.noSleep"));
          else if (enumstatus == EnumStatus.NOT_SAFE)
            TFC_Core.sendInfoMessage(player, new ChatComponentTranslation("tile.bed.notSafe"));

          return true;
        }
      } else {
        double d0 = x + 0.5D;
        double d1 = y + 0.5D;
        double d2 = z + 0.5D;
        world.setBlockToAir(x, y, z);
        int k1 = getDirection(i1);
        x += footBlockToHeadBlockMap[k1][0];
        z += footBlockToHeadBlockMap[k1][1];

        if (world.getBlock(x, y, z) == this) {
          world.setBlockToAir(x, y, z);
          d0 = (d0 + x + 0.5D) / 2.0D;
          d1 = (d1 + y + 0.5D) / 2.0D;
          d2 = (d2 + z + 0.5D) / 2.0D;
        }

        world.newExplosion((Entity) null, x + 0.5F, y + 0.5F, z + 0.5F, 5.0F, true, true);
        return true;
      }
    }
  }