Improved handling of missing icons of fluids and in Texture class

This commit is contained in:
bdew committed 2014-10-08 12:11:53 +03:00
1 parent 9a837361e7
commit bcb8edc8a5
4 files changed
+33 -5

No files matched your search

+5
View File
@@ -10,6 +10,7 @@
package net.bdew.lib
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.texture.TextureMap
import org.lwjgl.input.Keyboard
/**
@@ -21,6 +22,10 @@ object Client {
def renderEngine = Minecraft.getMinecraft.renderEngine
def world = Minecraft.getMinecraft.theWorld
def player = Minecraft.getMinecraft.thePlayer
def textureManager = Minecraft.getMinecraft.getTextureManager
def blockMissingIcon = textureManager.getTexture(TextureMap.locationBlocksTexture).asInstanceOf[TextureMap].getAtlasSprite("missingno")
def itemMissingIcon = textureManager.getTexture(TextureMap.locationItemsTexture).asInstanceOf[TextureMap].getAtlasSprite("missingno")
def shiftDown: Boolean = {
return Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)
+17 -1
View File
@@ -15,9 +15,10 @@ import cpw.mods.fml.common.versioning.{ArtifactVersion, VersionParser}
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntity
import net.minecraft.util.StatCollector
import net.minecraft.util.{IIcon, StatCollector}
import net.minecraft.world.biome.BiomeGenBase
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.{Fluid, FluidStack}
import net.minecraftforge.oredict.ShapedOreRecipe
object Misc {
@@ -98,5 +99,20 @@ object Misc {
f(init)
init
}
def getFluidIcon(fs: FluidStack): IIcon =
if (fs != null && fs.getFluid != null && fs.getFluid.getIcon != null)
fs.getFluid.getIcon(fs)
else
Client.blockMissingIcon
def getFluidIcon(f: Fluid): IIcon =
if (f != null) getFluidIcon(new FluidStack(f, 1)) else Client.blockMissingIcon
def getFluidColor(fs: FluidStack): Int =
if (fs != null && fs.getFluid != null) fs.getFluid.getColor(fs) else 0xFFFFFF
def getFluidColor(f: Fluid): Int =
if (f != null) getFluidColor(new FluidStack(f, 1)) else 0xFFFFFF
}
+8 -1
View File
@@ -9,6 +9,7 @@
package net.bdew.lib.gui
import net.bdew.lib.Client
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.texture.TextureMap
import net.minecraft.util.{IIcon, ResourceLocation}
@@ -29,7 +30,13 @@ class InterpolatedTexture(val texture: Texture, rect: Rect) extends Texture {
def v2 = rect.y2 * (texture.v2 - texture.v1) + texture.v1
}
class IconWrapper(val resource: ResourceLocation, val icon: IIcon) extends Texture {
class IconWrapper(val resource: ResourceLocation, picon: IIcon) extends Texture {
val icon = if (picon == null) {
if (resource == Texture.ITEMS) Client.itemMissingIcon
else if (resource == Texture.BLOCKS) Client.blockMissingIcon
else sys.error("Attempt to create IconWrapper for null IIcon")
} else picon
def u1 = icon.getMinU
def u2 = icon.getMaxU
def v1 = icon.getMinV
@@ -35,11 +35,11 @@ class WidgetFluidGauge(val rect: Rect, overlay: Texture, dslot: DataSlotTankBase
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA)
val fstack = dslot.getFluid
if (fstack != null && fstack.getFluid.getStillIcon != null) {
val icon = Texture(Texture.BLOCKS, fstack.getFluid.getStillIcon)
if (fstack != null) {
val color = Color.fromInt(Misc.getFluidColor(fstack))
val icon = Texture(Texture.BLOCKS, Misc.getFluidIcon(fstack))
var fillHeight = if (dslot.getCapacity > 0) rect.h * fstack.amount / dslot.getCapacity else 0
var yStart: Int = 0
val color = Color.fromInt(fstack.getFluid.getColor(fstack))
while (fillHeight > 0) {
if (fillHeight > 16) {