public static Texture getTextureFromUrl(String url) {
   Texture tex = getTextureFromUrl(null, url);
   if (tex == null) {
     CustomTextureManager.downloadTexture(url, true);
     tex =
         CustomTextureManager.getTextureFromPath(
             FileUtil.getAssetsDir().getPath() + "/block/spout.png");
   }
   return tex;
 }
Example #2
0
  public void render(int x, int y, int width, int height) {
    MCRenderDelegate r = (MCRenderDelegate) SpoutClient.getInstance().getRenderDelegate();
    FontRenderer font = SpoutClient.getHandle().fontRenderer;

    String sResolution = resolution + "x";
    int sWidth = font.getStringWidth(sResolution);
    font.drawStringWithShadow(sResolution, x + width - sWidth - 2, y + 2, 0xffaaaaaa);

    String name = r.getFittingText(getName(), width - 29 - sWidth - 2 - x);
    font.drawStringWithShadow(name, x + 29, y + 2, 0xffffffff);

    String sStatus = "";
    if (size > 1024 * 1024 * 9000) {
      sStatus = ChatColor.RED + "It's over 9000! ";
    }
    if (size > 1024 * 1024) {
      sStatus += size / (1024 * 1024) + " MB";
    } else if (size > 1024) {
      sStatus = size / 1024 + " KB";
    } else {
      sStatus = size + " Bytes";
    }
    if (isDownloading()) {
      sStatus = "Downloading: " + ChatColor.WHITE + download.getProgress() + "%";
    }
    if (downloadFail != null) {
      sStatus = downloadFail;
    }
    if (installed) {
      sStatus = ChatColor.GREEN + "Installed";
    }
    if (sStatus != null) {
      sWidth = font.getStringWidth(sStatus);
      font.drawStringWithShadow(sStatus, x + width - sWidth - 2, y + 11, 0xffaaaaaa);
    }

    String author = "by " + ChatColor.WHITE + getAuthor();
    author = r.getFittingText(author, width - 29 - sWidth - 2 - x);
    font.drawStringWithShadow(author, x + 29, y + 11, 0xffaaaaaa);

    String desc = r.getFittingText(getDescription(), width - 2 - 29);
    font.drawStringWithShadow(desc, x + 29, y + 20, 0xffaaaaaa);

    String iconUrl = getIconUrl();
    Texture icon = CustomTextureManager.getTextureFromUrl(iconUrl);
    if (icon == null) {
      CustomTextureManager.downloadTexture(iconUrl, true);
    } else {
      GL11.glPushMatrix();
      GL11.glTranslated(x + 2, y + 2, 0);
      r.drawTexture(icon, 25, 25);
      GL11.glPopMatrix();
    }
  }
Example #3
0
 public void onWorldExit() {
   disableSandbox();
   FileUtil.deleteTempDirectory();
   CustomTextureManager.resetTextures();
   CRCManager.clear();
   SpoutcraftChunk.loadedChunks.clear();
   if (clipboardThread != null) {
     clipboardThread.interrupt();
     clipboardThread = null;
   }
   Minecraft.theMinecraft.sndManager.stopMusic();
   PacketDecompressionThread.endThread();
   MaterialData.reset();
   FileDownloadThread.preCacheCompleted.lazySet(0);
   server = -1L;
   inWorldTicks = 0L;
   MaterialData.reset();
   MinimapConfig.getInstance().getServerWaypoints().clear();
 }
 // Don't call this method, for future use.
 protected Texture getTextureFromItemStack(ItemStack itemStack) {
   BlockDesign design = null;
   Texture texture = null;
   org.spoutcraft.api.material.CustomItem item =
       MaterialData.getCustomItem(itemStack.getItemDamage());
   if (item != null) {
     String textureURI = item.getTexture();
     if (textureURI == null) {
       org.spoutcraft.api.material.CustomBlock block =
           MaterialData.getCustomBlock(itemStack.getItemDamage());
       design = block != null ? block.getBlockDesign() : null;
       textureURI = design != null ? design.getTextureURL() : null;
     }
     if (textureURI != null) {
       texture = CustomTextureManager.getTextureFromUrl(item.getAddon(), textureURI);
     }
   }
   return texture;
 }
Example #5
0
  public void renderItem(EntityLiving par1EntityLiving, ItemStack par2ItemStack, int par3) {
    GL11.glPushMatrix();
    // Spout Start
    boolean custom = false;
    BlockDesign design = null;
    if (par2ItemStack.itemID == 318) {
      org.spoutcraft.spoutcraftapi.material.CustomItem item =
          MaterialData.getCustomItem(par2ItemStack.getItemDamage());
      if (item != null) {
        String textureURI = item.getTexture();
        if (textureURI == null) {
          org.spoutcraft.spoutcraftapi.material.CustomBlock block =
              MaterialData.getCustomBlock(par2ItemStack.getItemDamage());
          design = block != null ? block.getBlockDesign() : null;
          textureURI = design != null ? design.getTexureURL() : null;
        }
        if (textureURI != null) {
          Texture texture =
              CustomTextureManager.getTextureFromUrl(
                  item.getAddon().getDescription().getName(), textureURI);
          if (texture != null) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
            custom = true;
          }
        }
      }
    }

    if (!custom) {
      if (par2ItemStack.itemID < 256) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
      } else {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/gui/items.png"));
      }
    }

    if (design != null) {
      design.renderItemstack(null, -0.5F, -0.5F, -0.5F, 0, 1F, rand);
    } else if (par2ItemStack.itemID < 256
        && RenderBlocks.renderItemIn3d(Block.blocksList[par2ItemStack.itemID].getRenderType())) {
      this.renderBlocksInstance.renderBlockAsItem(
          Block.blocksList[par2ItemStack.itemID], par2ItemStack.getItemDamage(), 1.0F);
    } else {

      Tessellator var4 = Tessellator.instance;
      int var5 = par1EntityLiving.getItemIcon(par2ItemStack, par3);
      float var6 = ((float) (var5 % 16 * TileSize.int_size) + 0.0F) / TileSize.float_size16;
      float var7 =
          ((float) (var5 % 16 * TileSize.int_size) + TileSize.float_sizeMinus0_01)
              / TileSize.float_size16;
      float var8 = ((float) (var5 / 16 * TileSize.int_size) + 0.0F) / TileSize.float_size16;
      float var9 =
          ((float) (var5 / 16 * TileSize.int_size) + TileSize.float_sizeMinus0_01)
              / TileSize.float_size16;

      if (custom) {
        var6 = 0;
        var7 = 1;
        var8 = 1;
        var9 = 0;
      }
      // Spout end
      float var10 = 0.0F;
      float var11 = 0.3F;
      GL11.glEnable(GL12.GL_RESCALE_NORMAL);
      GL11.glTranslatef(-var10, -var11, 0.0F);
      float var12 = 1.5F;
      GL11.glScalef(var12, var12, var12);
      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);
      Colorizer.colorizeWaterBlockGL(par2ItemStack.itemID); // Spout HD
      this.renderItemIn2D(var4, var7, var8, var6, var9);
      if (par2ItemStack != null && par2ItemStack.hasEffect() && par3 == 0) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        this.mc.renderEngine.bindTexture(this.mc.renderEngine.getTexture("%blur%/misc/glint.png"));
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
        float var13 = 0.76F;
        GL11.glColor4f(0.5F * var13, 0.25F * var13, 0.8F * var13, 1.0F);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        float var14 = 0.125F;
        GL11.glScalef(var14, var14, var14);
        float var15 = (float) (System.currentTimeMillis() % 3000L) / 3000.0F * 8.0F;
        GL11.glTranslatef(var15, 0.0F, 0.0F);
        GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
        this.renderItemIn2D(var4, 0.0F, 0.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(var14, var14, var14);
        var15 = (float) (System.currentTimeMillis() % 4873L) / 4873.0F * 8.0F;
        GL11.glTranslatef(-var15, 0.0F, 0.0F);
        GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
        this.renderItemIn2D(var4, 0.0F, 0.0F, 1.0F, 1.0F);
        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);
    }

    GL11.glPopMatrix();
  }