Made texture picker work again... somewhat (not side-aware, but hey).

This commit is contained in:
Florian Nücke 2015-03-25 19:39:21 +01:00
parent 68fc33bd41
commit eb534f828a
2 changed files with 16 additions and 15 deletions

View File

@ -30,10 +30,7 @@ object PrintModel extends SmartBlockModelBase with ISmartItemModel {
for (shape <- if (print.state) print.data.stateOn else print.data.stateOff) { for (shape <- if (print.state) print.data.stateOn else print.data.stateOff) {
val bounds = shape.bounds.rotateTowards(print.facing) val bounds = shape.bounds.rotateTowards(print.facing)
var texture = Textures.getSprite(shape.texture) val texture = resolveTexture(shape.texture)
if (texture.getIconName == "missingno") {
texture = Textures.getSprite("minecraft:blocks/" + shape.texture)
}
faces ++= bakeQuads(makeBox(bounds.min, bounds.max), Array.fill(6)(texture), shape.tint.getOrElse(NoTint)) faces ++= bakeQuads(makeBox(bounds.min, bounds.max), Array.fill(6)(texture), shape.tint.getOrElse(NoTint))
} }
@ -51,10 +48,7 @@ object PrintModel extends SmartBlockModelBase with ISmartItemModel {
Textures.Block.bind() Textures.Block.bind()
for (shape <- data.stateOff) { for (shape <- data.stateOff) {
val bounds = shape.bounds val bounds = shape.bounds
var texture = Textures.getSprite(shape.texture) val texture = resolveTexture(shape.texture)
if (texture.getIconName == "missingno") {
texture = Textures.getSprite("minecraft:blocks/" + shape.texture)
}
faces ++= bakeQuads(makeBox(bounds.min, bounds.max), Array.fill(6)(texture), shape.tint.getOrElse(NoTint)) faces ++= bakeQuads(makeBox(bounds.min, bounds.max), Array.fill(6)(texture), shape.tint.getOrElse(NoTint))
} }
@ -62,4 +56,10 @@ object PrintModel extends SmartBlockModelBase with ISmartItemModel {
} }
} }
private def resolveTexture(name: String) = {
val texture = Textures.getSprite(name)
if (texture.getIconName == "missingno") Textures.getSprite("minecraft:blocks/" + name)
else texture
}
} }

View File

@ -4,21 +4,22 @@ import li.cil.oc.Localization
import li.cil.oc.util.BlockPosition import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._ import li.cil.oc.util.ExtendedWorld._
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.client.Minecraft
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.util.EnumFacing import net.minecraft.util.EnumFacing
import net.minecraft.util.ResourceLocation
class TexturePicker(val parent: Delegator) extends Delegate { class TexturePicker(val parent: Delegator) extends Delegate {
override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = { override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: EnumFacing, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
player.getEntityWorld.getBlock(position) match { player.getEntityWorld.getBlock(position) match {
case block: Block => case block: Block =>
// TODO Any way to do this in 1.8 at all? if (player.getEntityWorld.isRemote) {
// if (player.getEntityWorld.isRemote) { val model = Minecraft.getMinecraft.getBlockRendererDispatcher.getModelFromBlockState(player.getEntityWorld.getBlockState(position.toBlockPos), player.getEntityWorld, position.toBlockPos)
// val icon = block.getIcon(player.getEntityWorld, position.x, position.y, position.z, side) if (model != null && model.getTexture != null && model.getTexture.getIconName != null) {
// if (icon != null) { player.addChatMessage(Localization.Chat.TextureName(model.getTexture.getIconName))
// player.addChatMessage(Localization.Chat.TextureName(icon.getIconName)) }
// } }
// }
true true
case _ => super.onItemUse(stack, player, position, side, hitX, hitY, hitZ) case _ => super.onItemUse(stack, player, position, side, hitX, hitY, hitZ)
} }