1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-29 00:32:18 +00:00

Merge branch 'fabric' into fabric

This commit is contained in:
Cloud Chagnon 2021-09-30 16:26:35 -06:00 committed by GitHub
commit 967f00cd1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 25 deletions

View File

@ -80,7 +80,7 @@ public final class FixedWidthFontRenderer
}
private static void drawBackground( @Nonnull Matrix4f transform, @Nonnull VertexConsumer renderer, float x, float y,
private static void drawBackground( @Nonnull Matrix4f transform, @Nonnull BufferBuilder renderer, float x, float y,
@Nonnull TextBuffer backgroundColour, @Nonnull Palette palette, boolean greyscale, float leftMarginSize,
float rightMarginSize, float height )
{
@ -146,7 +146,7 @@ public final class FixedWidthFontRenderer
return (float) ((rgb[0] + rgb[1] + rgb[2]) / 3);
}
private static void drawChar( Matrix4f transform, VertexConsumer buffer, float x, float y, int index, float r, float g, float b )
private static void drawChar( Matrix4f transform, BufferBuilder buffer, float x, float y, int index, float r, float g, float b )
{
// Short circuit to avoid the common case - the texture should be blank here after all.
if( index == '\0' || index == ' ' )
@ -186,7 +186,7 @@ public final class FixedWidthFontRenderer
.next();
}
private static void drawQuad( Matrix4f transform, VertexConsumer buffer, float x, float y, float width, float height, Palette palette,
private static void drawQuad( Matrix4f transform, BufferBuilder buffer, float x, float y, float width, float height, Palette palette,
boolean greyscale, char colourIndex )
{
double[] colour = palette.getColour( getColour( colourIndex, Colour.BLACK ) );
@ -205,7 +205,7 @@ public final class FixedWidthFontRenderer
drawQuad( transform, buffer, x, y, width, height, r, g, b );
}
private static void drawQuad( Matrix4f transform, VertexConsumer buffer, float x, float y, float width, float height, float r, float g, float b )
private static void drawQuad( Matrix4f transform, BufferBuilder buffer, float x, float y, float width, float height, float r, float g, float b )
{
buffer.vertex( transform, x, y, 0 )
.color( r, g, b, 1.0f )
@ -233,7 +233,7 @@ public final class FixedWidthFontRenderer
.next();
}
public static void drawTerminalWithoutCursor( @Nonnull Matrix4f transform, @Nonnull VertexConsumer buffer, float x, float y,
public static void drawTerminalWithoutCursor( @Nonnull Matrix4f transform, @Nonnull BufferBuilder buffer, float x, float y,
@Nonnull Terminal terminal, boolean greyscale, float topMarginSize, float bottomMarginSize,
float leftMarginSize, float rightMarginSize )
{
@ -280,7 +280,7 @@ public final class FixedWidthFontRenderer
}
}
public static void drawCursor( @Nonnull Matrix4f transform, @Nonnull VertexConsumer buffer, float x, float y, @Nonnull Terminal terminal,
public static void drawCursor( @Nonnull Matrix4f transform, @Nonnull BufferBuilder buffer, float x, float y, @Nonnull Terminal terminal,
boolean greyscale )
{
Palette palette = terminal.getPalette();
@ -308,7 +308,7 @@ public final class FixedWidthFontRenderer
}
}
public static void drawTerminal( @Nonnull Matrix4f transform, @Nonnull VertexConsumer buffer, float x, float y, @Nonnull Terminal terminal,
public static void drawTerminal( @Nonnull Matrix4f transform, @Nonnull BufferBuilder buffer, float x, float y, @Nonnull Terminal terminal,
boolean greyscale, float topMarginSize, float bottomMarginSize, float leftMarginSize, float rightMarginSize )
{
drawTerminalWithoutCursor( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
@ -325,7 +325,9 @@ public final class FixedWidthFontRenderer
.getEntityVertexConsumers();
VertexConsumer buffer = renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH );
drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
renderer.draw();
// buffer.end();
Tessellator.getInstance().draw();
// renderer.draw();
}
public static void drawTerminal( float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, float bottomMarginSize,
@ -344,21 +346,25 @@ public final class FixedWidthFontRenderer
{
// bindFont();
VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance()
.getBufferBuilders()
.getEntityVertexConsumers();
drawEmptyTerminal( transform, renderer, x, y, width, height );
renderer.draw();
// VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance()
// .getBufferBuilders()
// .getEntityVertexConsumers();
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
buffer.begin( VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR_TEXTURE );
drawEmptyTerminal( transform, buffer, x, y, width, height );
// buffer.end();
Tessellator.getInstance().draw();
// renderer.draw();
}
public static void drawEmptyTerminal( @Nonnull Matrix4f transform, @Nonnull VertexConsumerProvider renderer, float x, float y, float width,
public static void drawEmptyTerminal( @Nonnull Matrix4f transform, @Nonnull BufferBuilder renderer, float x, float y, float width,
float height )
{
Colour colour = Colour.BLACK;
drawQuad( transform, renderer.getBuffer( RenderTypes.TERMINAL_WITH_DEPTH ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
}
public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull VertexConsumerProvider renderer, float x, float y, float width, float height )
public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull BufferBuilder renderer, float x, float y, float width, float height )
{
Colour colour = Colour.BLACK;
drawQuad( transform, renderer.getBuffer(RenderTypes.TERMINAL_BLOCKER), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );

View File

@ -102,6 +102,20 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
double xSize = origin.getWidth() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER);
double ySize = origin.getHeight() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER);
// // Draw the background blocker
// BufferBuilder buffer = Tessellator.getInstance().getBuffer();
// buffer.begin( VertexFormat.DrawMode.TRIANGLES, VertexFormats.POSITION_COLOR_TEXTURE );
// FixedWidthFontRenderer.drawBlocker( transform.peek().getModel(),
// buffer,
// (float) -TileMonitor.RENDER_MARGIN,
// (float) TileMonitor.RENDER_MARGIN,
// (float) (xSize + 2 * TileMonitor.RENDER_MARGIN),
// (float) -(ySize + TileMonitor.RENDER_MARGIN * 2) );
// // buffer.end();
// Tessellator.getInstance().draw();
// // Set the contents slightly off the surface to prevent z-fighting
// transform.translate( 0.0, 0.0, 0.001 );
// Draw the contents
Terminal terminal = originTerminal.getTerminal();
if( terminal != null )
@ -136,13 +150,17 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
}
else
{
buffer = Tessellator.getInstance().getBuffer();
buffer.begin( VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR_TEXTURE );
FixedWidthFontRenderer.drawEmptyTerminal( transform.peek()
.getModel(),
renderer,
buffer,
-MARGIN,
MARGIN,
(float) (xSize + 2 * MARGIN),
(float) -(ySize + MARGIN * 2) );
// buffer.end();
Tessellator.getInstance().draw();
}
transform.pop();

View File

@ -44,6 +44,7 @@ import dan200.computercraft.shared.turtle.items.ItemTurtle;
import dan200.computercraft.shared.turtle.upgrades.*;
//import dan200.computercraft.shared.util.FixedPointTileEntityType;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder.Factory;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.block.*;
@ -90,31 +91,31 @@ public final class ComputerCraftRegistry
public static final class ModBlocks
{
public static final BlockComputer COMPUTER_NORMAL = register( "computer_normal",
new BlockComputer( properties(), ComputerFamily.NORMAL, ModTiles.COMPUTER_NORMAL ) );
new BlockComputer( properties(), ComputerFamily.NORMAL, ComputerCraftRegistry.ModTiles.COMPUTER_NORMAL ) );
public static final BlockComputer COMPUTER_ADVANCED = register( "computer_advanced",
new BlockComputer( properties(),
ComputerFamily.ADVANCED,
ModTiles.COMPUTER_ADVANCED ) );
ComputerCraftRegistry.ModTiles.COMPUTER_ADVANCED ) );
public static final BlockComputer COMPUTER_COMMAND = register( "computer_command",
new BlockComputer( FabricBlockSettings.copyOf( Blocks.STONE )
.strength( -1, 6000000.0F ),
ComputerFamily.COMMAND,
ModTiles.COMPUTER_COMMAND ) );
ComputerCraftRegistry.ModTiles.COMPUTER_COMMAND ) );
public static final BlockTurtle TURTLE_NORMAL = register( "turtle_normal",
new BlockTurtle( turtleProperties(), ComputerFamily.NORMAL, ModTiles.TURTLE_NORMAL ) );
new BlockTurtle( turtleProperties(), ComputerFamily.NORMAL, ComputerCraftRegistry.ModTiles.TURTLE_NORMAL ) );
public static final BlockTurtle TURTLE_ADVANCED = register( "turtle_advanced",
new BlockTurtle( turtleProperties(), ComputerFamily.ADVANCED, ModTiles.TURTLE_ADVANCED ) );
new BlockTurtle( turtleProperties(), ComputerFamily.ADVANCED, ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED ) );
public static final BlockSpeaker SPEAKER = register( "speaker", new BlockSpeaker( properties() ) );
public static final BlockDiskDrive DISK_DRIVE = register( "disk_drive", new BlockDiskDrive( properties() ) );
public static final BlockPrinter PRINTER = register( "printer", new BlockPrinter( properties() ) );
public static final BlockMonitor MONITOR_NORMAL = register( "monitor_normal", new BlockMonitor( properties(), ModTiles.MONITOR_NORMAL, false ) );
public static final BlockMonitor MONITOR_ADVANCED = register( "monitor_advanced", new BlockMonitor( properties(), ModTiles.MONITOR_ADVANCED, true ) );
public static final BlockWirelessModem WIRELESS_MODEM_NORMAL = register( "wireless_modem_normal",
new BlockWirelessModem( properties(), ModTiles.WIRELESS_MODEM_NORMAL ) );
new BlockWirelessModem( properties(), ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_NORMAL ) );
public static final BlockWirelessModem WIRELESS_MODEM_ADVANCED = register( "wireless_modem_advanced",
new BlockWirelessModem( properties(), ModTiles.WIRELESS_MODEM_ADVANCED ) );
new BlockWirelessModem( properties(), ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_ADVANCED ) );
public static final BlockWiredModemFull WIRED_MODEM_FULL = register( "wired_modem_full",
new BlockWiredModemFull( emProperties(), ModTiles.WIRED_MODEM_FULL ) );
new BlockWiredModemFull( emProperties(), ComputerCraftRegistry.ModTiles.WIRED_MODEM_FULL ) );
public static final BlockCable CABLE = register( "cable", new BlockCable( emProperties() ) );
private static Block.Settings properties()

View File

@ -8,6 +8,7 @@ package dan200.computercraft.shared.peripheral.modem.wireless;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralTile;
import dan200.computercraft.shared.ComputerCraftRegistry.ModTiles;
import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
import dan200.computercraft.shared.peripheral.modem.ModemState;
@ -31,7 +32,7 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile
public TileWirelessModem( BlockEntityType<? extends TileWirelessModem> type, boolean advanced, BlockPos pos, BlockState state )
{
super( type, pos, state );
super( ModTiles.WIRELESS_MODEM_ADVANCED, pos, state );
this.advanced = advanced;
modem = new Peripheral( this );
}