mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 18:30:27 -04:00
Fixed icons for subitems with damage bar.
GUI rendering fixes.
This commit is contained in:
parent
17790ea156
commit
64f853d95e
@ -81,8 +81,10 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
|
|||||||
mc.getTextureManager.bindTexture(component.tierIcon)
|
mc.getTextureManager.bindTexture(component.tierIcon)
|
||||||
Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
|
Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
|
||||||
}
|
}
|
||||||
mc.getTextureManager.bindTexture(slot.getBackgroundLocation)
|
if (component.hasBackground) {
|
||||||
Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
|
mc.getTextureManager.bindTexture(slot.getBackgroundLocation)
|
||||||
|
Gui.drawModalRectWithCustomSizedTexture(slot.xDisplayPosition, slot.yDisplayPosition, 0, 0, 16, 16, 16, 16)
|
||||||
|
}
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST)
|
GL11.glEnable(GL11.GL_DEPTH_TEST)
|
||||||
case _ =>
|
case _ =>
|
||||||
}
|
}
|
||||||
@ -146,12 +148,6 @@ abstract class DynamicGuiContainer(container: Container) extends CustomGuiContai
|
|||||||
t.draw()
|
t.draw()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override def drawGradientRect(par1: Int, par2: Int, par3: Int, par4: Int, par5: Int, par6: Int) {
|
|
||||||
super.drawGradientRect(par1, par2, par3, par4, par5, par6)
|
|
||||||
RenderState.makeItBlend()
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING)
|
|
||||||
}
|
|
||||||
|
|
||||||
private def isInPlayerInventory(slot: Slot) = container match {
|
private def isInPlayerInventory(slot: Slot) = container match {
|
||||||
case player: Player => slot.inventory == player.playerInventory
|
case player: Player => slot.inventory == player.playerInventory
|
||||||
case _ => false
|
case _ => false
|
||||||
|
@ -2,6 +2,7 @@ package li.cil.oc.common.container
|
|||||||
|
|
||||||
import li.cil.oc.common
|
import li.cil.oc.common
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
|
import net.minecraft.inventory.IInventory
|
||||||
import net.minecraft.inventory.Slot
|
import net.minecraft.inventory.Slot
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.util.ResourceLocation
|
import net.minecraft.util.ResourceLocation
|
||||||
@ -10,7 +11,7 @@ import net.minecraftforge.fml.relauncher.SideOnly
|
|||||||
|
|
||||||
import scala.collection.convert.WrapAsScala._
|
import scala.collection.convert.WrapAsScala._
|
||||||
|
|
||||||
trait ComponentSlot extends Slot {
|
abstract class ComponentSlot(inventory: IInventory, index: Int, x: Int, y: Int) extends Slot(inventory, index, x, y) {
|
||||||
def container: Player
|
def container: Player
|
||||||
|
|
||||||
def slot: String
|
def slot: String
|
||||||
@ -23,6 +24,8 @@ trait ComponentSlot extends Slot {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
def hasBackground = backgroundLocation != null
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
override def canBeHovered = slot != common.Slot.None && tier != common.Tier.None && super.canBeHovered
|
override def canBeHovered = slot != common.Slot.None && tier != common.Tier.None && super.canBeHovered
|
||||||
|
|
||||||
|
@ -6,9 +6,8 @@ import li.cil.oc.common.InventorySlots.InventorySlot
|
|||||||
import li.cil.oc.util.SideTracker
|
import li.cil.oc.util.SideTracker
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.inventory.IInventory
|
import net.minecraft.inventory.IInventory
|
||||||
import net.minecraft.inventory.Slot
|
|
||||||
|
|
||||||
class DynamicComponentSlot(val container: Player, inventory: IInventory, index: Int, x: Int, y: Int, val info: DynamicComponentSlot => InventorySlot, val containerTierGetter: () => Int) extends Slot(inventory, index, x, y) with ComponentSlot {
|
class DynamicComponentSlot(val container: Player, inventory: IInventory, index: Int, x: Int, y: Int, val info: DynamicComponentSlot => InventorySlot, val containerTierGetter: () => Int) extends ComponentSlot(inventory, index, x, y) {
|
||||||
override def tier = {
|
override def tier = {
|
||||||
val mainTier = containerTierGetter()
|
val mainTier = containerTierGetter()
|
||||||
if (mainTier >= 0) info(this).tier
|
if (mainTier >= 0) info(this).tier
|
||||||
@ -23,7 +22,9 @@ class DynamicComponentSlot(val container: Player, inventory: IInventory, index:
|
|||||||
else common.Slot.None
|
else common.Slot.None
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getBackgroundLocation = Textures.Icons.get(slot)
|
override def hasBackground = Textures.Icons.get(slot) != null
|
||||||
|
|
||||||
|
override def getBackgroundLocation = Option(Textures.Icons.get(slot)).getOrElse(super.getBackgroundLocation)
|
||||||
|
|
||||||
override def getSlotStackLimit =
|
override def getSlotStackLimit =
|
||||||
slot match {
|
slot match {
|
||||||
|
@ -3,9 +3,8 @@ package li.cil.oc.common.container
|
|||||||
import li.cil.oc.client.Textures
|
import li.cil.oc.client.Textures
|
||||||
import li.cil.oc.common
|
import li.cil.oc.common
|
||||||
import net.minecraft.inventory.IInventory
|
import net.minecraft.inventory.IInventory
|
||||||
import net.minecraft.inventory.Slot
|
|
||||||
|
|
||||||
class StaticComponentSlot(val container: Player, inventory: IInventory, index: Int, x: Int, y: Int, val slot: String, val tier: Int) extends Slot(inventory, index, x, y) with ComponentSlot {
|
class StaticComponentSlot(val container: Player, inventory: IInventory, index: Int, x: Int, y: Int, val slot: String, val tier: Int) extends ComponentSlot(inventory, index, x, y) {
|
||||||
setBackgroundLocation(Textures.Icons.get(slot))
|
setBackgroundLocation(Textures.Icons.get(slot))
|
||||||
|
|
||||||
val tierIcon = Textures.Icons.get(tier)
|
val tierIcon = Textures.Icons.get(tier)
|
||||||
|
@ -101,11 +101,9 @@ trait Delegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def isDamageable = false
|
def showDurabilityBar(stack: ItemStack) = false
|
||||||
|
|
||||||
def damage(stack: ItemStack) = 0
|
def durability(stack: ItemStack) = 0.0
|
||||||
|
|
||||||
def maxDamage(stack: ItemStack) = 0
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
@ -147,20 +147,14 @@ class Delegator extends Item {
|
|||||||
|
|
||||||
override def getDurabilityForDisplay(stack: ItemStack) =
|
override def getDurabilityForDisplay(stack: ItemStack) =
|
||||||
Delegator.subItem(stack) match {
|
Delegator.subItem(stack) match {
|
||||||
case Some(subItem) if subItem.isDamageable => subItem.damage(stack)
|
case Some(subItem) => subItem.durability(stack)
|
||||||
case _ => super.getDurabilityForDisplay(stack)
|
case _ => super.getDurabilityForDisplay(stack)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getMaxDamage(stack: ItemStack) =
|
override def showDurabilityBar(stack: ItemStack) =
|
||||||
Delegator.subItem(stack) match {
|
Delegator.subItem(stack) match {
|
||||||
case Some(subItem) if subItem.isDamageable => subItem.maxDamage(stack)
|
case Some(subItem) => subItem.showDurabilityBar(stack)
|
||||||
case _ => super.getMaxDamage(stack)
|
case _ => super.showDurabilityBar(stack)
|
||||||
}
|
|
||||||
|
|
||||||
override def isDamaged(stack: ItemStack) =
|
|
||||||
Delegator.subItem(stack) match {
|
|
||||||
case Some(subItem) if subItem.isDamageable => subItem.damage(stack) > 0
|
|
||||||
case _ => false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override def onUpdate(stack: ItemStack, world: World, player: Entity, slot: Int, selected: Boolean) =
|
override def onUpdate(stack: ItemStack, world: World, player: Entity, slot: Int, selected: Boolean) =
|
||||||
|
@ -49,26 +49,15 @@ class Tablet(val parent: Delegator) extends Delegate {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def isDamageable = true
|
override def showDurabilityBar(stack: ItemStack) = true
|
||||||
|
|
||||||
override def damage(stack: ItemStack) = {
|
override def durability(stack: ItemStack) = {
|
||||||
val nbt = stack.getTagCompound
|
if (stack.hasTagCompound) {
|
||||||
if (nbt != null) {
|
|
||||||
val data = new ItemUtils.TabletData()
|
val data = new ItemUtils.TabletData()
|
||||||
data.load(nbt)
|
data.load(stack.getTagCompound)
|
||||||
(data.maxEnergy - data.energy).toInt
|
data.energy / data.maxEnergy
|
||||||
}
|
}
|
||||||
else 100
|
else 1.0
|
||||||
}
|
|
||||||
|
|
||||||
override def maxDamage(stack: ItemStack) = {
|
|
||||||
val nbt = stack.getTagCompound
|
|
||||||
if (nbt != null) {
|
|
||||||
val data = new ItemUtils.TabletData()
|
|
||||||
data.load(nbt)
|
|
||||||
data.maxEnergy.toInt max 1
|
|
||||||
}
|
|
||||||
else 100
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -10,16 +10,13 @@ class UpgradeBattery(val parent: Delegator, val tier: Int) extends Delegate with
|
|||||||
|
|
||||||
override protected def tooltipData = Seq(Settings.get.bufferCapacitorUpgrades(tier).toInt)
|
override protected def tooltipData = Seq(Settings.get.bufferCapacitorUpgrades(tier).toInt)
|
||||||
|
|
||||||
override def isDamageable = true
|
override def showDurabilityBar(stack: ItemStack) = true
|
||||||
|
|
||||||
override def damage(stack: ItemStack) = {
|
override def durability(stack: ItemStack) = {
|
||||||
val nbt = stack.getTagCompound
|
if (stack.hasTagCompound) {
|
||||||
if (nbt != null) {
|
val stored = stack.getTagCompound.getCompoundTag(Settings.namespace + "data").getCompoundTag("node").getDouble("buffer")
|
||||||
val stored = nbt.getCompoundTag(Settings.namespace + "data").getCompoundTag("node").getDouble("buffer")
|
1 - stored / Settings.get.bufferCapacitorUpgrades(tier)
|
||||||
((1 - stored / Settings.get.bufferCapacitorUpgrades(tier)) * 100).toInt
|
|
||||||
}
|
}
|
||||||
else 100
|
else 1.0
|
||||||
}
|
}
|
||||||
|
|
||||||
override def maxDamage(stack: ItemStack) = 100
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user