2013-10-03 01:10:20 +02:00
|
|
|
package mekanism.client.render;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2013-12-21 00:14:31 +01:00
|
|
|
import mekanism.api.Coord4D;
|
2013-12-20 22:47:09 +01:00
|
|
|
import mekanism.client.model.ModelTransporterBox;
|
2013-12-03 04:14:21 +01:00
|
|
|
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
|
|
|
import mekanism.client.render.MekanismRenderer.Model3D;
|
2013-12-21 00:14:31 +01:00
|
|
|
import mekanism.common.item.ItemConfigurator;
|
|
|
|
import mekanism.common.multipart.PartDiversionTransporter;
|
2013-12-18 02:28:25 +01:00
|
|
|
import mekanism.common.multipart.PartLogisticalTransporter;
|
|
|
|
import mekanism.common.multipart.PartMechanicalPipe;
|
|
|
|
import mekanism.common.multipart.PartPressurizedTube;
|
|
|
|
import mekanism.common.multipart.PartSidedPipe;
|
2013-12-19 22:55:41 +01:00
|
|
|
import mekanism.common.multipart.PartSidedPipe.ConnectionType;
|
2013-12-18 02:28:25 +01:00
|
|
|
import mekanism.common.multipart.PartTransmitter;
|
|
|
|
import mekanism.common.multipart.PartUniversalCable;
|
2014-01-07 17:22:59 +01:00
|
|
|
import mekanism.common.multipart.TransmitterType;
|
|
|
|
import mekanism.common.multipart.TransmitterType.Size;
|
2013-12-21 00:14:31 +01:00
|
|
|
import mekanism.common.transporter.TransporterStack;
|
2013-12-13 05:08:16 +01:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-12-21 00:14:31 +01:00
|
|
|
import mekanism.common.util.TransporterUtils;
|
2013-12-03 04:14:21 +01:00
|
|
|
import net.minecraft.block.Block;
|
2013-12-20 22:47:09 +01:00
|
|
|
import net.minecraft.client.Minecraft;
|
2013-12-21 07:31:52 +01:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
2013-12-20 22:47:09 +01:00
|
|
|
import net.minecraft.client.renderer.entity.RenderItem;
|
|
|
|
import net.minecraft.client.renderer.entity.RenderManager;
|
2013-12-03 04:14:21 +01:00
|
|
|
import net.minecraft.client.renderer.texture.IconRegister;
|
2013-12-20 22:47:09 +01:00
|
|
|
import net.minecraft.entity.item.EntityItem;
|
2013-12-21 00:14:31 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-20 22:47:09 +01:00
|
|
|
import net.minecraft.item.Item;
|
2013-12-21 00:14:31 +01:00
|
|
|
import net.minecraft.item.ItemBlock;
|
2013-12-20 22:47:09 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2013-12-03 04:14:21 +01:00
|
|
|
import net.minecraft.util.Icon;
|
2013-12-21 00:14:31 +01:00
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
import net.minecraft.util.MovingObjectPosition;
|
2013-12-20 22:47:09 +01:00
|
|
|
import net.minecraft.world.World;
|
2013-12-03 04:14:21 +01:00
|
|
|
import net.minecraftforge.common.ForgeDirection;
|
|
|
|
import net.minecraftforge.fluids.Fluid;
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import codechicken.lib.colour.Colour;
|
|
|
|
import codechicken.lib.colour.ColourRGBA;
|
2013-12-21 07:31:52 +01:00
|
|
|
import codechicken.lib.lighting.LazyLightMatrix;
|
|
|
|
import codechicken.lib.lighting.LightMatrix;
|
2013-10-03 01:10:20 +02:00
|
|
|
import codechicken.lib.lighting.LightModel;
|
2014-01-06 22:49:39 +01:00
|
|
|
import codechicken.lib.lighting.LightModel.Light;
|
2013-10-03 01:10:20 +02:00
|
|
|
import codechicken.lib.render.CCModel;
|
|
|
|
import codechicken.lib.render.CCRenderState;
|
|
|
|
import codechicken.lib.render.ColourMultiplier;
|
2013-12-21 07:31:52 +01:00
|
|
|
import codechicken.lib.render.IVertexModifier;
|
2013-10-03 01:10:20 +02:00
|
|
|
import codechicken.lib.render.IconTransformation;
|
|
|
|
import codechicken.lib.render.TextureUtils;
|
|
|
|
import codechicken.lib.render.TextureUtils.IIconRegister;
|
2013-12-21 07:31:52 +01:00
|
|
|
import codechicken.lib.render.UV;
|
2013-10-03 01:10:20 +02:00
|
|
|
import codechicken.lib.vec.Translation;
|
|
|
|
import codechicken.lib.vec.Vector3;
|
2013-12-22 07:49:55 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-22 07:49:55 +01:00
|
|
|
@SideOnly(Side.CLIENT)
|
2013-10-03 01:10:20 +02:00
|
|
|
public class RenderPartTransmitter implements IIconRegister
|
|
|
|
{
|
|
|
|
public static RenderPartTransmitter INSTANCE;
|
2013-12-03 14:42:13 +01:00
|
|
|
|
2013-12-12 21:23:03 +01:00
|
|
|
public static Map<String, CCModel> small_models;
|
|
|
|
public static Map<String, CCModel> large_models;
|
2013-12-17 20:39:38 +01:00
|
|
|
public static Map<String, CCModel> contents_models;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-18 02:28:25 +01:00
|
|
|
private static final int stages = 100;
|
2013-12-03 16:54:50 +01:00
|
|
|
private static final double height = 0.45;
|
2013-10-03 01:10:20 +02:00
|
|
|
private static final double offset = 0.015;
|
2013-12-03 17:24:23 +01:00
|
|
|
|
2013-12-20 22:47:09 +01:00
|
|
|
private ModelTransporterBox modelBox = new ModelTransporterBox();
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
private HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>> cachedLiquids = new HashMap<ForgeDirection, HashMap<Fluid, DisplayInteger[]>>();
|
2013-12-20 22:47:09 +01:00
|
|
|
private HashMap<ForgeDirection, HashMap<Integer, DisplayInteger>> cachedOverlays = new HashMap<ForgeDirection, HashMap<Integer, DisplayInteger>>();
|
|
|
|
|
|
|
|
private Minecraft mc = Minecraft.getMinecraft();
|
|
|
|
|
|
|
|
private EntityItem entityItem = new EntityItem(null);
|
|
|
|
private RenderItem renderer = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class);
|
2013-12-13 05:08:16 +01:00
|
|
|
|
|
|
|
public static RenderPartTransmitter getInstance()
|
|
|
|
{
|
|
|
|
return INSTANCE;
|
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-13 05:08:16 +01:00
|
|
|
public static void init()
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
2013-12-13 05:08:16 +01:00
|
|
|
INSTANCE = new RenderPartTransmitter();
|
|
|
|
TextureUtils.addIconRegistrar(INSTANCE);
|
|
|
|
|
|
|
|
small_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_small.obj"), 7, null);
|
2013-12-12 21:23:03 +01:00
|
|
|
|
|
|
|
for(CCModel c : small_models.values())
|
2013-12-03 16:54:50 +01:00
|
|
|
{
|
2013-10-03 01:10:20 +02:00
|
|
|
c.apply(new Translation(.5, .5, .5));
|
|
|
|
c.computeLighting(LightModel.standardLightModel);
|
|
|
|
c.shrinkUVs(0.0005);
|
|
|
|
}
|
2013-12-12 21:23:03 +01:00
|
|
|
|
2013-12-13 05:08:16 +01:00
|
|
|
large_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_large.obj"), 7, null);
|
2013-12-12 21:23:03 +01:00
|
|
|
|
|
|
|
for(CCModel c : large_models.values())
|
|
|
|
{
|
|
|
|
c.apply(new Translation(.5, .5, .5));
|
|
|
|
c.computeLighting(LightModel.standardLightModel);
|
|
|
|
c.shrinkUVs(0.0005);
|
|
|
|
}
|
|
|
|
|
2013-12-17 20:39:38 +01:00
|
|
|
contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null);
|
2014-01-06 22:49:39 +01:00
|
|
|
LightModel interiorLightModel = new LightModel()
|
|
|
|
.setAmbient(new Vector3(0.6, 0.6, 0.6))
|
|
|
|
.addLight(new Light(new Vector3(0.3, 1, -0.7))
|
|
|
|
.setDiffuse(new Vector3(0.6, 0.6, 0.6)))
|
|
|
|
.addLight(new Light(new Vector3(-0.3, 1, 0.7))
|
|
|
|
.setDiffuse(new Vector3(0.6, 0.6, 0.6)));
|
|
|
|
|
2013-12-17 20:39:38 +01:00
|
|
|
for(CCModel c : contents_models.values())
|
2013-12-03 16:54:50 +01:00
|
|
|
{
|
2013-10-03 01:10:20 +02:00
|
|
|
c.apply(new Translation(.5, .5, .5));
|
2014-01-06 22:49:39 +01:00
|
|
|
c.computeLighting(interiorLightModel);
|
2013-10-03 01:10:20 +02:00
|
|
|
c.shrinkUVs(0.0005);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void push()
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
|
|
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void pop()
|
|
|
|
{
|
|
|
|
GL11.glPopAttrib();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
2014-01-07 17:22:59 +01:00
|
|
|
|
|
|
|
public void renderItem(TransmitterType type)
|
|
|
|
{
|
|
|
|
CCRenderState.reset();
|
|
|
|
CCRenderState.startDrawing(7);
|
|
|
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
|
|
|
{
|
|
|
|
renderSide(side, type);
|
|
|
|
}
|
|
|
|
CCRenderState.draw();
|
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-21 00:14:31 +01:00
|
|
|
public void renderContents(PartLogisticalTransporter transporter, float partialTick, Vector3 vec)
|
2013-12-20 22:47:09 +01:00
|
|
|
{
|
2013-12-21 00:14:31 +01:00
|
|
|
GL11.glPushMatrix();
|
2013-12-21 00:29:22 +01:00
|
|
|
|
2013-12-21 00:14:31 +01:00
|
|
|
entityItem.age = 0;
|
|
|
|
entityItem.hoverStart = 0;
|
|
|
|
|
|
|
|
entityItem.setPosition(transporter.x() + 0.5, transporter.y() + 0.5, transporter.z() + 0.5);
|
|
|
|
entityItem.worldObj = transporter.world();
|
2013-12-20 22:47:09 +01:00
|
|
|
|
2013-12-21 00:14:31 +01:00
|
|
|
for(TransporterStack stack : transporter.transit)
|
|
|
|
{
|
|
|
|
if(stack != null)
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
entityItem.setEntityItemStack(stack.itemStack);
|
|
|
|
|
2014-01-05 08:24:06 +01:00
|
|
|
float[] pos = TransporterUtils.getStackPosition(transporter, stack, partialTick*PartLogisticalTransporter.SPEED);
|
2013-12-21 00:14:31 +01:00
|
|
|
|
|
|
|
GL11.glTranslated(vec.x + pos[0], vec.y + pos[1] - entityItem.yOffset, vec.z + pos[2]);
|
|
|
|
GL11.glScalef(0.75F, 0.75F, 0.75F);
|
|
|
|
|
|
|
|
renderer.doRenderItem(entityItem, 0, 0, 0, 0, 0);
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
|
|
|
|
if(stack.color != null)
|
|
|
|
{
|
|
|
|
CCRenderState.changeTexture(MekanismUtils.getResource(ResourceType.RENDER, "TransporterBox.png"));
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
MekanismRenderer.glowOn();
|
|
|
|
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
|
|
GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F);
|
|
|
|
GL11.glTranslatef((float)(vec.x + pos[0]), (float)(vec.y + pos[1] - entityItem.yOffset - ((stack.itemStack.getItem() instanceof ItemBlock) ? 0.1 : 0)), (float)(vec.z + pos[2]));
|
|
|
|
modelBox.render(0.0625F);
|
|
|
|
MekanismRenderer.glowOff();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(transporter instanceof PartDiversionTransporter)
|
|
|
|
{
|
|
|
|
EntityPlayer player = mc.thePlayer;
|
|
|
|
World world = mc.thePlayer.worldObj;
|
|
|
|
ItemStack itemStack = player.getCurrentEquippedItem();
|
|
|
|
MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F);
|
|
|
|
|
|
|
|
if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator)
|
|
|
|
{
|
|
|
|
int xPos = MathHelper.floor_double(pos.blockX);
|
|
|
|
int yPos = MathHelper.floor_double(pos.blockY);
|
|
|
|
int zPos = MathHelper.floor_double(pos.blockZ);
|
|
|
|
|
2013-12-23 23:06:22 +01:00
|
|
|
Coord4D obj = new Coord4D(xPos, yPos, zPos, transporter.world().provider.dimensionId);
|
2013-12-21 00:14:31 +01:00
|
|
|
|
|
|
|
if(obj.equals(Coord4D.get(transporter.tile())))
|
|
|
|
{
|
|
|
|
int mode = ((PartDiversionTransporter)transporter).modes[pos.sideHit];
|
|
|
|
ForgeDirection side = ForgeDirection.getOrientation(pos.sideHit);
|
|
|
|
|
|
|
|
pushTransporter();
|
|
|
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F);
|
|
|
|
|
|
|
|
CCRenderState.changeTexture(mode == 0 ? MekanismRenderer.getItemsTexture() : MekanismRenderer.getBlocksTexture());
|
|
|
|
GL11.glTranslatef((float)vec.x, (float)vec.y, (float)vec.z);
|
|
|
|
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
|
|
|
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
|
|
|
|
|
|
|
int display = getOverlayDisplay(world, side, mode).display;
|
|
|
|
GL11.glCallList(display);
|
|
|
|
|
|
|
|
popTransporter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-21 00:29:22 +01:00
|
|
|
|
|
|
|
GL11.glPopMatrix();
|
2013-12-20 22:47:09 +01:00
|
|
|
}
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
public void renderContents(PartUniversalCable cable, Vector3 pos)
|
|
|
|
{
|
2013-12-13 04:31:27 +01:00
|
|
|
if(cable.currentPower == 0)
|
2013-12-03 16:54:50 +01:00
|
|
|
{
|
2013-10-03 01:10:20 +02:00
|
|
|
return;
|
2013-12-03 16:54:50 +01:00
|
|
|
}
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
GL11.glPushMatrix();
|
|
|
|
CCRenderState.reset();
|
|
|
|
CCRenderState.useNormals(true);
|
|
|
|
CCRenderState.useModelColours(true);
|
|
|
|
CCRenderState.startDrawing(7);
|
|
|
|
GL11.glTranslated(pos.x, pos.y, pos.z);
|
2013-12-03 16:54:50 +01:00
|
|
|
|
|
|
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
2014-01-06 22:49:39 +01:00
|
|
|
renderEnergySide(side, cable);
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
2013-12-03 16:54:50 +01:00
|
|
|
|
|
|
|
MekanismRenderer.glowOn();
|
2014-01-06 22:49:39 +01:00
|
|
|
MekanismRenderer.cullFrontFace();
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
CCRenderState.draw();
|
2014-01-06 22:49:39 +01:00
|
|
|
|
|
|
|
MekanismRenderer.disableCullFace();
|
2013-12-03 16:54:50 +01:00
|
|
|
MekanismRenderer.glowOff();
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void renderContents(PartMechanicalPipe pipe, Vector3 pos)
|
|
|
|
{
|
2013-12-17 21:54:06 +01:00
|
|
|
float targetScale = pipe.getTransmitterNetwork().fluidScale;
|
|
|
|
|
|
|
|
if(Math.abs(pipe.currentScale - targetScale) > 0.01)
|
|
|
|
{
|
2013-12-18 18:39:37 +01:00
|
|
|
pipe.currentScale = (12 * pipe.currentScale + targetScale) / 13;
|
2013-12-17 21:54:06 +01:00
|
|
|
}
|
2013-12-18 17:19:30 +01:00
|
|
|
else {
|
|
|
|
pipe.currentScale = targetScale;
|
|
|
|
}
|
2013-12-17 21:54:06 +01:00
|
|
|
|
2013-12-03 17:24:23 +01:00
|
|
|
Fluid fluid = pipe.getTransmitterNetwork().refFluid;
|
2013-12-17 21:36:25 +01:00
|
|
|
float scale = pipe.currentScale;
|
2013-12-03 17:24:23 +01:00
|
|
|
|
2013-12-18 00:20:18 +01:00
|
|
|
if(scale > 0.01 && fluid != null)
|
2013-12-03 17:24:23 +01:00
|
|
|
{
|
2013-10-03 01:10:20 +02:00
|
|
|
push();
|
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
MekanismRenderer.glowOn(fluid.getLuminosity());
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2014-01-03 03:58:14 +01:00
|
|
|
CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture());
|
2013-10-03 01:10:20 +02:00
|
|
|
GL11.glTranslated(pos.x, pos.y, pos.z);
|
|
|
|
|
2013-12-03 17:24:23 +01:00
|
|
|
boolean gas = fluid.isGaseous();
|
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
2014-01-08 03:06:07 +01:00
|
|
|
if(pipe.getConnectionType(side) == ConnectionType.NORMAL)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
DisplayInteger[] displayLists = getListAndRender(side, fluid);
|
2013-10-03 01:10:20 +02:00
|
|
|
|
|
|
|
if(displayLists != null)
|
|
|
|
{
|
2013-12-03 17:24:23 +01:00
|
|
|
if(!gas)
|
|
|
|
{
|
|
|
|
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GL11.glColor4f(1F, 1F, 1F, scale);
|
|
|
|
displayLists[stages-1].render();
|
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
}
|
2014-01-08 03:06:07 +01:00
|
|
|
else if(pipe.getConnectionType(side) != ConnectionType.NONE) {
|
|
|
|
GL11.glCullFace(GL11.GL_FRONT);
|
|
|
|
CCRenderState.startDrawing(7);
|
|
|
|
renderFluidInOut(side, pipe);
|
|
|
|
CCRenderState.draw();
|
|
|
|
GL11.glCullFace(GL11.GL_BACK);
|
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, fluid);
|
2013-10-03 01:10:20 +02:00
|
|
|
|
|
|
|
if(displayLists != null)
|
|
|
|
{
|
2013-12-03 17:24:23 +01:00
|
|
|
if(!gas)
|
|
|
|
{
|
|
|
|
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GL11.glColor4f(1F, 1F, 1F, scale);
|
|
|
|
displayLists[stages-1].render();
|
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
MekanismRenderer.glowOff();
|
2013-10-03 01:10:20 +02:00
|
|
|
|
|
|
|
pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid)
|
|
|
|
{
|
|
|
|
if(side == null || fluid == null || fluid.getIcon() == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(cachedLiquids.containsKey(side) && cachedLiquids.get(side).containsKey(fluid))
|
|
|
|
{
|
|
|
|
return cachedLiquids.get(side).get(fluid);
|
|
|
|
}
|
|
|
|
|
|
|
|
Model3D toReturn = new Model3D();
|
|
|
|
toReturn.baseBlock = Block.waterStill;
|
|
|
|
toReturn.setTexture(fluid.getIcon());
|
|
|
|
|
|
|
|
toReturn.setSideRender(side, false);
|
|
|
|
toReturn.setSideRender(side.getOpposite(), false);
|
|
|
|
|
|
|
|
DisplayInteger[] displays = new DisplayInteger[stages];
|
|
|
|
|
|
|
|
if(cachedLiquids.containsKey(side))
|
|
|
|
{
|
|
|
|
cachedLiquids.get(side).put(fluid, displays);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>();
|
|
|
|
map.put(fluid, displays);
|
|
|
|
cachedLiquids.put(side, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismRenderer.colorFluid(fluid);
|
|
|
|
|
|
|
|
for(int i = 0; i < stages; i++)
|
|
|
|
{
|
|
|
|
displays[i] = DisplayInteger.createAndStart();
|
|
|
|
|
|
|
|
switch(side)
|
|
|
|
{
|
|
|
|
case UNKNOWN:
|
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minX = 0.25 + offset;
|
|
|
|
toReturn.minY = 0.25 + offset;
|
|
|
|
toReturn.minZ = 0.25 + offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxX = 0.75 - offset;
|
|
|
|
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
|
|
|
toReturn.maxZ = 0.75 - offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DOWN:
|
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2;
|
2013-10-03 01:10:20 +02:00
|
|
|
toReturn.minY = 0.0;
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2;
|
|
|
|
toReturn.maxY = 0.25 + offset;
|
|
|
|
toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2;
|
2013-10-03 01:10:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UP:
|
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2;
|
|
|
|
toReturn.minY = 0.25 - offset + ((float)i / (float)stages)*height;
|
|
|
|
toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2;
|
2013-10-03 01:10:20 +02:00
|
|
|
toReturn.maxY = 1.0;
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2;
|
2013-10-03 01:10:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NORTH:
|
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minX = 0.25 + offset;
|
|
|
|
toReturn.minY = 0.25 + offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
toReturn.minZ = 0.0;
|
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxX = 0.75 - offset;
|
|
|
|
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
|
|
|
toReturn.maxZ = 0.25 + offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SOUTH:
|
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minX = 0.25 + offset;
|
|
|
|
toReturn.minY = 0.25 + offset;
|
|
|
|
toReturn.minZ = 0.75 - offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxX = 0.75 - offset;
|
|
|
|
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
2013-10-03 01:10:20 +02:00
|
|
|
toReturn.maxZ = 1.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WEST:
|
|
|
|
{
|
|
|
|
toReturn.minX = 0.0;
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minY = 0.25 + offset;
|
|
|
|
toReturn.minZ = 0.25 + offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxX = 0.25 + offset;
|
|
|
|
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
|
|
|
toReturn.maxZ = 0.75 - offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EAST:
|
|
|
|
{
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.minX = 0.75 - offset;
|
|
|
|
toReturn.minY = 0.25 + offset;
|
|
|
|
toReturn.minZ = 0.25 + offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
|
|
|
|
toReturn.maxX = 1.0;
|
2013-12-03 16:54:50 +01:00
|
|
|
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
|
|
|
toReturn.maxZ = 0.75 - offset;
|
2013-10-03 01:10:20 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismRenderer.renderObject(toReturn);
|
2013-12-18 02:28:25 +01:00
|
|
|
displays[i].endList();
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
|
|
|
|
return displays;
|
|
|
|
}
|
|
|
|
|
2013-12-03 22:23:08 +01:00
|
|
|
public void renderContents(PartPressurizedTube tube, Vector3 pos)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
2013-12-18 02:28:25 +01:00
|
|
|
if(tube.getTransmitterNetwork().refGas == null || tube.getTransmitterNetwork().gasScale == 0)
|
2013-12-03 22:23:08 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
CCRenderState.reset();
|
|
|
|
CCRenderState.useNormals(true);
|
|
|
|
CCRenderState.useModelColours(true);
|
|
|
|
CCRenderState.startDrawing(7);
|
|
|
|
GL11.glTranslated(pos.x, pos.y, pos.z);
|
|
|
|
|
|
|
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
|
|
|
{
|
2014-01-06 22:49:39 +01:00
|
|
|
renderGasSide(side, tube);
|
2013-12-03 22:23:08 +01:00
|
|
|
}
|
|
|
|
|
2014-01-06 22:49:39 +01:00
|
|
|
MekanismRenderer.glowOn(0);
|
|
|
|
MekanismRenderer.cullFrontFace();
|
|
|
|
|
2013-12-03 22:23:08 +01:00
|
|
|
CCRenderState.draw();
|
|
|
|
|
2014-01-06 22:49:39 +01:00
|
|
|
MekanismRenderer.disableCullFace();
|
|
|
|
MekanismRenderer.glowOff();
|
2013-12-03 22:23:08 +01:00
|
|
|
GL11.glPopMatrix();
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
2013-12-21 07:31:52 +01:00
|
|
|
public void renderStatic(PartSidedPipe transmitter, LazyLightMatrix olm)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
|
|
|
TextureUtils.bindAtlas(0);
|
|
|
|
CCRenderState.reset();
|
|
|
|
CCRenderState.useModelColours(true);
|
|
|
|
CCRenderState.setBrightness(transmitter.world(), transmitter.x(), transmitter.y(), transmitter.z());
|
2013-12-03 17:03:03 +01:00
|
|
|
|
|
|
|
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
2013-12-21 07:31:52 +01:00
|
|
|
renderSide(side, transmitter, olm);
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 07:31:52 +01:00
|
|
|
public void renderSide(ForgeDirection side, PartSidedPipe transmitter, LazyLightMatrix olm)
|
2013-10-03 01:10:20 +02:00
|
|
|
{
|
|
|
|
boolean connected = PartTransmitter.connectionMapContainsSide(transmitter.getAllCurrentConnections(), side);
|
2013-12-17 20:39:38 +01:00
|
|
|
Icon renderIcon = transmitter.getIconForSide(side);
|
2013-12-21 00:29:22 +01:00
|
|
|
|
2013-12-21 03:05:44 +01:00
|
|
|
Colour c = null;
|
|
|
|
|
2013-12-21 00:29:22 +01:00
|
|
|
if(transmitter.getRenderColor() != null)
|
|
|
|
{
|
2013-12-21 03:05:44 +01:00
|
|
|
c = new ColourRGBA(transmitter.getRenderColor().getColor(0), transmitter.getRenderColor().getColor(1), transmitter.getRenderColor().getColor(2), 1);
|
2013-12-21 00:29:22 +01:00
|
|
|
}
|
|
|
|
|
2013-12-21 07:31:52 +01:00
|
|
|
renderPart(renderIcon, transmitter.getModelForSide(side, false), transmitter.x(), transmitter.y(), transmitter.z(), c, olm);
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:22:59 +01:00
|
|
|
public void renderSide(ForgeDirection side, TransmitterType type)
|
|
|
|
{
|
|
|
|
boolean out = side == ForgeDirection.UP || side == ForgeDirection.DOWN;
|
|
|
|
|
|
|
|
Icon renderIcon = out ? type.getSideIcon() : type.getCenterIcon();
|
|
|
|
|
|
|
|
renderPart(renderIcon, getItemModel(side, type), 0,0,0, null, null);
|
|
|
|
}
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
public void renderEnergySide(ForgeDirection side, PartUniversalCable cable)
|
|
|
|
{
|
2014-01-06 22:49:39 +01:00
|
|
|
CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture());
|
2013-12-17 20:39:38 +01:00
|
|
|
renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower));
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
2013-12-03 22:23:08 +01:00
|
|
|
|
2014-01-08 03:06:07 +01:00
|
|
|
public void renderFluidInOut(ForgeDirection side, PartMechanicalPipe pipe)
|
|
|
|
{
|
|
|
|
CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture());
|
|
|
|
renderTransparency(pipe.getTransmitterNetwork().refFluid.getIcon(), pipe.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale));
|
|
|
|
}
|
|
|
|
|
2013-12-03 22:23:08 +01:00
|
|
|
public void renderGasSide(ForgeDirection side, PartPressurizedTube tube)
|
|
|
|
{
|
2014-01-06 22:49:39 +01:00
|
|
|
CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture());
|
2013-12-18 22:09:30 +01:00
|
|
|
renderTransparency(tube.getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale));
|
2013-12-03 22:23:08 +01:00
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
|
2013-12-21 07:31:52 +01:00
|
|
|
public void renderPart(Icon icon, CCModel cc, double x, double y, double z, Colour color, LazyLightMatrix olm)
|
2013-12-03 22:23:08 +01:00
|
|
|
{
|
2013-12-21 07:31:52 +01:00
|
|
|
cc.render(0, cc.verts.length, new Translation(x, y, z), new IconTransformation(icon), new TransmitterTransformation(color, null));
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
2013-12-03 22:23:08 +01:00
|
|
|
public void renderTransparency(Icon icon, CCModel cc, Colour colour)
|
|
|
|
{
|
2013-12-03 17:03:03 +01:00
|
|
|
cc.render(0, cc.verts.length, new Translation(0, 0, 0), new IconTransformation(icon), new ColourMultiplier(colour));
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
2014-01-07 17:22:59 +01:00
|
|
|
public CCModel getItemModel(ForgeDirection side, TransmitterType type)
|
|
|
|
{
|
|
|
|
String name = side.name().toLowerCase();
|
|
|
|
boolean out = side == ForgeDirection.UP || side == ForgeDirection.DOWN;
|
|
|
|
name += out ? "NORMAL" : "NONE";
|
|
|
|
if(type.getSize() == Size.SMALL)
|
|
|
|
{
|
|
|
|
return small_models.get(name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return large_models.get(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-03 01:10:20 +02:00
|
|
|
@Override
|
|
|
|
public void registerIcons(IconRegister register)
|
|
|
|
{
|
2013-12-16 15:00:43 +01:00
|
|
|
PartUniversalCable.registerIcons(register);
|
|
|
|
PartMechanicalPipe.registerIcons(register);
|
|
|
|
PartPressurizedTube.registerIcons(register);
|
|
|
|
PartLogisticalTransporter.registerIcons(register);
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int atlasIndex()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-12-20 22:47:09 +01:00
|
|
|
|
|
|
|
private void popTransporter()
|
|
|
|
{
|
|
|
|
GL11.glPopAttrib();
|
|
|
|
MekanismRenderer.glowOff();
|
|
|
|
MekanismRenderer.blendOff();
|
|
|
|
GL11.glPopMatrix();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void pushTransporter()
|
|
|
|
{
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
|
|
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
|
|
MekanismRenderer.glowOn();
|
|
|
|
MekanismRenderer.blendOn();
|
|
|
|
}
|
|
|
|
|
|
|
|
private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, int mode)
|
|
|
|
{
|
|
|
|
if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(mode))
|
|
|
|
{
|
|
|
|
return cachedOverlays.get(side).get(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
Icon icon = null;
|
|
|
|
|
|
|
|
switch(mode)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
icon = Item.gunpowder.getIcon(new ItemStack(Item.gunpowder), 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
icon = Block.torchRedstoneActive.getIcon(0, 0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
icon = Block.torchRedstoneIdle.getIcon(0, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Model3D toReturn = new Model3D();
|
|
|
|
toReturn.baseBlock = Block.stone;
|
|
|
|
toReturn.setTexture(icon);
|
|
|
|
|
|
|
|
DisplayInteger display = DisplayInteger.createAndStart();
|
|
|
|
|
|
|
|
if(cachedOverlays.containsKey(side))
|
|
|
|
{
|
|
|
|
cachedOverlays.get(side).put(mode, display);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
HashMap<Integer, DisplayInteger> map = new HashMap<Integer, DisplayInteger>();
|
|
|
|
map.put(mode, display);
|
|
|
|
cachedOverlays.put(side, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(side)
|
|
|
|
{
|
|
|
|
case DOWN:
|
|
|
|
{
|
|
|
|
toReturn.minY = -0.01;
|
|
|
|
toReturn.maxY = 0;
|
|
|
|
|
|
|
|
toReturn.minX = 0;
|
|
|
|
toReturn.minZ = 0;
|
|
|
|
toReturn.maxX = 1;
|
|
|
|
toReturn.maxZ = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case UP:
|
|
|
|
{
|
|
|
|
toReturn.minY = 1;
|
|
|
|
toReturn.maxY = 1.01;
|
|
|
|
|
|
|
|
toReturn.minX = 0;
|
|
|
|
toReturn.minZ = 0;
|
|
|
|
toReturn.maxX = 1;
|
|
|
|
toReturn.maxZ = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NORTH:
|
|
|
|
{
|
|
|
|
toReturn.minZ = -0.01;
|
|
|
|
toReturn.maxZ = 0;
|
|
|
|
|
|
|
|
toReturn.minX = 0;
|
|
|
|
toReturn.minY = 0;
|
|
|
|
toReturn.maxX = 1;
|
|
|
|
toReturn.maxY = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SOUTH:
|
|
|
|
{
|
|
|
|
toReturn.minZ = 1;
|
|
|
|
toReturn.maxZ = 1.01;
|
|
|
|
|
|
|
|
toReturn.minX = 0;
|
|
|
|
toReturn.minY = 0;
|
|
|
|
toReturn.maxX = 1;
|
|
|
|
toReturn.maxY = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WEST:
|
|
|
|
{
|
|
|
|
toReturn.minX = -0.01;
|
|
|
|
toReturn.maxX = 0;
|
|
|
|
|
|
|
|
toReturn.minY = 0;
|
|
|
|
toReturn.minZ = 0;
|
|
|
|
toReturn.maxY = 1;
|
|
|
|
toReturn.maxZ = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EAST:
|
|
|
|
{
|
|
|
|
toReturn.minX = 1;
|
|
|
|
toReturn.maxX = 1.01;
|
|
|
|
|
|
|
|
toReturn.minY = 0;
|
|
|
|
toReturn.minZ = 0;
|
|
|
|
toReturn.maxY = 1;
|
|
|
|
toReturn.maxZ = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MekanismRenderer.renderObject(toReturn);
|
|
|
|
display.endList();
|
|
|
|
|
|
|
|
return display;
|
|
|
|
}
|
2013-12-21 07:31:52 +01:00
|
|
|
|
|
|
|
public static class TransmitterTransformation implements IVertexModifier
|
|
|
|
{
|
|
|
|
public ColourMultiplier colour;
|
|
|
|
public LightMatrix lightMatrix;
|
|
|
|
|
|
|
|
public TransmitterTransformation(Colour color, LazyLightMatrix olm)
|
|
|
|
{
|
|
|
|
if(color != null)
|
|
|
|
{
|
|
|
|
colour = new ColourMultiplier(color);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(olm != null)
|
|
|
|
{
|
|
|
|
lightMatrix = olm.lightMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void applyModifiers(CCModel m, Tessellator tess, Vector3 vec, UV uv, Vector3 normal, int i)
|
|
|
|
{
|
|
|
|
if(colour != null)
|
|
|
|
{
|
|
|
|
colour.applyModifiers(m, tess, vec, uv, normal, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(lightMatrix != null)
|
|
|
|
{
|
|
|
|
lightMatrix.applyModifiers(m, tess, vec, uv, normal, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean needsNormals()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-10-03 01:10:20 +02:00
|
|
|
}
|