mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-27 17:34:48 +00:00
Rewrite some in-hand rendering code
- Fix missing shader for printout render type - Use current buffer provider for pocket computers rather than the tesselator. This requires us to use a non-depth-writing terminal + depth blocker, as otherwise one gets z-fighting. - Thus refactor some of the shaders to be terminal wide, not just for monitors. Fixes #894
This commit is contained in:
parent
aa857c1be3
commit
0a537eaeee
36
build.gradle
36
build.gradle
@ -7,7 +7,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.18'
|
||||
classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.19'
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,50 +69,34 @@ minecraft {
|
||||
lazyToken('minecraft_classpath') {
|
||||
configurations.shade.copyRecursive().resolve().collect { it.absolutePath }.join(File.pathSeparator)
|
||||
}
|
||||
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
computercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
client {
|
||||
workingDirectory project.file('run')
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
computercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
workingDirectory project.file("run/server")
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
arg "--nogui"
|
||||
|
||||
mods {
|
||||
computercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data {
|
||||
workingDirectory project.file('run')
|
||||
property 'forge.logging.markers', 'REGISTRIES'
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
args '--mod', 'computercraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
|
||||
mods {
|
||||
computercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
testServer {
|
||||
workingDirectory project.file('test-files/server')
|
||||
parent runs.server
|
||||
arg "--nogui"
|
||||
|
||||
mods {
|
||||
cctest {
|
||||
|
@ -3,5 +3,5 @@ mod_version=1.98.1
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.17.1
|
||||
forge_version=37.0.25
|
||||
forge_version=37.0.34
|
||||
# NO SERIOUSLY, UPDATE mods.toml WHEN CHANGING
|
||||
|
@ -23,7 +23,7 @@ import javax.annotation.Nullable;
|
||||
|
||||
public final class FixedWidthFontRenderer
|
||||
{
|
||||
private static final RenderType TYPE = RenderTypes.BASIC_TERM;
|
||||
private static final RenderType TYPE = RenderTypes.TERMINAL_WITH_DEPTH;
|
||||
|
||||
public static final ResourceLocation FONT = new ResourceLocation( "computercraft", "textures/gui/term_font.png" );
|
||||
|
||||
@ -247,15 +247,15 @@ public final class FixedWidthFontRenderer
|
||||
)
|
||||
{
|
||||
MultiBufferSource.BufferSource renderer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.BASIC_TERM );
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH );
|
||||
drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
||||
renderer.endBatch( RenderTypes.BASIC_TERM );
|
||||
renderer.endBatch( RenderTypes.TERMINAL_WITH_DEPTH );
|
||||
}
|
||||
|
||||
public static void drawEmptyTerminal( @Nonnull Matrix4f transform, @Nonnull MultiBufferSource renderer, float x, float y, float width, float height )
|
||||
{
|
||||
Colour colour = Colour.BLACK;
|
||||
drawQuad( transform, renderer.getBuffer( RenderTypes.BASIC_TERM ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||
drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
|
||||
public static void drawEmptyTerminal( @Nonnull Matrix4f transform, float x, float y, float width, float height )
|
||||
@ -268,6 +268,6 @@ public final class FixedWidthFontRenderer
|
||||
public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull MultiBufferSource renderer, float x, float y, float width, float height )
|
||||
{
|
||||
Colour colour = Colour.BLACK;
|
||||
drawQuad( transform, renderer.getBuffer( RenderTypes.MONITOR_BLOCKER ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||
drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_BLOCKER ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
*/
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3f;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
@ -17,6 +17,7 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
@ -53,7 +54,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderItem( PoseStack transform, MultiBufferSource render, ItemStack stack )
|
||||
protected void renderItem( PoseStack transform, MultiBufferSource renderer, ItemStack stack )
|
||||
{
|
||||
ClientComputer computer = ItemPocketComputer.createClientComputer( stack );
|
||||
Terminal terminal = computer == null ? null : computer.getTerminal();
|
||||
@ -81,7 +82,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
transform.scale( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT );
|
||||
transform.scale( scale, scale, 0 );
|
||||
transform.scale( scale, scale, -1.0f );
|
||||
transform.translate( -0.5 * width, -0.5 * height, 0 );
|
||||
|
||||
// Render the main frame
|
||||
@ -90,62 +91,51 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
|
||||
int frameColour = item.getColour( stack );
|
||||
|
||||
Matrix4f matrix = transform.last().pose();
|
||||
renderFrame( matrix, family, frameColour, width, height );
|
||||
renderFrame( matrix, renderer, family, frameColour, width, height );
|
||||
|
||||
// Render the light
|
||||
int lightColour = ItemPocketComputer.getLightState( stack );
|
||||
if( lightColour == -1 ) lightColour = Colour.BLACK.getHex();
|
||||
renderLight( matrix, lightColour, width, height );
|
||||
renderLight( matrix, renderer, lightColour, width, height );
|
||||
|
||||
if( computer != null && terminal != null )
|
||||
{
|
||||
FixedWidthFontRenderer.drawTerminal( matrix, MARGIN, MARGIN, terminal, !computer.isColour(), MARGIN, MARGIN, MARGIN, MARGIN );
|
||||
FixedWidthFontRenderer.drawTerminal(
|
||||
matrix, renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ),
|
||||
MARGIN, MARGIN, terminal, !computer.isColour(), MARGIN, MARGIN, MARGIN, MARGIN
|
||||
);
|
||||
FixedWidthFontRenderer.drawBlocker( transform.last().pose(), renderer, 0, 0, width, height );
|
||||
}
|
||||
else
|
||||
{
|
||||
FixedWidthFontRenderer.drawEmptyTerminal( matrix, 0, 0, width, height );
|
||||
FixedWidthFontRenderer.drawEmptyTerminal( matrix, renderer, 0, 0, width, height );
|
||||
}
|
||||
|
||||
transform.popPose();
|
||||
}
|
||||
|
||||
private static void renderFrame( Matrix4f transform, ComputerFamily family, int colour, int width, int height )
|
||||
private static void renderFrame( Matrix4f transform, MultiBufferSource render, ComputerFamily family, int colour, int width, int height )
|
||||
{
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.setShaderTexture( 0,
|
||||
colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family )
|
||||
);
|
||||
ResourceLocation texture = colour != -1 ? ComputerBorderRenderer.BACKGROUND_COLOUR : ComputerBorderRenderer.getTexture( family );
|
||||
|
||||
float r = ((colour >>> 16) & 0xFF) / 255.0f;
|
||||
float g = ((colour >>> 8) & 0xFF) / 255.0f;
|
||||
float b = (colour & 0xFF) / 255.0f;
|
||||
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuilder();
|
||||
buffer.begin( VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX );
|
||||
|
||||
ComputerBorderRenderer.render( transform, buffer, 0, 0, 0, width, height, true, r, g, b );
|
||||
|
||||
tessellator.end();
|
||||
ComputerBorderRenderer.render( transform, render.getBuffer( RenderTypes.positionColorTex( texture ) ), 0, 0, 0, width, height, true, r, g, b );
|
||||
}
|
||||
|
||||
private static void renderLight( Matrix4f transform, int colour, int width, int height )
|
||||
private static void renderLight( Matrix4f transform, MultiBufferSource render, int colour, int width, int height )
|
||||
{
|
||||
RenderSystem.disableTexture();
|
||||
|
||||
float r = ((colour >>> 16) & 0xFF) / 255.0f;
|
||||
float g = ((colour >>> 8) & 0xFF) / 255.0f;
|
||||
float b = (colour & 0xFF) / 255.0f;
|
||||
float z = 0.001f;
|
||||
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder buffer = tessellator.getBuilder();
|
||||
buffer.begin( VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR );
|
||||
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.vertex( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.vertex( transform, width, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0 ).color( r, g, b, 1.0f ).endVertex();
|
||||
|
||||
tessellator.end();
|
||||
RenderSystem.enableTexture();
|
||||
VertexConsumer buffer = render.getBuffer( RenderTypes.POSITION_COLOR );
|
||||
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, z ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.vertex( transform, width, height + LIGHT_HEIGHT + BORDER / 2.0f, z ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.vertex( transform, width, height + BORDER / 2.0f, z ).color( r, g, b, 1.0f ).endVertex();
|
||||
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, z ).color( r, g, b, 1.0f ).endVertex();
|
||||
}
|
||||
}
|
||||
|
@ -5,24 +5,18 @@
|
||||
*/
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
|
||||
|
||||
public final class PrintoutRenderer
|
||||
{
|
||||
private static final ResourceLocation BG = new ResourceLocation( "computercraft", "textures/gui/printout.png" );
|
||||
private static final float BG_SIZE = 256.0f;
|
||||
|
||||
/**
|
||||
@ -62,7 +56,7 @@ public final class PrintoutRenderer
|
||||
|
||||
public static void drawText( Matrix4f transform, MultiBufferSource renderer, int x, int y, int start, TextBuffer[] text, TextBuffer[] colours )
|
||||
{
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.BASIC_TERM );
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH );
|
||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
||||
{
|
||||
FixedWidthFontRenderer.drawString( transform, buffer,
|
||||
@ -74,7 +68,7 @@ public final class PrintoutRenderer
|
||||
|
||||
public static void drawText( Matrix4f transform, MultiBufferSource renderer, int x, int y, int start, String[] text, String[] colours )
|
||||
{
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.BASIC_TERM );
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH );
|
||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
||||
{
|
||||
FixedWidthFontRenderer.drawString( transform, buffer,
|
||||
@ -90,7 +84,7 @@ public final class PrintoutRenderer
|
||||
int leftPages = page;
|
||||
int rightPages = pages - page - 1;
|
||||
|
||||
VertexConsumer buffer = renderer.getBuffer( Type.TYPE );
|
||||
VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_BACKGROUND );
|
||||
|
||||
if( isBook )
|
||||
{
|
||||
@ -164,21 +158,4 @@ public final class PrintoutRenderer
|
||||
{
|
||||
return (float) (32 * (1 - Math.pow( 1.2, -page )));
|
||||
}
|
||||
|
||||
private static final class Type extends RenderStateShard
|
||||
{
|
||||
static final RenderType TYPE = RenderType.create(
|
||||
"printout_background", DefaultVertexFormat.POSITION_TEX, VertexFormat.Mode.QUADS, 1024,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setTextureState( new RenderStateShard.TextureStateShard( BG, false, false ) ) // blur, minimap
|
||||
.setLightmapState( NO_LIGHTMAP )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
private Type( String name, Runnable setup, Runnable destroy )
|
||||
{
|
||||
super( name, setup, destroy );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
@ -21,18 +22,27 @@ import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD )
|
||||
public class RenderTypes
|
||||
{
|
||||
private static MonitorTextureBufferShader monitorTboShader;
|
||||
private static ShaderInstance monitorBasicShader;
|
||||
private static ShaderInstance terminalShader;
|
||||
|
||||
public static final RenderType MONITOR_BASIC = Types.MONITOR_BASIC;
|
||||
public static final RenderType TERMINAL_WITHOUT_DEPTH = Types.TERMINAL_WITHOUT_DEPTH;
|
||||
public static final RenderType TERMINAL_BLOCKER = Types.TERMINAL_BLOCKER;
|
||||
public static final RenderType TERMINAL_WITH_DEPTH = Types.TERMINAL_WITH_DEPTH;
|
||||
public static final RenderType MONITOR_TBO = Types.MONITOR_TBO;
|
||||
public static final RenderType MONITOR_BLOCKER = Types.MONITOR_BLOCKER;
|
||||
|
||||
public static final RenderType BASIC_TERM = Types.BASIC_TERM;
|
||||
public static final RenderType PRINTOUT_BACKGROUND = Types.PRINTOUT_BACKGROUND;
|
||||
|
||||
public static final RenderType POSITION_COLOR = Types.POSITION_COLOR;
|
||||
|
||||
public static RenderType positionColorTex( ResourceLocation location )
|
||||
{
|
||||
return Types.POSITION_COLOR_TEX.apply( location );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static MonitorTextureBufferShader getMonitorTextureBufferShader()
|
||||
@ -42,10 +52,10 @@ public class RenderTypes
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
static ShaderInstance getMonitorBasicShader()
|
||||
static ShaderInstance getTerminalShader()
|
||||
{
|
||||
if( monitorBasicShader == null ) throw new NullPointerException( "MonitorTboShader has not been registered" );
|
||||
return monitorBasicShader;
|
||||
if( terminalShader == null ) throw new NullPointerException( "MonitorTboShader has not been registered" );
|
||||
return terminalShader;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@ -61,12 +71,12 @@ public class RenderTypes
|
||||
);
|
||||
|
||||
event.registerShader(
|
||||
new MonitorTextureBufferShader(
|
||||
new ShaderInstance(
|
||||
event.getResourceManager(),
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "monitor_basic" ),
|
||||
MONITOR_BASIC.format()
|
||||
new ResourceLocation( ComputerCraft.MOD_ID, "terminal" ),
|
||||
TERMINAL_WITHOUT_DEPTH.format()
|
||||
),
|
||||
x -> monitorBasicShader = x
|
||||
x -> terminalShader = x
|
||||
);
|
||||
}
|
||||
|
||||
@ -89,33 +99,66 @@ public class RenderTypes
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
static final RenderType MONITOR_BASIC = RenderType.create(
|
||||
static final RenderType TERMINAL_WITHOUT_DEPTH = RenderType.create(
|
||||
"monitor_basic", TERM_FORMAT, TERM_MODE, 1024,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setTextureState( TERM_FONT_TEXTURE )
|
||||
.setShaderState( new ShaderStateShard( RenderTypes::getMonitorBasicShader ) )
|
||||
.setShaderState( new ShaderStateShard( RenderTypes::getTerminalShader ) )
|
||||
.setWriteMaskState( COLOR_WRITE )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
static final RenderType MONITOR_BLOCKER = RenderType.create(
|
||||
static final RenderType TERMINAL_BLOCKER = RenderType.create(
|
||||
"monitor_blocker", TERM_FORMAT, TERM_MODE, 256,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setTextureState( TERM_FONT_TEXTURE )
|
||||
.setShaderState( new ShaderStateShard( RenderTypes::getMonitorBasicShader ) )
|
||||
.setShaderState( new ShaderStateShard( RenderTypes::getTerminalShader ) )
|
||||
.setWriteMaskState( DEPTH_WRITE )
|
||||
.setLightmapState( NO_LIGHTMAP )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
static final RenderType BASIC_TERM = RenderType.create(
|
||||
static final RenderType TERMINAL_WITH_DEPTH = RenderType.create(
|
||||
"basic_terminal", TERM_FORMAT, TERM_MODE, 1024,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setTextureState( TERM_FONT_TEXTURE )
|
||||
.setShaderState( new RenderStateShard.ShaderStateShard( GameRenderer::getPositionColorTexShader ) )
|
||||
.setShaderState( POSITION_COLOR_TEX_SHADER )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
static final RenderType POSITION_COLOR = RenderType.create(
|
||||
"position_color", DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.QUADS, 128,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setShaderState( POSITION_COLOR_SHADER )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
static final Function<ResourceLocation, RenderType> POSITION_COLOR_TEX = Util.memoize( location ->
|
||||
{
|
||||
return RenderType.create(
|
||||
"position_color_tex", DefaultVertexFormat.POSITION_COLOR_TEX, VertexFormat.Mode.QUADS, 1024,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setTextureState( new RenderStateShard.TextureStateShard( location, false, false ) )// blur, minimap
|
||||
.setShaderState( POSITION_COLOR_TEX_SHADER )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
} );
|
||||
|
||||
static final RenderType PRINTOUT_BACKGROUND = RenderType.create(
|
||||
"printout_background", DefaultVertexFormat.POSITION_TEX, VertexFormat.Mode.QUADS, 1024,
|
||||
false, false, // useDelegate, needsSorting
|
||||
RenderType.CompositeState.builder()
|
||||
.setTextureState( new RenderStateShard.TextureStateShard(
|
||||
new ResourceLocation( "computercraft", "textures/gui/printout.png" ),
|
||||
false, false // blur, minimap
|
||||
) )
|
||||
.setShaderState( new RenderStateShard.ShaderStateShard( GameRenderer::getPositionTexShader ) )
|
||||
.setLightmapState( NO_LIGHTMAP )
|
||||
.createCompositeState( false )
|
||||
);
|
||||
|
||||
|
@ -114,19 +114,26 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
|
||||
Matrix4f matrix = transform.last().pose();
|
||||
|
||||
// Sneaky hack here: we get a buffer now in order to flush existing ones and set up the appropriate
|
||||
// render state. I've no clue how well this'll work in future versions of Minecraft, but it does the trick
|
||||
// for now.
|
||||
renderTerminal( renderer, matrix, originTerminal, (float) (MARGIN / xScale), (float) (MARGIN / yScale) );
|
||||
|
||||
// We don't draw the cursor with the VBO, as it's dynamic and so we'll end up refreshing far more than is
|
||||
// reasonable.
|
||||
FixedWidthFontRenderer.drawCursor(
|
||||
matrix, renderer.getBuffer( RenderTypes.MONITOR_BASIC ),
|
||||
matrix, renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ),
|
||||
0, 0, terminal, !originTerminal.isColour()
|
||||
);
|
||||
|
||||
transform.popPose();
|
||||
|
||||
FixedWidthFontRenderer.drawBlocker(
|
||||
transform.last().pose(), renderer,
|
||||
(float) -TileMonitor.RENDER_MARGIN, (float) TileMonitor.RENDER_MARGIN,
|
||||
(float) (xSize + 2 * TileMonitor.RENDER_MARGIN), (float) -(ySize + TileMonitor.RENDER_MARGIN * 2)
|
||||
);
|
||||
|
||||
// Force a flush of the blocker. WorldRenderer.updateCameraAndRender will "finish" all the built-in
|
||||
// buffers before calling renderer.finish, which means the blocker isn't actually rendered at that point!
|
||||
renderer.getBuffer( RenderType.solid() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -137,16 +144,6 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
);
|
||||
}
|
||||
|
||||
FixedWidthFontRenderer.drawBlocker(
|
||||
transform.last().pose(), renderer,
|
||||
(float) -TileMonitor.RENDER_MARGIN, (float) TileMonitor.RENDER_MARGIN,
|
||||
(float) (xSize + 2 * TileMonitor.RENDER_MARGIN), (float) -(ySize + TileMonitor.RENDER_MARGIN * 2)
|
||||
);
|
||||
|
||||
// Force a flush of the blocker. WorldRenderer.updateCameraAndRender will "finish" all the built-in
|
||||
// buffers before calling renderer.finish, which means the blocker isn't actually rendered at that point!
|
||||
renderer.getBuffer( RenderType.solid() );
|
||||
|
||||
transform.popPose();
|
||||
}
|
||||
|
||||
@ -209,7 +206,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
|
||||
// And force things to flush. We strictly speaking do this later on anyway for the cursor, but nice to
|
||||
// be consistent.
|
||||
renderer.getBuffer( RenderTypes.MONITOR_BASIC );
|
||||
renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH );
|
||||
break;
|
||||
}
|
||||
|
||||
@ -220,7 +217,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
{
|
||||
Tesselator tessellator = Tesselator.getInstance();
|
||||
BufferBuilder builder = tessellator.getBuilder();
|
||||
builder.begin( RenderTypes.MONITOR_BASIC.mode(), RenderTypes.MONITOR_BASIC.format() );
|
||||
builder.begin( RenderTypes.TERMINAL_WITHOUT_DEPTH.mode(), RenderTypes.TERMINAL_WITHOUT_DEPTH.format() );
|
||||
FixedWidthFontRenderer.drawTerminalWithoutCursor(
|
||||
IDENTITY, builder, 0, 0,
|
||||
terminal, !monitor.isColour(), yMargin, yMargin, xMargin, xMargin
|
||||
@ -230,9 +227,9 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
||||
vbo.upload( builder );
|
||||
}
|
||||
|
||||
renderer.getBuffer( RenderTypes.MONITOR_BASIC );
|
||||
RenderTypes.MONITOR_BASIC.setupRenderState();
|
||||
vbo.drawWithShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getMonitorBasicShader() );
|
||||
renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH );
|
||||
RenderTypes.TERMINAL_WITHOUT_DEPTH.setupRenderState();
|
||||
vbo.drawWithShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user