Fixed gutter and mixer item render

This commit is contained in:
Calclavia 2014-10-25 19:32:36 +08:00
parent 6fbc93b6cd
commit 79a8147f00
5 changed files with 366 additions and 344 deletions

View file

@ -17,8 +17,9 @@ import org.lwjgl.opengl.GL11
import resonant.api.recipe.{MachineRecipes, RecipeResource} import resonant.api.recipe.{MachineRecipes, RecipeResource}
import resonant.content.factory.resources.RecipeType import resonant.content.factory.resources.RecipeType
import resonant.lib.render.{FluidRenderUtility, RenderUtility} import resonant.lib.render.{FluidRenderUtility, RenderUtility}
import resonant.lib.utility.{FluidUtility, WorldUtility} import resonant.lib.utility.FluidUtility
import resonant.lib.utility.inventory.InventoryUtility import resonant.lib.utility.inventory.InventoryUtility
import resonant.lib.wrapper.BitmaskWrapper._
import resonantinduction.core.Reference import resonantinduction.core.Reference
import resonantinduction.core.prefab.node.TilePressureNode import resonantinduction.core.prefab.node.TilePressureNode
import universalelectricity.core.transform.region.Cuboid import universalelectricity.core.transform.region.Cuboid
@ -26,8 +27,8 @@ import universalelectricity.core.transform.vector.Vector3
object TileGutter object TileGutter
{ {
@SideOnly(Side.CLIENT) private[gutter] var MODEL: IModelCustom = _; @SideOnly(Side.CLIENT) private var MODEL: IModelCustom = _
@SideOnly(Side.CLIENT) private[gutter] var TEXTURE: ResourceLocation = _; @SideOnly(Side.CLIENT) private var TEXTURE: ResourceLocation = _
} }
/** /**
@ -37,36 +38,34 @@ object TileGutter
*/ */
class TileGutter extends TilePressureNode(Material.rock) class TileGutter extends TilePressureNode(Material.rock)
{ {
tankNode = new FluidGravityNode(this)
//Constructor
tankNode_$eq(new FluidGravityNode(this))
setTextureName("material_wood_surface") setTextureName("material_wood_surface")
isOpaqueCube(false) isOpaqueCube = false
normalRender(false) normalRender = false
bounds(new Cuboid(0, 0, 0, 1, 0.99, 1)) bounds = new Cuboid(0, 0, 0, 1, 0.99, 1)
override def getCollisionBoxes: java.lang.Iterable[Cuboid] = override def getCollisionBoxes: java.lang.Iterable[Cuboid] =
{ {
val list: List[Cuboid] = new ArrayList[Cuboid] val list: List[Cuboid] = new ArrayList[Cuboid]
val thickness: Float = 0.1F val thickness = 0.1f
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.DOWN))
if (!renderSides.mask(ForgeDirection.DOWN))
{ {
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F)) list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, thickness, 1.0F))
} }
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.WEST)) if (!renderSides.mask(ForgeDirection.WEST))
{ {
list.add(new Cuboid(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F)) list.add(new Cuboid(0.0F, 0.0F, 0.0F, thickness, 1.0F, 1.0F))
} }
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.NORTH)) if (!renderSides.mask(ForgeDirection.NORTH))
{ {
list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness)) list.add(new Cuboid(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, thickness))
} }
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.EAST)) if (!renderSides.mask(ForgeDirection.EAST))
{ {
list.add(new Cuboid(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F)) list.add(new Cuboid(1.0F - thickness, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F))
} }
if (!WorldUtility.isEnabledSide(renderSides, ForgeDirection.SOUTH)) if (!renderSides.mask(ForgeDirection.SOUTH))
{ {
list.add(new Cuboid(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F)) list.add(new Cuboid(0.0F, 0.0F, 1.0F - thickness, 1.0F, 1.0F, 1.0F))
} }
@ -83,6 +82,7 @@ class TileGutter extends TilePressureNode(Material.rock)
val pressure: Int = getPressure(dir) val pressure: Int = getPressure(dir)
val _position: Vector3 = asVector3.add(dir) val _position: Vector3 = asVector3.add(dir)
val checkTile: TileEntity = _position.getTileEntity(world) val checkTile: TileEntity = _position.getTileEntity(world)
if (checkTile.isInstanceOf[TileGutter]) if (checkTile.isInstanceOf[TileGutter])
{ {
val deltaPressure: Int = pressure - (checkTile.asInstanceOf[TileGutter]).getPressure(dir.getOpposite) val deltaPressure: Int = pressure - (checkTile.asInstanceOf[TileGutter]).getPressure(dir.getOpposite)
@ -143,7 +143,7 @@ class TileGutter extends TilePressureNode(Material.rock)
return true return true
} }
override def onFillRain override def onFillRain()
{ {
if (!world.isRemote) if (!world.isRemote)
{ {
@ -161,58 +161,62 @@ class TileGutter extends TilePressureNode(Material.rock)
{ {
TileGutter.TEXTURE = new ResourceLocation(Reference.domain, Reference.modelPath + "gutter.png") TileGutter.TEXTURE = new ResourceLocation(Reference.domain, Reference.modelPath + "gutter.png")
} }
GL11.glPushMatrix
GL11.glPushMatrix()
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5) GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5)
val liquid: FluidStack = getTank.getFluid
val capacity: Int = getTank.getCapacity
render(0, renderSides) render(0, renderSides)
if (world != null) if (world != null)
{ {
val tank: IFluidTank = getTank val tank: IFluidTank = getTank
val percentageFilled: Double = tank.getFluidAmount.asInstanceOf[Double] / tank.getCapacity.asInstanceOf[Double] val percentageFilled = tank.getFluidAmount / tank.getCapacity.toDouble
if (percentageFilled > 0.1) if (percentageFilled > 0.1)
{ {
GL11.glPushMatrix GL11.glPushMatrix()
GL11.glScaled(0.990, 0.99, 0.990) GL11.glScaled(0.99, 0.99, 0.99)
val ySouthEast: Double = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.SOUTH, ForgeDirection.EAST) val ySouthEast = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.SOUTH, ForgeDirection.EAST)
val yNorthEast: Double = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.NORTH, ForgeDirection.EAST) val yNorthEast = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.NORTH, ForgeDirection.EAST)
val ySouthWest: Double = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.SOUTH, ForgeDirection.WEST) val ySouthWest = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.SOUTH, ForgeDirection.WEST)
val yNorthWest: Double = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.NORTH, ForgeDirection.WEST) val yNorthWest = FluidUtility.getAveragePercentageFilledForSides(classOf[TileGutter], percentageFilled, world, position, ForgeDirection.NORTH, ForgeDirection.WEST)
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest) FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest)
GL11.glPopMatrix GL11.glPopMatrix()
} }
} }
GL11.glPopMatrix
GL11.glPopMatrix()
} }
def render(meta: Int, sides: Byte) def render(meta: Int, sides: Byte)
{ {
RenderUtility.bind(TileGutter.TEXTURE) RenderUtility.bind(TileGutter.TEXTURE)
val thickness: Double = 0.055
val height: Double = 0.5
for (dir <- ForgeDirection.VALID_DIRECTIONS) for (dir <- ForgeDirection.VALID_DIRECTIONS)
{ {
if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN) if (dir != ForgeDirection.UP && dir != ForgeDirection.DOWN)
{ {
GL11.glPushMatrix GL11.glPushMatrix()
RenderUtility.rotateBlockBasedOnDirection(dir) RenderUtility.rotateBlockBasedOnDirection(dir)
if (WorldUtility.isEnabledSide(sides, ForgeDirection.DOWN))
if (sides.mask(ForgeDirection.DOWN))
{ {
GL11.glTranslatef(0, -0.075f, 0) GL11.glTranslatef(0, -0.075f, 0)
GL11.glScalef(1, 1.15f, 1) GL11.glScalef(1, 1.15f, 1)
} }
if (!WorldUtility.isEnabledSide(sides, dir)) if (!sides.mask(dir))
{ {
TileGutter.MODEL.renderOnly("left") TileGutter.MODEL.renderOnly("left")
} }
if (!WorldUtility.isEnabledSide(sides, dir) || !WorldUtility.isEnabledSide(sides, dir.getRotation(ForgeDirection.UP))) if (!sides.mask(dir) || !sides.mask(dir.getRotation(ForgeDirection.UP)))
{ {
TileGutter.MODEL.renderOnly("backCornerL") TileGutter.MODEL.renderOnly("backCornerL")
} }
GL11.glPopMatrix GL11.glPopMatrix()
} }
} }
if (!WorldUtility.isEnabledSide(sides, ForgeDirection.DOWN))
if (!sides.mask(ForgeDirection.DOWN))
{ {
TileGutter.MODEL.renderOnly("base") TileGutter.MODEL.renderOnly("base")
} }

View file

@ -66,7 +66,6 @@ import universalelectricity.core.transform.vector.Vector3
ItemRenderHandler.register(Item.getItemFromBlock(MechanicalContent.blockWindTurbine), new RenderWindTurbine) ItemRenderHandler.register(Item.getItemFromBlock(MechanicalContent.blockWindTurbine), new RenderWindTurbine)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMechanicalPiston], new RenderMechanicalPiston) ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMechanicalPiston], new RenderMechanicalPiston)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileGrindingWheel], new RenderGrindingWheel) ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileGrindingWheel], new RenderGrindingWheel)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMixer], new RenderMixer)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileWaterTurbine], new RenderWaterTurbine) ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileWaterTurbine], new RenderWaterTurbine)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileWindTurbine], new RenderWindTurbine) ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileWindTurbine], new RenderWindTurbine)
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileElectricTurbine], new RenderElectricTurbine) ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileElectricTurbine], new RenderElectricTurbine)

View file

@ -25,11 +25,11 @@ class TileTankNode(material: Material) extends TileAdvanced(material) with INode
var tankNode: NodeTank = new NodeTank(this, 16) var tankNode: NodeTank = new NodeTank(this, 16)
protected var colorID: Int = 0 protected var colorID: Int = 0
def getFluid(): FluidStack = getTank().getFluid def getFluid: FluidStack = getTank.getFluid
def getFluidCapacity(): Int = getTank().getCapacity def getFluidCapacity: Int = getTank.getCapacity
def getTank(): IFluidTank = tankNode def getTank: IFluidTank = tankNode
override def readFromNBT(nbt: NBTTagCompound) override def readFromNBT(nbt: NBTTagCompound)
{ {

View file

@ -1,59 +1,47 @@
package resonantinduction.mechanical.mech.process.mixer package resonantinduction.mechanical.mech.process.mixer
import org.lwjgl.opengl.GL11.glPopMatrix import cpw.mods.fml.relauncher.{Side, SideOnly}
import org.lwjgl.opengl.GL11.glPushMatrix
import org.lwjgl.opengl.GL11.glRotatef
import org.lwjgl.opengl.GL11.glTranslatef
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.tileentity.TileEntity import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ResourceLocation import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.IItemRenderer import net.minecraftforge.client.IItemRenderer
import net.minecraftforge.client.model.AdvancedModelLoader import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
import net.minecraftforge.client.model.IModelCustom
import org.lwjgl.opengl.GL11 import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11.{glPopMatrix, glPushMatrix, glRotatef, glTranslatef}
import resonant.content.prefab.scala.render.ISimpleItemRenderer import resonant.content.prefab.scala.render.ISimpleItemRenderer
import resonant.lib.render.RenderUtility import resonant.lib.render.RenderUtility
import resonantinduction.core.Reference import resonantinduction.core.Reference
import cpw.mods.fml.relauncher.Side
import cpw.mods.fml.relauncher.SideOnly
/** /**
* @author Calclavia * @author Calclavia
* *
*/ */
@SideOnly(Side.CLIENT) object RenderMixer @SideOnly(Side.CLIENT)
object RenderMixer extends TileEntitySpecialRenderer with ISimpleItemRenderer
{ {
final val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.tcn")) val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.tcn"))
var TEXTURE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.png") var TEXTURE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.png")
}
@SideOnly(Side.CLIENT) class RenderMixer extends TileEntitySpecialRenderer with ISimpleItemRenderer
{
def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float) def renderTileEntityAt(t: TileEntity, x: Double, y: Double, z: Double, f: Float)
{ {
if (t.isInstanceOf[TileMixer]) if (t.isInstanceOf[TileMixer])
{ {
val tile: TileMixer = t.asInstanceOf[TileMixer] val tile: TileMixer = t.asInstanceOf[TileMixer]
glPushMatrix glPushMatrix()
glTranslatef(x.asInstanceOf[Float] + 0.5F, y.asInstanceOf[Float] + 0.5f, z.asInstanceOf[Float] + 0.5F) glTranslatef(x.asInstanceOf[Float] + 0.5F, y.asInstanceOf[Float] + 0.5f, z.asInstanceOf[Float] + 0.5F)
RenderUtility.bind(RenderMixer.TEXTURE)
RenderMixer.MODEL.renderOnly("centerTop", "centerBase") glPopMatrix()
glPushMatrix
glRotatef(Math.toDegrees(tile.mechanicalNode.renderAngle.asInstanceOf[Float]).asInstanceOf[Float], 0, 1, 0)
RenderMixer. MODEL.renderAllExcept("centerTop", "centerBase")
glPopMatrix
glPopMatrix
} }
} }
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*) def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
{ {
glPushMatrix glPushMatrix()
GL11.glScalef(0.5f, 0.5f, 0.5f) GL11.glScalef(0.25f, 0.25f, 0.25f)
glTranslatef(0.5F, 0.5f, 0.5f) glTranslatef(0.5F, 0.5f, 0.5f)
RenderUtility.bind(RenderMixer.TEXTURE) RenderUtility.bind(RenderMixer.TEXTURE)
RenderMixer.MODEL.renderAll RenderMixer.MODEL.renderAll()
glPopMatrix glPopMatrix()
} }
} }

View file

@ -2,25 +2,32 @@ package resonantinduction.mechanical.mech.process.mixer
import java.util.{LinkedHashSet, List, Set} import java.util.{LinkedHashSet, List, Set}
import cpw.mods.fml.relauncher.{Side, SideOnly}
import net.minecraft.block.Block import net.minecraft.block.Block
import net.minecraft.block.material.Material import net.minecraft.block.material.Material
import net.minecraft.entity.Entity import net.minecraft.entity.Entity
import net.minecraft.entity.item.EntityItem import net.minecraft.entity.item.EntityItem
import net.minecraft.init.Blocks import net.minecraft.init.Blocks
import net.minecraft.item.ItemStack import net.minecraft.item.ItemStack
import net.minecraft.util.AxisAlignedBB import net.minecraft.util.{AxisAlignedBB, ResourceLocation}
import net.minecraftforge.client.IItemRenderer
import net.minecraftforge.client.model.{AdvancedModelLoader, IModelCustom}
import net.minecraftforge.common.util.ForgeDirection import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.fluids.IFluidBlock import net.minecraftforge.fluids.IFluidBlock
import org.lwjgl.opengl.GL11
import org.lwjgl.opengl.GL11._
import resonant.api.recipe.MachineRecipes import resonant.api.recipe.MachineRecipes
import resonant.content.factory.resources.RecipeType import resonant.content.factory.resources.RecipeType
import resonant.content.factory.resources.block.BlockFluidMixture import resonant.content.factory.resources.block.BlockFluidMixture
import resonant.engine.ResonantEngine import resonant.engine.ResonantEngine
import resonant.lib.render.RenderUtility
import resonant.lib.utility.Timer import resonant.lib.utility.Timer
import resonantinduction.core.Reference import resonantinduction.core.Reference
import resonantinduction.mechanical.mech.TileMechanical import resonantinduction.mechanical.mech.TileMechanical
import universalelectricity.api.core.grid.INode import universalelectricity.api.core.grid.INode
import universalelectricity.core.transform.rotation.Quaternion import universalelectricity.core.transform.rotation.Quaternion
import universalelectricity.core.transform.vector.Vector3 import universalelectricity.core.transform.vector.Vector3
import scala.collection.JavaConversions._ import scala.collection.JavaConversions._
/** /**
@ -30,10 +37,14 @@ object TileMixer
{ {
final val PROCESS_TIME: Int = 12 * 20 final val PROCESS_TIME: Int = 12 * 20
final val MIXER_ITEM_TIMER: Timer[EntityItem] = new Timer[EntityItem] final val MIXER_ITEM_TIMER: Timer[EntityItem] = new Timer[EntityItem]
@SideOnly(Side.CLIENT) val MODEL: IModelCustom = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.tcn"))
@SideOnly(Side.CLIENT) var TEXTURE: ResourceLocation = new ResourceLocation(Reference.domain, Reference.modelPath + "mixer.png")
} }
class TileMixer extends TileMechanical(Material.iron) class TileMixer extends TileMechanical(Material.iron)
{ {
private var areaBlockedFromMoving: Boolean = false
//Constructor //Constructor
mechanicalNode = new MixerNode(this) mechanicalNode = new MixerNode(this)
isOpaqueCube(false) isOpaqueCube(false)
@ -129,10 +140,9 @@ class TileMixer extends TileMechanical(Material.iron)
{ {
if (doneWork(processingItem)) if (doneWork(processingItem))
{ {
if (({ processingItem.getEntityItem.stackSize -= 1
processingItem.getEntityItem.stackSize -= 1;
processingItem.getEntityItem.stackSize if (processingItem.getEntityItem.stackSize <= 0)
}) <= 0)
{ {
processingItem.setDead processingItem.setDead
TileMixer.MIXER_ITEM_TIMER.remove(processingItem) TileMixer.MIXER_ITEM_TIMER.remove(processingItem)
@ -192,5 +202,26 @@ class TileMixer extends TileMechanical(Material.iron)
return false return false
} }
private var areaBlockedFromMoving: Boolean = false override def renderDynamic(position: Vector3, frame: Float, pass: Int): Unit =
{
GL11.glPushMatrix()
GL11.glTranslated(position.x + 0.5, position.y + 0.5, position.z + 0.5)
RenderUtility.bind(RenderMixer.TEXTURE)
RenderMixer.MODEL.renderOnly("centerTop", "centerBase")
glPushMatrix()
glRotatef(Math.toDegrees(mechanicalNode.renderAngle.asInstanceOf[Float]).asInstanceOf[Float], 0, 1, 0)
RenderMixer.MODEL.renderAllExcept("centerTop", "centerBase")
glPopMatrix()
GL11.glPopMatrix()
}
override def renderInventory(itemStack: ItemStack)
{
glPushMatrix()
GL11.glScalef(0.7f, 0.7f, 0.7f)
glTranslatef(0.5F, 0.5f, 0.5f)
RenderUtility.bind(RenderMixer.TEXTURE)
RenderMixer.MODEL.renderAll()
glPopMatrix()
}
} }