Merge branch 'master' of cil.li:oc

This commit is contained in:
Florian Nücke 2013-11-24 15:55:03 +01:00
commit ec1d708b56
6 changed files with 166 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

View File

@ -1,6 +1,7 @@
package li.cil.oc package li.cil.oc
import java.io.File import java.io.File
import cpw.mods.fml.client.registry.RenderingRegistry
import li.cil.oc.util.ExtendedConfiguration._ import li.cil.oc.util.ExtendedConfiguration._
import li.cil.oc.util.PackedColor import li.cil.oc.util.PackedColor

View File

@ -27,7 +27,8 @@ private[oc] class Proxy extends CommonProxy {
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.PowerDistributor], PowerDistributorRenderer) ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.PowerDistributor], PowerDistributorRenderer)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.RobotProxy], RobotRenderer) ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.RobotProxy], RobotRenderer)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Screen], ScreenRenderer) ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Screen], ScreenRenderer)
//ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Keyboard], KeyboardRenderer)
// RenderingRegistry.registerBlockHandler()
TickRegistry.registerTickHandler(ScreenRenderer, Side.CLIENT) TickRegistry.registerTickHandler(ScreenRenderer, Side.CLIENT)
MinecraftForge.EVENT_BUS.register(gui.Icons) MinecraftForge.EVENT_BUS.register(gui.Icons)

View File

@ -9,6 +9,8 @@ import net.minecraft.util.Icon
import net.minecraft.world.IBlockAccess import net.minecraft.world.IBlockAccess
import net.minecraftforge.common.ForgeDirection import net.minecraftforge.common.ForgeDirection
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import li.cil.oc.common.tileentity
object BlockRenderer extends ISimpleBlockRenderingHandler { object BlockRenderer extends ISimpleBlockRenderingHandler {
var getRenderId = -1 var getRenderId = -1
@ -23,7 +25,7 @@ object BlockRenderer extends ISimpleBlockRenderingHandler {
GL11.glTranslatef(-0.5f, -0.5f, -0.5f) GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
CableRenderer.renderCable(ForgeDirection.DOWN.flag) CableRenderer.renderCable(ForgeDirection.DOWN.flag)
GL11.glTranslatef(0.5f, 0.5f, 0.5f) GL11.glTranslatef(0.5f, 0.5f, 0.5f)
case Some(keyboard: Keyboard) =>
case Some(proxy: RobotProxy) => case Some(proxy: RobotProxy) =>
GL11.glTranslatef(0, -0.1f, 0) GL11.glTranslatef(0, -0.1f, 0)
GL11.glScalef(1.5f, 1.5f, 1.5f) GL11.glScalef(1.5f, 1.5f, 1.5f)
@ -51,5 +53,45 @@ object BlockRenderer extends ISimpleBlockRenderingHandler {
} }
} }
def renderWorldBlock(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, modelId: Int, renderer: RenderBlocks) = renderer.renderStandardBlock(block, x, y, z) def renderWorldBlock(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, modelId: Int, renderer: RenderBlocks) = {
Delegator.subBlock(block, world.getBlockMetadata(x, y, z)) match {
case Some(keyboard: Keyboard) =>
world.getBlockTileEntity(x, y, z) match {
case teK: tileentity.Keyboard =>
if (teK.facing == ForgeDirection.UP || teK.facing == ForgeDirection.DOWN) {
teK.yaw match {
case ForgeDirection.NORTH =>
renderer.uvRotateTop = 0
renderer.uvRotateBottom = 0
case ForgeDirection.EAST =>
renderer.uvRotateTop = 1
renderer.uvRotateBottom = 2
case ForgeDirection.SOUTH =>
renderer.uvRotateTop = 3
renderer.uvRotateBottom = 3
case ForgeDirection.WEST =>
renderer.uvRotateTop = 2
renderer.uvRotateBottom = 1
case _ =>
}
if (teK.facing == ForgeDirection.DOWN) {
renderer.flipTexture = true
}
//
}
val ret = renderer.renderStandardBlock(block, x, y, z)
renderer.uvRotateTop = 0
renderer.uvRotateBottom = 0
renderer.flipTexture = false
ret
case _ =>
true
}
case _ => renderer.renderStandardBlock(block, x, y, z)
}
}
} }

View File

@ -0,0 +1,106 @@
package li.cil.oc.client.renderer.tileentity
import net.minecraft.util.ResourceLocation
import li.cil.oc.Config
import net.minecraft.tileentity.TileEntity
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.{RenderBlocks, Tessellator}
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler
import net.minecraft.block.Block
import net.minecraft.world.IBlockAccess
//object KeyboardRenderer extends ISimpleBlockRenderingHandler {
//
// private val frontOn = new ResourceLocation(Config.resourceDomain, "textures/blocks/computer_front.png")
//
// override def renderInventoryBlock(block: Block, metadata: Int, modelID: Int, renderer: RenderBlocks) {
//
// }
//
// override def renderWorldBlock(world: IBlockAccess, x: Int, y: Int, z: Int, block: Block, modelId: Int, renderer: RenderBlocks): Boolean = {
////
////
//// // dont create them here, create them in your constructor and save a reference as a member variable please
//// val tessellator = Tessellator.instance;
////
////
////
////
//// if (this.hasOverrideBlockTexture) {
//// icon = this.overrideBlockTexture
//// }
////
////
////
//// val d5: Double = icon.getMinU.asInstanceOf[Double]
//// val d6: Double = icon.getMinV.asInstanceOf[Double]
//// val d7: Double = icon.getMaxU.asInstanceOf[Double]
//// val d8: Double = icon.getMaxV.asInstanceOf[Double]
//// val d9: Double = icon.getInterpolatedU(7.0D).asInstanceOf[Double]
//// val d10: Double = icon.getInterpolatedV(6.0D).asInstanceOf[Double]
//// val d11: Double = icon.getInterpolatedU(9.0D).asInstanceOf[Double]
//// val d12: Double = icon.getInterpolatedV(8.0D).asInstanceOf[Double]
//// val d13: Double = icon.getInterpolatedU(7.0D).asInstanceOf[Double]
//// val d14: Double = icon.getInterpolatedV(13.0D).asInstanceOf[Double]
//// val d15: Double = icon.getInterpolatedU(9.0D).asInstanceOf[Double]
//// val d16: Double = icon.getInterpolatedV(15.0D).asInstanceOf[Double]
//// tessellator.setBrightness(par1Block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z))
//// tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F)
////
//// //+1 so that our "drawing" appears 1 block over our block (to get a better view)
//// // tessellator.startDrawingQuads()
//// //back
//// tessellator.addVertexWithUV(0, 0, 0, 0, 0)
//// tessellator.addVertexWithUV(0, 1, 0, 0, 1)
//// tessellator.addVertexWithUV(1, 1, 0, 1, 1)
//// tessellator.addVertexWithUV(1, 0, 0, 1, 0)
////
////
//// //front
//// tessellator.addVertexWithUV(0, 0, 0.5, 0, 0)
//// tessellator.addVertexWithUV(1, 0, 0.5, 1, 0)
//// tessellator.addVertexWithUV(1, 1, 0.5, 1, 1)
//// tessellator.addVertexWithUV(0, 1, 0.5, 0, 1)
////
//// //top
//// tessellator.addVertexWithUV(0, 1, 0.5, 0, 0)
//// tessellator.addVertexWithUV(1, 1, 0.5, 1, 0)
//// tessellator.addVertexWithUV(1, 1, 0, 1, 1)
//// tessellator.addVertexWithUV(0, 1, 0, 0, 1)
////
//// //bottom
//// tessellator.addVertexWithUV(0, 0, 0, 0, 1)
//// tessellator.addVertexWithUV(1, 0, 0, 1, 1)
//// tessellator.addVertexWithUV(1, 0, 0.5, 1, 0)
//// tessellator.addVertexWithUV(0, 0, 0.5, 0, 0)
////
////
//// //left
//// tessellator.addVertexWithUV(0, 0, 0.5, 0, 0)
//// tessellator.addVertexWithUV(0, 1, 0.5, 1, 0)
//// tessellator.addVertexWithUV(0, 1, 0, 1, 1)
//// tessellator.addVertexWithUV(0, 0, 0, 0, 1)
////
//// //right
//// tessellator.addVertexWithUV(1, 0, 0.5, 0, 0)
//// tessellator.addVertexWithUV(1, 0, 0, 0, 1)
//// tessellator.addVertexWithUV(1, 1, 0, 1, 1)
//// tessellator.addVertexWithUV(1, 1, 0.5, 1, 0)
////
////
//// //tessellator.draw()
////
// true
// }
//
// override def shouldRender3DInInventory = false
//
// def getRenderId: Int = Config.blockRenderId
//
//
// def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) = {
//
// }
//
//}

View File

@ -6,9 +6,22 @@ import net.minecraft.entity.EntityLivingBase
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.world.{IBlockAccess, World} import net.minecraft.world.{IBlockAccess, World}
import net.minecraftforge.common.ForgeDirection import net.minecraftforge.common.ForgeDirection
import li.cil.oc.Config
import net.minecraftforge.common.ForgeDirection
import net.minecraft.client.renderer.texture.IconRegister
import net.minecraft.util.Icon
class Keyboard(val parent: SpecialDelegator) extends SpecialDelegate { class Keyboard(val parent: SpecialDelegator) extends SpecialDelegate {
val unlocalizedName = "Keyboard" val unlocalizedName = "Keyboard"
var icon: Icon = null
override def icon(side: ForgeDirection) = Some(icon)
override def registerIcons(iconRegister: IconRegister) = {
icon = iconRegister.registerIcon(Config.resourceDomain + ":keyboard")
}
//override def shouldSideBeRendered(world: IBlockAccess, x: Int, y: Int, z: Int, side: ForgeDirection) = false
override def hasTileEntity = true override def hasTileEntity = true