Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No more TESR on conduits #176

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/main/java/crazypants/enderio/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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;
Expand Down Expand Up @@ -378,7 +377,6 @@ public void load() {
cbr = new ConduitBundleRenderer((float) Config.conduitScale);
BlockConduitBundle.rendererId = RenderingRegistry.getNextAvailableRenderId();
RenderingRegistry.registerBlockHandler(cbr);
ClientRegistry.bindTileEntitySpecialRenderer(TileConduitBundle.class, cbr);

ClientRegistry.bindTileEntitySpecialRenderer(TileTravelAnchor.class, new TravelEntitySpecialRenderer());

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -57,44 +56,58 @@ public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBu
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);
}
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);
}
}
}
}
Expand Down Expand Up @@ -243,49 +256,6 @@ protected void renderTransmission(IConduit con, IIcon tex, CollidableComponent c
// 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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@
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;
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;
Expand Down Expand Up @@ -53,59 +48,12 @@

@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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ public void renderEntity(ConduitBundleRenderer conduitBundleRenderer, IConduitBu
}
}

@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();

Expand Down Expand Up @@ -349,8 +345,4 @@ public BoundingBox[] toCubes(BoundingBox bb) {
return new BoundingBox[] { bb };
}

@Override
public boolean isDynamic() {
return false;
}
}