1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-07-02 10:02:59 +00:00
SquidDev fb440b0d2e Update to 1.15
Most of the port is pretty simple. The main problems are regarding
changes to Minecraft's rendering system.

 - Remove several rendering tweaks until Forge's compatibility it
   brought up-to-date
    - Map rendering for pocket computers and printouts
    - Item frame rendering for printouts
    - Custom block outlines for monitors and cables/wired modems
    - Custom breaking progress for cables/wired modems

 - Turtle "Dinnerbone" rendering is currently broken, as normals are not
   correctly transformed.

 - Rewrite FixedWidthFontRenderer to to the buffer in a single sweep.
   In order to do this, the term_font now also bundles a "background"
   section, which is just a blank region of the screen.

 - Render monitors using a VBO instead of a call list. I haven't
   compared performance yet, but it manages to render a 6x5 array of
   _static_ monitors at almost 60fps, which seems pretty reasonable.
2020-01-24 09:12:29 +00:00

87 lines
2.2 KiB
Java

/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.shared.peripheral.monitor;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.shared.common.ClientTerminal;
import net.minecraft.client.renderer.vertex.VertexBuffer;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class ClientMonitor extends ClientTerminal
{
private static final Set<ClientMonitor> allMonitors = new HashSet<>();
private final TileMonitor origin;
public long lastRenderFrame = -1;
public BlockPos lastRenderPos = null;
public VertexBuffer buffer = null;
public ClientMonitor( boolean colour, TileMonitor origin )
{
super( colour );
this.origin = origin;
}
public TileMonitor getOrigin()
{
return origin;
}
@OnlyIn( Dist.CLIENT )
public void createBuffer()
{
if( buffer == null )
{
buffer = new VertexBuffer( FixedWidthFontRenderer.TYPE.getVertexFormat() );
synchronized( allMonitors )
{
allMonitors.add( this );
}
}
}
@OnlyIn( Dist.CLIENT )
public void destroy()
{
if( buffer != null )
{
synchronized( allMonitors )
{
allMonitors.remove( this );
}
buffer.close();
buffer = null;
}
}
@OnlyIn( Dist.CLIENT )
public static void destroyAll()
{
synchronized( allMonitors )
{
for( Iterator<ClientMonitor> iterator = allMonitors.iterator(); iterator.hasNext(); )
{
ClientMonitor monitor = iterator.next();
if( monitor.buffer != null )
{
monitor.buffer.close();
monitor.buffer = null;
}
iterator.remove();
}
}
}
}