mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-10-25 20:22:23 +00:00
No more TESR on conduits (#176)
* Goodbye TESR, Hello ISBRH * More fluid conduit rendering work * more stuff * spotless * Add empty check to fluid conduit renderer
This commit is contained in:
1 parent
bf9c2cd2c7
commit
0fbf6f05ba
5 files changed
+40
-136
No files matched your search
@@ -27,7 +27,6 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.conduit.BlockConduitBundle;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.facade.FacadeRenderer;
|
||||
import crazypants.enderio.conduit.gas.GasConduit;
|
||||
import crazypants.enderio.conduit.gas.GasUtil;
|
||||
@@ -378,7 +377,6 @@ public class ClientProxy extends CommonProxy {
|
||||
cbr = new ConduitBundleRenderer((float) Config.conduitScale);
|
||||
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(cbr);
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTravelAnchor.class, new TravelEntitySpecialRenderer());
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package crazypants.enderio.conduit.liquid;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -57,10 +56,17 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
|
||||
super.renderEntity(conduitBundleRenderer, te, conduit, x, y, z, partialTick, worldLight, rb);
|
||||
}
|
||||
|
||||
public void renderDynamicEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit,
|
||||
double x, double y, double z, float partialTick, float worldLight) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderConduit(IIcon tex, IConduit conduit, CollidableComponent component, float brightness) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if (isNSEWUD(component.dir)) {
|
||||
LiquidConduit lc = (LiquidConduit) conduit;
|
||||
IIcon fluidTex = conduit.getTransmitionTextureForState(component);
|
||||
FluidStack fluid = lc.getFluidType();
|
||||
if (fluid != null) {
|
||||
renderFluidOutline(component, fluid);
|
||||
@@ -68,33 +74,40 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
|
||||
BoundingBox[] cubes = toCubes(component.bound);
|
||||
for (BoundingBox cube : cubes) {
|
||||
drawSection(cube, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV(), component.dir, false);
|
||||
// This check is kinda broken, but whatever, it was like that when this was done in a TESR too
|
||||
if (lc.getTank().getFilledRatio() <= 0) {
|
||||
continue;
|
||||
}
|
||||
tessellator.setColorOpaque_F(0.7f, 0.7f, 0.7f);
|
||||
drawSection(
|
||||
cube,
|
||||
fluidTex.getMinU(),
|
||||
fluidTex.getMaxU(),
|
||||
fluidTex.getMinV(),
|
||||
fluidTex.getMaxV(),
|
||||
component.dir,
|
||||
true);
|
||||
}
|
||||
|
||||
} else {
|
||||
drawSection(
|
||||
component.bound,
|
||||
tex.getMinU(),
|
||||
tex.getMaxU(),
|
||||
tex.getMinV(),
|
||||
tex.getMaxV(),
|
||||
component.dir,
|
||||
true);
|
||||
}
|
||||
|
||||
if (conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) {
|
||||
final CubeRenderer cr = CubeRenderer.get();
|
||||
int i;
|
||||
tex = EnderIO.blockConduitBundle.getConnectorIcon(component.data);
|
||||
List<Vertex> corners = component.bound
|
||||
.getCornersWithUvForFace(component.dir, tex.getMinU(), tex.getMaxU(), tex.getMinV(), tex.getMaxV());
|
||||
for (i = corners.size() - 1; i >= 0; i--) {
|
||||
Vertex c = corners.get(i);
|
||||
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
|
||||
}
|
||||
// back face
|
||||
for (i = corners.size() - 1; i >= 0; i--) {
|
||||
Vertex c = corners.get(i);
|
||||
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
|
||||
if (conduit.getConnectionMode(component.dir) == ConnectionMode.DISABLED) {
|
||||
final CubeRenderer cr = CubeRenderer.get();
|
||||
int i;
|
||||
tex = EnderIO.blockConduitBundle.getConnectorIcon(component.data);
|
||||
List<Vertex> corners = component.bound.getCornersWithUvForFace(
|
||||
component.dir,
|
||||
tex.getMinU(),
|
||||
tex.getMaxU(),
|
||||
tex.getMinV(),
|
||||
tex.getMaxV());
|
||||
for (i = corners.size() - 1; i >= 0; i--) {
|
||||
Vertex c = corners.get(i);
|
||||
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
|
||||
}
|
||||
// back face
|
||||
for (i = corners.size() - 1; i >= 0; i--) {
|
||||
Vertex c = corners.get(i);
|
||||
cr.addVecWithUV(c.xyz, c.uv.x, c.uv.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,49 +256,6 @@ public class LiquidConduitRenderer extends DefaultConduitRenderer implements IRe
|
||||
// done in the dynamic section
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamicEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit conduit,
|
||||
double x, double y, double z, float partialTick, float worldLight) {
|
||||
|
||||
if (((LiquidConduit) conduit).getTank().getFilledRatio() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<CollidableComponent> components = conduit.getCollidableComponents();
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
calculateRatios((LiquidConduit) conduit);
|
||||
transmissionScaleFactor = conduit.getTransmitionGeometryScale();
|
||||
|
||||
IIcon tex;
|
||||
for (CollidableComponent component : components) {
|
||||
if (renderComponent(component)) {
|
||||
if (isNSEWUD(component.dir) && conduit.getTransmitionTextureForState(component) != null) {
|
||||
|
||||
tessellator.setColorOpaque_F(1, 1, 1);
|
||||
tex = conduit.getTransmitionTextureForState(component);
|
||||
|
||||
BoundingBox[] cubes = toCubes(component.bound);
|
||||
for (BoundingBox cube : cubes) {
|
||||
drawSection(
|
||||
cube,
|
||||
tex.getMinU(),
|
||||
tex.getMaxU(),
|
||||
tex.getMinV(),
|
||||
tex.getMaxV(),
|
||||
component.dir,
|
||||
true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setVerticesForTransmission(BoundingBox bound, ForgeDirection id) {
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -19,13 +18,9 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import com.enderio.core.client.render.BoundingBox;
|
||||
import com.enderio.core.client.render.CubeRenderer;
|
||||
import com.enderio.core.client.render.IconUtil;
|
||||
import com.enderio.core.client.render.RenderUtil;
|
||||
import com.enderio.core.common.util.BlockCoord;
|
||||
import com.enderio.core.common.util.IBlockAccessWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -53,59 +48,12 @@ import crazypants.util.RenderPassHelper;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@ThreadSafeISBRH(perThread = false)
|
||||
public class ConduitBundleRenderer extends TileEntitySpecialRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class ConduitBundleRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public ConduitBundleRenderer(float conduitScale) {}
|
||||
|
||||
public ConduitBundleRenderer() {}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) {
|
||||
IConduitBundle bundle = (IConduitBundle) te;
|
||||
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
|
||||
if (bundle == null || (bundle.hasFacade() && bundle.getFacadeId().isOpaqueCube()
|
||||
&& !ConduitUtil.isFacadeHidden(bundle, player))) {
|
||||
return;
|
||||
}
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
float brightness = -1;
|
||||
for (IConduit con : bundle.getConduits()) {
|
||||
if (ConduitUtil.renderConduit(player, con)) {
|
||||
final ConduitRenderer renderer = con.getRenderer();
|
||||
if (renderer.isDynamic()) {
|
||||
if (brightness == -1) {
|
||||
BlockCoord loc = bundle.getLocation();
|
||||
brightness = bundle.getEntity().getWorldObj()
|
||||
.getLightBrightnessForSkyBlocks(loc.x, loc.y, loc.z, 0);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT);
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GL11.glShadeModel(GL11.GL_SMOOTH);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
renderer.renderDynamicEntity(this, bundle, con, x, y, z, partialTick, brightness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (brightness != -1) {
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glShadeModel(GL11.GL_FLAT);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
|
||||
RenderBlocks rb) {
|
||||
|
||||
@@ -10,8 +10,4 @@ public interface ConduitRenderer {
|
||||
void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit con, double x, double y,
|
||||
double z, float partialTick, float worldLight, RenderBlocks rb);
|
||||
|
||||
boolean isDynamic();
|
||||
|
||||
void renderDynamicEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit con, double x,
|
||||
double y, double z, float partialTick, float worldLight);
|
||||
}
|
||||
@@ -63,10 +63,6 @@ public class DefaultConduitRenderer implements ConduitRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderDynamicEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBundle te, IConduit con,
|
||||
double x, double y, double z, float partialTick, float worldLight) {}
|
||||
|
||||
protected void renderConduit(IIcon tex, IConduit conduit, CollidableComponent component, float brightness) {
|
||||
final CubeRenderer cr = CubeRenderer.get();
|
||||
|
||||
@@ -349,8 +345,4 @@ public class DefaultConduitRenderer implements ConduitRenderer {
|
||||
return new BoundingBox[] { bb };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamic() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user