Converted RenderPipe to Scala
This commit is contained in:
parent
d7463300e4
commit
3610631e53
5 changed files with 150 additions and 218 deletions
|
@ -1,39 +0,0 @@
|
|||
package resonantinduction.mechanical;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import net.minecraft.item.Item;
|
||||
import resonant.content.wrapper.ItemRenderHandler;
|
||||
import resonantinduction.mechanical.fluid.pipe.RenderPipe;
|
||||
import resonantinduction.mechanical.fluid.transport.RenderPump;
|
||||
import resonantinduction.mechanical.fluid.transport.TilePump;
|
||||
import resonantinduction.mechanical.mech.gear.RenderGear;
|
||||
import resonantinduction.mechanical.mech.gearshaft.RenderGearShaft;
|
||||
import resonantinduction.mechanical.mech.process.crusher.RenderMechanicalPiston;
|
||||
import resonantinduction.mechanical.mech.process.crusher.TileMechanicalPiston;
|
||||
import resonantinduction.mechanical.mech.process.grinder.RenderGrindingWheel;
|
||||
import resonantinduction.mechanical.mech.process.grinder.TileGrindingWheel;
|
||||
import resonantinduction.mechanical.mech.process.mixer.RenderMixer;
|
||||
import resonantinduction.mechanical.mech.process.mixer.TileMixer;
|
||||
import resonantinduction.mechanical.mech.turbine.*;
|
||||
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
ItemRenderHandler.register(Mechanical.itemGear, RenderGear.INSTANCE);
|
||||
ItemRenderHandler.register(Mechanical.itemGearShaft, RenderGearShaft.INSTANCE);
|
||||
ItemRenderHandler.register(Mechanical.itemPipe, RenderPipe.INSTANCE);
|
||||
|
||||
ItemRenderHandler.register(Item.getItemFromBlock(Mechanical.blockWaterTurbine), new RenderWaterTurbine());
|
||||
ItemRenderHandler.register(Item.getItemFromBlock(Mechanical.blockWindTurbine), new RenderWindTurbine());
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileMechanicalPiston.class, new RenderMechanicalPiston());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileGrindingWheel.class, new RenderGrindingWheel());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileMixer.class, new RenderMixer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileWaterTurbine.class, new RenderWaterTurbine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileWindTurbine.class, new RenderWindTurbine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileElectricTurbine.class, new RenderElectricTurbine());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePump.class, new RenderPump());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package resonantinduction.mechanical
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry
|
||||
import net.minecraft.item.Item
|
||||
import resonant.content.wrapper.ItemRenderHandler
|
||||
import resonantinduction.mechanical.fluid.pipe.RenderPipe
|
||||
import resonantinduction.mechanical.fluid.transport.RenderPump
|
||||
import resonantinduction.mechanical.fluid.transport.TilePump
|
||||
import resonantinduction.mechanical.mech.gear.RenderGear
|
||||
import resonantinduction.mechanical.mech.gearshaft.RenderGearShaft
|
||||
import resonantinduction.mechanical.mech.process.crusher.RenderMechanicalPiston
|
||||
import resonantinduction.mechanical.mech.process.crusher.TileMechanicalPiston
|
||||
import resonantinduction.mechanical.mech.process.grinder.RenderGrindingWheel
|
||||
import resonantinduction.mechanical.mech.process.grinder.TileGrindingWheel
|
||||
import resonantinduction.mechanical.mech.process.mixer.RenderMixer
|
||||
import resonantinduction.mechanical.mech.process.mixer.TileMixer
|
||||
import resonantinduction.mechanical.mech.turbine._
|
||||
|
||||
class ClientProxy extends CommonProxy
|
||||
{
|
||||
override def init()
|
||||
{
|
||||
ItemRenderHandler.register(Mechanical.itemGear, RenderGear.INSTANCE)
|
||||
ItemRenderHandler.register(Mechanical.itemGearShaft, RenderGearShaft.INSTANCE)
|
||||
ItemRenderHandler.register(Mechanical.itemPipe, RenderPipe)
|
||||
ItemRenderHandler.register(Item.getItemFromBlock(Mechanical.blockWaterTurbine), new RenderWaterTurbine)
|
||||
ItemRenderHandler.register(Item.getItemFromBlock(Mechanical.blockWindTurbine), new RenderWindTurbine)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMechanicalPiston], new RenderMechanicalPiston)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileGrindingWheel], new RenderGrindingWheel)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileMixer], new RenderMixer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileWaterTurbine], new RenderWaterTurbine)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileWindTurbine], new RenderWindTurbine)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TileElectricTurbine], new RenderElectricTurbine)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[TilePump], new RenderPump)
|
||||
}
|
||||
}
|
|
@ -135,7 +135,7 @@ class PartPipe extends PartFramedNode with TMaterial[PipeMaterial] with TColorab
|
|||
@SideOnly(Side.CLIENT)
|
||||
override def renderDynamic(pos: Vector3, frame: Float, pass: Int)
|
||||
{
|
||||
RenderPipe.INSTANCE.render(this, pos.x, pos.y, pos.z, frame)
|
||||
RenderPipe.render(this, pos.x, pos.y, pos.z, frame)
|
||||
}
|
||||
|
||||
def getItem: ItemStack =
|
||||
|
|
|
@ -1,178 +0,0 @@
|
|||
package resonantinduction.mechanical.fluid.pipe;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
||||
import net.minecraftforge.client.model.IModelCustom;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import resonant.content.prefab.scala.render.ISimpleItemRenderer;
|
||||
import resonant.lib.render.RenderUtility;
|
||||
import resonant.lib.utility.WorldUtility;
|
||||
import resonantinduction.core.Reference;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderPipe implements ISimpleItemRenderer
|
||||
{
|
||||
public static final RenderPipe INSTANCE = new RenderPipe();
|
||||
|
||||
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelPath() + "pipe.tcn"));
|
||||
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.domain(), Reference.modelPath() + "pipe.png");
|
||||
|
||||
public void render(PartPipe part, double x, double y, double z, float f)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
render(part.getMaterialID(), part.getColor() > 0 ? ItemDye.field_150922_c[part.getColor()] : -1, part.connectionMask());
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
FluidStack fluid = part.tank().getFluid();
|
||||
int capacity = part.tank().getCapacity();
|
||||
int renderSides = part.connectionMask();
|
||||
/**
|
||||
if (fluid != null && fluid.amount > 0)
|
||||
{
|
||||
double filledPercentage = Math.min((double) fluid.amount / (double) capacity, 1);
|
||||
double renderPercentage = fluid.getFluid().isGaseous() ? 1 : filledPercentage;
|
||||
|
||||
int[] displayList = FluidRenderUtility.getFluidDisplayLists(fluid, part.world(), false);
|
||||
RenderUtility.bind(FluidRenderUtility.getFluidSheet(fluid));
|
||||
Color color = new Color(fluid.getFluid().getColor());
|
||||
GL11.glColor4d(color.getRed() / 255, color.getGreen() / 255, color.getBlue() / 255, fluid.getFluid().isGaseous() ? filledPercentage : 1);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glTranslatef((float) x + 0.35f, (float) y + 0.35f, (float) z + 0.35f);
|
||||
GL11.glScalef(0.33f, 0.33f, 0.33f);
|
||||
|
||||
GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (WorldUtility.isEnabledSide(renderSides, direction))
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
switch (direction.ordinal())
|
||||
{
|
||||
case 0:
|
||||
GL11.glTranslatef((float) x + 0.35F, (float) y - 0f, (float) z + 0.35F);
|
||||
break;
|
||||
case 1:
|
||||
GL11.glTranslatef((float) x + 0.35F, (float) y + 0.65f, (float) z + 0.35F);
|
||||
break;
|
||||
case 2:
|
||||
GL11.glTranslatef((float) x + 0.35F, (float) y + 0.35f, (float) z + 0F);
|
||||
break;
|
||||
case 3:
|
||||
GL11.glTranslatef((float) x + 0.35F, (float) y + 0.35f, (float) z + 0.65F);
|
||||
break;
|
||||
case 4:
|
||||
GL11.glTranslatef((float) x + 0F, (float) y + 0.35f, (float) z + 0.35F);
|
||||
break;
|
||||
case 5:
|
||||
GL11.glTranslatef((float) x + 0.65F, (float) y + 0.35f, (float) z + 0.35F);
|
||||
break;
|
||||
}
|
||||
|
||||
GL11.glScalef(0.33f, 0.33f, 0.33f);
|
||||
GL11.glCallList(displayList[(int) (renderPercentage * (FluidRenderUtility.DISPLAY_STAGES - 1))]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
public static void render(int meta, int colorCode, int sides)
|
||||
{
|
||||
RenderUtility.enableBlending();
|
||||
RenderUtility.bind(TEXTURE);
|
||||
PipeMaterials.PipeMaterial material = (PipeMaterials.PipeMaterial) PipeMaterials.apply(meta);
|
||||
Color matColor = new Color(material.color());
|
||||
GL11.glColor4f(matColor.getRed() / 255f, matColor.getGreen() / 255f, matColor.getBlue() / 255f, 1);
|
||||
MODEL.renderOnly("Mid");
|
||||
|
||||
/**
|
||||
* Render each side
|
||||
*/
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (WorldUtility.isEnabledSide(sides, dir))
|
||||
{
|
||||
GL11.glColor4f(matColor.getRed() / 255f, matColor.getGreen() / 255f, matColor.getBlue() / 255f, 1);
|
||||
String prefix = null;
|
||||
|
||||
switch (dir)
|
||||
{
|
||||
case DOWN:
|
||||
prefix = "Bottom";
|
||||
break;
|
||||
case UP:
|
||||
prefix = "Top";
|
||||
break;
|
||||
case NORTH:
|
||||
prefix = "Front";
|
||||
break;
|
||||
case SOUTH:
|
||||
prefix = "Back";
|
||||
break;
|
||||
case WEST:
|
||||
prefix = "Right";
|
||||
break;
|
||||
case EAST:
|
||||
prefix = "Left";
|
||||
break;
|
||||
}
|
||||
|
||||
MODEL.renderOnly(prefix + "Inter", prefix + "Connect");
|
||||
|
||||
if (colorCode > 0)
|
||||
{
|
||||
Color color = new Color(colorCode);
|
||||
GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1);
|
||||
}
|
||||
|
||||
MODEL.renderOnly(prefix + "Pipe");
|
||||
}
|
||||
}
|
||||
|
||||
RenderUtility.disableBlending();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryItem(IItemRenderer.ItemRenderType type, ItemStack itemStack, Object... data)
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
render(itemStack.getItemDamage(), -1, 0xC);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package resonantinduction.mechanical.fluid.pipe
|
||||
|
||||
import java.awt.Color
|
||||
|
||||
import cpw.mods.fml.relauncher.{Side, SideOnly}
|
||||
import net.minecraft.item.{ItemDye, ItemStack}
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import net.minecraftforge.client.IItemRenderer
|
||||
import net.minecraftforge.client.model.AdvancedModelLoader
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import net.minecraftforge.fluids.FluidStack
|
||||
import org.lwjgl.opengl.GL11
|
||||
import resonant.content.prefab.scala.render.ISimpleItemRenderer
|
||||
import resonant.lib.render.{FluidRenderUtility, RenderUtility}
|
||||
import resonant.lib.utility.WorldUtility
|
||||
import resonantinduction.core.Reference
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
object RenderPipe extends ISimpleItemRenderer
|
||||
{
|
||||
val model = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain, Reference.modelPath + "pipe.tcn"))
|
||||
var texture = new ResourceLocation(Reference.domain, Reference.modelPath + "pipe.png")
|
||||
|
||||
/**
|
||||
* Render Pipe Model
|
||||
*/
|
||||
def render(meta: Int, colorCode: Int, sides: Int)
|
||||
{
|
||||
RenderUtility.enableBlending()
|
||||
RenderUtility.bind(texture)
|
||||
val material: PipeMaterials.PipeMaterial = PipeMaterials.apply(meta).asInstanceOf[PipeMaterials.PipeMaterial]
|
||||
val matColor: Color = new Color(material.color)
|
||||
GL11.glColor4f(matColor.getRed / 255f, matColor.getGreen / 255f, matColor.getBlue / 255f, 1)
|
||||
|
||||
model.renderOnly("Mid")
|
||||
|
||||
for (dir <- ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
if (WorldUtility.isEnabledSide(sides, dir))
|
||||
{
|
||||
GL11.glColor4f(matColor.getRed / 255f, matColor.getGreen / 255f, matColor.getBlue / 255f, 1)
|
||||
var prefix: String = null
|
||||
|
||||
dir match
|
||||
{
|
||||
case ForgeDirection.DOWN =>
|
||||
prefix = "Bottom"
|
||||
case ForgeDirection.UP =>
|
||||
prefix = "Top"
|
||||
case ForgeDirection.NORTH =>
|
||||
prefix = "Front"
|
||||
case ForgeDirection.SOUTH =>
|
||||
prefix = "Back"
|
||||
case ForgeDirection.WEST =>
|
||||
prefix = "Right"
|
||||
case ForgeDirection.EAST =>
|
||||
prefix = "Left"
|
||||
case _ =>
|
||||
}
|
||||
|
||||
model.renderOnly(prefix + "Inter", prefix + "Connect")
|
||||
|
||||
if (colorCode > 0)
|
||||
{
|
||||
val color = new Color(colorCode)
|
||||
GL11.glColor4f(color.getRed / 255f, color.getGreen / 255f, color.getBlue / 255f, 1)
|
||||
}
|
||||
|
||||
model.renderOnly(prefix + "Pipe")
|
||||
}
|
||||
}
|
||||
|
||||
RenderUtility.disableBlending()
|
||||
}
|
||||
|
||||
/**
|
||||
* Render pipe in world
|
||||
*/
|
||||
def render(part: PartPipe, x: Double, y: Double, z: Double, f: Float)
|
||||
{
|
||||
GL11.glPushMatrix()
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
render(part.getMaterialID, if (part.getColor > 0) ItemDye.field_150922_c(part.getColor) else -1, part.connectionMask)
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPushMatrix()
|
||||
val fluid: FluidStack = part.tank.getFluid
|
||||
val renderSides: Int = part.connectionMask
|
||||
|
||||
if (fluid != null && fluid.amount > 0)
|
||||
{
|
||||
GL11.glScaled(0.99, 0.99, 0.99)
|
||||
val tank = part.tank
|
||||
val percentageFilled: Double = tank.getFluidAmount.asInstanceOf[Double] / tank.getCapacity.asInstanceOf[Double]
|
||||
val ySouthEast = percentageFilled
|
||||
val yNorthEast = percentageFilled
|
||||
val ySouthWest = percentageFilled
|
||||
val yNorthWest = percentageFilled
|
||||
FluidRenderUtility.renderFluidTesselation(tank, ySouthEast, yNorthEast, ySouthWest, yNorthWest)
|
||||
}
|
||||
|
||||
GL11.glPopMatrix()
|
||||
}
|
||||
|
||||
/**
|
||||
* Render inventory pipe
|
||||
*/
|
||||
def renderInventoryItem(`type`: IItemRenderer.ItemRenderType, itemStack: ItemStack, data: AnyRef*)
|
||||
{
|
||||
GL11.glPushMatrix()
|
||||
render(itemStack.getItemDamage, -1, 0xC)
|
||||
GL11.glPopMatrix()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue