re-did render code
Yes the fluid code is based off of Build Craft fluid render and has been for a while. This is not a copy though as the code is not 100% buildcraft and has been modified to meet my use of the code.
This commit is contained in:
parent
dccac5415d
commit
c1f99d46d3
9 changed files with 427 additions and 278 deletions
|
@ -9,7 +9,7 @@ import cpw.mods.fml.client.registry.ClientRegistry;
|
|||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.client.renders.RenderCopperWire;
|
||||
import dark.core.client.renders.RenderBlockWire;
|
||||
import dark.core.common.CommonProxy;
|
||||
import dark.core.common.CoreRecipeLoader;
|
||||
import dark.core.common.DarkMain;
|
||||
|
@ -40,7 +40,7 @@ public class ClientProxy extends CommonProxy
|
|||
{
|
||||
if (CoreRecipeLoader.blockWire != null)
|
||||
{
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWire.class, new RenderCopperWire());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWire.class, new RenderBlockWire());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package dark.core.prefab.helpers;
|
||||
package dark.core.client.renders;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
|
@ -1,127 +0,0 @@
|
|||
package dark.core.client.renders;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.prefab.helpers.BlockRenderInfo;
|
||||
|
||||
/** @author CovertJaguar <railcraft.wikispaces.com> from BuildCraft , modified by DarkGuardsman */
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class FluidBlockRenderer
|
||||
{
|
||||
private static Map<Fluid, int[]> flowingRenderCache = new HashMap<Fluid, int[]>();
|
||||
private static Map<Fluid, int[]> stillRenderCache = new HashMap<Fluid, int[]>();
|
||||
public static final int DISPLAY_STAGES = 100;
|
||||
private static final BlockRenderInfo liquidBlock = new BlockRenderInfo();
|
||||
|
||||
/** Gets the icon for the given fluid */
|
||||
public static Icon getFluidTexture(Fluid fluid)
|
||||
{
|
||||
if (fluid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Icon icon = fluid.getStillIcon();
|
||||
if (icon == null)
|
||||
{
|
||||
if (fluid.getBlockID() > 0)
|
||||
{
|
||||
Block block = Block.blocksList[fluid.getBlockID()];
|
||||
if (block != null)
|
||||
{
|
||||
if (block.blockID == Block.waterStill.blockID)
|
||||
{
|
||||
icon = Block.waterStill.getIcon(0, 0);
|
||||
}
|
||||
if (block.blockID == Block.lavaStill.blockID)
|
||||
{
|
||||
icon = Block.lavaStill.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (icon == null)
|
||||
{
|
||||
icon = Block.waterStill.getIcon(0, 0);
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
/** Get the texture sheet used to bind textures to the render */
|
||||
public static ResourceLocation getFluidSheet(FluidStack liquid)
|
||||
{
|
||||
return TextureMap.field_110575_b;
|
||||
}
|
||||
|
||||
/** Gets the GL11 display list used to render the fluidStack as a block */
|
||||
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing)
|
||||
{
|
||||
if (fluidStack == null || fluidStack.getFluid() == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
|
||||
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
|
||||
int[] diplayLists = cache.get(fluid);
|
||||
if (diplayLists != null)
|
||||
{
|
||||
return diplayLists;
|
||||
}
|
||||
|
||||
diplayLists = new int[DISPLAY_STAGES];
|
||||
|
||||
liquidBlock.baseBlock = fluid.getBlockID() > 0 ? Block.blocksList[fluid.getBlockID()] : Block.waterStill;
|
||||
liquidBlock.texture = getFluidTexture(fluid);
|
||||
|
||||
cache.put(fluid, diplayLists);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
int color = fluid.getColor(fluidStack);
|
||||
if (color != 0xFFFFFF)
|
||||
{
|
||||
float c1 = (float) (color >> 16 & 255) / 255.0F;
|
||||
float c2 = (float) (color >> 8 & 255) / 255.0F;
|
||||
float c3 = (float) (color & 255) / 255.0F;
|
||||
GL11.glColor4f(c1, c2, c3, 1);
|
||||
}
|
||||
for (int s = 0; s < DISPLAY_STAGES; ++s)
|
||||
{
|
||||
diplayLists[s] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);
|
||||
|
||||
liquidBlock.min = new Vector3(0.01f, 0, 0.01f);
|
||||
liquidBlock.max = new Vector3(0.99f, (float) s / (float) DISPLAY_STAGES, 0.99f);
|
||||
|
||||
RenderFakeBlock.INSTANCE.renderBlock(liquidBlock, world, new Vector3());
|
||||
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
return diplayLists;
|
||||
}
|
||||
|
||||
}
|
197
src/dark/core/client/renders/RenderBlockEntity.java
Normal file
197
src/dark/core/client/renders/RenderBlockEntity.java
Normal file
|
@ -0,0 +1,197 @@
|
|||
package dark.core.client.renders;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
import dark.core.prefab.entity.EntityBlock;
|
||||
|
||||
public class RenderBlockEntity extends Render
|
||||
{
|
||||
|
||||
public static RenderBlockEntity INSTANCE = new RenderBlockEntity();
|
||||
|
||||
@Override
|
||||
protected ResourceLocation func_110775_a(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
private RenderBlockEntity()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double i, double j, double k, float f, float f1)
|
||||
{
|
||||
doRenderBlock((EntityBlock) entity, i, j, k);
|
||||
}
|
||||
|
||||
public void doRenderBlock(EntityBlock entity, double i, double j, double k)
|
||||
{
|
||||
if (entity.isDead)
|
||||
return;
|
||||
|
||||
shadowSize = entity.shadowSize;
|
||||
World world = entity.worldObj;
|
||||
BlockRenderInfo util = new BlockRenderInfo();
|
||||
util.texture = entity.texture;
|
||||
func_110776_a(TextureMap.field_110575_b);
|
||||
|
||||
for (int iBase = 0; iBase < entity.iSize; ++iBase)
|
||||
{
|
||||
for (int jBase = 0; jBase < entity.jSize; ++jBase)
|
||||
{
|
||||
for (int kBase = 0; kBase < entity.kSize; ++kBase)
|
||||
{
|
||||
|
||||
util.min = new Vector3();
|
||||
util.max = new Vector3();
|
||||
|
||||
double remainX = entity.iSize - iBase;
|
||||
double remainY = entity.jSize - jBase;
|
||||
double remainZ = entity.kSize - kBase;
|
||||
|
||||
util.max.x = (remainX > 1.0 ? 1.0 : remainX);
|
||||
util.max.y = (remainY > 1.0 ? 1.0 : remainY);
|
||||
util.max.z = (remainZ > 1.0 ? 1.0 : remainZ);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) i, (float) j, (float) k);
|
||||
GL11.glRotatef(entity.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(entity.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(entity.rotationZ, 0, 0, 1);
|
||||
GL11.glTranslatef(iBase, jBase, kBase);
|
||||
|
||||
int lightX, lightY, lightZ;
|
||||
|
||||
lightX = (int) (Math.floor(entity.posX) + iBase);
|
||||
lightY = (int) (Math.floor(entity.posY) + jBase);
|
||||
lightZ = (int) (Math.floor(entity.posZ) + kBase);
|
||||
|
||||
GL11.glDisable(2896 /* GL_LIGHTING */);
|
||||
renderBlock(util, world, lightX, lightY, lightZ, false, true);
|
||||
GL11.glEnable(2896 /* GL_LIGHTING */);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderBlock(BlockRenderInfo block, IBlockAccess blockAccess, int x, int y, int z, boolean doLight, boolean doTessellating)
|
||||
{
|
||||
float f = 0.5F;
|
||||
float f1 = 1.0F;
|
||||
float f2 = 0.8F;
|
||||
float f3 = 0.6F;
|
||||
|
||||
renderBlocks.renderMaxX = block.max.x;
|
||||
renderBlocks.renderMinX = block.min.x;
|
||||
|
||||
renderBlocks.renderMaxY = block.max.y;
|
||||
renderBlocks.renderMinY = block.min.y;
|
||||
|
||||
renderBlocks.renderMaxZ = block.max.z;
|
||||
renderBlocks.renderMinZ = block.min.z;
|
||||
|
||||
renderBlocks.enableAO = false;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (doTessellating)
|
||||
{
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
float f4 = 0, f5 = 0;
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f4 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
|
||||
|
||||
if (doLight)
|
||||
{
|
||||
f5 = block.getBlockBrightness(blockAccess, x, y, z);
|
||||
if (f5 < f4)
|
||||
{
|
||||
f5 = f4;
|
||||
}
|
||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
||||
}
|
||||
|
||||
renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
|
||||
|
||||
if (doTessellating)
|
||||
{
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
}
|
125
src/dark/core/client/renders/RenderBlockFluid.java
Normal file
125
src/dark/core/client/renders/RenderBlockFluid.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package dark.core.client.renders;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderBlockFluid
|
||||
{
|
||||
|
||||
private static final ResourceLocation BLOCK_TEXTURE = TextureMap.field_110575_b;
|
||||
|
||||
private static Map<Fluid, int[]> flowingRenderCache = new HashMap<Fluid, int[]>();
|
||||
private static Map<Fluid, int[]> stillRenderCache = new HashMap<Fluid, int[]>();
|
||||
|
||||
public static final int DISPLAY_STAGES = 100;
|
||||
|
||||
private static final BlockRenderInfo liquidBlock = new BlockRenderInfo();
|
||||
|
||||
public static ResourceLocation getFluidSheet(FluidStack liquid)
|
||||
{
|
||||
return BLOCK_TEXTURE;
|
||||
}
|
||||
|
||||
public static Icon getFluidTexture(Fluid fluid, boolean flowing)
|
||||
{
|
||||
if (fluid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
|
||||
if (icon == null)
|
||||
{
|
||||
icon = ((TextureMap) Minecraft.getMinecraft().func_110434_K().func_110581_b(TextureMap.field_110575_b)).func_110572_b("missingno");
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static void setColorForFluidStack(FluidStack fluidstack)
|
||||
{
|
||||
if (fluidstack == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int color = fluidstack.getFluid().getColor(fluidstack);
|
||||
float red = (float) (color >> 16 & 255) / 255.0F;
|
||||
float green = (float) (color >> 8 & 255) / 255.0F;
|
||||
float blue = (float) (color & 255) / 255.0F;
|
||||
GL11.glColor4f(red, green, blue, 1);
|
||||
}
|
||||
|
||||
public static int[] getFluidDisplayLists(FluidStack fluidStack, World world, boolean flowing)
|
||||
{
|
||||
if (fluidStack == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Fluid fluid = fluidStack.getFluid();
|
||||
if (fluid == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Map<Fluid, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
|
||||
int[] diplayLists = cache.get(fluid);
|
||||
if (diplayLists != null)
|
||||
{
|
||||
return diplayLists;
|
||||
}
|
||||
|
||||
diplayLists = new int[DISPLAY_STAGES];
|
||||
|
||||
if (fluid.getBlockID() > 0)
|
||||
{
|
||||
liquidBlock.baseBlock = Block.blocksList[fluid.getBlockID()];
|
||||
liquidBlock.texture = getFluidTexture(fluidStack.getFluid(), flowing);
|
||||
}
|
||||
else
|
||||
{
|
||||
liquidBlock.baseBlock = Block.waterStill;
|
||||
liquidBlock.texture = getFluidTexture(fluidStack.getFluid(), flowing);
|
||||
}
|
||||
|
||||
cache.put(fluid, diplayLists);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
|
||||
for (int s = 0; s < DISPLAY_STAGES; ++s)
|
||||
{
|
||||
diplayLists[s] = GLAllocation.generateDisplayLists(1);
|
||||
GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);
|
||||
|
||||
liquidBlock.min.x = 0.01f;
|
||||
liquidBlock.min.y = 0;
|
||||
liquidBlock.min.z = 0.01f;
|
||||
|
||||
liquidBlock.max.x = 0.99f;
|
||||
liquidBlock.max.y = (float) s / (float) DISPLAY_STAGES;
|
||||
liquidBlock.max.z = 0.99f;
|
||||
|
||||
RenderBlockEntity.INSTANCE.renderBlock(liquidBlock, world, 0, 0, 0, false, true);
|
||||
|
||||
GL11.glEndList();
|
||||
}
|
||||
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
return diplayLists;
|
||||
}
|
||||
}
|
|
@ -19,7 +19,7 @@ import dark.core.client.models.ModelCopperWire;
|
|||
import dark.core.common.DarkMain;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderCopperWire extends RenderMachine
|
||||
public class RenderBlockWire extends RenderTileMachine
|
||||
{
|
||||
private static final ResourceLocation copperWireTexture = new ResourceLocation(DarkMain.getInstance().DOMAIN, "textures/models/copperWire.png");
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
||||
* 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package dark.core.client.renders;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.prefab.helpers.BlockRenderInfo;
|
||||
import dark.core.prefab.helpers.EntityFakeBlock;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderFakeBlock extends Render
|
||||
{
|
||||
/** Render instance */
|
||||
public static RenderFakeBlock INSTANCE = new RenderFakeBlock();
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double i, double j, double k, float f, float f1)
|
||||
{
|
||||
doRenderBlock((EntityFakeBlock) entity, i, j, k);
|
||||
}
|
||||
|
||||
/** Renders a block as an Entity */
|
||||
public void doRenderBlock(EntityFakeBlock entity, double i, double j, double k)
|
||||
{
|
||||
if (entity.isDead)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
shadowSize = entity.shadowSize;
|
||||
World world = entity.worldObj;
|
||||
BlockRenderInfo util = new BlockRenderInfo();
|
||||
util.texture = entity.texture;
|
||||
func_110776_a(TextureMap.field_110575_b);
|
||||
|
||||
for (int iBase = 0; iBase < entity.iSize; ++iBase)
|
||||
{
|
||||
for (int jBase = 0; jBase < entity.jSize; ++jBase)
|
||||
{
|
||||
for (int kBase = 0; kBase < entity.kSize; ++kBase)
|
||||
{
|
||||
|
||||
util.min = new Vector3();
|
||||
|
||||
double remainX = entity.iSize - iBase;
|
||||
double remainY = entity.jSize - jBase;
|
||||
double remainZ = entity.kSize - kBase;
|
||||
|
||||
util.max = new Vector3((remainX > 1.0 ? 1.0 : remainX), (remainY > 1.0 ? 1.0 : remainY), (remainZ > 1.0 ? 1.0 : remainZ));
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) i, (float) j, (float) k);
|
||||
GL11.glRotatef(entity.rotationX, 1, 0, 0);
|
||||
GL11.glRotatef(entity.rotationY, 0, 1, 0);
|
||||
GL11.glRotatef(entity.rotationZ, 0, 0, 1);
|
||||
GL11.glTranslatef(iBase, jBase, kBase);
|
||||
|
||||
int lightX, lightY, lightZ;
|
||||
|
||||
lightX = (int) (Math.floor(entity.posX) + iBase);
|
||||
lightY = (int) (Math.floor(entity.posY) + jBase);
|
||||
lightZ = (int) (Math.floor(entity.posZ) + kBase);
|
||||
|
||||
GL11.glDisable(2896 /* GL_LIGHTING */);
|
||||
renderBlock(util, world, new Vector3(lightX, lightY, lightZ));
|
||||
GL11.glEnable(2896 /* GL_LIGHTING */);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Renders a block at given location
|
||||
*
|
||||
* @param blockInterface - class used to store info for the render process
|
||||
* @param world - world rendering in
|
||||
* @param x - position on x axis
|
||||
* @param y - position on y axis
|
||||
* @param z - position on z axis */
|
||||
public void renderBlock(BlockRenderInfo blockInterface, IBlockAccess world, Vector3 vec)
|
||||
{
|
||||
renderBlocks.renderMaxX = blockInterface.max.x;
|
||||
renderBlocks.renderMinX = blockInterface.min.x;
|
||||
renderBlocks.renderMaxY = blockInterface.max.y;
|
||||
renderBlocks.renderMinY = blockInterface.min.y;
|
||||
renderBlocks.renderMaxZ = blockInterface.max.z;
|
||||
renderBlocks.renderMinZ = blockInterface.min.z;
|
||||
renderBlocks.enableAO = false;
|
||||
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
Block block = blockInterface.baseBlock;
|
||||
//TODO do a check for "should render side" to solve issue with transparent blocks. Mainly rendering water blocks next to each other
|
||||
if (block.shouldSideBeRendered(world, vec.intX(), vec.intY(), vec.intZ(), 0))
|
||||
{
|
||||
renderBlocks.renderFaceYNeg(block, 0, 0, 0, blockInterface.getBlockIconFromSideAndMetadata(0, blockInterface.meta));
|
||||
}
|
||||
if (block.shouldSideBeRendered(world, vec.intX(), vec.intY(), vec.intZ(), 1))
|
||||
{
|
||||
renderBlocks.renderFaceYPos(block, 0, 0, 0, blockInterface.getBlockIconFromSideAndMetadata(1, blockInterface.meta));
|
||||
}
|
||||
if (block.shouldSideBeRendered(world, vec.intX(), vec.intY(), vec.intZ(), 2))
|
||||
{
|
||||
renderBlocks.renderFaceZNeg(block, 0, 0, 0, blockInterface.getBlockIconFromSideAndMetadata(2, blockInterface.meta));
|
||||
}
|
||||
if (block.shouldSideBeRendered(world, vec.intX(), vec.intY(), vec.intZ(), 3))
|
||||
{
|
||||
renderBlocks.renderFaceZPos(block, 0, 0, 0, blockInterface.getBlockIconFromSideAndMetadata(3, blockInterface.meta));
|
||||
}
|
||||
if (block.shouldSideBeRendered(world, vec.intX(), vec.intY(), vec.intZ(), 4))
|
||||
{
|
||||
renderBlocks.renderFaceXNeg(block, 0, 0, 0, blockInterface.getBlockIconFromSideAndMetadata(4, blockInterface.meta));
|
||||
}
|
||||
if (block.shouldSideBeRendered(world, vec.intX(), vec.intY(), vec.intZ(), 5))
|
||||
{
|
||||
renderBlocks.renderFaceXPos(block, 0, 0, 0, blockInterface.getBlockIconFromSideAndMetadata(5, blockInterface.meta));
|
||||
}
|
||||
tessellator.draw();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation func_110775_a(Entity entity)
|
||||
{
|
||||
throw new UnsupportedOperationException("Getting resoure location for this is not support as of yet");
|
||||
}
|
||||
}
|
|
@ -6,10 +6,10 @@ import cpw.mods.fml.relauncher.Side;
|
|||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class RenderMachine extends TileEntitySpecialRenderer
|
||||
public abstract class RenderTileMachine extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
||||
public RenderMachine()
|
||||
public RenderTileMachine()
|
||||
{
|
||||
|
||||
}
|
99
src/dark/core/prefab/entity/EntityBlock.java
Normal file
99
src/dark/core/prefab/entity/EntityBlock.java
Normal file
|
@ -0,0 +1,99 @@
|
|||
package dark.core.prefab.entity;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityBlock extends Entity
|
||||
{
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon texture;
|
||||
public float shadowSize = 0;
|
||||
public float rotationX = 0;
|
||||
public float rotationY = 0;
|
||||
public float rotationZ = 0;
|
||||
public double iSize, jSize, kSize;
|
||||
private int brightness = -1;
|
||||
|
||||
public EntityBlock(World world)
|
||||
{
|
||||
super(world);
|
||||
preventEntitySpawning = false;
|
||||
noClip = true;
|
||||
isImmuneToFire = true;
|
||||
}
|
||||
|
||||
public EntityBlock(World world, double xPos, double yPos, double zPos)
|
||||
{
|
||||
super(world);
|
||||
setPositionAndRotation(xPos, yPos, zPos, 0, 0);
|
||||
}
|
||||
|
||||
public EntityBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize)
|
||||
{
|
||||
this(world);
|
||||
this.iSize = iSize;
|
||||
this.jSize = jSize;
|
||||
this.kSize = kSize;
|
||||
setPositionAndRotation(i, j, k, 0, 0);
|
||||
this.motionX = 0.0;
|
||||
this.motionY = 0.0;
|
||||
this.motionZ = 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(double d, double d1, double d2)
|
||||
{
|
||||
super.setPosition(d, d1, d2);
|
||||
boundingBox.minX = posX;
|
||||
boundingBox.minY = posY;
|
||||
boundingBox.minZ = posZ;
|
||||
|
||||
boundingBox.maxX = posX + iSize;
|
||||
boundingBox.maxY = posY + jSize;
|
||||
boundingBox.maxZ = posZ + kSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveEntity(double d, double d1, double d2)
|
||||
{
|
||||
setPosition(posX + d, posY + d1, posZ + d2);
|
||||
}
|
||||
|
||||
public void setBrightness(int brightness)
|
||||
{
|
||||
this.brightness = brightness;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readEntityFromNBT(NBTTagCompound data)
|
||||
{
|
||||
iSize = data.getDouble("iSize");
|
||||
jSize = data.getDouble("jSize");
|
||||
kSize = data.getDouble("kSize");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeEntityToNBT(NBTTagCompound data)
|
||||
{
|
||||
data.setDouble("iSize", iSize);
|
||||
data.setDouble("jSize", jSize);
|
||||
data.setDouble("kSize", kSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBrightnessForRender(float par1)
|
||||
{
|
||||
return brightness > 0 ? brightness : super.getBrightnessForRender(par1);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue