mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
fixed somewhat item rendering
This commit is contained in:
parent
b39e550e15
commit
092fea907d
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.client
|
||||
|
||||
import cpw.mods.fml.client.registry.{RenderingRegistry, ClientRegistry}
|
||||
import cpw.mods.fml.common.event.{FMLPostInitializationEvent, FMLInitializationEvent}
|
||||
import cpw.mods.fml.common.event.{FMLPreInitializationEvent, FMLPostInitializationEvent, FMLInitializationEvent}
|
||||
import cpw.mods.fml.common.network.NetworkRegistry
|
||||
import li.cil.oc.client
|
||||
import li.cil.oc.client.renderer.WirelessNetworkDebugRenderer
|
||||
@ -33,7 +33,7 @@ private[oc] class Proxy extends CommonProxy {
|
||||
|
||||
MinecraftForgeClient.registerItemRenderer(Items.multi, UpgradeRenderer)
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(gui.Icons)
|
||||
|
||||
OpenComputers.channel.register(client.PacketHandler)
|
||||
}
|
||||
|
||||
@ -45,4 +45,10 @@ private[oc] class Proxy extends CommonProxy {
|
||||
MinecraftForge.EVENT_BUS.register(WirelessNetworkDebugRenderer)
|
||||
}
|
||||
}
|
||||
|
||||
override def preInit(e: FMLPreInitializationEvent): Unit = {
|
||||
MinecraftForge.EVENT_BUS.register(gui.Icons)
|
||||
super.preInit(e)
|
||||
|
||||
}
|
||||
}
|
@ -2,16 +2,30 @@ package li.cil.oc.client.gui
|
||||
|
||||
import li.cil.oc.client.Textures
|
||||
import net.minecraft.client.gui.inventory.GuiContainer
|
||||
import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.inventory.Container
|
||||
import net.minecraft.util.StatCollector
|
||||
import org.lwjgl.opengl.GL11
|
||||
import net.minecraft.client.renderer.{OpenGlHelper, RenderHelper, Tessellator}
|
||||
import net.minecraft.inventory.{Slot, Container}
|
||||
import net.minecraft.util.{IIcon, EnumChatFormatting, MathHelper, StatCollector}
|
||||
import org.lwjgl.opengl.{GL12, GL11}
|
||||
import net.minecraft.entity.player.InventoryPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.client.Minecraft
|
||||
import li.cil.oc.util.RenderState
|
||||
import li.cil.oc.common.container.ComponentSlot
|
||||
import net.minecraft.client.renderer.texture.TextureMap
|
||||
|
||||
abstract class DynamicGuiContainer(container: Container) extends GuiContainer(container) {
|
||||
override def drawGuiContainerForegroundLayer(mouseX: Int, mouseY: Int) {
|
||||
|
||||
fontRendererObj.drawString(
|
||||
StatCollector.translateToLocal("container.inventory"),
|
||||
8, ySize - 96 + 2, 0x404040)
|
||||
for (i1 <- 0 until inventorySlots.inventorySlots.size()) {
|
||||
val slot: Slot = inventorySlots.inventorySlots.get(i1).asInstanceOf[Slot]
|
||||
this.drawSlotInventory(slot, mouseX, mouseY)
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override def drawGuiContainerBackgroundLayer(dt: Float, mouseX: Int, mouseY: Int) {
|
||||
@ -21,24 +35,26 @@ abstract class DynamicGuiContainer(container: Container) extends GuiContainer(co
|
||||
|
||||
|
||||
// TODO private now?
|
||||
// override def drawSlotInventory(slot: Slot) {
|
||||
// if (slot.slotNumber < container.inventorySlots.size() - 36) {
|
||||
// GL11.glDisable(GL11.GL_LIGHTING)
|
||||
// drawSlotBackground(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1)
|
||||
// GL11.glEnable(GL11.GL_LIGHTING)
|
||||
// }
|
||||
// RenderState.makeItBlend()
|
||||
// super.drawSlotInventory(slot)
|
||||
// GL11.glDisable(GL11.GL_BLEND)
|
||||
// if (!slot.getHasStack) slot match {
|
||||
// case component: ComponentSlot if component.tierIcon != null =>
|
||||
// mc.getTextureManager.bindTexture(TextureMap.locationItemsTexture)
|
||||
// GL11.glDisable(GL11.GL_DEPTH_TEST)
|
||||
// drawTexturedModelRectFromIcon(slot.xDisplayPosition, slot.yDisplayPosition, component.tierIcon, 16, 16)
|
||||
// GL11.glEnable(GL11.GL_DEPTH_TEST)
|
||||
// case _ =>
|
||||
// }
|
||||
// }
|
||||
def drawSlotInventory(slot: Slot, mouseX: Int, mouseY: Int) {
|
||||
if (slot.slotNumber < container.inventorySlots.size() - 36) {
|
||||
GL11.glDisable(GL11.GL_LIGHTING)
|
||||
drawSlotBackground(slot.xDisplayPosition - 1, slot.yDisplayPosition - 1)
|
||||
GL11.glEnable(GL11.GL_LIGHTING)
|
||||
}
|
||||
RenderState.makeItBlend()
|
||||
|
||||
|
||||
GL11.glDisable(GL11.GL_BLEND)
|
||||
if (!slot.getHasStack) slot match {
|
||||
case component: ComponentSlot if component.tierIcon != null =>
|
||||
mc.getTextureManager.bindTexture(TextureMap.locationItemsTexture)
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST)
|
||||
drawTexturedModelRectFromIcon(slot.xDisplayPosition, slot.yDisplayPosition, component.tierIcon, 16, 16)
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST)
|
||||
case something =>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private def drawSlotBackground(x: Int, y: Int) {
|
||||
GL11.glColor4f(1, 1, 1, 1)
|
||||
@ -51,4 +67,6 @@ abstract class DynamicGuiContainer(container: Container) extends GuiContainer(co
|
||||
t.addVertexWithUV(x, y, zLevel, 0, 0)
|
||||
t.draw()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ object Icons {
|
||||
private val byTier = mutable.Map.empty[Int, IIcon]
|
||||
|
||||
@SubscribeEvent
|
||||
def onItemIconRegister(e: TextureStitchEvent.Pre) {
|
||||
def onItemIconRegister(e: TextureStitchEvent) {
|
||||
val iconRegister = e.map
|
||||
if (iconRegister.getTextureType == 1) {
|
||||
bySlotType += Slot.Card -> iconRegister.registerIcon(Settings.resourceDomain + ":icon_card")
|
||||
|
Loading…
x
Reference in New Issue
Block a user