Skip to content

Commit

Permalink
fixed textures loses transparency when drawing specific items
Browse files Browse the repository at this point in the history
  • Loading branch information
RedthMC committed Aug 23, 2023
1 parent 7695301 commit 80fe0a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod_name=InventoryOCHUD
# Sets the id of your mod that mod loaders use to recognize it.
mod_id=inventory_oc_hud
# Sets the version of your mod. Make sure to update this when you make changes according to semver.
mod_version=1.0.0
mod_version=1.0.1
# Sets the name of the jar file that you put in your 'mods' folder.
mod_archives_name=InventoryOCHUD

Expand Down
22 changes: 11 additions & 11 deletions src/main/java/me/redth/inventoryochud/hud/InventoryHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;

public abstract class InventoryHUD extends BasicHud {
protected static final transient Minecraft mc = Minecraft.getMinecraft();
Expand All @@ -18,9 +19,14 @@ public InventoryHUD(int x, int y) {
@Override
protected void draw(UMatrixStack matrices, float x, float y, float scale, boolean example) {
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, 100F);
GlStateManager.translate(x, y, 100);
GlStateManager.scale(scale, scale, 1.0);

GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
RenderHelper.enableGUIStandardItemLighting();

for (int row = 0; row < 3; row++) {
for (int column = 0; column < 9; column++) {
int index = row * 9 + column;
Expand All @@ -30,6 +36,10 @@ protected void draw(UMatrixStack matrices, float x, float y, float scale, boolea
GlStateManager.translate(-162, 18, 0);
}

RenderHelper.disableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.disableRescaleNormal();
GlStateManager.enableAlpha();

GlStateManager.popMatrix();
}
Expand All @@ -53,18 +63,8 @@ protected float getHeight(float scale, boolean example) {

protected static void drawItem(ItemStack item) {
if (item == null) return;

GlStateManager.enableRescaleNormal();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
RenderHelper.enableGUIStandardItemLighting();

RenderItem itemRenderer = mc.getRenderItem();
itemRenderer.renderItemAndEffectIntoGUI(item, 0, 0);
itemRenderer.renderItemOverlayIntoGUI(mc.fontRendererObj, item, 0, 0, null);

RenderHelper.disableStandardItemLighting();
GlStateManager.disableBlend();
GlStateManager.disableRescaleNormal();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public PlayerInventoryHUD() {

@Override
protected ItemStack getItem(int index) {
if (mc.thePlayer == null) return null;
return mc.thePlayer.inventory.mainInventory[index + 9];
}
}

0 comments on commit 80fe0a6

Please sign in to comment.