diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/ElementImage.java b/src/main/java/slimeknights/mantle/client/screen/book/element/ElementImage.java index 702d58c..b1c50fb 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/ElementImage.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/ElementImage.java @@ -13,6 +13,8 @@ public class ElementImage extends SizedBookElement { public ImageData image; public int colorMultiplier; + private ElementItem itemElement; + public ElementImage(ImageData image) { this(image, 0xFFFFFF); } @@ -51,6 +53,10 @@ public class ElementImage extends SizedBookElement { this.width = width; this.height = height; this.colorMultiplier = colorMultiplier; + + if(image.item != null) { + itemElement = new ElementItem(0, 0, 1F, image.item.getItems()); + } } @Override @@ -68,9 +74,9 @@ public class ElementImage extends SizedBookElement { } else { GlStateManager.pushMatrix(); - GlStateManager.scalef(this.width, this.height, 1F); - RenderHelper.enableGUIStandardItemLighting(); - this.mc.getItemRenderer().renderItemAndEffectIntoGUI(this.image.item.getItems().get(0), this.x, this.y); + GlStateManager.translatef(this.x, this.y, 0F); + GlStateManager.scalef(this.width / 16F, this.height / 16F, 1F); + itemElement.draw(mouseX, mouseY, partialTicks, fontRenderer); RenderHelper.disableStandardItemLighting(); GlStateManager.popMatrix(); } diff --git a/src/main/java/slimeknights/mantle/client/screen/book/element/ElementSection.java b/src/main/java/slimeknights/mantle/client/screen/book/element/ElementSection.java index db4a02a..2d9a5f1 100644 --- a/src/main/java/slimeknights/mantle/client/screen/book/element/ElementSection.java +++ b/src/main/java/slimeknights/mantle/client/screen/book/element/ElementSection.java @@ -2,7 +2,6 @@ package slimeknights.mantle.client.screen.book.element; import com.mojang.blaze3d.platform.GlStateManager; import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.RenderHelper; import net.minecraft.util.text.TextFormatting; import slimeknights.mantle.client.book.data.SectionData; @@ -17,11 +16,19 @@ public class ElementSection extends SizedBookElement { public static final int HEIGHT = 42; private SectionData section; + private ElementImage iconRenderer; + + private final int iconX; + private final int iconY; public ElementSection(int x, int y, SectionData section) { super(x, y, WIDTH, HEIGHT); this.section = section; + + iconX = this.x + WIDTH / 2 - IMG_SIZE / 2; + iconY = this.y + HEIGHT / 2 - IMG_SIZE / 2; + iconRenderer = new ElementImage(iconX, iconY, IMG_SIZE, IMG_SIZE, section.icon); } @Override @@ -29,39 +36,20 @@ public class ElementSection extends SizedBookElement { boolean unlocked = this.section.isUnlocked(this.parent.advancementCache); boolean hover = this.isHovered(mouseX, mouseY); - if (this.section.icon != null) { - int iconX = this.x + WIDTH / 2 - IMG_SIZE / 2; - int iconY = this.y + HEIGHT / 2 - IMG_SIZE / 2; - if (hover) { - fill(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, this.parent.book.appearance.hoverColor); - } - if (unlocked) { - GlStateManager.color4f(1F, 1F, 1F, hover ? 1F : 0.5F); - } - else { - float r = ((this.parent.book.appearance.lockedSectionColor >> 16) & 0xff) / 255.F; - float g = ((this.parent.book.appearance.lockedSectionColor >> 8) & 0xff) / 255.F; - float b = (this.parent.book.appearance.lockedSectionColor & 0xff) / 255.F; - GlStateManager.color4f(r, g, b, 0.75F); - } - - if (this.section.icon.item == null) { - if (this.section.icon.location != null) { - this.renderEngine.bindTexture(this.section.icon.location); - - blit(iconX, iconY, this.section.icon.u, this.section.icon.v, this.section.icon.uw, this.section.icon.vh, IMG_SIZE, IMG_SIZE, this.section.icon.texWidth, this.section.icon.texHeight); - } - } - else { - GlStateManager.pushMatrix(); - GlStateManager.translatef(iconX, iconY, 0); - GlStateManager.scalef(2F, 2F, 1F); - RenderHelper.enableGUIStandardItemLighting(); - this.mc.getItemRenderer().renderItemAndEffectIntoGUI(this.section.icon.item.getItems().get(0), 0, 0); - RenderHelper.disableStandardItemLighting(); - GlStateManager.popMatrix(); - } + if (hover) { + fill(iconX, iconY, iconX + IMG_SIZE, iconY + IMG_SIZE, this.parent.book.appearance.hoverColor); } + if (unlocked) { + GlStateManager.color4f(1F, 1F, 1F, hover ? 1F : 0.5F); + } + else { + float r = ((this.parent.book.appearance.lockedSectionColor >> 16) & 0xff) / 255.F; + float g = ((this.parent.book.appearance.lockedSectionColor >> 8) & 0xff) / 255.F; + float b = (this.parent.book.appearance.lockedSectionColor & 0xff) / 255.F; + GlStateManager.color4f(r, g, b, 0.75F); + } + + iconRenderer.draw(mouseX, mouseY, partialTicks, fontRenderer); if (this.section.parent.appearance.drawSectionListText) { int textW = fontRenderer.getStringWidth(this.section.getTitle());