Beispiel #1
0
  @Override
  public void update() {
    super.update();
    if (!((GuiWorkspace) workspace).projectManager.projects.isEmpty()) {
      ProjectInfo info =
          ((GuiWorkspace) workspace)
              .projectManager.projects.get(
                  ((GuiWorkspace) workspace).projectManager.selectedProject);

      listenTime++;
      if (listenTime > 20) {
        listenTime = 0;
        boolean shouldListen = false;
        for (Element e : elements) {
          if (e.id == 0) {
            shouldListen = ((ElementToggle) e).toggledState;
          }
        }
        if (shouldListen && info.textureFile != null && info.textureFile.exists()) {
          String md5 = IOUtil.getMD5Checksum(info.textureFile);
          if (md5 != null && !md5.equals(info.textureFileMd5)) {
            info.ignoreNextImage = true;
            info.textureFileMd5 = md5;

            BufferedImage image = null;
            try {
              image = ImageIO.read(info.textureFile);
            } catch (IOException e) {
            }

            if (!((GuiWorkspace) workspace).remoteSession) {
              Tabula.proxy.tickHandlerClient.mainframe.loadTexture(info.identifier, image, false);
            } else if (!((GuiWorkspace) workspace).sessionEnded
                && ((GuiWorkspace) workspace).isEditor) {
              ProjectHelper.sendTextureToServer(
                  ((GuiWorkspace) workspace).host, info.identifier, false, image);
            }
          }
        }
      }

      if (info.bufferedTexture != this.image) {
        if (this.imageId != -1) {
          TextureUtil.deleteTexture(this.imageId);
          this.imageId = -1;
        }
        this.image = info.bufferedTexture;
        if (this.image != null) {
          this.imageId = TextureUtil.uploadTextureImage(TextureUtil.glGenTextures(), this.image);
        }
      }
    }
  }
 public void onResourceManagerReload(IResourceManager p_110549_1_) {
   try {
     ColorizerFoliage.setFoliageBiomeColorizer(
         TextureUtil.readImageData(p_110549_1_, field_130079_a));
   } catch (IOException var3) {;
   }
 }
 public void func_110549_a(ResourceManager par1ResourceManager) {
   try {
     ColorizerGrass.setGrassBiomeColorizer(
         TextureUtil.func_110986_a(par1ResourceManager, field_130078_a));
   } catch (IOException ioexception) {;
   }
 }
 private Object verify(Object obj) {
   if (obj instanceof String)
     AbyssalCraftAPI.getInternalNDHandler().verifyImageURL((String) obj);
   if (!(obj instanceof ResourceLocation)) return obj;
   if (FMLCommonHandler.instance().getSide().isServer()) return obj;
   ResourceLocation res = (ResourceLocation) obj;
   if (res.toString().equals("abyssalcraft:textures/gui/necronomicon/missing.png")) return obj;
   try {
     TextureUtil.readBufferedImage(
         Minecraft.getMinecraft().getResourceManager().getResource(res).getInputStream());
   } catch (IOException e) {
     return new ResourceLocation("abyssalcraft", "textures/gui/necronomicon/missing.png");
   }
   return res;
 }
  @Override
  public void func_110551_a(ResourceManager resourcemanager) throws IOException {
    BufferedImage image = null;

    image =
        new BufferedImage(
            PatternStore.small_rgbs[crest.getPattern()][0].length,
            PatternStore.small_rgbs[crest.getPattern()][0][0].length,
            BufferedImage.TYPE_4BYTE_ABGR);

    for (int x = 0; x < image.getWidth(); x++) {
      for (int y = 0; y < image.getHeight(); y++) {
        image.setRGB(
            x,
            y,
            PatternStore.getBlendedSmallPixel(
                crest.getPattern(),
                x,
                y,
                crest.getColour(0),
                crest.getColour(1),
                crest.getColour(2)));
      }
    }

    CrestImages crestImage = CrestImages.images[crest.getCrest()];
    if (crestImage.getId() != 0 && crestImage != null) {
      System.out.println(crestImage);
      Graphics g = image.getGraphics();
      // g.setColor(new Color(0x00000000));
      g.drawImage(
          crestImage.getImage(crest.getColour(3)),
          image.getWidth() / 4,
          image.getHeight() / 4,
          image.getWidth() / 2,
          image.getHeight() / 2,
          null);
      g.dispose();

      System.out.println(Integer.toHexString(crest.getColour(3)));
    }

    TextureUtil.func_110987_a(this.func_110552_b(), image);
  }
Beispiel #6
0
 @Override
 public void drawScreen(int x, int y, float par3) {
   x = applyXOffset(x);
   y = applyYOffset(y);
   if (nbt.getBoolean("canDisplay")) {
     int wheel = Mouse.getDWheel();
     if (wheel != 0) {
       PacketSenders.GPUEvent(x, y, tile, wheel);
     }
     if (isMouseDown) {
       if (x > -1 & y > -1 & x < mon.getWidth() + 1 & y < mon.getHeight() + 1) {
         mx = x;
         my = y;
         if (mlx != mx | mly != my) {
           PacketSenders.mouseEventMove(mx, my, tile);
         }
         mlx = mx;
         mly = my;
       } else {
         mouseMovedOrUp(unapplyXOffset(x) / 2, unapplyYOffset(y) / 2, mouseButton);
       }
     }
   }
   drawWorldBackground(0);
   synchronized (tex) {
     try {
       if (tex.renderLock) {
         tex.wait(1L);
       }
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
   }
   TextureUtil.uploadTexture(
       TabletRenderer.dyntex.getGlTextureId(), tex.rgbCache, 16 * 32, 9 * 32);
   drawTexturedModalRect(unapplyXOffset(0), unapplyYOffset(0), tex.getWidth(), tex.getHeight());
   GL11.glDisable(GL11.GL_TEXTURE_2D);
 }
 public void func_110549_a(ResourceManager p_110549_1_) {
   try {
     ColorizerGrass.func_77479_a(TextureUtil.func_110986_a(p_110549_1_, field_130078_a));
   } catch (IOException var3) {;
   }
 }
  protected void doRenderItem(
      ItemRenderType type, ItemStack item, Item iconItem, FluidStack liquid) {

    IIcon icon = iconItem.getIcon(item, 0);
    IIcon mask = iconItem.getIcon(item, 1);
    boolean hasLiquid = liquid != null;
    IIcon fluid = hasLiquid ? liquid != null ? liquid.getFluid().getIcon(liquid) : null : mask;
    int liquidSheet = hasLiquid & liquid != null ? liquid.getFluid().getSpriteNumber() : 0;
    int colorMult = hasLiquid & liquid != null ? liquid.getFluid().getColor(liquid) : 0xFFFFFF;
    boolean isFloaty =
        hasLiquid & liquid != null ? liquid.getFluid().getDensity(liquid) < 0 : false;

    if (fluid == null) {
      fluid = Blocks.flowing_lava.getIcon(2, 0);
      liquidSheet = 0;
      colorMult = 0x3F3F3F;
    }

    TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;

    float iconMinX = icon.getMinU();
    float iconMaxX = icon.getMaxU();
    float iconMinY = icon.getMinV();
    float iconMaxY = icon.getMaxV();

    float maskMinX = mask.getMinU();
    float maskMaxX = mask.getMaxU();
    float maskMinY = mask.getMinV();
    float maskMaxY = mask.getMaxV();

    float fluidMinX = fluid.getMinU();
    float fluidMaxX = fluid.getMaxU();
    float fluidMinY = fluid.getMinV();
    float fluidMaxY = fluid.getMaxV();

    if (isFloaty && canFlip) {
      iconMaxY = icon.getMinV();
      iconMinY = icon.getMaxV();

      maskMaxY = mask.getMinV();
      maskMinY = mask.getMaxV();

      fluidMaxY = fluid.getMinV();
      fluidMinY = fluid.getMaxV();
    }

    TextureUtil.func_147950_a(false, false);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(
        GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    if (type == ItemRenderType.INVENTORY) {
      GL11.glDisable(GL11.GL_LIGHTING);

      tessellator.startDrawingQuads();
      tessellator.addVertexWithUV(0, 16, 0, iconMinX, iconMaxY);
      tessellator.addVertexWithUV(16, 16, 0, iconMaxX, iconMaxY);
      tessellator.addVertexWithUV(16, 0, 0, iconMaxX, iconMinY);
      tessellator.addVertexWithUV(0, 0, 0, iconMinX, iconMinY);
      tessellator.draw();

      if (hasLiquid) {
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(0, 16, 0.001, maskMinX, maskMaxY);
        tessellator.addVertexWithUV(16, 16, 0.001, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(16, 0, 0.001, maskMaxX, maskMinY);
        tessellator.addVertexWithUV(0, 0, 0.001, maskMinX, maskMinY);
        tessellator.draw();

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDepthMask(false);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        bindTexture(renderEngine, liquidSheet);
        OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);

        tessellator.startDrawingQuads();
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 16, 0.001, fluidMinX, fluidMaxY);
        tessellator.addVertexWithUV(16, 16, 0.001, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(16, 0, 0.001, fluidMaxX, fluidMinY);
        tessellator.addVertexWithUV(0, 0, 0.001, fluidMinX, fluidMinY);
        tessellator.draw();

        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }

      GL11.glEnable(GL11.GL_LIGHTING);
    } else {
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);

      if (type == ItemRenderType.ENTITY) {
        GL11.glTranslatef(0.5f, 4 / -16f, 0);
        GL11.glRotatef(180, 0, 1, 0);
      }

      ItemRenderer.renderItemIn2D(
          tessellator,
          iconMaxX,
          iconMinY,
          iconMinX,
          iconMaxY,
          icon.getIconWidth(),
          icon.getIconHeight(),
          0.0625F);

      if (hasLiquid) {
        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, 1);
        tessellator.addVertexWithUV(0, 0, 0.001, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(1, 0, 0.001, maskMinX, maskMaxY);
        tessellator.addVertexWithUV(1, 1, 0.001, maskMinX, maskMinY);
        tessellator.addVertexWithUV(0, 1, 0.001, maskMaxX, maskMinY);
        tessellator.draw();
        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, -1);
        tessellator.addVertexWithUV(0, 1, -0.0635, maskMinX, maskMinY);
        tessellator.addVertexWithUV(1, 1, -0.0635, maskMaxX, maskMinY);
        tessellator.addVertexWithUV(1, 0, -0.0635, maskMaxX, maskMaxY);
        tessellator.addVertexWithUV(0, 0, -0.0635, maskMinX, maskMaxY);
        tessellator.draw();

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDepthMask(false);
        bindTexture(renderEngine, liquidSheet);
        OpenGlHelper.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE, GL11.GL_ZERO);

        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, 1);
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 0, 0.001, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(1, 0, 0.001, fluidMinX, fluidMaxY);
        tessellator.addVertexWithUV(1, 1, 0.001, fluidMinX, fluidMinY);
        tessellator.addVertexWithUV(0, 1, 0.001, fluidMaxX, fluidMinY);
        tessellator.draw();

        tessellator.startDrawingQuads();
        tessellator.setNormal(0, 0, -1);
        tessellator.setColorOpaque_I(colorMult);
        tessellator.addVertexWithUV(0, 1, -0.0635, fluidMinX, fluidMinY);
        tessellator.addVertexWithUV(1, 1, -0.0635, fluidMaxX, fluidMinY);
        tessellator.addVertexWithUV(1, 0, -0.0635, fluidMaxX, fluidMaxY);
        tessellator.addVertexWithUV(0, 0, -0.0635, fluidMinX, fluidMaxY);
        tessellator.draw();

        GL11.glDepthMask(true);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }
      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    }

    OpenGlHelper.glBlendFunc(
        GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    TextureUtil.func_147945_b();
    GL11.glPopMatrix();
  }
 public void reUploadImage() {
   TextureUtil.uploadTextureImage(getGlTextureId(), image);
 }
 @Override
 public void loadTexture(IResourceManager par1ResourceManager) {
   TextureUtil.uploadTextureImage(getGlTextureId(), image);
 }
Beispiel #11
0
 @Override
 public void shutdown() {
   if (imageId != -1) {
     TextureUtil.deleteTexture(imageId);
   }
 }
  public static void renderItem(EntityLivingBase entity, ItemStack itemStack, int renderPass) {
    TextureManager texturemanager = FMLClientHandler.instance().getClient().getTextureManager();
    Item item = itemStack.getItem();
    Block block = Block.getBlockFromItem(item);

    GL11.glPushMatrix();
    if (itemStack.getItemSpriteNumber() == 0
        && item instanceof ItemBlock
        && RenderBlocks.renderItemIn3d(block.getRenderType())) {
      texturemanager.bindTexture(texturemanager.getResourceLocation(0));

      if (itemStack != null && block != null && block.getRenderBlockPass() != 0) {
        GL11.glDepthMask(false);
        RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F);
        GL11.glDepthMask(true);
      } else {
        RenderHelper.BLOCK_RENDERER.renderBlockAsItem(block, itemStack.getItemDamage(), 1.0F);
      }
    } else {
      IIcon iicon = entity.getItemIcon(itemStack, renderPass);
      if (iicon == null) {
        GL11.glPopMatrix();
        return;
      }

      texturemanager.bindTexture(
          texturemanager.getResourceLocation(itemStack.getItemSpriteNumber()));
      TextureUtil.func_152777_a(false, false, 1.0F);
      Tessellator tessellator = Tessellator.instance;
      float minU = iicon.getMinU();
      float maxU = iicon.getMaxU();
      float minV = iicon.getMinV();
      float maxV = iicon.getMaxV();
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glTranslatef(0.0F, -0.3F, 0.0F);
      GL11.glScalef(1.5F, 1.5F, 1.5F);
      GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
      GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
      GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
      ItemRenderer.renderItemIn2D(
          tessellator,
          maxU,
          minV,
          minU,
          maxV,
          iicon.getIconWidth(),
          iicon.getIconHeight(),
          0.0625F);

      if (itemStack.hasEffect(renderPass)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        texturemanager.bindTexture(RenderHelper.RES_ITEM_GLINT);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(768, 1, 1, 0);
        GL11.glColor4f(0.38F, 0.19F, 0.608F, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);

        GL11.glPushMatrix();
        GL11.glScalef(0.125F, 0.125F, 0.125F);
        float animOffset = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
        GL11.glTranslatef(animOffset, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glScalef(0.125F, 0.125F, 0.125F);
        animOffset = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
        GL11.glTranslatef(-animOffset, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
        GL11.glPopMatrix();

        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
      }

      GL11.glDisable(GL12.GL_RESCALE_NORMAL);
      texturemanager.bindTexture(
          texturemanager.getResourceLocation(itemStack.getItemSpriteNumber()));
      TextureUtil.func_147945_b();
    }
    if (itemStack != null && block != null && block.getRenderBlockPass() != 0) {
      GL11.glDisable(GL11.GL_BLEND);
    }
    GL11.glPopMatrix();
  }