diff --git a/src/main/scala/li/cil/oc/client/renderer/block/PrintModel.scala b/src/main/scala/li/cil/oc/client/renderer/block/PrintModel.scala index 6876add04..8fb6df363 100644 --- a/src/main/scala/li/cil/oc/client/renderer/block/PrintModel.scala +++ b/src/main/scala/li/cil/oc/client/renderer/block/PrintModel.scala @@ -30,10 +30,7 @@ object PrintModel extends SmartBlockModelBase with ISmartItemModel { for (shape <- if (print.state) print.data.stateOn else print.data.stateOff) { val bounds = shape.bounds.rotateTowards(print.facing) - var texture = Textures.getSprite(shape.texture) - if (texture.getIconName == "missingno") { - texture = Textures.getSprite("minecraft:blocks/" + shape.texture) - } + val texture = resolveTexture(shape.texture) 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() for (shape <- data.stateOff) { val bounds = shape.bounds - var texture = Textures.getSprite(shape.texture) - if (texture.getIconName == "missingno") { - texture = Textures.getSprite("minecraft:blocks/" + shape.texture) - } + val texture = resolveTexture(shape.texture) 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 + } + } diff --git a/src/main/scala/li/cil/oc/common/item/TexturePicker.scala b/src/main/scala/li/cil/oc/common/item/TexturePicker.scala index 090499ff3..93a206229 100644 --- a/src/main/scala/li/cil/oc/common/item/TexturePicker.scala +++ b/src/main/scala/li/cil/oc/common/item/TexturePicker.scala @@ -4,21 +4,22 @@ import li.cil.oc.Localization import li.cil.oc.util.BlockPosition import li.cil.oc.util.ExtendedWorld._ import net.minecraft.block.Block +import net.minecraft.client.Minecraft import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.EnumFacing +import net.minecraft.util.ResourceLocation 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 = { player.getEntityWorld.getBlock(position) match { case block: Block => - // TODO Any way to do this in 1.8 at all? -// if (player.getEntityWorld.isRemote) { -// val icon = block.getIcon(player.getEntityWorld, position.x, position.y, position.z, side) -// if (icon != null) { -// player.addChatMessage(Localization.Chat.TextureName(icon.getIconName)) -// } -// } + if (player.getEntityWorld.isRemote) { + val model = Minecraft.getMinecraft.getBlockRendererDispatcher.getModelFromBlockState(player.getEntityWorld.getBlockState(position.toBlockPos), player.getEntityWorld, position.toBlockPos) + if (model != null && model.getTexture != null && model.getTexture.getIconName != null) { + player.addChatMessage(Localization.Chat.TextureName(model.getTexture.getIconName)) + } + } true case _ => super.onItemUse(stack, player, position, side, hitX, hitY, hitZ) }