mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-17 10:55:06 +00:00
tank
This commit is contained in:
1 parent
99f8e98017
commit
482298021e
25 files changed
+1010
-174
No files matched your search
@@ -1,20 +1,38 @@
|
||||
package com.glodblock.github.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.FluidCraft;
|
||||
import com.glodblock.github.client.render.tank.ModelCertusTank;
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
import com.glodblock.github.loader.ItemAndBlockHolder;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
|
||||
public class ItemCertusQuartzTankRender implements IItemRenderer {
|
||||
|
||||
public ItemCertusQuartzTankRender() {
|
||||
private final ModelCertusTank model = new ModelCertusTank();
|
||||
|
||||
//
|
||||
// MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK),
|
||||
// this);
|
||||
public ItemCertusQuartzTankRender() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileCertusQuartzTank.class, new RenderBlockCertusQuartzTank());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ItemAndBlockHolder.CERTUS_QUARTZ_TANK), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
return type != ItemRenderType.EQUIPPED_FIRST_PERSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -23,5 +41,65 @@ public class ItemCertusQuartzTankRender implements IItemRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {}
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
Minecraft.getMinecraft().renderEngine
|
||||
.bindTexture(FluidCraft.resource("textures/blocks/certus_quartz_tank/map.png"));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
|
||||
GL11.glScalef(1, -1, -1);
|
||||
this.model.render(0.0625f);
|
||||
GL11.glScalef(1, -1, 1);
|
||||
this.model.render(0.0625f);
|
||||
|
||||
if (item != null && item.hasTagCompound()) {
|
||||
FluidStack storedFluid = FluidStack
|
||||
.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("tileEntity"));
|
||||
int tankCapacity = 32000;
|
||||
|
||||
if (storedFluid != null && storedFluid.getFluid() != null) {
|
||||
IIcon fluidIcon = storedFluid.getFluid().getIcon();
|
||||
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
RenderBlocks renderer = new RenderBlocks();
|
||||
GL11.glScalef(1, 1, -1);
|
||||
renderer.setRenderBounds(
|
||||
0.08F,
|
||||
0.001F,
|
||||
0.08F,
|
||||
0.92F,
|
||||
(float) storedFluid.amount / (float) tankCapacity * 0.999F,
|
||||
0.92F);
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Block waterBlock = FluidRegistry.WATER.getBlock();
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(
|
||||
(storedFluid.getFluid().getColor() >> 16 & 0xFF) / 255.0F,
|
||||
(storedFluid.getFluid().getColor() >> 8 & 0xFF) / 255.0F,
|
||||
(storedFluid.getFluid().getColor() & 0xFF) / 255.0F,
|
||||
1.0F);
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderer.renderFaceYNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderer.renderFaceZNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(waterBlock, 0.0D, 0.0D, 0.0D, fluidIcon);
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -27,25 +27,19 @@ public class ItemWalrusRender implements IItemRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) {
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) {
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(this.textureWalrus);
|
||||
GL11.glPushMatrix();
|
||||
switch (type) {
|
||||
case ENTITY:
|
||||
break;
|
||||
case EQUIPPED:
|
||||
break;
|
||||
case EQUIPPED_FIRST_PERSON:
|
||||
GL11.glRotated(180, 0, 1, 0);
|
||||
GL11.glTranslatef(-1F, 0.5F, -0.5F);
|
||||
break;
|
||||
case FIRST_PERSON_MAP:
|
||||
break;
|
||||
case INVENTORY:
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.1F);
|
||||
break;
|
||||
@@ -57,8 +51,7 @@ public class ItemWalrusRender implements IItemRenderer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item,
|
||||
IItemRenderer.ItemRendererHelper helper) {
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.glodblock.github.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.client.render.tank.FluidTankRenderer;
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
import com.glodblock.github.util.Util;
|
||||
|
||||
public class RenderBlockCertusQuartzTank extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
TileCertusQuartzTank tank = (TileCertusQuartzTank) tileentity;
|
||||
|
||||
FluidStack liquid = tank.tank.getFluid();
|
||||
if (liquid == null || liquid.getFluid() == null || liquid.amount <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int color = liquid.getFluid().getColor(liquid);
|
||||
|
||||
int[] displayList = FluidTankRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false);
|
||||
if (displayList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
bindTexture(TextureMap.locationBlocksTexture);
|
||||
RenderUtil.setGLColorFromInt(color);
|
||||
|
||||
GL11.glTranslatef((float) x + 0.0625F, (float) y + 0.5F, (float) z + 0.0625F);
|
||||
GL11.glScalef(0.875F, 0.99F, 0.875F);
|
||||
GL11.glTranslatef(0, -0.5F, 0);
|
||||
|
||||
int dl = (int) ((float) liquid.amount / (float) (tank.tank.getCapacity())
|
||||
* (FluidTankRenderer.DISPLAY_STAGES - 1));
|
||||
GL11.glCallList(displayList[Util.clamp(dl, 0, FluidTankRenderer.DISPLAY_STAGES - 1)]);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.glodblock.github.client.render.tank;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.util.RenderUtil;
|
||||
|
||||
public class FluidTankRenderer {
|
||||
|
||||
public static final int DISPLAY_STAGES = 100;
|
||||
private static final Map<Fluid, int[]> flowingRenderCache = new HashMap<>();
|
||||
private static final Map<Fluid, int[]> stillRenderCache = new HashMap<>();
|
||||
private static final RenderEntityBlock.RenderInfo liquidBlock = new RenderEntityBlock.RenderInfo();
|
||||
|
||||
public static void onTextureReload() {
|
||||
for (int[] ia : flowingRenderCache.values()) {
|
||||
for (int i : ia) {
|
||||
GL11.glDeleteLists(i, 1);
|
||||
}
|
||||
}
|
||||
flowingRenderCache.clear();
|
||||
|
||||
for (int[] ia : stillRenderCache.values()) {
|
||||
for (int i : ia) {
|
||||
GL11.glDeleteLists(i, 1);
|
||||
}
|
||||
}
|
||||
stillRenderCache.clear();
|
||||
}
|
||||
|
||||
public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) {
|
||||
if (fluidStack == null) {
|
||||
return null;
|
||||
}
|
||||
return getFluidTexture(fluidStack.getFluid(), flowing);
|
||||
}
|
||||
|
||||
public static IIcon getFluidTexture(Fluid fluid, boolean flowing) {
|
||||
if (fluid == null) {
|
||||
return null;
|
||||
}
|
||||
IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon();
|
||||
if (icon == null) {
|
||||
icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager()
|
||||
.getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno");
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static void setColorForFluidStack(FluidStack fluidstack) {
|
||||
if (fluidstack == null) {
|
||||
return;
|
||||
}
|
||||
int color = fluidstack.getFluid().getColor(fluidstack);
|
||||
RenderUtil.setGLColorFromInt(color);
|
||||
}
|
||||
|
||||
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.getBlock() != null) {
|
||||
liquidBlock.baseBlock = fluid.getBlock();
|
||||
} else {
|
||||
liquidBlock.baseBlock = Blocks.water;
|
||||
}
|
||||
liquidBlock.texture = getFluidTexture(fluidStack, 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.minX = 0.01f;
|
||||
liquidBlock.minY = 0;
|
||||
liquidBlock.minZ = 0.01f;
|
||||
|
||||
liquidBlock.maxX = 0.99f;
|
||||
liquidBlock.maxY = Math.max(s, 1) / (float) DISPLAY_STAGES;
|
||||
liquidBlock.maxZ = 0.99f;
|
||||
|
||||
RenderEntityBlock.INSTANCE.renderBlock(liquidBlock);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.glodblock.github.client.render.tank;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.glodblock.github.common.tile.TileCertusQuartzTank;
|
||||
|
||||
public class ModelCertusTank extends ModelBase {
|
||||
|
||||
ModelRenderer Shape1;
|
||||
|
||||
public ModelCertusTank() {
|
||||
this.textureWidth = 64;
|
||||
this.textureHeight = 64;
|
||||
|
||||
this.Shape1 = new ModelRenderer(this, 0, 0);
|
||||
this.Shape1.addBox(0F, 0F, 0F, 14, 16, 14);
|
||||
this.Shape1.setRotationPoint(-7F, -8F, -7F);
|
||||
this.Shape1.setTextureSize(this.textureWidth, this.textureHeight);
|
||||
this.Shape1.mirror = true;
|
||||
setRotation(this.Shape1, 0F, 0F, 0F);
|
||||
|
||||
}
|
||||
|
||||
public void render(float f) {
|
||||
this.Shape1.render(f);
|
||||
}
|
||||
|
||||
public void renderFluid(TileEntity tileEntity, double x, double y, double z, RenderBlocks renderer) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if (tileEntity != null
|
||||
&& ((TileCertusQuartzTank) tileEntity).getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null) {
|
||||
Fluid storedFluid = ((TileCertusQuartzTank) tileEntity).getRenderFluid();
|
||||
float scale = ((TileCertusQuartzTank) tileEntity).getRenderScale();
|
||||
if (storedFluid != null && scale > 0) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Block id = Block.getBlockById(FluidRegistry.WATER.getID());
|
||||
IIcon fluidIcon = storedFluid.getIcon();
|
||||
if (fluidIcon == null) fluidIcon = FluidRegistry.LAVA.getIcon();
|
||||
renderer.setRenderBounds(0.08F, 0.001F, 0.08F, 0.92, scale * 0.999F, 0.92F);
|
||||
tessellator.setColorRGBA_F(
|
||||
(storedFluid.getColor() >> 16 & 0xFF) / 255.0F,
|
||||
(storedFluid.getColor() >> 8 & 0xFF) / 255.0F,
|
||||
(storedFluid.getColor() & 0xFF) / 255.0F,
|
||||
1.0F);
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderer.renderFaceYNeg(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderer.renderFaceZNeg(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(id, x, y, z, fluidIcon);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(id, x, y, z, fluidIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderInnerBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
tessellator.setBrightness(15728640);
|
||||
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
|
||||
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
|
||||
int meta = 0;
|
||||
if (tankUp && tankDown) meta = 3;
|
||||
else if (tankUp) meta = 2;
|
||||
else if (tankDown) meta = 1;
|
||||
if (!tankUp) {
|
||||
tessellator.setNormal(0, -1, 0);
|
||||
renderer.renderFaceYNeg(block, x, y + 0.99F, z, block.getIcon(1, 0));
|
||||
}
|
||||
if (!tankDown) {
|
||||
tessellator.setNormal(0, 1, 0);
|
||||
renderer.renderFaceYPos(block, x, y - 0.99F, z, block.getIcon(0, 0));
|
||||
}
|
||||
IIcon sideIcon = block.getIcon(3, meta);
|
||||
tessellator.setNormal(0, 0, -1);
|
||||
renderer.renderFaceZNeg(block, x, y, z + 0.875F, sideIcon);
|
||||
tessellator.setNormal(0, 0, 1);
|
||||
renderer.renderFaceZPos(block, x, y, z - 0.875F, sideIcon);
|
||||
tessellator.setNormal(-1, 0, 0);
|
||||
renderer.renderFaceXNeg(block, x + 0.875F, y, z, sideIcon);
|
||||
tessellator.setNormal(1, 0, 0);
|
||||
renderer.renderFaceXPos(block, x - 0.875F, y, z, sideIcon);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void renderOuterBlock(Block block, int x, int y, int z, RenderBlocks renderer, IBlockAccess world) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
boolean tankUp = world.getTileEntity(x, y + 1, z) instanceof TileCertusQuartzTank;
|
||||
boolean tankDown = world.getTileEntity(x, y - 1, z) instanceof TileCertusQuartzTank;
|
||||
int meta = 0;
|
||||
if (tankUp && tankDown) meta = 3;
|
||||
else if (tankUp) meta = 2;
|
||||
else if (tankDown) meta = 1;
|
||||
if (!tankDown) {
|
||||
tessellator.setNormal(0.0F, -1F, 0.0F);
|
||||
renderer.renderFaceYNeg(block, x, y, z, block.getIcon(0, 0));
|
||||
}
|
||||
if (!tankUp) {
|
||||
tessellator.setNormal(0.0F, 1.0F, 0.0F);
|
||||
renderer.renderFaceYPos(block, x, y, z, block.getIcon(1, 0));
|
||||
}
|
||||
|
||||
IIcon sideIcon = block.getIcon(3, meta);
|
||||
tessellator.setNormal(0.0F, 0.0F, -1F);
|
||||
renderer.renderFaceZNeg(block, x, y, z, sideIcon);
|
||||
tessellator.setNormal(0.0F, 0.0F, 1.0F);
|
||||
renderer.renderFaceZPos(block, x, y, z, sideIcon);
|
||||
tessellator.setNormal(-1F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXNeg(block, x, y, z, sideIcon);
|
||||
tessellator.setNormal(1.0F, 0.0F, 0.0F);
|
||||
renderer.renderFaceXPos(block, x, y, z, sideIcon);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z) {
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.glodblock.github.client.render.tank;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class RenderEntityBlock extends Render {
|
||||
|
||||
public static RenderEntityBlock INSTANCE = new RenderEntityBlock();
|
||||
protected RenderBlocks renderBlocks;
|
||||
|
||||
private RenderEntityBlock() {
|
||||
renderBlocks = field_147909_c;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public static class RenderInfo {
|
||||
|
||||
public double minX = 0.0F;
|
||||
public double minY = 0.0F;
|
||||
public double minZ = 0.0F;
|
||||
public double maxX = 1.0F;
|
||||
public double maxY = 1.0F;
|
||||
public double maxZ = 1.0F;
|
||||
public Block baseBlock = Blocks.sand;
|
||||
public IIcon texture = null;
|
||||
public IIcon[] textureArray = null;
|
||||
public boolean[] renderSide = new boolean[] { true, true, true, true, true, true };
|
||||
public int light = -1;
|
||||
public int brightness = -1;
|
||||
|
||||
public RenderInfo() {}
|
||||
|
||||
public RenderInfo(Block template, IIcon[] texture) {
|
||||
this();
|
||||
this.baseBlock = template;
|
||||
this.textureArray = texture;
|
||||
}
|
||||
|
||||
public RenderInfo(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
this();
|
||||
setBounds(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
public void setSkyBlockLight(World world, int x, int y, int z, int light) {
|
||||
this.brightness = world.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z) << 16 | light;
|
||||
}
|
||||
|
||||
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) {
|
||||
return baseBlock.getMixedBrightnessForBlock(iblockaccess, i, j, k);
|
||||
}
|
||||
|
||||
public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public final void setRenderSingleSide(int side) {
|
||||
Arrays.fill(renderSide, false);
|
||||
renderSide[side] = true;
|
||||
}
|
||||
|
||||
public final void setRenderAllSides() {
|
||||
Arrays.fill(renderSide, true);
|
||||
}
|
||||
|
||||
public void rotate() {
|
||||
double temp = minX;
|
||||
minX = minZ;
|
||||
minZ = temp;
|
||||
|
||||
temp = maxX;
|
||||
maxX = maxZ;
|
||||
maxZ = temp;
|
||||
}
|
||||
|
||||
public void reverseX() {
|
||||
double temp = minX;
|
||||
minX = 1 - maxX;
|
||||
maxX = 1 - temp;
|
||||
}
|
||||
|
||||
public void reverseZ() {
|
||||
double temp = minZ;
|
||||
minZ = 1 - maxZ;
|
||||
maxZ = 1 - temp;
|
||||
}
|
||||
|
||||
public IIcon getBlockTextureFromSide(int i) {
|
||||
if (texture != null) {
|
||||
return texture;
|
||||
}
|
||||
|
||||
int index = i;
|
||||
|
||||
if (textureArray == null || textureArray.length == 0) {
|
||||
return baseBlock.getBlockTextureFromSide(index);
|
||||
} else {
|
||||
if (index >= textureArray.length) {
|
||||
index = 0;
|
||||
}
|
||||
|
||||
return textureArray[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRender(Entity entity, double x, double y, double z, float f, float f1) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
public void renderBlock(RenderInfo info) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
tessellator.startDrawingQuads();
|
||||
|
||||
renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
|
||||
|
||||
if (info.light != -1) {
|
||||
tessellator.setBrightness(info.light << 20 | info.light << 4);
|
||||
} else if (info.brightness != -1) {
|
||||
tessellator.setBrightness(info.brightness << 4);
|
||||
}
|
||||
|
||||
if (info.renderSide[0]) {
|
||||
tessellator.setNormal(0, -1, 0);
|
||||
renderBlocks.renderFaceYNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(0));
|
||||
}
|
||||
if (info.renderSide[1]) {
|
||||
tessellator.setNormal(0, 1, 0);
|
||||
renderBlocks.renderFaceYPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(1));
|
||||
}
|
||||
if (info.renderSide[2]) {
|
||||
tessellator.setNormal(0, 0, -1);
|
||||
renderBlocks.renderFaceZNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(2));
|
||||
}
|
||||
if (info.renderSide[3]) {
|
||||
tessellator.setNormal(0, 0, 1);
|
||||
renderBlocks.renderFaceZPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(3));
|
||||
}
|
||||
if (info.renderSide[4]) {
|
||||
tessellator.setNormal(-1, 0, 0);
|
||||
renderBlocks.renderFaceXNeg(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(4));
|
||||
}
|
||||
if (info.renderSide[5]) {
|
||||
tessellator.setNormal(1, 0, 0);
|
||||
renderBlocks.renderFaceXPos(info.baseBlock, 0, 0, 0, info.getBlockTextureFromSide(5));
|
||||
}
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user