2017-05-07 00:18:59 +00:00
|
|
|
/*
|
2017-05-01 13:32:39 +00:00
|
|
|
* This file is part of ComputerCraft - http://www.computercraft.info
|
2019-01-01 01:10:18 +00:00
|
|
|
* Copyright Daniel Ratcliffe, 2011-2019. Do not distribute without permission.
|
2017-05-01 13:32:39 +00:00
|
|
|
* Send enquiries to dratcliffe@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
package dan200.computercraft.client.render;
|
|
|
|
|
2018-12-27 11:58:08 +00:00
|
|
|
import dan200.computercraft.client.FrameInfo;
|
2017-05-01 13:32:39 +00:00
|
|
|
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
|
|
|
|
import dan200.computercraft.core.terminal.Terminal;
|
|
|
|
import dan200.computercraft.core.terminal.TextBuffer;
|
2018-02-14 21:21:00 +00:00
|
|
|
import dan200.computercraft.shared.peripheral.monitor.ClientMonitor;
|
2017-05-01 13:32:39 +00:00
|
|
|
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
|
|
|
import dan200.computercraft.shared.util.Colour;
|
|
|
|
import dan200.computercraft.shared.util.DirectionUtil;
|
2017-05-05 13:24:29 +00:00
|
|
|
import dan200.computercraft.shared.util.Palette;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.client.Minecraft;
|
2017-06-12 08:14:57 +00:00
|
|
|
import net.minecraft.client.renderer.BufferBuilder;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2018-03-30 11:57:27 +00:00
|
|
|
import net.minecraft.client.renderer.OpenGlHelper;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
2017-05-01 13:32:39 +00:00
|
|
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
2017-05-04 21:38:24 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2017-05-01 13:32:39 +00:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
public class TileEntityMonitorRenderer extends TileEntityRenderer<TileMonitor>
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
@Override
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
public void render( TileMonitor tileEntity, double posX, double posY, double posZ, float f, int i )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
if( tileEntity != null )
|
|
|
|
{
|
|
|
|
renderMonitorAt( tileEntity, posX, posY, posZ, f, i );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 21:21:39 +00:00
|
|
|
private static void renderMonitorAt( TileMonitor monitor, double posX, double posY, double posZ, float f, int i )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
// Render from the origin monitor
|
2018-02-14 21:21:00 +00:00
|
|
|
ClientMonitor originTerminal = monitor.getClientMonitor();
|
|
|
|
|
|
|
|
if( originTerminal == null ) return;
|
|
|
|
TileMonitor origin = originTerminal.getOrigin();
|
2018-03-29 11:31:20 +00:00
|
|
|
BlockPos monitorPos = monitor.getPos();
|
2017-05-01 13:32:39 +00:00
|
|
|
|
2018-03-29 11:31:20 +00:00
|
|
|
// Ensure each monitor terminal is rendered only once. We allow rendering a specific tile
|
2018-12-23 17:46:58 +00:00
|
|
|
// multiple times in a single frame to ensure compatibility with shaders which may run a
|
2018-03-29 11:31:20 +00:00
|
|
|
// pass multiple times.
|
2019-01-12 16:27:40 +00:00
|
|
|
long renderFrame = FrameInfo.getRenderFrame();
|
2018-03-29 11:31:20 +00:00
|
|
|
if( originTerminal.lastRenderFrame == renderFrame && !monitorPos.equals( originTerminal.lastRenderPos ) )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-29 11:31:20 +00:00
|
|
|
originTerminal.lastRenderFrame = renderFrame;
|
|
|
|
originTerminal.lastRenderPos = monitorPos;
|
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
BlockPos originPos = origin.getPos();
|
|
|
|
posX += originPos.getX() - monitorPos.getX();
|
|
|
|
posY += originPos.getY() - monitorPos.getY();
|
|
|
|
posZ += originPos.getZ() - monitorPos.getZ();
|
|
|
|
|
|
|
|
// Determine orientation
|
|
|
|
EnumFacing dir = origin.getDirection();
|
|
|
|
EnumFacing front = origin.getFront();
|
2018-12-26 09:29:41 +00:00
|
|
|
float yaw = dir.getHorizontalAngle();
|
2017-05-01 13:32:39 +00:00
|
|
|
float pitch = DirectionUtil.toPitchAngle( front );
|
|
|
|
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
// Setup initial transform
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.translated( posX + 0.5, posY + 0.5, posZ + 0.5 );
|
|
|
|
GlStateManager.rotatef( -yaw, 0.0f, 1.0f, 0.0f );
|
|
|
|
GlStateManager.rotatef( pitch, 1.0f, 0.0f, 0.0f );
|
|
|
|
GlStateManager.translated(
|
2017-05-01 13:32:39 +00:00
|
|
|
-0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN,
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0,
|
2017-05-01 13:32:39 +00:00
|
|
|
0.5
|
|
|
|
);
|
2018-12-23 17:46:58 +00:00
|
|
|
double xSize = origin.getWidth() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER);
|
|
|
|
double ySize = origin.getHeight() - 2.0 * (TileMonitor.RENDER_MARGIN + TileMonitor.RENDER_BORDER);
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Get renderers
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
Minecraft mc = Minecraft.getInstance();
|
2017-05-01 13:32:39 +00:00
|
|
|
Tessellator tessellator = Tessellator.getInstance();
|
2017-06-12 08:14:57 +00:00
|
|
|
BufferBuilder renderer = tessellator.getBuffer();
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Get terminal
|
2018-02-21 14:32:53 +00:00
|
|
|
boolean redraw = originTerminal.pollTerminalChanged();
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Draw the contents
|
|
|
|
GlStateManager.depthMask( false );
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
OpenGlHelper.glMultiTexCoord2f( OpenGlHelper.GL_TEXTURE1, 0xFFFF, 0xFFFF );
|
2017-05-01 13:32:39 +00:00
|
|
|
GlStateManager.disableLighting();
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
mc.gameRenderer.disableLightmap();
|
2017-05-01 13:32:39 +00:00
|
|
|
try
|
|
|
|
{
|
2018-02-14 21:21:00 +00:00
|
|
|
Terminal terminal = originTerminal.getTerminal();
|
2017-05-01 13:32:39 +00:00
|
|
|
if( terminal != null )
|
|
|
|
{
|
2017-05-06 18:23:44 +00:00
|
|
|
Palette palette = terminal.getPalette();
|
|
|
|
|
2017-05-01 13:32:39 +00:00
|
|
|
// Allocate display lists
|
2018-02-24 16:21:12 +00:00
|
|
|
if( originTerminal.renderDisplayLists == null )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-02-24 20:37:14 +00:00
|
|
|
originTerminal.createLists();
|
2017-05-01 13:32:39 +00:00
|
|
|
redraw = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw a terminal
|
2018-02-14 21:21:00 +00:00
|
|
|
boolean greyscale = !originTerminal.isColour();
|
2017-05-01 13:32:39 +00:00
|
|
|
int width = terminal.getWidth();
|
|
|
|
int height = terminal.getHeight();
|
|
|
|
int cursorX = terminal.getCursorX();
|
|
|
|
int cursorY = terminal.getCursorY();
|
2018-12-27 11:58:08 +00:00
|
|
|
FixedWidthFontRenderer fontRenderer = FixedWidthFontRenderer.instance();
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
try
|
|
|
|
{
|
2018-12-23 17:46:58 +00:00
|
|
|
double xScale = xSize / (width * FixedWidthFontRenderer.FONT_WIDTH);
|
|
|
|
double yScale = ySize / (height * FixedWidthFontRenderer.FONT_HEIGHT);
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.scaled( xScale, -yScale, 1.0 );
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Draw background
|
2018-12-27 11:58:08 +00:00
|
|
|
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.BACKGROUND );
|
2017-05-01 13:32:39 +00:00
|
|
|
if( redraw )
|
|
|
|
{
|
|
|
|
// Build background display list
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.newList( originTerminal.renderDisplayLists[0], GL11.GL_COMPILE );
|
2017-05-01 13:32:39 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
double marginXSize = TileMonitor.RENDER_MARGIN / xScale;
|
|
|
|
double marginYSize = TileMonitor.RENDER_MARGIN / yScale;
|
2017-09-24 05:18:20 +00:00
|
|
|
double marginSquash = marginYSize / FixedWidthFontRenderer.FONT_HEIGHT;
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Top and bottom margins
|
2017-05-04 21:38:24 +00:00
|
|
|
GlStateManager.pushMatrix();
|
2017-05-01 13:32:39 +00:00
|
|
|
try
|
|
|
|
{
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.scaled( 1.0, marginSquash, 1.0 );
|
|
|
|
GlStateManager.translated( 0.0, -marginYSize / marginSquash, 0.0 );
|
2017-05-05 13:24:29 +00:00
|
|
|
fontRenderer.drawStringBackgroundPart( 0, 0, terminal.getBackgroundColourLine( 0 ), marginXSize, marginXSize, greyscale, palette );
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.translated( 0.0, (marginYSize + height * FixedWidthFontRenderer.FONT_HEIGHT) / marginSquash, 0.0 );
|
2017-05-05 13:24:29 +00:00
|
|
|
fontRenderer.drawStringBackgroundPart( 0, 0, terminal.getBackgroundColourLine( height - 1 ), marginXSize, marginXSize, greyscale, palette );
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
2017-05-04 21:38:24 +00:00
|
|
|
GlStateManager.popMatrix();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Backgrounds
|
2018-12-23 17:46:58 +00:00
|
|
|
for( int y = 0; y < height; y++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
fontRenderer.drawStringBackgroundPart(
|
2018-12-23 17:46:58 +00:00
|
|
|
0, FixedWidthFontRenderer.FONT_HEIGHT * y,
|
|
|
|
terminal.getBackgroundColourLine( y ),
|
|
|
|
marginXSize, marginXSize,
|
|
|
|
greyscale,
|
|
|
|
palette
|
2017-05-01 13:32:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.endList();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-24 16:21:12 +00:00
|
|
|
GlStateManager.callList( originTerminal.renderDisplayLists[0] );
|
2017-07-04 20:54:20 +00:00
|
|
|
GlStateManager.resetColor();
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Draw text
|
2017-07-10 21:20:07 +00:00
|
|
|
fontRenderer.bindFont();
|
2017-05-01 13:32:39 +00:00
|
|
|
if( redraw )
|
|
|
|
{
|
|
|
|
// Build text display list
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.newList( originTerminal.renderDisplayLists[1], GL11.GL_COMPILE );
|
2017-05-01 13:32:39 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// Lines
|
2018-12-23 17:46:58 +00:00
|
|
|
for( int y = 0; y < height; y++ )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
|
|
|
fontRenderer.drawStringTextPart(
|
2018-12-23 17:46:58 +00:00
|
|
|
0, FixedWidthFontRenderer.FONT_HEIGHT * y,
|
|
|
|
terminal.getLine( y ),
|
|
|
|
terminal.getTextColourLine( y ),
|
|
|
|
greyscale,
|
|
|
|
palette
|
2017-05-01 13:32:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.endList();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2018-02-24 16:21:12 +00:00
|
|
|
GlStateManager.callList( originTerminal.renderDisplayLists[1] );
|
2017-07-04 20:54:20 +00:00
|
|
|
GlStateManager.resetColor();
|
2017-05-01 13:32:39 +00:00
|
|
|
|
|
|
|
// Draw cursor
|
2017-07-10 21:20:07 +00:00
|
|
|
fontRenderer.bindFont();
|
2017-05-01 13:32:39 +00:00
|
|
|
if( redraw )
|
|
|
|
{
|
|
|
|
// Build cursor display list
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.newList( originTerminal.renderDisplayLists[2], GL11.GL_COMPILE );
|
2017-05-01 13:32:39 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
// Cursor
|
|
|
|
if( terminal.getCursorBlink() && cursorX >= 0 && cursorX < width && cursorY >= 0 && cursorY < height )
|
|
|
|
{
|
|
|
|
TextBuffer cursor = new TextBuffer( "_" );
|
|
|
|
TextBuffer cursorColour = new TextBuffer( "0123456789abcdef".charAt( terminal.getTextColour() ), 1 );
|
|
|
|
fontRenderer.drawString(
|
2018-12-23 17:46:58 +00:00
|
|
|
cursor,
|
|
|
|
FixedWidthFontRenderer.FONT_WIDTH * cursorX,
|
|
|
|
FixedWidthFontRenderer.FONT_HEIGHT * cursorY,
|
|
|
|
cursorColour, null,
|
|
|
|
0, 0,
|
|
|
|
greyscale,
|
|
|
|
palette
|
2017-05-01 13:32:39 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.endList();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-12 16:27:40 +00:00
|
|
|
if( FrameInfo.getGlobalCursorBlink() )
|
2017-05-01 13:32:39 +00:00
|
|
|
{
|
2018-02-24 16:21:12 +00:00
|
|
|
GlStateManager.callList( originTerminal.renderDisplayLists[2] );
|
2017-07-04 20:54:20 +00:00
|
|
|
GlStateManager.resetColor();
|
2017-05-01 13:32:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Draw a big black quad
|
2018-12-27 11:58:08 +00:00
|
|
|
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.BACKGROUND );
|
2017-05-04 21:38:24 +00:00
|
|
|
final Colour colour = Colour.Black;
|
|
|
|
|
|
|
|
final float r = colour.getR();
|
|
|
|
final float g = colour.getG();
|
|
|
|
final float b = colour.getB();
|
|
|
|
|
|
|
|
renderer.begin( GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION_TEX_COLOR );
|
|
|
|
renderer.pos( -TileMonitor.RENDER_MARGIN, TileMonitor.RENDER_MARGIN, 0.0D ).tex( 0.0, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
|
|
|
renderer.pos( -TileMonitor.RENDER_MARGIN, -ySize - TileMonitor.RENDER_MARGIN, 0.0 ).tex( 0.0, 1.0 ).color( r, g, b, 1.0f ).endVertex();
|
|
|
|
renderer.pos( xSize + TileMonitor.RENDER_MARGIN, TileMonitor.RENDER_MARGIN, 0.0D ).tex( 1.0, 0.0 ).color( r, g, b, 1.0f ).endVertex();
|
|
|
|
renderer.pos( xSize + TileMonitor.RENDER_MARGIN, -ySize - TileMonitor.RENDER_MARGIN, 0.0 ).tex( 1.0, 1.0 ).color( r, g, b, 1.0f ).endVertex();
|
2017-05-01 13:32:39 +00:00
|
|
|
tessellator.draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
GlStateManager.depthMask( true );
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
mc.gameRenderer.enableLightmap();
|
2017-05-01 13:32:39 +00:00
|
|
|
GlStateManager.enableLighting();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Draw the depth blocker
|
|
|
|
GlStateManager.colorMask( false, false, false, false );
|
|
|
|
try
|
|
|
|
{
|
2018-12-27 11:58:08 +00:00
|
|
|
mc.getTextureManager().bindTexture( FixedWidthFontRenderer.BACKGROUND );
|
2017-05-04 21:38:24 +00:00
|
|
|
renderer.begin( GL11.GL_TRIANGLE_STRIP, DefaultVertexFormats.POSITION );
|
|
|
|
renderer.pos( -TileMonitor.RENDER_MARGIN, TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
|
|
|
renderer.pos( -TileMonitor.RENDER_MARGIN, -ySize - TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
|
|
|
renderer.pos( xSize + TileMonitor.RENDER_MARGIN, TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
|
|
|
renderer.pos( xSize + TileMonitor.RENDER_MARGIN, -ySize - TileMonitor.RENDER_MARGIN, 0.0 ).endVertex();
|
2017-05-01 13:32:39 +00:00
|
|
|
tessellator.draw();
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
|
|
|
GlStateManager.colorMask( true, true, true, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
finally
|
|
|
|
{
|
Update CC: Tweaked to 1.13
Look, I originally had this split into several commits, but lots of
other cleanups got mixed in. I then backported some of the cleanups to
1.12, did other tidy ups there, and eventually the web of merges was
unreadable.
Yes, this is a horrible mess, but it's still nicer than it was. Anyway,
changes:
- Flatten everything. For instance, there are now three instances of
BlockComputer, two BlockTurtle, ItemPocketComputer. There's also no
more BlockPeripheral (thank heavens) - there's separate block classes
for each peripheral type.
- Remove pretty much all legacy code. As we're breaking world
compatibility anyway, we can remove all the code to load worlds from
1.4 days.
- The command system is largely rewriten to take advantage of 1.13's
new system. It's very fancy!
- WidgetTerminal now uses Minecraft's "GUI listener" system.
- BREAKING CHANGE: All the codes in keys.lua are different, due to the
move to LWJGL 3. Hopefully this won't have too much of an impact.
I don't want to map to the old key codes on the Java side, as there
always ends up being small but slight inconsistencies. IMO it's
better to make a clean break - people should be using keys rather
than hard coding the constants anyway.
- commands.list now allows fetching sub-commands. The ROM has already
been updated to allow fancy usage such as commands.time.set("noon").
- Turtles, modems and cables can be waterlogged.
2019-04-02 12:27:27 +00:00
|
|
|
GlStateManager.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
2017-05-01 13:32:39 +00:00
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|