Ejemplo n.º 1
0
  /** Retrieve a space station data entry, creating if necessary (with provided data) */
  public static SpaceStationWorldData getStationData(
      World world,
      int stationID,
      int homeID,
      int providerIdDynamic,
      int providerIdStatic,
      EntityPlayer player) {
    int providerType = DimensionManager.getProviderType(stationID);

    boolean foundMatch = false;

    // Loop through all registered satellites, checking for a provider ID match. If none is found,
    // this method is
    // being called on an incorrect
    for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
      if (satellite.getDimensionIdStatic() == providerType
          || satellite.getDimensionID() == providerType) {
        foundMatch = true;
        break;
      }
    }

    if (!foundMatch) {
      return null;
    } else {
      final String stationIdentifier = SpaceStationWorldData.getSpaceStationID(stationID);
      SpaceStationWorldData stationData =
          (SpaceStationWorldData)
              world.loadItemData(SpaceStationWorldData.class, stationIdentifier);

      if (stationData == null) {
        stationData = new SpaceStationWorldData(stationIdentifier);
        world.setItemData(stationIdentifier, stationData);
        stationData.dataCompound = new NBTTagCompound();

        if (player != null) {
          stationData.owner = player.getGameProfile().getName().replace(".", "");
        }

        stationData.spaceStationName = "Station: " + stationData.owner;

        if (player != null) {
          stationData.allowedPlayers.add(player.getGameProfile().getName());
        }

        if (homeID == -1) {
          throw new RuntimeException("Space station being created on bad home planet ID!");
        } else {
          stationData.homePlanet = homeID;
        }

        if (providerIdDynamic == -1 || providerIdStatic == -1) {
          throw new RuntimeException("Space station being created on bad provider IDs!");
        } else {
          stationData.dimensionIdDynamic = providerIdDynamic;
          stationData.dimensionIdStatic = providerIdStatic;
        }

        stationData.markDirty();
      }

      if (stationData.getSpaceStationName().replace(" ", "").isEmpty()) {
        stationData.setSpaceStationName("Station: " + stationData.owner);
        stationData.markDirty();
      }

      return stationData;
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void drawSlot(
      int var1, int var2, int var3, int var4, Tessellator var5, int var6, int var7) {
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GuiChoosePlanet.getDestinations(this.choosePlanetGui)[var1].toLowerCase();

    if (this.isSelected(var1)) {
      ArrayList<CelestialBody> cBodyList = new ArrayList<CelestialBody>();
      cBodyList.addAll(GalaxyRegistry.getRegisteredPlanets().values());
      cBodyList.addAll(GalaxyRegistry.getRegisteredMoons().values());

      for (CelestialBody celestialBody : cBodyList) {
        if (celestialBody != null) {
          String str = GuiChoosePlanet.getDestinations(this.choosePlanetGui)[var1].toLowerCase();

          if (str.contains("*")) {
            str = str.replace("*", "");
          }

          if (str.contains("$")) {
            final String[] twoDimensions = str.split("\\$");

            if (twoDimensions.length > 2) {
              str = twoDimensions[2];
            } else {
              str = "";
            }
          }

          if (celestialBody.getLocalizedName().equals(str)) {
            FMLClientHandler.instance()
                .getClient()
                .renderEngine
                .bindTexture(celestialBody.getPlanetIcon());
            GuiGalaxyMap.renderPlanet(var1, var2 - 18, var3 + 9, var4 + 3, var5);
          }
        }
      }

      if (this.choosePlanetGui.isValidDestination(var1)) {
        String str = GuiChoosePlanet.getDestinations(this.choosePlanetGui)[var1];

        if (str.contains("$")) {
          final String[] strs = str.split("\\$");

          if (strs.length > 2) {
            str = strs[2];
          } else {
            str = "";
          }
        } else {
          str = StatCollector.translateToLocal("dimension." + str + ".name");
        }

        this.choosePlanetGui.drawCenteredString(
            GuiChoosePlanet.getFontRenderer(this.choosePlanetGui),
            str,
            this.choosePlanetGui.width / 2,
            var3 + 3,
            0xEEEEEE);
      } else {
        String str = GuiChoosePlanet.getDestinations(this.choosePlanetGui)[var1];
        str = str.replace("*", "");

        this.choosePlanetGui.drawCenteredString(
            GuiChoosePlanet.getFontRenderer(this.choosePlanetGui),
            str,
            this.choosePlanetGui.width / 2,
            var3 + 3,
            0xEEEEEE);
      }
    } else {
      if (this.choosePlanetGui.isValidDestination(var1)) {
        String str = GuiChoosePlanet.getDestinations(this.choosePlanetGui)[var1];

        if (str.contains("$")) {
          final String[] strs = str.split("\\$");

          if (strs.length > 2) {
            str = strs[2];
          } else {
            str = "";
          }
        } else {
          str = StatCollector.translateToLocal("dimension." + str + ".name");
        }

        this.choosePlanetGui.drawCenteredString(
            GuiChoosePlanet.getFontRenderer(this.choosePlanetGui),
            str,
            this.choosePlanetGui.width / 2,
            var3 + 3,
            0xEEEEEE);
      } else {
        String str = GuiChoosePlanet.getDestinations(this.choosePlanetGui)[var1];
        str = str.replace("*", "");

        this.choosePlanetGui.drawCenteredString(
            GuiChoosePlanet.getFontRenderer(this.choosePlanetGui),
            str,
            this.choosePlanetGui.width / 2,
            var3 + 3,
            0xEEEEEE);
      }
    }

    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
  }