コード例 #1
0
  public static void applyShape(
      IShape shape,
      EntityPlayer player,
      ArrayList<NBTTagCompound> blockDataNbtList,
      byte baseRotation) {
    try {
      ArrayList<BlockData> blockDataList = new ArrayList<>();
      for (NBTTagCompound compound : blockDataNbtList) {
        BlockData blockData = new BlockData(compound);
        for (int i = 0; i <= blockData.weight; i++) blockDataList.add(blockData);
      }

      int x = Helper.round(player.posX),
          y = Helper.round(player.posY + 1),
          z = Helper.round(player.posZ);
      Collection<PointI> points =
          shape
              .rotate(baseRotation)
              .rotate(baseRotation == -1 ? -1 : Helper.getHeading(player))
              .move(x, y, z)
              .getPoints();
      for (PointI p : points) {
        if (!shape.getReplaceableOnly()
            || player
                .worldObj
                .getBlock(p.getX(), p.getY(), p.getZ())
                .isReplaceable(player.worldObj, p.getX(), p.getY(), p.getZ())) {
          BlockData block =
              blockDataList.size() == 1
                  ? blockDataList.get(0)
                  : Helper.getRandomFromSet(blockDataList);
          Block block1 = Block.getBlockById(block.id);
          player.worldObj.setBlock(p.getX(), p.getY(), p.getZ(), block1, block.meta, 2);
          if (block.te != null) {
            TileEntity tileEntity = TileEntity.createAndLoadEntity(block.te);
            tileEntity.setWorldObj(player.worldObj);
            tileEntity.xCoord = p.getX();
            tileEntity.yCoord = p.getY();
            tileEntity.zCoord = p.getZ();
            player.worldObj.setTileEntity(p.getX(), p.getY(), p.getZ(), tileEntity);
          }
        }
      }
    } catch (BlockData.BannedBlockException e) {
      ((EntityPlayerMP) player).playerNetServerHandler.kickPlayerFromServer(e.getMessage());
    } catch (Exception e) {
      e.printStackTrace();
      Pay2Spawn.getLogger().warn("Error spawning in shape.");
      Pay2Spawn.getLogger().warn("Shape: " + shape.toString());
      Pay2Spawn.getLogger().warn("Player: " + player);
      Pay2Spawn.getLogger()
          .warn("BlockData array: " + Arrays.deepToString(blockDataNbtList.toArray()));
    }
  }
コード例 #2
0
 @SubscribeEvent
 public void disconnect(FMLNetworkEvent.ClientDisconnectionFromServerEvent event) {
   Pay2Spawn.reloadDB();
   StatusMessage.resetServerStatus();
   new Timer()
       .schedule(
           new TimerTask() {
             @Override
             public void run() {
               if (!StatusMessage.doesServerHaveMod())
                 Helper.msg(
                     EnumChatFormatting.RED
                         + NAME
                         + " isn't on the server. No rewards will spawn!");
             }
           },
           5 * 1000);
 }
コード例 #3
0
 @SubscribeEvent
 public void connectionReceived(FMLNetworkEvent.ServerConnectionFromClientEvent event) {
   if (!event.isLocal && Pay2Spawn.getConfig().forceP2S) {
     final String username =
         ((NetHandlerPlayServer) event.handler).playerEntity.getCommandSenderName();
     new Timer()
         .schedule(
             new TimerTask() {
               @Override
               public void run() {
                 if (!StatusMessage.doesPlayerHaveValidConfig(username))
                   MinecraftServer.getServer()
                       .getConfigurationManager()
                       .func_152612_a(username)
                       .playerNetServerHandler
                       .kickPlayerFromServer(
                           "Pay2Spawn is required on this server.\nIt needs to be configured properly.");
               }
             },
             5 * 1000);
   }
 }
コード例 #4
0
 private File getFile() {
   return new File(Pay2Spawn.getFolder(), "Permissions.json");
 }