move small part of gate rendering to ISBRH for improved performance
This commit is contained in:
parent
3880661c12
commit
1a5e52b2f7
2 changed files with 41 additions and 4 deletions
|
@ -4,6 +4,7 @@ import java.util.Set;
|
|||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
@ -12,6 +13,7 @@ import net.minecraft.util.AxisAlignedBB;
|
|||
import net.minecraftforge.common.util.Constants;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.core.render.ITextureStates;
|
||||
import buildcraft.api.gates.GateExpansions;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.transport.IPipe;
|
||||
|
@ -26,8 +28,8 @@ import buildcraft.transport.TileGenericPipe;
|
|||
import buildcraft.transport.render.PipeRendererTESR;
|
||||
|
||||
public class GatePluggable extends PipePluggable {
|
||||
private static class GatePluggableRenderer implements IPipePluggableDynamicRenderer {
|
||||
public static final IPipePluggableDynamicRenderer INSTANCE = new GatePluggableRenderer();
|
||||
private static class GatePluggableRenderer implements IPipePluggableRenderer, IPipePluggableDynamicRenderer {
|
||||
public static final GatePluggableRenderer INSTANCE = new GatePluggableRenderer();
|
||||
|
||||
private GatePluggableRenderer() {
|
||||
|
||||
|
@ -37,6 +39,13 @@ public class GatePluggable extends PipePluggable {
|
|||
public void renderPluggable(IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, double x, double y, double z) {
|
||||
PipeRendererTESR.renderGate(x, y, z, (GatePluggable) pipePluggable, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderPluggable(RenderBlocks renderblocks, IPipe pipe, ForgeDirection side, PipePluggable pipePluggable, ITextureStates blockStateMachine, int renderPass, int x, int y, int z) {
|
||||
if (renderPass == 0) {
|
||||
PipeRendererTESR.renderGateStatic(renderblocks, side, (GatePluggable) pipePluggable, blockStateMachine, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
public GateDefinition.GateMaterial material;
|
||||
public GateDefinition.GateLogic logic;
|
||||
|
@ -228,7 +237,7 @@ public class GatePluggable extends PipePluggable {
|
|||
|
||||
@Override
|
||||
public IPipePluggableRenderer getRenderer() {
|
||||
return null;
|
||||
return GatePluggableRenderer.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
|
@ -33,6 +34,7 @@ import buildcraft.BuildCraftCore.RenderMode;
|
|||
import buildcraft.BuildCraftTransport;
|
||||
import buildcraft.api.core.EnumColor;
|
||||
import buildcraft.api.core.Position;
|
||||
import buildcraft.api.core.render.ITextureStates;
|
||||
import buildcraft.api.gates.IGateExpansion;
|
||||
import buildcraft.api.items.IItemCustomPipeRender;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
|
@ -469,6 +471,32 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
public static void renderGateStatic(RenderBlocks renderblocks, ForgeDirection direction, GatePluggable gate, ITextureStates blockStateMachine, int x, int y, int z) {
|
||||
blockStateMachine.getTextureState().set(gate.getLogic().getGateIcon());
|
||||
|
||||
float trim = 0.1F;
|
||||
float[][] zeroState = new float[3][2];
|
||||
float min = CoreConstants.PIPE_MIN_POS + trim / 2F;
|
||||
float max = CoreConstants.PIPE_MAX_POS - trim / 2F;
|
||||
|
||||
// X START - END
|
||||
zeroState[0][0] = min;
|
||||
zeroState[0][1] = max;
|
||||
// Y START - END
|
||||
zeroState[1][0] = CoreConstants.PIPE_MIN_POS - 0.10F;
|
||||
zeroState[1][1] = CoreConstants.PIPE_MIN_POS + 0.001F;
|
||||
// Z START - END
|
||||
zeroState[2][0] = min;
|
||||
zeroState[2][1] = max;
|
||||
|
||||
float[][] rotated = MatrixTranformations.deepClone(zeroState);
|
||||
MatrixTranformations.transform(rotated, direction);
|
||||
|
||||
blockStateMachine.setRenderAllSides();
|
||||
renderblocks.setRenderBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]);
|
||||
renderblocks.renderStandardBlock(blockStateMachine.getBlock(), x, y, z);
|
||||
}
|
||||
|
||||
public static void renderGate(double x, double y, double z, GatePluggable gate, ForgeDirection direction) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
|
@ -485,7 +513,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer {
|
|||
float translateCenter = 0;
|
||||
|
||||
// Render base gate
|
||||
renderGate(gateIcon, 0, 0.1F, 0, 0, direction, false);
|
||||
//renderGate(gateIcon, 0, 0.1F, 0, 0, direction, false);
|
||||
renderGate(lightIcon, 0, 0.1F, 0, 0, direction, gate.isLit);
|
||||
|
||||
float pulseStage = gate.getPulseStage() * 2F;
|
||||
|
|
Loading…
Reference in a new issue