Exemple #1
0
  private static void renderMoon(
      float partialTickTime,
      WorldClient world,
      TextureManager renderEngine,
      Tessellator tessellator,
      float offset,
      float factor,
      float yangle,
      float size,
      ResourceLocation moon) {
    GL11.glTranslatef(0.0F, 0.0F, 0.0F);
    GL11.glRotatef(yangle, 0.0F, 1.0F, 0.0F);
    float angle =
        world.provider.calculateCelestialAngle(
            world.getWorldInfo().getWorldTime(), partialTickTime);
    angle = angle * factor + offset;
    GL11.glRotatef(angle * 360.0F, 1.0F, 0.0F, 0.0F);

    float f14, f15, f16, f17;
    renderEngine.bindTexture(moon);
    if (!moon.equals(locationMoonPhasesPng)) {
      f14 = 0.0f;
      f15 = 0.0f;
      f16 = 1.0f;
      f17 = 1.0f;
    } else {
      int k = world.getMoonPhase();
      int l = k % 4;
      int i1 = k / 4 % 2;
      f14 = (l + 0) / 4.0F;
      f15 = (i1 + 0) / 2.0F;
      f16 = (l + 1) / 4.0F;
      f17 = (i1 + 1) / 2.0F;
    }
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV((-size), -100.0D, size, f16, f17);
    tessellator.addVertexWithUV(size, -100.0D, size, f14, f17);
    tessellator.addVertexWithUV(size, -100.0D, (-size), f14, f15);
    tessellator.addVertexWithUV((-size), -100.0D, (-size), f16, f15);
    tessellator.draw();
  }
Exemple #2
0
  private static void renderCelestialBodies(
      float partialTickTime,
      DimensionInformation information,
      WorldClient world,
      TextureManager renderEngine,
      Tessellator tessellator) {
    List<CelestialBodyDescriptor> celestialBodies = information.getCelestialBodyDescriptors();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.glBlendFunc(770, 1, 1, 0);
    GL11.glPushMatrix();

    float f6 = 1.0F - world.getRainStrength(partialTickTime);
    ResourceLocation sun = getSun(information);
    ResourceLocation moon = getMoon(information);

    if (celestialBodies.isEmpty()) {
      GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
      GL11.glTranslatef(0.0F, 0.0F, 0.0F);
      GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(world.getCelestialAngle(partialTickTime) * 360.0F, 1.0F, 0.0F, 0.0F);
      float f10 = 30.0F;
      renderEngine.bindTexture(sun);
      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV((-f10), 100.0D, (-f10), 0.0D, 0.0D);
      tessellator.addVertexWithUV(f10, 100.0D, (-f10), 1.0D, 0.0D);
      tessellator.addVertexWithUV(f10, 100.0D, f10, 1.0D, 1.0D);
      tessellator.addVertexWithUV((-f10), 100.0D, f10, 0.0D, 1.0D);
      tessellator.draw();
      f10 = 20.0F;
      float f14, f15, f16, f17;
      renderEngine.bindTexture(moon);
      if (!moon.equals(locationMoonPhasesPng)) {
        f14 = 0.0f;
        f15 = 0.0f;
        f16 = 1.0f;
        f17 = 1.0f;
      } else {
        int k = world.getMoonPhase();
        int l = k % 4;
        int i1 = k / 4 % 2;
        f14 = (l + 0) / 4.0F;
        f15 = (i1 + 0) / 2.0F;
        f16 = (l + 1) / 4.0F;
        f17 = (i1 + 1) / 2.0F;
      }
      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV((-f10), -100.0D, f10, f16, f17);
      tessellator.addVertexWithUV(f10, -100.0D, f10, f14, f17);
      tessellator.addVertexWithUV(f10, -100.0D, (-f10), f14, f15);
      tessellator.addVertexWithUV((-f10), -100.0D, (-f10), f16, f15);
      tessellator.draw();
    } else {
      Random random = new Random(world.getSeed());
      for (CelestialBodyDescriptor body : celestialBodies) {
        float offset = 0.0f;
        float factor = 1.0f;
        float yangle = -90.0f;
        if (!body.isMain()) {
          offset = random.nextFloat() * 200.0f;
          factor = random.nextFloat() * 3.0f;
          yangle = random.nextFloat() * 180.0f;
        }
        switch (body.getType()) {
          case BODY_NONE:
            break;
          case BODY_SUN:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                30.0F,
                sun);
            break;
          case BODY_LARGESUN:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                80.0F,
                sun);
            break;
          case BODY_SMALLSUN:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                10.0F,
                sun);
            break;
          case BODY_REDSUN:
            GL11.glColor4f(1.0F, 0.0F, 0.0F, f6);
            renderSun(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                30.0F,
                sun);
            break;
          case BODY_MOON:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                20.0F,
                moon);
            break;
          case BODY_LARGEMOON:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                60.0F,
                moon);
            break;
          case BODY_SMALLMOON:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                10.0F,
                moon);
            break;
          case BODY_REDMOON:
            GL11.glColor4f(1.0F, 0.0F, 0.0F, f6);
            renderMoon(
                partialTickTime,
                world,
                renderEngine,
                tessellator,
                offset,
                factor,
                yangle,
                20.0F,
                moon);
            break;
          case BODY_PLANET:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderPlanet(
                partialTickTime, world, renderEngine, tessellator, offset, factor, yangle, 10.0F);
            break;
          case BODY_LARGEPLANET:
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f6);
            renderPlanet(
                partialTickTime, world, renderEngine, tessellator, offset, factor, yangle, 30.0F);
            break;
        }
      }
    }

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    float f18 = world.getStarBrightness(partialTickTime) * f6;

    if (f18 > 0.0F) {
      GL11.glColor4f(f18, f18, f18, f18);
      GL11.glCallList(starGLCallList);
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_FOG);
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
  }
    public Collection<ResourceLocation> getTextures() {
      // setting parent here to make textures resolve properly
      if (model.getParentLocation() != null) {
        if (model.getParentLocation().getResourcePath().equals("builtin/generated")) {
          model.parent = MODEL_GENERATED;
        } else {
          try {
            IModel parent = getModel(model.getParentLocation());
            if (parent instanceof VanillaModelWrapper) {
              model.parent = ((VanillaModelWrapper) parent).model;
            } else {
              throw new IllegalStateException(
                  "vanilla model '" + model + "' can't have non-vanilla parent");
            }
          } catch (IOException e) {
            FMLLog.warning(
                "Could not load vanilla model parent '"
                    + model.getParentLocation()
                    + "' for '"
                    + model
                    + "': "
                    + e.toString());
            IModel missing = ModelLoader.this.getMissingModel();
            if (missing instanceof VanillaModelWrapper) {
              model.parent = ((VanillaModelWrapper) missing).model;
            } else {
              throw new IllegalStateException(
                  "vanilla model '"
                      + model
                      + "' has missing parent, and missing model is not a vanilla model");
            }
          }
        }
      }

      ImmutableSet.Builder<ResourceLocation> builder = ImmutableSet.builder();

      if (hasItemModel(model)) {
        for (String s : (List<String>) ItemModelGenerator.LAYERS) {
          String r = model.resolveTextureName(s);
          ResourceLocation loc = new ResourceLocation(r);
          if (!r.equals(s)) {
            builder.add(loc);
          }
          // mojang hardcode
          if (model.getRootModel() == MODEL_COMPASS
              && !loc.equals(TextureMap.LOCATION_MISSING_TEXTURE)) {
            TextureAtlasSprite.setLocationNameCompass(loc.toString());
          } else if (model.getRootModel() == MODEL_CLOCK
              && !loc.equals(TextureMap.LOCATION_MISSING_TEXTURE)) {
            TextureAtlasSprite.setLocationNameClock(loc.toString());
          }
        }
      }
      for (String s : (Iterable<String>) model.textures.values()) {
        if (!s.startsWith("#")) {
          builder.add(new ResourceLocation(s));
        }
      }
      return builder.build();
    }