mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-29 21:02:59 +00:00
Merge remote-tracking branch 'origin/fabric' into fabric
This commit is contained in:
@@ -16,6 +16,7 @@ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import dan200.computercraft.core.terminal.TextBuffer;
|
||||
import dan200.computercraft.shared.common.ContainerHeldItem;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
@@ -102,23 +103,23 @@ public class GuiPrintout extends HandledScreen<ContainerHeldItem> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBackground(float partialTicks, int mouseX, int mouseY) {
|
||||
public void drawBackground(MatrixStack stack, float partialTicks, int mouseX, int mouseY) {
|
||||
// Draw the printout
|
||||
GlStateManager.color4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
GlStateManager.enableDepthTest();
|
||||
|
||||
drawBorder(this.x, this.y, blitOffset, this.m_page, this.m_pages, this.m_book);
|
||||
drawBorder(this.x, this.y, getZOffset(), this.m_page, this.m_pages, this.m_book);
|
||||
drawText(this.x + X_TEXT_MARGIN, this.y + Y_TEXT_MARGIN, ItemPrintout.LINES_PER_PAGE * this.m_page, this.m_text, this.m_colours);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
||||
// We must take the background further back in order to not overlap with our printed pages.
|
||||
blitOffset--;
|
||||
renderBackground();
|
||||
blitOffset++;
|
||||
setZOffset(getZOffset() - 1);
|
||||
renderBackground(stack);
|
||||
setZOffset(getZOffset() + 1);
|
||||
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.drawMouseoverTooltip(mouseX, mouseY);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
this.drawMouseoverTooltip(stack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
||||
@@ -43,12 +44,12 @@ public class GuiTurtle extends HandledScreen<ContainerTurtle> {
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
minecraft.keyboard.enableRepeatEvents(true);
|
||||
client.keyboard.setRepeatEvents(true);
|
||||
|
||||
int termPxWidth = ComputerCraft.terminalWidth_turtle * FixedWidthFontRenderer.FONT_WIDTH;
|
||||
int termPxHeight = ComputerCraft.terminalHeight_turtle * FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
|
||||
this.terminal = new WidgetTerminal(minecraft, () -> this.m_computer, ComputerCraft.terminalWidth_turtle, ComputerCraft.terminalHeight_turtle, 2, 2, 2, 2);
|
||||
this.terminal = new WidgetTerminal(client, () -> this.m_computer, ComputerCraft.terminalWidth_turtle, ComputerCraft.terminalHeight_turtle, 2, 2, 2, 2);
|
||||
this.terminalWrapper = new WidgetWrapper(this.terminal, 2 + 8 + this.x, 2 + 8 + this.y, termPxWidth, termPxHeight);
|
||||
|
||||
this.children.add(this.terminalWrapper);
|
||||
@@ -79,7 +80,7 @@ public class GuiTurtle extends HandledScreen<ContainerTurtle> {
|
||||
super.removed();
|
||||
this.children.remove(this.terminal);
|
||||
this.terminal = null;
|
||||
minecraft.keyboard.enableRepeatEvents(false);
|
||||
client.keyboard.setRepeatEvents(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,37 +90,37 @@ public class GuiTurtle extends HandledScreen<ContainerTurtle> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawBackground(float partialTicks, int mouseX, int mouseY) {
|
||||
protected void drawBackground(MatrixStack stack, float partialTicks, int mouseX, int mouseY) {
|
||||
// Draw term
|
||||
boolean advanced = this.m_family == ComputerFamily.Advanced;
|
||||
this.terminal.draw(this.terminalWrapper.getX(), this.terminalWrapper.getY());
|
||||
|
||||
// Draw border/inventory
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
minecraft.getTextureManager()
|
||||
client.getTextureManager()
|
||||
.bindTextureInner(advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL);
|
||||
blit(this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
drawTexture(stack, this.x, this.y, 0, 0, this.backgroundWidth, this.backgroundHeight);
|
||||
|
||||
this.drawSelectionSlot(advanced);
|
||||
this.drawSelectionSlot(stack, advanced);
|
||||
}
|
||||
|
||||
private void drawSelectionSlot(boolean advanced) {
|
||||
private void drawSelectionSlot(MatrixStack stack, boolean advanced) {
|
||||
// Draw selection slot
|
||||
int slot = this.m_container.getSelectedSlot();
|
||||
if (slot >= 0) {
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int slotX = slot % 4;
|
||||
int slotY = slot / 4;
|
||||
minecraft.getTextureManager()
|
||||
client.getTextureManager()
|
||||
.bindTextureInner(advanced ? BACKGROUND_ADVANCED : BACKGROUND_NORMAL);
|
||||
blit(this.x + this.m_container.m_turtleInvStartX - 2 + slotX * 18, this.y + this.m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24);
|
||||
drawTexture(stack, this.x + this.m_container.m_turtleInvStartX - 2 + slotX * 18, this.y + this.m_container.m_playerInvStartY - 2 + slotY * 18, 0, 217, 24, 24);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground();
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.drawMouseoverTooltip(mouseX, mouseY);
|
||||
public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground(stack);
|
||||
super.render(stack, mouseX, mouseY, partialTicks);
|
||||
this.drawMouseoverTooltip(stack, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import dan200.computercraft.shared.computer.core.ClientComputer;
|
||||
import dan200.computercraft.shared.computer.core.IComputer;
|
||||
import dan200.computercraft.shared.util.Colour;
|
||||
import dan200.computercraft.shared.util.Palette;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -30,6 +32,7 @@ import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class WidgetTerminal implements Element {
|
||||
private static final float TERMINATE_TIME = 0.5f;
|
||||
|
||||
@@ -410,16 +413,16 @@ public class WidgetTerminal implements Element {
|
||||
BufferBuilder buffer = tesslector.getBuffer();
|
||||
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_TEXTURE);
|
||||
buffer.vertex(x, y + height, 0)
|
||||
.texture(0 / 256.0, height / 256.0)
|
||||
.texture(0 / 256.0f, height / 256.0f)
|
||||
.next();
|
||||
buffer.vertex(x + width, y + height, 0)
|
||||
.texture(width / 256.0, height / 256.0)
|
||||
.texture(width / 256.0f, height / 256.f)
|
||||
.next();
|
||||
buffer.vertex(x + width, y, 0)
|
||||
.texture(width / 256.0, 0 / 256.0)
|
||||
.texture(width / 256.0f, 0 / 256.0f)
|
||||
.next();
|
||||
buffer.vertex(x, y, 0)
|
||||
.texture(0 / 256.0, 0 / 256.0)
|
||||
.texture(0 / 256.0f, 0 / 256.0f)
|
||||
.next();
|
||||
tesslector.draw();
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user