Esempio n. 1
0
 private void addRfToolsDimensions(
     World world, List<TeleportDestinationClientInfo> destinationList) {
   RfToolsDimensionManager dimensionManager = RfToolsDimensionManager.getDimensionManager(world);
   for (Map.Entry<Integer, DimensionDescriptor> me : dimensionManager.getDimensions().entrySet()) {
     int id = me.getKey();
     TeleportDestination destination = new TeleportDestination(new Coordinate(0, 70, 0), id);
     destination.setName("RfTools Dim: " + id);
     TeleportDestinationClientInfo teleportDestinationClientInfo =
         new TeleportDestinationClientInfo(destination);
     destinationList.add(teleportDestinationClientInfo);
   }
 }
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    if (!world.isRemote) {
      int id = player.worldObj.provider.dimensionId;
      RfToolsDimensionManager dimensionManager =
          RfToolsDimensionManager.getDimensionManager(player.worldObj);
      DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
      if (dimensionInformation == null) {
        Logging.message(player, "Not an RFTools dimension!");
      } else {
        String name = dimensionInformation.getName();
        DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
        int power = storage != null ? storage.getEnergyLevel(id) : 0;

        Logging.message(
            player,
            EnumChatFormatting.BLUE
                + "Name: "
                + name
                + " (Id "
                + id
                + ")"
                + EnumChatFormatting.YELLOW
                + "    Power: "
                + power
                + " RF");
        if (player.isSneaking()) {
          Logging.message(
              player,
              EnumChatFormatting.RED
                  + "Description: "
                  + dimensionInformation.getDescriptor().getDescriptionString());
          System.out.println(
              "Description:  = " + dimensionInformation.getDescriptor().getDescriptionString());
        }
      }
      return stack;
    }
    return stack;
  }
  @Override
  public void addInformation(
      ItemStack itemStack, EntityPlayer player, List list, boolean whatIsThis) {
    super.addInformation(itemStack, player, list, whatIsThis);
    int id = player.worldObj.provider.dimensionId;
    RfToolsDimensionManager dimensionManager =
        RfToolsDimensionManager.getDimensionManager(player.worldObj);
    DimensionInformation dimensionInformation = dimensionManager.getDimensionInformation(id);
    if (dimensionInformation == null) {
      list.add("Not an RFTools dimension!");
    } else {
      if (System.currentTimeMillis() - lastTime > 500) {
        lastTime = System.currentTimeMillis();
        PacketHandler.INSTANCE.sendToServer(new PacketGetDimensionEnergy(id));
      }
      String name = dimensionInformation.getName();
      DimensionStorage storage = DimensionStorage.getDimensionStorage(player.getEntityWorld());
      int power = storage != null ? storage.getEnergyLevel(id) : 0;

      list.add(EnumChatFormatting.BLUE + "Name: " + name + " (Id " + id + ")");

      list.add(EnumChatFormatting.YELLOW + "Power: " + power + " RF");
    }
  }