mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Showing question mark texture when trying to render items/blocks/oredict entries that cannot be resolved instead of an error string, logging error to console. Closes #1053.
Fixed crash caused by invalid `block:` image definitions. Fixed `mods` dir being included in builds... with a part of the RC API... wherever the heck that comes from...
This commit is contained in:
parent
e91f6671c4
commit
7a46657835
@ -211,6 +211,7 @@ processResources {
|
||||
|
||||
jar {
|
||||
exclude "cofh/**"
|
||||
exclude "mods/**"
|
||||
configurations.embedded.each { dep ->
|
||||
from(project.zipTree(dep)) {
|
||||
exclude 'META-INF', 'META-INF/**'
|
||||
|
@ -27,3 +27,7 @@ isn't*.
|
||||
asdasd  qweqwe
|
||||
|
||||
And finally, [this is a link!](https://avatars1.githubusercontent.com/u/514903).
|
||||
|
||||

|
||||

|
||||

|
||||
|
Binary file not shown.
After Width: | Height: | Size: 333 B |
@ -27,6 +27,7 @@ object Textures {
|
||||
val guiKeyboardMissing = new ResourceLocation(Settings.resourceDomain, "textures/gui/keyboard_missing.png")
|
||||
val guiManual = new ResourceLocation(Settings.resourceDomain, "textures/gui/manual.png")
|
||||
val guiManualTab = new ResourceLocation(Settings.resourceDomain, "textures/gui/manual_tab.png")
|
||||
val guiManualMissingItem = new ResourceLocation(Settings.resourceDomain, "textures/gui/manual_missing_item.png")
|
||||
val guiPrinter = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer.png")
|
||||
val guiPrinterInk = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_ink.png")
|
||||
val guiPrinterMaterial = new ResourceLocation(Settings.resourceDomain, "textures/gui/printer_material.png")
|
||||
|
@ -37,7 +37,10 @@ object Document {
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
|
||||
|
||||
// Because reasons.
|
||||
// On some systems/drivers/graphics cards the next calls won't update the
|
||||
// depth buffer correctly if alpha test is enabled. Guess how we found out?
|
||||
// By noticing that on those systems it only worked while chat messages
|
||||
// were visible. Yeah. I know.
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST)
|
||||
|
||||
// Clear depth mask, then create masks in foreground above and below scroll area.
|
||||
|
@ -1,9 +1,12 @@
|
||||
package li.cil.oc.client.renderer.markdown.segment.render
|
||||
|
||||
import com.google.common.base.Strings
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.api.manual.ImageProvider
|
||||
import li.cil.oc.api.manual.ImageRenderer
|
||||
import li.cil.oc.client.Textures
|
||||
import net.minecraft.block.Block
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object BlockImageProvider extends ImageProvider {
|
||||
@ -12,8 +15,10 @@ object BlockImageProvider extends ImageProvider {
|
||||
val (name, optMeta) = if (splitIndex > 0) data.splitAt(splitIndex) else (data, "")
|
||||
val meta = if (Strings.isNullOrEmpty(optMeta)) 0 else Integer.parseInt(optMeta.drop(1))
|
||||
Block.blockRegistry.getObject(name) match {
|
||||
case block: Block => new ItemStackImageRenderer(Array(new ItemStack(block, 1, meta)))
|
||||
case _ => null
|
||||
case block: Block if Item.getItemFromBlock(block) != null => new ItemStackImageRenderer(Array(new ItemStack(block, 1, meta)))
|
||||
case _ =>
|
||||
OpenComputers.log.warn(s"Failed looking up block '$data'.")
|
||||
new TextureImageRenderer(Textures.guiManualMissingItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
package li.cil.oc.client.renderer.markdown.segment.render
|
||||
|
||||
import com.google.common.base.Strings
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.api.manual.ImageProvider
|
||||
import li.cil.oc.api.manual.ImageRenderer
|
||||
import li.cil.oc.client.Textures
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@ -13,7 +15,9 @@ object ItemImageProvider extends ImageProvider {
|
||||
val meta = if (Strings.isNullOrEmpty(optMeta)) 0 else Integer.parseInt(optMeta.drop(1))
|
||||
Item.itemRegistry.getObject(name) match {
|
||||
case item: Item => new ItemStackImageRenderer(Array(new ItemStack(item, 1, meta)))
|
||||
case _ => null
|
||||
case _ =>
|
||||
OpenComputers.log.warn(s"Failed looking up item '$data'.")
|
||||
new TextureImageRenderer(Textures.guiManualMissingItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,20 @@
|
||||
package li.cil.oc.client.renderer.markdown.segment.render
|
||||
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.api.manual.ImageProvider
|
||||
import li.cil.oc.api.manual.ImageRenderer
|
||||
import net.minecraft.item.ItemStack
|
||||
import li.cil.oc.client.Textures
|
||||
import net.minecraftforge.oredict.OreDictionary
|
||||
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
|
||||
object OreDictImageProvider extends ImageProvider {
|
||||
override def getImage(data: String): ImageRenderer = {
|
||||
val stacks = OreDictionary.getOres(data)
|
||||
if (stacks != null && stacks.nonEmpty) new ItemStackImageRenderer(stacks.toArray(new Array[ItemStack](stacks.size())))
|
||||
else null
|
||||
val stacks = OreDictionary.getOres(data).filter(stack => stack != null && stack.getItem != null)
|
||||
if (stacks != null && stacks.nonEmpty) new ItemStackImageRenderer(stacks.toArray)
|
||||
else {
|
||||
OpenComputers.log.warn(s"Failed looking up OreDictionary entry '$data'.")
|
||||
new TextureImageRenderer(Textures.guiManualMissingItem)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,14 @@
|
||||
package li.cil.oc.client.renderer.markdown.segment.render
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.manual.ImageProvider
|
||||
import li.cil.oc.api.manual.ImageRenderer
|
||||
import net.minecraft.util.ResourceLocation
|
||||
|
||||
object TextureImageProvider extends ImageProvider {
|
||||
override def getImage(data: String): ImageRenderer = new TextureImageRenderer(data)
|
||||
override def getImage(data: String): ImageRenderer = {
|
||||
val path = if (data.startsWith("/")) data else "doc/" + data
|
||||
val location = new ResourceLocation(Settings.resourceDomain, path)
|
||||
new TextureImageRenderer(location)
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package li.cil.oc.client.renderer.markdown.segment.render
|
||||
import java.io.InputStream
|
||||
import javax.imageio.ImageIO
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.manual.ImageRenderer
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture
|
||||
@ -12,9 +11,7 @@ import net.minecraft.client.resources.IResourceManager
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
class TextureImageRenderer(val url: String) extends ImageRenderer {
|
||||
private val path = if (url.startsWith("/")) url else "doc/" + url
|
||||
private val location = new ResourceLocation(Settings.resourceDomain, path)
|
||||
class TextureImageRenderer(val location: ResourceLocation) extends ImageRenderer {
|
||||
private val texture = {
|
||||
val manager = Minecraft.getMinecraft.getTextureManager
|
||||
manager.getTexture(location) match {
|
||||
|
Loading…
x
Reference in New Issue
Block a user