コード例 #1
0
 public void removePlayerFromWhiteList(String name) {
   if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
     safePlayers.remove(name);
     numSafePlayers--;
   }
   safePlayers.removeAll(Arrays.asList("", null));
   ReikaChatHelper.write(
       name + " removed from " + placer + "'s " + this.getName() + " whitelist.");
 }
コード例 #2
0
  private final void drawRecipes() {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    int posX = (width - xSize) / 2;
    int posY = (height - ySize) / 2;
    try {
      this.drawAuxData(posX, posY);
    } catch (Exception e) {
      ReikaChatHelper.write(Arrays.toString(e.getStackTrace()));
      e.printStackTrace();
    }
  }
コード例 #3
0
 public void addPlayerToWhiteList(String name) {
   ReikaChatHelper.write(
       name
           + " added to "
           + placer
           + "'s whitelist for the\n"
           + this.getName()
           + " at "
           + xCoord
           + ", "
           + yCoord
           + ", "
           + zCoord
           + ".");
   if (name.equals(placer)) {
     ReikaChatHelper.write("Note: " + name + " is the owner;");
     ReikaChatHelper.write(
         "They did not need to tell the " + this.getName() + " to not target them.");
   }
   if (FMLCommonHandler.instance().getEffectiveSide() != Side.SERVER) return;
   safePlayers.add(name);
   numSafePlayers++;
 }
コード例 #4
0
  @Override
  public boolean onItemUse(
      ItemStack is,
      EntityPlayer ep,
      World world,
      int x,
      int y,
      int z,
      int side,
      float a,
      float b,
      float c) {
    if (is.stackTagCompound == null) {
      is.setTagCompound(new NBTTagCompound());
      is.stackTagCompound.setInteger("sx", Integer.MIN_VALUE);
      is.stackTagCompound.setInteger("sy", Integer.MIN_VALUE);
      is.stackTagCompound.setInteger("sz", Integer.MIN_VALUE);
      is.stackTagCompound.setInteger("ex", Integer.MIN_VALUE);
      is.stackTagCompound.setInteger("ey", Integer.MIN_VALUE);
      is.stackTagCompound.setInteger("ez", Integer.MIN_VALUE);
    }
    MovingObjectPosition mov = new MovingObjectPosition(x, y, z, side, ep.getLookVec());
    if (!WorldEditHelper.hasPlayer(ep)) {
      ReikaChatHelper.write("Player " + ep.getEntityName() + " has no chosen block!");
      return false;
    }
    int id = WorldEditHelper.getCommandedID(ep);
    int meta = WorldEditHelper.getCommandedMetadata(ep);

    if (id != 0) {
      if (id >= Block.blocksList.length
          || Block.blocksList[id] == null
          || Block.blocksList[id].getLocalizedName() == "") {
        ReikaChatHelper.write("Block " + id + " does not exist!");
        return false;
      }
    }

    if (ep.isSneaking()) {
      is.stackTagCompound.setInteger("ex", mov.blockX);
      is.stackTagCompound.setInteger("ey", mov.blockY);
      is.stackTagCompound.setInteger("ez", mov.blockZ);
      ReikaChatHelper.write(
          "Position 2 set to "
              + is.stackTagCompound.getInteger("ex")
              + ", "
              + is.stackTagCompound.getInteger("ey")
              + ", "
              + is.stackTagCompound.getInteger("ez"));
    } else {
      is.stackTagCompound.setInteger("sx", mov.blockX);
      is.stackTagCompound.setInteger("sy", mov.blockY);
      is.stackTagCompound.setInteger("sz", mov.blockZ);
      ReikaChatHelper.write(
          "Position 1 set to "
              + is.stackTagCompound.getInteger("sx")
              + ", "
              + is.stackTagCompound.getInteger("sy")
              + ", "
              + is.stackTagCompound.getInteger("sz"));
    }
    is.setItemDamage(1);
    ep.setCurrentItemOrArmor(0, is);
    int[] s = {
      is.stackTagCompound.getInteger("sx"),
      is.stackTagCompound.getInteger("sy"),
      is.stackTagCompound.getInteger("sz")
    };
    int[] e = {
      is.stackTagCompound.getInteger("ex"),
      is.stackTagCompound.getInteger("ey"),
      is.stackTagCompound.getInteger("ez")
    };
    if (s[0] != Integer.MIN_VALUE && s[1] != Integer.MIN_VALUE && s[2] != Integer.MIN_VALUE) {
      if (e[0] != Integer.MIN_VALUE && e[1] != Integer.MIN_VALUE && e[2] != Integer.MIN_VALUE) {
        if (s[0] != e[0] || s[1] != e[1] || s[2] != e[2]) {
          String name;
          if (id == 0) name = "Air";
          else name = Block.blocksList[id].getLocalizedName();
          ReikaChatHelper.write(
              String.format(
                      "%d", Math.abs((s[0] - e[0] + 1) * (s[1] - e[1] + 1) * (s[2] - e[2] + 1)))
                  + " blocks being changed to Block "
                  + name
                  + " (ID "
                  + id
                  + ") with Metadata "
                  + meta);
          for (int m = 0; m < 3; m++) {
            if (s[m] > e[m]) {
              int sc = s[m];
              s[m] = e[m];
              e[m] = sc;
            }
          }
          if (!world.isRemote)
            for (int i = s[0]; i <= e[0]; i += 1) {
              for (int j = s[1]; j <= e[1]; j += 1) {
                for (int k = s[2]; k <= e[2]; k += 1) {
                  world.setBlock(i, j, k, id, meta, 3);
                  world.markBlockForUpdate(i, j, k);
                }
              }
            }
          this.reset(is, ep);
        }
      }
    }
    return true;
  }
コード例 #5
0
 public void handleData(PacketObj packet, World world, EntityPlayer ep) {
   DataInputStream inputStream = packet.getDataIn();
   int control = Integer.MIN_VALUE;
   int len;
   int[] data = new int[0];
   long longdata = 0;
   float floatdata = 0;
   int x = 0;
   int y = 0;
   int z = 0;
   double dx = 0;
   double dy = 0;
   double dz = 0;
   boolean readinglong = false;
   String stringdata = null;
   UUID id = null;
   // System.out.print(packet.length);
   try {
     // ReikaJavaLibrary.pConsole(inputStream.readInt()+":"+inputStream.readInt()+":"+inputStream.readInt()+":"+inputStream.readInt()+":"+inputStream.readInt()+":"+inputStream.readInt()+":"+inputStream.readInt());
     PacketTypes packetType = packet.getType();
     switch (packetType) {
       case FULLSOUND:
         break;
       case SOUND:
         return;
       case STRING:
         stringdata = packet.readString();
         control = inputStream.readInt();
         // pack = ReactorPackets.getEnum(control);
         break;
       case DATA:
         control = inputStream.readInt();
         len = 1;
         data = new int[len];
         for (int i = 0; i < len; i++) data[i] = inputStream.readInt();
         break;
       case POS:
         control = inputStream.readInt();
         dx = inputStream.readDouble();
         dy = inputStream.readDouble();
         dz = inputStream.readDouble();
         len = 1;
         data = new int[len];
         for (int i = 0; i < len; i++) data[i] = inputStream.readInt();
         break;
       case UPDATE:
         control = inputStream.readInt();
         // pack = ReactorPackets.getEnum(control);
         break;
       case FLOAT:
         control = inputStream.readInt();
         // pack = ReactorPackets.getEnum(control);
         floatdata = inputStream.readFloat();
         break;
       case SYNC:
         String name = packet.readString();
         x = inputStream.readInt();
         y = inputStream.readInt();
         z = inputStream.readInt();
         ReikaPacketHelper.updateTileEntityData(world, x, y, z, name, inputStream);
         return;
       case TANK:
         String tank = packet.readString();
         x = inputStream.readInt();
         y = inputStream.readInt();
         z = inputStream.readInt();
         int level = inputStream.readInt();
         ReikaPacketHelper.updateTileEntityTankData(world, x, y, z, tank, level);
         return;
       case RAW:
         control = inputStream.readInt();
         len = 1;
         data = new int[len];
         for (int i = 0; i < len; i++) data[i] = inputStream.readInt();
         break;
       case PREFIXED:
         control = inputStream.readInt();
         len = inputStream.readInt();
         data = new int[len];
         for (int i = 0; i < len; i++) data[i] = inputStream.readInt();
         break;
       case NBT:
         break;
       case STRINGINT:
         stringdata = packet.readString();
         control = inputStream.readInt();
         data = new int[1];
         for (int i = 0; i < data.length; i++) data[i] = inputStream.readInt();
         break;
       case UUID:
         control = inputStream.readInt();
         long l1 = inputStream.readLong(); // most
         long l2 = inputStream.readLong(); // least
         id = new UUID(l1, l2);
         break;
     }
     if (packetType.hasCoordinates()) {
       x = inputStream.readInt();
       y = inputStream.readInt();
       z = inputStream.readInt();
     }
   } catch (IOException e) {
     e.printStackTrace();
     return;
   }
   TileEntity te = world.getTileEntity(x, y, z);
   try {
     switch (control) {
       case 0:
         ((AnalogWireless) te).setChannel(data[0]);
         break;
     }
   } catch (Exception e) {
     ExpandedRedstone.logger.logError(
         "Machine/item was deleted before its packet could be received!");
     ReikaChatHelper.writeString("Machine/item was deleted before its packet could be received!");
     e.printStackTrace();
   }
 }
コード例 #6
0
 @Override
 public void onPlayerLogin(EntityPlayer ep) {
   ReikaChatHelper.sendChatToPlayer(ep, message);
 }