mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Merge branch '1.8.9' of github.com:aidancbrady/Mekanism into 1.8.9
This commit is contained in:
commit
ffb114e11c
8 files changed
+512
-109
No files matched your search
@@ -161,7 +161,7 @@ public class Gas
|
||||
{
|
||||
sprite = tex;
|
||||
}
|
||||
System.out.println(sprite);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mcmultipart.client.multipart.MultipartRegistryClient;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.MekanismConfig.client;
|
||||
@@ -97,6 +98,8 @@ import mekanism.client.render.tileentity.RenderSolarNeutronActivator;
|
||||
import mekanism.client.render.tileentity.RenderTeleporter;
|
||||
import mekanism.client.render.tileentity.RenderThermalEvaporationController;
|
||||
import mekanism.client.render.tileentity.RenderThermoelectricBoiler;
|
||||
import mekanism.client.render.transmitter.RenderMechanicalPipe;
|
||||
import mekanism.client.render.transmitter.RenderUniversalCable;
|
||||
import mekanism.common.CommonProxy;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
@@ -123,6 +126,8 @@ import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.item.ItemSeismicReader;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.multiblock.MultiblockManager;
|
||||
import mekanism.common.multipart.PartMechanicalPipe;
|
||||
import mekanism.common.multipart.PartUniversalCable;
|
||||
import mekanism.common.network.PacketPortableTeleporter.PortableTeleporterMessage;
|
||||
import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.tile.TileEntityAdvancedFactory;
|
||||
@@ -314,6 +319,9 @@ public class ClientProxy extends CommonProxy
|
||||
ClientRegistry.registerTileEntity(TileEntitySecurityDesk.class, "SecurityDesk", new RenderSecurityDesk());
|
||||
ClientRegistry.registerTileEntity(TileEntityQuantumEntangloporter.class, "QuantumEntangloporter", new RenderQuantumEntangloporter());
|
||||
ClientRegistry.registerTileEntity(TileEntityChemicalDissolutionChamber.class, "ChemicalDissolutionChamber", new RenderChemicalDissolutionChamber());
|
||||
|
||||
MultipartRegistryClient.bindMultipartSpecialRenderer(PartMechanicalPipe.class, new RenderMechanicalPipe());
|
||||
MultipartRegistryClient.bindMultipartSpecialRenderer(PartUniversalCable.class, new RenderUniversalCable());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -616,7 +624,7 @@ public class ClientProxy extends CommonProxy
|
||||
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.BasicBlock), basicMesher);
|
||||
ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), basicMesher);
|
||||
|
||||
|
||||
OBJLoader.instance.addDomain("mekanism");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
package mekanism.client.render;
|
||||
|
||||
/*
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.multipart.PartGlowPanel;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.util.IIcon;
|
||||
import codechicken.lib.colour.Colour;
|
||||
import codechicken.lib.colour.ColourRGBA;
|
||||
import codechicken.lib.lighting.LightModel;
|
||||
import codechicken.lib.render.CCModel;
|
||||
import codechicken.lib.render.CCRenderState;
|
||||
import codechicken.lib.render.ColourMultiplier;
|
||||
import codechicken.lib.render.TextureUtils;
|
||||
import codechicken.lib.render.TextureUtils.IIconSelfRegister;
|
||||
import codechicken.lib.render.uv.IconTransformation;
|
||||
import codechicken.lib.vec.Translation;
|
||||
import codechicken.lib.vec.Vector3;
|
||||
*/
|
||||
|
||||
public class RenderGlowPanel//TODO implements IIconSelfRegister
|
||||
{
|
||||
/*TODO
|
||||
public static RenderGlowPanel INSTANCE;
|
||||
|
||||
public static CCModel[] frameModels;
|
||||
public static CCModel[] lightModels;
|
||||
|
||||
public static IIcon icon;
|
||||
|
||||
public static RenderGlowPanel getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public static void init()
|
||||
{
|
||||
INSTANCE = new RenderGlowPanel();
|
||||
TextureUtils.addIconRegistrar(INSTANCE);
|
||||
|
||||
Map<String, CCModel> models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "glow_panel.obj"), 7, null);
|
||||
|
||||
frameModels = new CCModel[6];
|
||||
frameModels[0] = models.get("frame").backfacedCopy().apply(Vector3.center.translation()).shrinkUVs(0.0005);
|
||||
CCModel.generateSidedModels(frameModels, 0, Vector3.center);
|
||||
|
||||
lightModels = new CCModel[6];
|
||||
lightModels[0] = models.get("light").backfacedCopy().apply(Vector3.center.translation()).shrinkUVs(0.0005);
|
||||
CCModel.generateSidedModels(lightModels, 0, Vector3.center);
|
||||
|
||||
for(CCModel c : frameModels)
|
||||
{
|
||||
c.computeLighting(LightModel.standardLightModel);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderStatic(PartGlowPanel panel)
|
||||
{
|
||||
CCRenderState.reset();
|
||||
CCRenderState.setBrightness(panel.world(), panel.x(), panel.y(), panel.z());
|
||||
|
||||
Colour colour = new ColourRGBA(panel.colour.getColor(0), panel.colour.getColor(1), panel.colour.getColor(2), 1);
|
||||
int side = panel.side.ordinal();
|
||||
|
||||
frameModels[side].render(new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon));
|
||||
lightModels[side].render(new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon), new ColourMultiplier(colour.rgba()));
|
||||
}
|
||||
|
||||
public void renderItem(int metadata)
|
||||
{
|
||||
TextureUtils.bindAtlas(0);
|
||||
CCRenderState.reset();
|
||||
CCRenderState.startDrawing();
|
||||
CCRenderState.hasColour = true;
|
||||
EnumColor c = EnumColor.DYES[metadata];
|
||||
|
||||
Colour colour = new ColourRGBA(c.getColor(0), c.getColor(1), c.getColor(2), 1);
|
||||
Colour white = new ColourRGBA(1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
for(int i = 4; i < 5; i++)
|
||||
{
|
||||
frameModels[i].render(new IconTransformation(icon), new ColourMultiplier(white.rgba()));
|
||||
lightModels[i].render(new IconTransformation(icon), new ColourMultiplier(colour.rgba()));
|
||||
}
|
||||
|
||||
CCRenderState.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister register)
|
||||
{
|
||||
icon = register.registerIcon("mekanism:models/GlowPanel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int atlasIndex()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class MekanismOBJLoader extends OBJLoader
|
||||
|
||||
private final Map<ResourceLocation, MekanismOBJModel> modelCache = new HashMap<ResourceLocation, MekanismOBJModel>();
|
||||
|
||||
private static final ImmutableMap<String, String> flipData = ImmutableMap.of("flip-v", String.valueOf(true));
|
||||
public static final ImmutableMap<String, String> flipData = ImmutableMap.of("flip-v", String.valueOf(true));
|
||||
|
||||
public static final String[] OBJ_RENDERS = new String[] {"glow_panel"};
|
||||
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
package mekanism.client.render.transmitter;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import mcmultipart.multipart.IMultipart;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.client.render.MekanismRenderer.DisplayInteger;
|
||||
import mekanism.client.render.MekanismRenderer.FluidType;
|
||||
import mekanism.client.render.MekanismRenderer.Model3D;
|
||||
import mekanism.common.ColourRGBA;
|
||||
import mekanism.common.multipart.PartMechanicalPipe;
|
||||
import mekanism.common.multipart.PartSidedPipe.ConnectionType;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderMechanicalPipe extends RenderTransmitterBase
|
||||
{
|
||||
private HashMap<Integer, HashMap<Fluid, DisplayInteger[]>> cachedLiquids = new HashMap<Integer, HashMap<Fluid, DisplayInteger[]>>();
|
||||
|
||||
private static final int stages = 100;
|
||||
private static final double height = 0.45;
|
||||
private static final double offset = 0.015;
|
||||
|
||||
public RenderMechanicalPipe()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMultipartAt(IMultipart multipart, double x, double y, double z, float partialTick, int destroyStage)
|
||||
{
|
||||
PartMechanicalPipe pipe = (PartMechanicalPipe)multipart;
|
||||
float targetScale;
|
||||
|
||||
if(pipe.getTransmitter().hasTransmitterNetwork())
|
||||
{
|
||||
targetScale = pipe.getTransmitter().getTransmitterNetwork().fluidScale;
|
||||
}
|
||||
else {
|
||||
targetScale = (float)pipe.buffer.getFluidAmount() / (float)pipe.buffer.getCapacity();
|
||||
}
|
||||
|
||||
if(Math.abs(pipe.currentScale - targetScale) > 0.01)
|
||||
{
|
||||
pipe.currentScale = (12 * pipe.currentScale + targetScale) / 13;
|
||||
}
|
||||
else {
|
||||
pipe.currentScale = targetScale;
|
||||
}
|
||||
|
||||
Fluid fluid;
|
||||
|
||||
if(pipe.getTransmitter().hasTransmitterNetwork())
|
||||
{
|
||||
fluid = pipe.getTransmitter().getTransmitterNetwork().refFluid;
|
||||
}
|
||||
else {
|
||||
fluid = pipe.getBuffer() == null ? null : pipe.getBuffer().getFluid();
|
||||
}
|
||||
|
||||
float scale = pipe.currentScale;
|
||||
|
||||
if(scale > 0.01 && fluid != null)
|
||||
{
|
||||
push();
|
||||
|
||||
MekanismRenderer.glowOn(fluid.getLuminosity());
|
||||
MekanismRenderer.colorFluid(fluid);
|
||||
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
boolean gas = fluid.isGaseous();
|
||||
|
||||
for(EnumFacing side : EnumFacing.VALUES)
|
||||
{
|
||||
if(pipe.getConnectionType(side) == ConnectionType.NORMAL)
|
||||
{
|
||||
DisplayInteger[] displayLists = getListAndRender(side, fluid);
|
||||
|
||||
if(displayLists != null)
|
||||
{
|
||||
if(!gas)
|
||||
{
|
||||
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
||||
}
|
||||
else {
|
||||
GL11.glColor4f(1F, 1F, 1F, scale);
|
||||
displayLists[stages-1].render();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(pipe.getConnectionType(side) != ConnectionType.NONE)
|
||||
{
|
||||
GL11.glCullFace(GL11.GL_FRONT);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
|
||||
renderFluidInOut(worldRenderer, side, pipe);
|
||||
tessellator.draw();
|
||||
GL11.glCullFace(GL11.GL_BACK);
|
||||
}
|
||||
}
|
||||
|
||||
DisplayInteger[] displayLists = getListAndRender(null, fluid);
|
||||
|
||||
if(displayLists != null)
|
||||
{
|
||||
if(!gas)
|
||||
{
|
||||
displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render();
|
||||
}
|
||||
else {
|
||||
GL11.glColor4f(1F, 1F, 1F, scale);
|
||||
displayLists[stages-1].render();
|
||||
}
|
||||
}
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
MekanismRenderer.resetColor();
|
||||
|
||||
pop();
|
||||
}
|
||||
}
|
||||
|
||||
private DisplayInteger[] getListAndRender(EnumFacing side, Fluid fluid)
|
||||
{
|
||||
if(fluid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int sideOrdinal = side != null ? side.ordinal() : 6;
|
||||
|
||||
if(cachedLiquids.containsKey(sideOrdinal) && cachedLiquids.get(sideOrdinal).containsKey(fluid))
|
||||
{
|
||||
return cachedLiquids.get(sideOrdinal).get(fluid);
|
||||
}
|
||||
|
||||
Model3D toReturn = new Model3D();
|
||||
toReturn.baseBlock = Blocks.water;
|
||||
toReturn.setTexture(MekanismRenderer.getFluidTexture(fluid, FluidType.STILL));
|
||||
|
||||
toReturn.setSideRender(side, false);
|
||||
toReturn.setSideRender(side.getOpposite(), false);
|
||||
|
||||
DisplayInteger[] displays = new DisplayInteger[stages];
|
||||
|
||||
if(cachedLiquids.containsKey(sideOrdinal))
|
||||
{
|
||||
cachedLiquids.get(sideOrdinal).put(fluid, displays);
|
||||
}
|
||||
else {
|
||||
HashMap<Fluid, DisplayInteger[]> map = new HashMap<Fluid, DisplayInteger[]>();
|
||||
map.put(fluid, displays);
|
||||
cachedLiquids.put(sideOrdinal, map);
|
||||
}
|
||||
|
||||
for(int i = 0; i < stages; i++)
|
||||
{
|
||||
displays[i] = DisplayInteger.createAndStart();
|
||||
|
||||
switch(sideOrdinal)
|
||||
{
|
||||
case 6:
|
||||
{
|
||||
toReturn.minX = 0.25 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.25 + offset;
|
||||
|
||||
toReturn.maxX = 0.75 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.75 - offset;
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2;
|
||||
toReturn.minY = 0.0;
|
||||
toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2;
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
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;
|
||||
|
||||
toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2;
|
||||
toReturn.maxY = 1.0;
|
||||
toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
toReturn.minX = 0.25 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.0;
|
||||
|
||||
toReturn.maxX = 0.75 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.25 + offset;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
toReturn.minX = 0.25 + offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.75 - offset;
|
||||
|
||||
toReturn.maxX = 0.75 - offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 1.0;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
toReturn.minX = 0.0;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.25 + offset;
|
||||
|
||||
toReturn.maxX = 0.25 + offset;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.75 - offset;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
toReturn.minX = 0.75 - offset;
|
||||
toReturn.minY = 0.25 + offset;
|
||||
toReturn.minZ = 0.25 + offset;
|
||||
|
||||
toReturn.maxX = 1.0;
|
||||
toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height;
|
||||
toReturn.maxZ = 0.75 - offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MekanismRenderer.renderObject(toReturn);
|
||||
displays[i].endList();
|
||||
}
|
||||
|
||||
return displays;
|
||||
}
|
||||
|
||||
public void renderFluidInOut(WorldRenderer renderer, EnumFacing side, PartMechanicalPipe pipe)
|
||||
{
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
TextureAtlasSprite tex = MekanismRenderer.getFluidTexture(pipe.getTransmitter().getTransmitterNetwork().refFluid, FluidType.STILL);
|
||||
renderTransparency(renderer, tex, getModelForSide(pipe, side), new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
package mekanism.client.render.transmitter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import mcmultipart.client.multipart.MultipartSpecialRenderer;
|
||||
import mekanism.common.ColourRGBA;
|
||||
import mekanism.common.multipart.PartTransmitter;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.Attributes;
|
||||
import net.minecraftforge.client.model.IFlexibleBakedModel;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class RenderTransmitterBase extends MultipartSpecialRenderer
|
||||
{
|
||||
private static OBJModel contentsModel;
|
||||
private static Map<String, IFlexibleBakedModel> contentsMap = new HashMap<String, IFlexibleBakedModel>();
|
||||
|
||||
public RenderTransmitterBase()
|
||||
{
|
||||
if(contentsModel == null)
|
||||
{
|
||||
try {
|
||||
contentsModel = (OBJModel)OBJLoader.instance.loadModel(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"));
|
||||
contentsMap = getModelsForGroups(contentsModel);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected 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);
|
||||
}
|
||||
|
||||
protected void pop()
|
||||
{
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public static boolean isDrawing = false;
|
||||
|
||||
public void renderTransparency(WorldRenderer renderer, TextureAtlasSprite icon, IFlexibleBakedModel cc, ColourRGBA color)
|
||||
{
|
||||
if(!isDrawing)
|
||||
{
|
||||
renderer.begin(GL11.GL_QUADS, cc.getFormat());
|
||||
isDrawing = true;
|
||||
}
|
||||
|
||||
for(BakedQuad quad : cc.getGeneralQuads())
|
||||
{
|
||||
quad = iconTransform(quad, icon);
|
||||
LightUtil.renderQuadColor(renderer, quad, color.argb());
|
||||
}
|
||||
}
|
||||
|
||||
public static HashMap<String, IFlexibleBakedModel> getModelsForGroups(OBJModel objModel)
|
||||
{
|
||||
HashMap<String, IFlexibleBakedModel> modelParts = new HashMap<String, IFlexibleBakedModel>();
|
||||
|
||||
if(!objModel.getMatLib().getGroups().keySet().isEmpty())
|
||||
{
|
||||
for(String key : objModel.getMatLib().getGroups().keySet())
|
||||
{
|
||||
String k = key;
|
||||
|
||||
if(!modelParts.containsKey(key))
|
||||
{
|
||||
modelParts.put(k, objModel.bake(new OBJModel.OBJState(ImmutableList.of(k), false), Attributes.DEFAULT_BAKED_FORMAT, textureGetterFlipV));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modelParts;
|
||||
}
|
||||
|
||||
public IFlexibleBakedModel getModelForSide(PartTransmitter part, EnumFacing side)
|
||||
{
|
||||
String sideName = side.name().toLowerCase();
|
||||
String typeName = part.getConnectionType(side).name().toUpperCase();
|
||||
String name = sideName + typeName;
|
||||
|
||||
return contentsMap.get(name);
|
||||
}
|
||||
|
||||
/* Credit to Eternal Energy */
|
||||
public static Function<ResourceLocation, TextureAtlasSprite> textureGetterFlipV = new Function<ResourceLocation, TextureAtlasSprite>()
|
||||
{
|
||||
@Override
|
||||
public TextureAtlasSprite apply(ResourceLocation location)
|
||||
{
|
||||
return DummyAtlasTextureFlipV.instance;
|
||||
}
|
||||
};
|
||||
|
||||
public static BakedQuad iconTransform(BakedQuad quad, TextureAtlasSprite sprite)
|
||||
{
|
||||
int[] vertices = new int[28];
|
||||
System.arraycopy(quad.getVertexData(), 0, vertices, 0, vertices.length);
|
||||
|
||||
vertices[4] = Float.floatToRawIntBits(sprite.getInterpolatedU(16));
|
||||
vertices[5] = Float.floatToRawIntBits(sprite.getInterpolatedV(16));
|
||||
|
||||
vertices[7+4] = Float.floatToRawIntBits(sprite.getInterpolatedU(16));
|
||||
vertices[7+5] = Float.floatToRawIntBits(sprite.getInterpolatedV(0));
|
||||
|
||||
vertices[14+4] = Float.floatToRawIntBits(sprite.getInterpolatedU(0));
|
||||
vertices[14+5] = Float.floatToRawIntBits(sprite.getInterpolatedV(0));
|
||||
|
||||
vertices[21+4] = Float.floatToRawIntBits(sprite.getInterpolatedU(0));
|
||||
vertices[21+5] = Float.floatToRawIntBits(sprite.getInterpolatedV(16));
|
||||
|
||||
return new BakedQuad(vertices, quad.getTintIndex(), quad.getFace());
|
||||
}
|
||||
|
||||
private static class DummyAtlasTextureFlipV extends TextureAtlasSprite
|
||||
{
|
||||
public static DummyAtlasTextureFlipV instance = new DummyAtlasTextureFlipV();
|
||||
|
||||
protected DummyAtlasTextureFlipV()
|
||||
{
|
||||
super("dummyFlipV");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedU(double u)
|
||||
{
|
||||
return (float)u / 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getInterpolatedV(double v)
|
||||
{
|
||||
return (float)v / -16;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package mekanism.client.render.transmitter;
|
||||
|
||||
import mcmultipart.multipart.IMultipart;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.ColourRGBA;
|
||||
import mekanism.common.multipart.PartUniversalCable;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderUniversalCable extends RenderTransmitterBase
|
||||
{
|
||||
public RenderUniversalCable()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderMultipartAt(IMultipart multipart, double x, double y, double z, float partialTick, int destroyStage)
|
||||
{
|
||||
PartUniversalCable cable = (PartUniversalCable)multipart;
|
||||
|
||||
if(cable.currentPower == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
push();
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldRenderer = tessellator.getWorldRenderer();
|
||||
GL11.glTranslated(x + 0.5, y+0.5, z + 0.5);
|
||||
|
||||
for(EnumFacing side : EnumFacing.VALUES)
|
||||
{
|
||||
renderEnergySide(worldRenderer, side, cable);
|
||||
}
|
||||
|
||||
MekanismRenderer.glowOn();
|
||||
|
||||
tessellator.draw();
|
||||
isDrawing = false;
|
||||
|
||||
MekanismRenderer.glowOff();
|
||||
pop();
|
||||
}
|
||||
|
||||
public void renderEnergySide(WorldRenderer renderer, EnumFacing side, PartUniversalCable cable)
|
||||
{
|
||||
bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
renderTransparency(renderer, MekanismRenderer.energyIcon, getModelForSide(cable, side), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower));
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,31 @@ package mekanism.common;
|
||||
*/
|
||||
public class ColourRGBA
|
||||
{
|
||||
public ColourRGBA(double r, double g, double b, double a) {}
|
||||
public byte valR;
|
||||
public byte valG;
|
||||
public byte valB;
|
||||
public byte valA;
|
||||
|
||||
public ColourRGBA(double r, double g, double b, double a)
|
||||
{
|
||||
this((int)(r*255), (int)(g*255), (int)(b*255), (int)(a*255));
|
||||
}
|
||||
|
||||
public ColourRGBA(int r, int g, int b, int a)
|
||||
{
|
||||
valR = (byte)r;
|
||||
valG = (byte)g;
|
||||
valB = (byte)b;
|
||||
valA = (byte)a;
|
||||
}
|
||||
|
||||
public int rgba()
|
||||
{
|
||||
return (valR & 0xFF) << 24 | (valG & 0xFF) << 16 | (valB & 0xFF) << 8 | (valA & 0xFF);
|
||||
}
|
||||
|
||||
public int argb()
|
||||
{
|
||||
return (valA & 0xFF) << 24 | (valR & 0xFF) << 16 | (valG & 0xFF) << 8 | (valB & 0xFF);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user