mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-24 10:27:38 +00:00
Remove QuadEmitter
And remove EMI support. I'm not sure it survived the 1.21.4 recipe changes :(.
This commit is contained in:
@@ -50,7 +50,6 @@ repositories {
|
||||
includeGroup("com.simibubi.create")
|
||||
includeGroup("net.commoble.morered")
|
||||
includeGroup("dev.architectury")
|
||||
includeGroup("dev.emi")
|
||||
includeGroup("maven.modrinth")
|
||||
includeGroup("me.shedaniel.cloth")
|
||||
includeGroup("me.shedaniel")
|
||||
|
||||
@@ -36,7 +36,6 @@ kotlin-coroutines = "1.10.1"
|
||||
nightConfig = "3.8.1"
|
||||
|
||||
# Minecraft mods
|
||||
emi = "1.1.7+1.21"
|
||||
fabricPermissions = "0.3.3"
|
||||
iris-fabric = "1.9.1+1.21.7-fabric"
|
||||
iris-forge = "1.9.1+1.21.7-neoforge"
|
||||
@@ -106,7 +105,6 @@ slf4j = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
|
||||
# Minecraft mods
|
||||
create-fabric = { module = "com.simibubi.create:create-fabric-1.20.1", version.ref = "create-fabric" }
|
||||
create-forge = { module = "com.simibubi.create:create-1.21.1", version.ref = "create-forge" }
|
||||
emi = { module = "dev.emi:emi-xplat-mojmap", version.ref = "emi" }
|
||||
fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }
|
||||
fabric-junit = { module = "net.fabricmc:fabric-loader-junit", version.ref = "fabric-loader" }
|
||||
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
|
||||
|
||||
@@ -11,12 +11,6 @@ plugins {
|
||||
id("cc-tweaked.publishing")
|
||||
}
|
||||
|
||||
sourceSets.client {
|
||||
java {
|
||||
exclude("dan200/computercraft/client/integration/emi")
|
||||
}
|
||||
}
|
||||
|
||||
minecraft {
|
||||
accessWideners(
|
||||
"src/main/resources/computercraft.accesswidener",
|
||||
@@ -45,7 +39,6 @@ dependencies {
|
||||
compileOnly(libs.mixin)
|
||||
compileOnly(libs.mixinExtra)
|
||||
compileOnly(libs.bundles.externalMods.common)
|
||||
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
|
||||
|
||||
annotationProcessorEverywhere(libs.autoService)
|
||||
testFixturesAnnotationProcessor(libs.autoService)
|
||||
|
||||
@@ -189,7 +189,6 @@ public final class PrintoutScreen extends AbstractContainerScreen<PrintoutMenu>
|
||||
var buffer = bufferSource.getBuffer(PrintoutRenderer.BACKGROUND);
|
||||
drawBorder(pose.last().pose(), buffer, 0, 0, 0, state.page(), state.printout().pages(), state.printout().book(), LightTexture.FULL_BRIGHT);
|
||||
|
||||
// TODO: This can probably be shifted into a separate one now.
|
||||
drawText(
|
||||
pose, bufferSource, X_TEXT_MARGIN, Y_TEXT_MARGIN, PrintoutData.LINES_PER_PAGE * state.page(), LightTexture.FULL_BRIGHT,
|
||||
state.printout().text(), state.printout().colour()
|
||||
|
||||
@@ -310,9 +310,8 @@ public class TerminalWidget extends AbstractWidget {
|
||||
@Nullable ScreenRectangle scissorArea
|
||||
) implements GuiElementRenderState {
|
||||
@Override
|
||||
public void buildVertices(VertexConsumer vertexConsumer) {
|
||||
var quads = new FixedWidthFontRenderer.QuadEmitter(new Matrix4f().mul(pose), vertexConsumer);
|
||||
FixedWidthFontRenderer.drawTerminalBackground(quads, x, y, terminal, MARGIN, MARGIN, MARGIN, MARGIN);
|
||||
public void buildVertices(VertexConsumer buffer) {
|
||||
FixedWidthFontRenderer.drawTerminalBackground(new Matrix4f().mul(pose), buffer, x, y, terminal, MARGIN, MARGIN, MARGIN, MARGIN);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -326,14 +325,14 @@ public class TerminalWidget extends AbstractWidget {
|
||||
@Nullable ScreenRectangle bounds, @Nullable ScreenRectangle scissorArea
|
||||
) implements GuiElementRenderState {
|
||||
@Override
|
||||
public void buildVertices(VertexConsumer vertexConsumer) {
|
||||
var quads = new FixedWidthFontRenderer.QuadEmitter(new Matrix4f().mul(pose), vertexConsumer);
|
||||
FixedWidthFontRenderer.drawTerminalForeground(quads, x, y, terminal);
|
||||
FixedWidthFontRenderer.drawCursor(quads, x, y, terminal);
|
||||
public void buildVertices(VertexConsumer buffer) {
|
||||
var transform = new Matrix4f().mul(pose);
|
||||
FixedWidthFontRenderer.drawTerminalForeground(transform, buffer, x, y, terminal);
|
||||
FixedWidthFontRenderer.drawCursor(transform, buffer, x, y, terminal);
|
||||
|
||||
// The GUI renderer requires that the buffer is non-empty. Add a zero-size vertex so we always have something.
|
||||
for (var i = 0; i < 4; i++) {
|
||||
vertexConsumer.addVertex(0, 0, 0).setColor(0x00ffffff).setUv(0, 0).setLight(LightTexture.FULL_BRIGHT);
|
||||
buffer.addVertex(0, 0, 0).setColor(0x00ffffff).setUv(0, 0).setLight(LightTexture.FULL_BRIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2023 The CC: Tweaked Developers
|
||||
//
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
package dan200.computercraft.client.integration.emi;
|
||||
|
||||
import dan200.computercraft.api.turtle.TurtleSide;
|
||||
import dan200.computercraft.shared.ModRegistry;
|
||||
import dan200.computercraft.shared.integration.RecipeModHelpers;
|
||||
import dan200.computercraft.shared.pocket.items.PocketComputerItem;
|
||||
import dan200.computercraft.shared.turtle.items.TurtleItem;
|
||||
import dev.emi.emi.api.EmiEntrypoint;
|
||||
import dev.emi.emi.api.EmiPlugin;
|
||||
import dev.emi.emi.api.EmiRegistry;
|
||||
import dev.emi.emi.api.stack.Comparison;
|
||||
import dev.emi.emi.api.stack.EmiStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
@EmiEntrypoint
|
||||
public class EMIComputerCraft implements EmiPlugin {
|
||||
@Override
|
||||
public void register(EmiRegistry registry) {
|
||||
registry.setDefaultComparison(ModRegistry.Items.TURTLE_NORMAL.get(), turtleComparison);
|
||||
registry.setDefaultComparison(ModRegistry.Items.TURTLE_ADVANCED.get(), turtleComparison);
|
||||
|
||||
registry.setDefaultComparison(ModRegistry.Items.POCKET_COMPUTER_NORMAL.get(), pocketComparison);
|
||||
registry.setDefaultComparison(ModRegistry.Items.POCKET_COMPUTER_ADVANCED.get(), pocketComparison);
|
||||
|
||||
for (var stack : RecipeModHelpers.getExtraStacks(Minecraft.getInstance().level.registryAccess())) {
|
||||
registry.addEmiStack(EmiStack.of(stack));
|
||||
}
|
||||
}
|
||||
|
||||
private static final Comparison turtleComparison = compareStacks((left, right)
|
||||
-> TurtleItem.getUpgrade(left, TurtleSide.LEFT) == TurtleItem.getUpgrade(right, TurtleSide.LEFT)
|
||||
&& TurtleItem.getUpgrade(left, TurtleSide.RIGHT) == TurtleItem.getUpgrade(right, TurtleSide.RIGHT));
|
||||
|
||||
private static final Comparison pocketComparison = compareStacks((left, right) -> PocketComputerItem.getUpgrade(left) == PocketComputerItem.getUpgrade(right));
|
||||
|
||||
private static Comparison compareStacks(BiPredicate<ItemStack, ItemStack> test) {
|
||||
return Comparison.of((left, right) -> {
|
||||
ItemStack leftStack = left.getItemStack(), rightStack = right.getItemStack();
|
||||
return leftStack.getItem() == rightStack.getItem() && test.test(leftStack, rightStack);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -142,10 +142,8 @@ public class CustomLecternRenderer implements BlockEntityRenderer<CustomLecternB
|
||||
var marginX = ((LecternPocketModel.TERM_WIDTH / scale) - width) / 2;
|
||||
var marginY = ((LecternPocketModel.TERM_HEIGHT / scale) - height) / 2;
|
||||
|
||||
collector.submitCustomGeometry(poseStack, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) -> {
|
||||
var quadEmitter = new FixedWidthFontRenderer.QuadEmitter(pose.pose(), buffer);
|
||||
FixedWidthFontRenderer.drawTerminal(quadEmitter, marginX, marginY, terminal, marginY, marginY, marginX, marginX);
|
||||
});
|
||||
collector.submitCustomGeometry(poseStack, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) ->
|
||||
FixedWidthFontRenderer.drawTerminal(pose.pose(), buffer, marginX, marginY, terminal, marginY, marginY, marginX, marginX));
|
||||
}
|
||||
|
||||
private enum Type {
|
||||
|
||||
@@ -85,10 +85,8 @@ public final class PocketItemRenderer extends ItemMapLikeRenderer {
|
||||
if (terminal == null) {
|
||||
FixedWidthFontRenderer.drawEmptyTerminal(transform, collector, 0, 0, width, height);
|
||||
} else {
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) -> {
|
||||
var quadEmitter = new FixedWidthFontRenderer.QuadEmitter(pose.pose(), buffer);
|
||||
FixedWidthFontRenderer.drawTerminal(quadEmitter, MARGIN, MARGIN, terminal, MARGIN, MARGIN, MARGIN, MARGIN);
|
||||
});
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) ->
|
||||
FixedWidthFontRenderer.drawTerminal(pose.pose(), buffer, MARGIN, MARGIN, terminal, MARGIN, MARGIN, MARGIN, MARGIN));
|
||||
}
|
||||
|
||||
transform.popPose();
|
||||
@@ -162,7 +160,7 @@ public final class PocketItemRenderer extends ItemMapLikeRenderer {
|
||||
|
||||
private static void renderLight(PoseStack transform, SubmitNodeCollector render, int colour, int width, int height) {
|
||||
render.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) -> FixedWidthFontRenderer.drawQuad(
|
||||
new FixedWidthFontRenderer.QuadEmitter(pose.pose(), buffer),
|
||||
pose.pose(), buffer,
|
||||
width - LIGHT_HEIGHT * 2, height + BORDER / 2.0f, 0.001f, LIGHT_HEIGHT * 2, LIGHT_HEIGHT,
|
||||
ARGB.opaque(colour), LightTexture.FULL_BRIGHT
|
||||
));
|
||||
|
||||
@@ -74,9 +74,9 @@ public final class PrintoutRenderer {
|
||||
|
||||
public static void drawText(PoseStack transform, MultiBufferSource bufferSource, int x, int y, int start, int light, TextBuffer[] text, TextBuffer[] colours) {
|
||||
var buffer = bufferSource.getBuffer(FixedWidthFontRenderer.TERMINAL_TEXT);
|
||||
var emitter = FixedWidthFontRenderer.toVertexConsumer(transform, buffer);
|
||||
for (var line = 0; line < LINES_PER_PAGE && line < text.length; line++) {
|
||||
FixedWidthFontRenderer.drawString(emitter,
|
||||
FixedWidthFontRenderer.drawString(
|
||||
transform.last().pose(), buffer,
|
||||
x, y + line * FONT_HEIGHT, text[start + line], colours[start + line],
|
||||
Palette.DEFAULT, light
|
||||
);
|
||||
@@ -84,10 +84,10 @@ public final class PrintoutRenderer {
|
||||
}
|
||||
|
||||
public static void drawText(Matrix4f matrix4f, VertexConsumer buffer, int x, int y, int start, int light, List<PrintoutData.Line> lines) {
|
||||
var emitter = new FixedWidthFontRenderer.QuadEmitter(matrix4f, buffer);
|
||||
for (var line = 0; line < LINES_PER_PAGE && line < lines.size(); line++) {
|
||||
var lineContents = lines.get(start + line);
|
||||
FixedWidthFontRenderer.drawString(emitter,
|
||||
FixedWidthFontRenderer.drawString(
|
||||
matrix4f, buffer,
|
||||
x, y + line * FONT_HEIGHT,
|
||||
new TextBuffer(lineContents.text()), new TextBuffer(lineContents.foreground()),
|
||||
Palette.DEFAULT, light
|
||||
|
||||
@@ -88,18 +88,14 @@ public class MonitorBlockEntityRenderer implements BlockEntityRenderer<MonitorBl
|
||||
transform.scale((float) xScale, (float) -yScale, 1.0f);
|
||||
|
||||
var xMargin = (float) (MARGIN / xScale);
|
||||
var yMagin = (float) (MARGIN / yScale);
|
||||
var yMargin = (float) (MARGIN / yScale);
|
||||
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, consumer) -> {
|
||||
FixedWidthFontRenderer.drawTerminalBackground(
|
||||
new FixedWidthFontRenderer.QuadEmitter(pose.pose(), consumer),
|
||||
0, 0, terminal, yMagin, yMagin, xMargin, xMargin
|
||||
);
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) -> {
|
||||
FixedWidthFontRenderer.drawTerminalBackground(pose.pose(), buffer, 0, 0, terminal, yMargin, yMargin, xMargin, xMargin);
|
||||
});
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT_OFFSET, (pose, consumer) -> {
|
||||
var sink = new FixedWidthFontRenderer.QuadEmitter(pose.pose(), consumer);
|
||||
FixedWidthFontRenderer.drawTerminalForeground(sink, 0, 0, terminal);
|
||||
FixedWidthFontRenderer.drawCursor(sink, 0, 0, terminal);
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT_OFFSET, (pose, buffer) -> {
|
||||
FixedWidthFontRenderer.drawTerminalForeground(pose.pose(), buffer, 0, 0, terminal);
|
||||
FixedWidthFontRenderer.drawCursor(pose.pose(), buffer, 0, 0, terminal);
|
||||
});
|
||||
|
||||
transform.popPose();
|
||||
|
||||
@@ -68,7 +68,7 @@ public final class FixedWidthFontRenderer {
|
||||
return 15 - Terminal.getColour(c, def);
|
||||
}
|
||||
|
||||
private static void drawChar(QuadEmitter emitter, float x, float y, int index, int colour, int light) {
|
||||
private static void drawChar(Matrix4f matrix, VertexConsumer buffer, float x, float y, int index, int colour, int light) {
|
||||
// Short circuit to avoid the common case - the texture should be blank here after all.
|
||||
if (index == '\0' || index == ' ') return;
|
||||
|
||||
@@ -79,30 +79,30 @@ public final class FixedWidthFontRenderer {
|
||||
var yStart = 1 + row * (FONT_HEIGHT + 2);
|
||||
|
||||
quad(
|
||||
emitter, x, y, x + FONT_WIDTH, y + FONT_HEIGHT, 0, colour,
|
||||
matrix, buffer, x, y, x + FONT_WIDTH, y + FONT_HEIGHT, 0, colour,
|
||||
xStart / WIDTH, yStart / WIDTH, (xStart + FONT_WIDTH) / WIDTH, (yStart + FONT_HEIGHT) / WIDTH, light
|
||||
);
|
||||
}
|
||||
|
||||
public static void drawQuad(QuadEmitter emitter, float x, float y, float z, float width, float height, int colour, int light) {
|
||||
quad(emitter, x, y, x + width, y + height, z, colour, BACKGROUND_START, BACKGROUND_START, BACKGROUND_END, BACKGROUND_END, light);
|
||||
public static void drawQuad(Matrix4f matrix, VertexConsumer buffer, float x, float y, float z, float width, float height, int colour, int light) {
|
||||
quad(matrix, buffer, x, y, x + width, y + height, z, colour, BACKGROUND_START, BACKGROUND_START, BACKGROUND_END, BACKGROUND_END, light);
|
||||
}
|
||||
|
||||
private static void drawQuad(QuadEmitter emitter, float x, float y, float width, float height, Palette palette, char colourIndex, int light) {
|
||||
private static void drawQuad(Matrix4f matrix, VertexConsumer buffer, float x, float y, float width, float height, Palette palette, char colourIndex, int light) {
|
||||
var colour = palette.getRenderColours(getColour(colourIndex, Colour.BLACK));
|
||||
drawQuad(emitter, x, y, 0, width, height, colour, light);
|
||||
drawQuad(matrix, buffer, x, y, 0, width, height, colour, light);
|
||||
}
|
||||
|
||||
private static void drawBackground(
|
||||
QuadEmitter emitter, float x, float y, TextBuffer backgroundColour, Palette palette,
|
||||
Matrix4f matrix, VertexConsumer buffer, float x, float y, TextBuffer backgroundColour, Palette palette,
|
||||
float leftMarginSize, float rightMarginSize, float height, int light
|
||||
) {
|
||||
if (leftMarginSize > 0) {
|
||||
drawQuad(emitter, x - leftMarginSize, y, leftMarginSize, height, palette, backgroundColour.charAt(0), light);
|
||||
drawQuad(matrix, buffer, x - leftMarginSize, y, leftMarginSize, height, palette, backgroundColour.charAt(0), light);
|
||||
}
|
||||
|
||||
if (rightMarginSize > 0) {
|
||||
drawQuad(emitter, x + backgroundColour.length() * FONT_WIDTH, y, rightMarginSize, height, palette, backgroundColour.charAt(backgroundColour.length() - 1), light);
|
||||
drawQuad(matrix, buffer, x + backgroundColour.length() * FONT_WIDTH, y, rightMarginSize, height, palette, backgroundColour.charAt(backgroundColour.length() - 1), light);
|
||||
}
|
||||
|
||||
// Batch together runs of identical background cells.
|
||||
@@ -113,7 +113,7 @@ public final class FixedWidthFontRenderer {
|
||||
if (colourIndex == blockColour) continue;
|
||||
|
||||
if (blockColour != '\0') {
|
||||
drawQuad(emitter, x + blockStart * FONT_WIDTH, y, FONT_WIDTH * (i - blockStart), height, palette, blockColour, light);
|
||||
drawQuad(matrix, buffer, x + blockStart * FONT_WIDTH, y, FONT_WIDTH * (i - blockStart), height, palette, blockColour, light);
|
||||
}
|
||||
|
||||
blockColour = colourIndex;
|
||||
@@ -121,22 +121,22 @@ public final class FixedWidthFontRenderer {
|
||||
}
|
||||
|
||||
if (blockColour != '\0') {
|
||||
drawQuad(emitter, x + blockStart * FONT_WIDTH, y, FONT_WIDTH * (backgroundColour.length() - blockStart), height, palette, blockColour, light);
|
||||
drawQuad(matrix, buffer, x + blockStart * FONT_WIDTH, y, FONT_WIDTH * (backgroundColour.length() - blockStart), height, palette, blockColour, light);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawString(QuadEmitter emitter, float x, float y, TextBuffer text, TextBuffer textColour, Palette palette, int light) {
|
||||
public static void drawString(Matrix4f matrix, VertexConsumer buffer, float x, float y, TextBuffer text, TextBuffer textColour, Palette palette, int light) {
|
||||
for (var i = 0; i < text.length(); i++) {
|
||||
var colour = palette.getRenderColours(getColour(textColour.charAt(i), Colour.BLACK));
|
||||
|
||||
int index = text.charAt(i);
|
||||
if (index > 255) index = '?';
|
||||
drawChar(emitter, x + i * FONT_WIDTH, y, index, colour, light);
|
||||
drawChar(matrix, buffer, x + i * FONT_WIDTH, y, index, colour, light);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void drawTerminalForeground(QuadEmitter emitter, float x, float y, Terminal terminal) {
|
||||
public static void drawTerminalForeground(Matrix4f matrix, VertexConsumer buffer, float x, float y, Terminal terminal) {
|
||||
var palette = terminal.getPalette();
|
||||
var height = terminal.getHeight();
|
||||
|
||||
@@ -144,14 +144,14 @@ public final class FixedWidthFontRenderer {
|
||||
for (var i = 0; i < height; i++) {
|
||||
var rowY = y + FONT_HEIGHT * i;
|
||||
drawString(
|
||||
emitter, x, rowY, terminal.getLine(i), terminal.getTextColourLine(i),
|
||||
matrix, buffer, x, rowY, terminal.getLine(i), terminal.getTextColourLine(i),
|
||||
palette, LightTexture.FULL_BRIGHT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTerminalBackground(
|
||||
QuadEmitter emitter, float x, float y, Terminal terminal,
|
||||
Matrix4f matrix, VertexConsumer buffer, float x, float y, Terminal terminal,
|
||||
float topMarginSize, float bottomMarginSize, float leftMarginSize, float rightMarginSize
|
||||
) {
|
||||
var palette = terminal.getPalette();
|
||||
@@ -159,12 +159,12 @@ public final class FixedWidthFontRenderer {
|
||||
|
||||
// Top and bottom margins
|
||||
drawBackground(
|
||||
emitter, x, y - topMarginSize, terminal.getBackgroundColourLine(0), palette,
|
||||
matrix, buffer, x, y - topMarginSize, terminal.getBackgroundColourLine(0), palette,
|
||||
leftMarginSize, rightMarginSize, topMarginSize, LightTexture.FULL_BRIGHT
|
||||
);
|
||||
|
||||
drawBackground(
|
||||
emitter, x, y + height * FONT_HEIGHT, terminal.getBackgroundColourLine(height - 1), palette,
|
||||
matrix, buffer, x, y + height * FONT_HEIGHT, terminal.getBackgroundColourLine(height - 1), palette,
|
||||
leftMarginSize, rightMarginSize, bottomMarginSize, LightTexture.FULL_BRIGHT
|
||||
);
|
||||
|
||||
@@ -172,7 +172,7 @@ public final class FixedWidthFontRenderer {
|
||||
for (var i = 0; i < height; i++) {
|
||||
var rowY = y + FONT_HEIGHT * i;
|
||||
drawBackground(
|
||||
emitter, x, rowY, terminal.getBackgroundColourLine(i), palette,
|
||||
matrix, buffer, x, rowY, terminal.getBackgroundColourLine(i), palette,
|
||||
leftMarginSize, rightMarginSize, FONT_HEIGHT, LightTexture.FULL_BRIGHT
|
||||
);
|
||||
}
|
||||
@@ -186,55 +186,40 @@ public final class FixedWidthFontRenderer {
|
||||
return cursorX >= 0 && cursorX < terminal.getWidth() && cursorY >= 0 && cursorY < terminal.getHeight();
|
||||
}
|
||||
|
||||
public static void drawCursor(QuadEmitter emitter, float x, float y, Terminal terminal) {
|
||||
public static void drawCursor(Matrix4f matrix, VertexConsumer buffer, float x, float y, Terminal terminal) {
|
||||
if (isCursorVisible(terminal) && FrameInfo.getGlobalCursorBlink()) {
|
||||
var colour = terminal.getPalette().getRenderColours(15 - terminal.getTextColour());
|
||||
drawChar(emitter, x + terminal.getCursorX() * FONT_WIDTH, y + terminal.getCursorY() * FONT_HEIGHT, '_', colour, LightTexture.FULL_BRIGHT);
|
||||
drawChar(matrix, buffer, x + terminal.getCursorX() * FONT_WIDTH, y + terminal.getCursorY() * FONT_HEIGHT, '_', colour, LightTexture.FULL_BRIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawTerminal(
|
||||
QuadEmitter emitter, float x, float y, Terminal terminal,
|
||||
Matrix4f matrix, VertexConsumer buffer, float x, float y, Terminal terminal,
|
||||
float topMarginSize, float bottomMarginSize, float leftMarginSize, float rightMarginSize
|
||||
) {
|
||||
drawTerminalBackground(
|
||||
emitter, x, y, terminal,
|
||||
matrix, buffer, x, y, terminal,
|
||||
topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize
|
||||
);
|
||||
|
||||
// Render the foreground with a slight offset. By calling .translate() on the matrix itself, we're translating
|
||||
// in screen space, rather than in model/view space.
|
||||
// It's definitely not perfect, but better than z fighting!
|
||||
var transformBackup = new Matrix4f(emitter.poseMatrix());
|
||||
emitter.poseMatrix().translate(new Vector3f(0, 0, Z_OFFSET));
|
||||
var offsetMatrix = new Matrix4f(matrix).translate(new Vector3f(0, 0, Z_OFFSET));
|
||||
|
||||
drawTerminalForeground(emitter, x, y, terminal);
|
||||
drawCursor(emitter, x, y, terminal);
|
||||
|
||||
emitter.poseMatrix().set(transformBackup);
|
||||
drawTerminalForeground(offsetMatrix, buffer, x, y, terminal);
|
||||
drawCursor(offsetMatrix, buffer, x, y, terminal);
|
||||
}
|
||||
|
||||
public static void drawEmptyTerminal(PoseStack transform, SubmitNodeCollector collector, float x, float y, float width, float height) {
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) -> {
|
||||
var quadEmitter = new FixedWidthFontRenderer.QuadEmitter(pose.pose(), buffer);
|
||||
drawQuad(quadEmitter, x, y, 0, width, height, BLACK, LightTexture.FULL_BRIGHT);
|
||||
});
|
||||
collector.submitCustomGeometry(transform, FixedWidthFontRenderer.TERMINAL_TEXT, (pose, buffer) ->
|
||||
drawQuad(pose.pose(), buffer, x, y, 0, width, height, BLACK, LightTexture.FULL_BRIGHT));
|
||||
}
|
||||
|
||||
public record QuadEmitter(Matrix4f poseMatrix, VertexConsumer consumer) {
|
||||
}
|
||||
|
||||
public static QuadEmitter toVertexConsumer(PoseStack transform, VertexConsumer consumer) {
|
||||
return new QuadEmitter(transform.last().pose(), consumer);
|
||||
}
|
||||
|
||||
private static void quad(QuadEmitter c, float x1, float y1, float x2, float y2, float z, int colour, float u1, float v1, float u2, float v2, int light) {
|
||||
var poseMatrix = c.poseMatrix();
|
||||
var consumer = c.consumer();
|
||||
|
||||
consumer.addVertex(poseMatrix, x1, y1, z).setColor(colour).setUv(u1, v1).setLight(light);
|
||||
consumer.addVertex(poseMatrix, x1, y2, z).setColor(colour).setUv(u1, v2).setLight(light);
|
||||
consumer.addVertex(poseMatrix, x2, y2, z).setColor(colour).setUv(u2, v2).setLight(light);
|
||||
consumer.addVertex(poseMatrix, x2, y1, z).setColor(colour).setUv(u2, v1).setLight(light);
|
||||
private static void quad(Matrix4f matrix, VertexConsumer buffer, float x1, float y1, float x2, float y2, float z, int colour, float u1, float v1, float u2, float v2, int light) {
|
||||
buffer.addVertex(matrix, x1, y1, z).setColor(colour).setUv(u1, v1).setLight(light);
|
||||
buffer.addVertex(matrix, x1, y2, z).setColor(colour).setUv(u1, v2).setLight(light);
|
||||
buffer.addVertex(matrix, x2, y2, z).setColor(colour).setUv(u2, v2).setLight(light);
|
||||
buffer.addVertex(matrix, x2, y1, z).setColor(colour).setUv(u2, v1).setLight(light);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
|
||||
modCompileOnly(libs.bundles.externalMods.fabric.compile) {
|
||||
exclude("net.fabricmc", "fabric-loader")
|
||||
exclude("net.fabricmc.fabric-api")
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
],
|
||||
"rei_client": [
|
||||
"dan200.computercraft.client.integration.rei.REIComputerCraftClient"
|
||||
],
|
||||
"emi": [
|
||||
"dan200.computercraft.client.integration.emi.EMIComputerCraft"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
@@ -148,7 +148,6 @@ dependencies {
|
||||
compileOnly(libs.jetbrainsAnnotations)
|
||||
annotationProcessorEverywhere(libs.autoService)
|
||||
|
||||
clientCompileOnly(variantOf(libs.emi) { classifier("api") })
|
||||
compileOnly(libs.bundles.externalMods.forge.compile)
|
||||
clientRuntimeOnly(libs.bundles.externalMods.forge.runtime)
|
||||
compileOnly(libs.create.forge) { isTransitive = false }
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.neoforged.neoforge.common.util.FakePlayer;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
@@ -22,6 +23,9 @@ class FakePlayerExt extends FakePlayer {
|
||||
FakePlayerExt(ServerLevel serverLevel, GameProfile profile) {
|
||||
super(serverLevel, profile);
|
||||
refreshDimensions();
|
||||
// Force the player to be in survival. Only needed for NF, as Fabric does this by default.
|
||||
// TODO: Remove once https://github.com/neoforged/NeoForge/pull/2730 is merged.
|
||||
gameMode.changeGameModeForPlayer(GameType.SURVIVAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user