Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey there, so I try rending a calendar and an item info the calendar works fine and shows up as a semitransparent gray but for some reason the item info now renders the texture with a purple shade.

Any idea what might be causing this or where I should start looking for.

EDIT: Where would I ask for support if it's not supported here anymore?

grafik.png.2fa377f1669e278c24e2ffa312614172.png 

package dev.xenopyax.skyblockutils.gui;

import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

public class ItemStatsOverlay extends Gui {
	
	private Minecraft mc;
	private final ResourceLocation ITEM_DISPLAY_BACKGROUND;
	
	public ItemStatsOverlay(Minecraft mc) {
		this.mc = mc;
		ITEM_DISPLAY_BACKGROUND = new ResourceLocation("skyblockutils:textures/gui/itembackground.png");
		if(getStats().size() > 0) {
	        int length = 0;
	        
	        for(String s : getStats()) {
	        	if(mc.fontRendererObj.getStringWidth(s) > length) length = mc.fontRendererObj.getStringWidth(s);
	        }
	        if(mc.fontRendererObj.getStringWidth(getName()) > length) length = mc.fontRendererObj.getStringWidth(getName());
	        mc.getTextureManager().bindTexture(ITEM_DISPLAY_BACKGROUND);	        
	        drawModalRectWithCustomSizedTexture(4, 4, length + 16, 45, (int) length + 16, (int) 45, length + 16, 45);
			
	        drawString(mc.fontRendererObj, getName(), 30, 14, 0xffffff);
	        getStats().forEach((stat) -> drawString(mc.fontRendererObj, stat, 12, 30, 0xffffff));
	        if(mc.thePlayer.getHeldItem() != null) drawItemStack(10, 10, mc.thePlayer.getHeldItem());
		}
	}
	
	private void drawItemStack(int x, int y, ItemStack item) {
	    RenderItem itemRender = mc.getRenderItem();
	    RenderHelper.enableStandardItemLighting();
	    itemRender.renderItemIntoGUI(item, x, y);
	}
	
	public String getName() {
		return mc.thePlayer.getHeldItem().getTooltip(mc.thePlayer, true).get(0).split("\\(")[0];
	}
	
	public List<String> getStats() {
		List<String> stats = new ArrayList<String>();
		for(String s : mc.thePlayer.getHeldItem().getTooltip(mc.thePlayer, false)) {
			String lore = s.replaceAll("(§[0-9a-fk-or])(?!.*\\1)", "");
			if(lore.startsWith("Counter:") || lore.startsWith("Compact")) {
				stats.add(s);
			}
		}
		return stats;
	}

}

 

Edited by XenoPyax

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.