mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 13:10:13 +00:00
Combustion Gen Renderer getting there.
This commit is contained in:
1 parent
421c61317f
commit
d63244e9d3
10 files changed
+312
-9
No files matched your search
@@ -39,6 +39,8 @@ import crazypants.enderio.enderface.TileEnderIO;
|
||||
import crazypants.enderio.item.PoweredItemRenderer;
|
||||
import crazypants.enderio.item.YetaWrenchOverlayRenderer;
|
||||
import crazypants.enderio.item.YetaWrenchTickHandler;
|
||||
import crazypants.enderio.machine.generator.BlockCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.CombustionGeneratorRenderer;
|
||||
import crazypants.enderio.machine.hypercube.HyperCubeRenderer;
|
||||
import crazypants.enderio.machine.hypercube.TileHyperCube;
|
||||
import crazypants.enderio.machine.light.BlockElectricLight;
|
||||
@@ -114,6 +116,9 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
BlockFusedQuartz.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new FusedQuartzRenderer());
|
||||
|
||||
BlockCombustionGenerator.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(new CombustionGeneratorRenderer());
|
||||
|
||||
FusedQuartzFrameRenderer fqfr = new FusedQuartzFrameRenderer();
|
||||
MinecraftForgeClient.registerItemRenderer(EnderIO.itemFusedQuartzFrame, fqfr);
|
||||
@@ -210,3 +215,4 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class RedstoneSwitchRenderer extends DefaultConduitRenderer {
|
||||
BoundingBox bb = switchBounds.translate(trans);
|
||||
|
||||
for (VertexTransform tf : xForms) {
|
||||
CubeRenderer.render(bb, icons, tf);
|
||||
CubeRenderer.render(bb, icons, tf,null);
|
||||
}
|
||||
bb = connectorBounds.translate(trans);
|
||||
for (VertexTransform tf : xForms) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package crazypants.enderio.machine.generator;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
@@ -8,12 +10,28 @@ import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
|
||||
public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustionGenerator> {
|
||||
|
||||
public static int renderId;
|
||||
|
||||
protected IIcon frontOn;
|
||||
protected IIcon frontOff;
|
||||
|
||||
public static BlockCombustionGenerator create() {
|
||||
BlockCombustionGenerator gen = new BlockCombustionGenerator();
|
||||
gen.init();
|
||||
return gen;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister iIconRegister) {
|
||||
super.registerBlockIcons(iIconRegister);
|
||||
frontOn = iIconRegister.registerIcon("enderio:combustionGenFrontOn");
|
||||
frontOff = iIconRegister.registerIcon("enderio:combustionGenFront");
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected BlockCombustionGenerator() {
|
||||
super(ModObject.blockCombustionGenerator, TileCombustionGenerator.class);
|
||||
}
|
||||
@@ -34,11 +52,48 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
if(active) {
|
||||
return "enderio:combustionGenFrontOn";
|
||||
}
|
||||
return "enderio:combustionGenFront";
|
||||
public int getRenderType() {
|
||||
return renderId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IIcon getBlankSideIcon() {
|
||||
return iconBuffer[0][3];
|
||||
}
|
||||
|
||||
public IIcon getFrontOn() {
|
||||
return frontOn;
|
||||
}
|
||||
|
||||
public IIcon getFrontOff() {
|
||||
return frontOff;
|
||||
}
|
||||
|
||||
|
||||
public String getTopIconKey(boolean active) {
|
||||
return super.getTopIconKey(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackIconKey(boolean active) {
|
||||
return getMachineFrontIconKey(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMachineFrontIconKey(boolean active) {
|
||||
return "enderio:blankMachinePanel";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
package crazypants.enderio.machine.generator;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.material.BlockFusedQuartz;
|
||||
import crazypants.enderio.material.FusedQuartzRenderer;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.render.VertexTransform;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector3f;
|
||||
|
||||
public class CombustionGeneratorRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private VertXForm xform = new VertXForm();
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
short facing = 3;
|
||||
boolean active = false;
|
||||
if(world != null) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof TileCombustionGenerator) {
|
||||
TileCombustionGenerator gen = (TileCombustionGenerator) te;
|
||||
facing = gen.facing;
|
||||
active = gen.isActive();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
IIcon[] textures = new IIcon[6];
|
||||
if(world != null) {
|
||||
textures[0] = EnderIO.blockCombustionGenerator.getIcon(world, x, y, z, ForgeDirection.NORTH.ordinal());
|
||||
textures[1] = EnderIO.blockCombustionGenerator.getIcon(world, x, y, z, ForgeDirection.SOUTH.ordinal());
|
||||
textures[2] = EnderIO.blockCombustionGenerator.getIcon(world, x, y, z, ForgeDirection.UP.ordinal());
|
||||
textures[3] = EnderIO.blockCombustionGenerator.getIcon(world, x, y, z, ForgeDirection.DOWN.ordinal());
|
||||
textures[4] = EnderIO.blockCombustionGenerator.getIcon(world, x, y, z, ForgeDirection.WEST.ordinal());
|
||||
textures[5] = EnderIO.blockCombustionGenerator.getIcon(world, x, y, z, ForgeDirection.EAST.ordinal());
|
||||
} else {
|
||||
textures[0] = EnderIO.blockCombustionGenerator.getIcon(ForgeDirection.NORTH.ordinal(), 0);
|
||||
textures[1] = EnderIO.blockCombustionGenerator.getIcon(ForgeDirection.SOUTH.ordinal(), 0);
|
||||
textures[2] = EnderIO.blockCombustionGenerator.getIcon(ForgeDirection.UP.ordinal(), 0);
|
||||
textures[3] = EnderIO.blockCombustionGenerator.getIcon(ForgeDirection.DOWN.ordinal(), 0);
|
||||
textures[4] = EnderIO.blockCombustionGenerator.getIcon(ForgeDirection.WEST.ordinal(), 0);
|
||||
textures[5] = EnderIO.blockCombustionGenerator.getIcon(ForgeDirection.EAST.ordinal(), 0);
|
||||
}
|
||||
|
||||
float b = 1;
|
||||
if(world instanceof World) {
|
||||
b = RenderUtil.claculateTotalBrightnessForLocation((World) world, x, y, z);
|
||||
}
|
||||
|
||||
float[] cols = new float[6];
|
||||
for (int i = 0; i < 6; i++) {
|
||||
float m = RenderUtil.getColorMultiplierForFace(ForgeDirection.values()[i]);
|
||||
cols[i] = b * m;
|
||||
}
|
||||
|
||||
boolean scaleX = facing != 4 && facing != 5;
|
||||
float scx = scaleX ? 0.7f : 1;
|
||||
float scz = scaleX ? 1 : 0.7f;
|
||||
|
||||
//top 1/3
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE;
|
||||
bb = bb.scale(scx, 0.25, scz);
|
||||
bb = bb.translate(0, 0.29f, 0);
|
||||
xform.set(x, y, z, facing);
|
||||
CubeRenderer.render(bb, textures, xform, cols);
|
||||
|
||||
//lower 1/3
|
||||
bb = BoundingBox.UNIT_CUBE;
|
||||
bb = bb.scale(scx, 0.25, scz);
|
||||
bb = bb.translate(0, -0.29f, 0);
|
||||
xform.set(x, y, z, facing);
|
||||
CubeRenderer.render(bb, textures, xform, cols);
|
||||
|
||||
|
||||
IIcon tex = active ? EnderIO.blockCombustionGenerator.getFrontOn() : EnderIO.blockCombustionGenerator.getFrontOff();
|
||||
//middle chunk
|
||||
if(scaleX) {
|
||||
textures[0] = tex;
|
||||
textures[1] = tex;
|
||||
} else {
|
||||
textures[4] = tex;
|
||||
textures[5] = tex;
|
||||
}
|
||||
|
||||
bb = BoundingBox.UNIT_CUBE;
|
||||
bb = bb.scale(1, 0.34, 1);
|
||||
xform.set(x, y, z, facing);
|
||||
CubeRenderer.render(bb, textures, xform, cols);
|
||||
|
||||
|
||||
//top / bottom connectors
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.35,1,0.35);
|
||||
bb = bb.translate(x, y, z);
|
||||
//CubeRenderer.render(bb, EnderIO.blockCombustionGenerator.getBlankSideIcon(), null, cols, false);
|
||||
CubeRenderer.render(bb, textures[2], null, cols, false);
|
||||
|
||||
|
||||
|
||||
//tanks
|
||||
float size = 0.34f;
|
||||
bb = BoundingBox.UNIT_CUBE.scale(0.98, 1, 0.98);
|
||||
|
||||
scx = scaleX ? size : 1;
|
||||
scz = scaleX ? 1 : size;
|
||||
bb = bb.scale(scx, 1, scz);
|
||||
|
||||
float tx = scaleX ? size * 1.25f : 0;
|
||||
float tz = scaleX ? 0 : 0.25f * 1.25f;
|
||||
bb = bb.translate(x + tx, y, z + tz);
|
||||
|
||||
tex = EnderIO.blockFusedQuartz.getDefaultFrameIcon(0);
|
||||
CubeRenderer.render(bb, tex, null, cols, false);
|
||||
|
||||
bb = bb.translate(-tx * 2, 0, -tz * 2);
|
||||
CubeRenderer.render(bb, tex, null, cols, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
renderWorldBlock(null, 0, 0, 0, block, 0, renderer);
|
||||
tes.draw();
|
||||
|
||||
renderer.setRenderBoundsFromBlock(Blocks.stone);
|
||||
renderer.setOverrideBlockTexture(EnderIO.blockFusedQuartz.getDefaultFrameIcon(0));
|
||||
renderer.renderBlockAsItem(Blocks.cobblestone, 0, 1);
|
||||
renderer.setOverrideBlockTexture(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BlockCombustionGenerator.renderId;
|
||||
}
|
||||
|
||||
private static class VertXForm implements VertexTransform {
|
||||
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
boolean transX;
|
||||
|
||||
public VertXForm() {
|
||||
}
|
||||
|
||||
void set(int x, int y, int z, short facing) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
transX = facing != 4 && facing != 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Vector3d vec) {
|
||||
if(vec.y > 0.9 || vec.y < 0.1) {
|
||||
if(transX) {
|
||||
vec.x -= 0.5;
|
||||
vec.x *= 0.6;
|
||||
vec.x += 0.5;
|
||||
} else {
|
||||
vec.z -= 0.5;
|
||||
vec.z *= 0.6;
|
||||
vec.z += 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
vec.y -= 0.5;
|
||||
vec.y *= 0.8;
|
||||
vec.y += 0.5;
|
||||
|
||||
vec.add(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToNormal(Vector3f vec) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class ElectricLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
textures[3] = block.getBlockTextureFromSide(ForgeDirection.UP.ordinal());
|
||||
textures[4] = block.getBlockTextureFromSide(ForgeDirection.WEST.ordinal());
|
||||
textures[5] = block.getBlockTextureFromSide(ForgeDirection.EAST.ordinal());
|
||||
CubeRenderer.render(bb, textures, null);
|
||||
CubeRenderer.render(bb, textures, null, null);
|
||||
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class ElectricLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
textures[4] = block.getIcon(world, x, y, z, ForgeDirection.WEST.ordinal());
|
||||
textures[5] = block.getIcon(world, x, y, z, ForgeDirection.EAST.ordinal());
|
||||
|
||||
CubeRenderer.render(bb, textures, null);
|
||||
CubeRenderer.render(bb, textures, null, null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[3], minU, maxV);
|
||||
}
|
||||
|
||||
public static void render(BoundingBox bb, IIcon[] faceTextures, VertexTransform xForm) {
|
||||
public static void render(BoundingBox bb, IIcon[] faceTextures, VertexTransform xForm, float[] brightnessPerSide) {
|
||||
setupVertices(bb, xForm);
|
||||
float minU;
|
||||
float maxU;
|
||||
@@ -177,6 +177,11 @@ public final class CubeRenderer {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
tessellator.setNormal(0, 0, -1);
|
||||
if(brightnessPerSide != null) {
|
||||
float cm = brightnessPerSide[ForgeDirection.NORTH.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
|
||||
tex = faceTextures[0];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
@@ -188,6 +193,10 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[2], minU, maxV);
|
||||
|
||||
tessellator.setNormal(0, 0, 1);
|
||||
if(brightnessPerSide != null) {
|
||||
float cm = brightnessPerSide[ForgeDirection.SOUTH.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[1];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
@@ -199,6 +208,10 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[7], minU, maxV);
|
||||
|
||||
tessellator.setNormal(0, 1, 0);
|
||||
if(brightnessPerSide != null) {
|
||||
float cm = brightnessPerSide[ForgeDirection.UP.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[2];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
@@ -210,6 +223,10 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[7], maxU, minV);
|
||||
|
||||
tessellator.setNormal(0, -1, 0);
|
||||
if(brightnessPerSide != null) {
|
||||
float cm = brightnessPerSide[ForgeDirection.UP.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[3];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
@@ -221,6 +238,10 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[4], maxU, minV);
|
||||
|
||||
tessellator.setNormal(1, 0, 0);
|
||||
if(brightnessPerSide != null) {
|
||||
float cm = brightnessPerSide[ForgeDirection.EAST.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[4];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
@@ -232,6 +253,10 @@ public final class CubeRenderer {
|
||||
addVecWithUV(verts[1], minU, minV);
|
||||
|
||||
tessellator.setNormal(-1, 0, 0);
|
||||
if(brightnessPerSide != null) {
|
||||
float cm = brightnessPerSide[ForgeDirection.WEST.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[5];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
|
||||
@@ -55,6 +55,12 @@ public class Vector3f {
|
||||
y += vec.y;
|
||||
z += vec.z;
|
||||
}
|
||||
|
||||
public void add(int x2, int y2, int z2) {
|
||||
x += x2;
|
||||
y += y2;
|
||||
z += z2;
|
||||
}
|
||||
|
||||
public void sub(Vector3f vec) {
|
||||
x -= vec.x;
|
||||
@@ -108,4 +114,6 @@ public class Vector3f {
|
||||
return new Vector3d(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user