1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-30 05:12:58 +00:00

No more m_ nice guy

This commit is contained in:
Jonathan Coates
2021-06-09 08:55:11 +01:00
parent a198a5241d
commit 59266fe6e9
39 changed files with 1234 additions and 1211 deletions

View File

@@ -12,21 +12,21 @@ import net.minecraft.nbt.CompoundTag;
public class ClientTerminal implements ITerminal
{
private boolean m_colour;
private Terminal m_terminal;
private boolean m_terminalChanged;
private boolean colour;
private Terminal terminal;
private boolean terminalChanged;
public ClientTerminal( boolean colour )
{
this.m_colour = colour;
this.m_terminal = null;
this.m_terminalChanged = false;
this.colour = colour;
this.terminal = null;
this.terminalChanged = false;
}
public boolean pollTerminalChanged()
{
boolean changed = this.m_terminalChanged;
this.m_terminalChanged = false;
boolean changed = this.terminalChanged;
this.terminalChanged = false;
return changed;
}
@@ -35,22 +35,22 @@ public class ClientTerminal implements ITerminal
@Override
public Terminal getTerminal()
{
return this.m_terminal;
return this.terminal;
}
@Override
public boolean isColour()
{
return this.m_colour;
return this.colour;
}
public void read( TerminalState state )
{
this.m_colour = state.colour;
this.colour = state.colour;
if( state.hasTerminal() )
{
this.resizeTerminal( state.width, state.height );
state.apply( this.m_terminal );
state.apply( this.terminal );
}
else
{
@@ -60,34 +60,34 @@ public class ClientTerminal implements ITerminal
private void resizeTerminal( int width, int height )
{
if( this.m_terminal == null )
if( this.terminal == null )
{
this.m_terminal = new Terminal( width, height, () -> this.m_terminalChanged = true );
this.m_terminalChanged = true;
this.terminal = new Terminal( width, height, () -> this.terminalChanged = true );
this.terminalChanged = true;
}
else
{
this.m_terminal.resize( width, height );
this.terminal.resize( width, height );
}
}
private void deleteTerminal()
{
if( this.m_terminal != null )
if( this.terminal != null )
{
this.m_terminal = null;
this.m_terminalChanged = true;
this.terminal = null;
this.terminalChanged = true;
}
}
public void readDescription( CompoundTag nbt )
{
this.m_colour = nbt.getBoolean( "colour" );
this.colour = nbt.getBoolean( "colour" );
if( nbt.contains( "terminal" ) )
{
CompoundTag terminal = nbt.getCompound( "terminal" );
this.resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) );
this.m_terminal.readFromNBT( terminal );
this.terminal.readFromNBT( terminal );
}
else
{

View File

@@ -14,86 +14,86 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class ServerTerminal implements ITerminal
{
private final boolean m_colour;
private final AtomicBoolean m_terminalChanged = new AtomicBoolean( false );
private Terminal m_terminal;
private boolean m_terminalChangedLastFrame = false;
private final boolean colour;
private final AtomicBoolean terminalChanged = new AtomicBoolean( false );
private Terminal terminal;
private boolean terminalChangedLastFrame = false;
public ServerTerminal( boolean colour )
{
this.m_colour = colour;
this.m_terminal = null;
this.colour = colour;
this.terminal = null;
}
public ServerTerminal( boolean colour, int terminalWidth, int terminalHeight )
{
this.m_colour = colour;
this.m_terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged );
this.colour = colour;
this.terminal = new Terminal( terminalWidth, terminalHeight, this::markTerminalChanged );
}
protected void markTerminalChanged()
{
this.m_terminalChanged.set( true );
this.terminalChanged.set( true );
}
protected void resize( int width, int height )
{
if( this.m_terminal == null )
if( this.terminal == null )
{
this.m_terminal = new Terminal( width, height, this::markTerminalChanged );
this.terminal = new Terminal( width, height, this::markTerminalChanged );
this.markTerminalChanged();
}
else
{
this.m_terminal.resize( width, height );
this.terminal.resize( width, height );
}
}
public void delete()
{
if( this.m_terminal != null )
if( this.terminal != null )
{
this.m_terminal = null;
this.terminal = null;
this.markTerminalChanged();
}
}
public void update()
{
this.m_terminalChangedLastFrame = this.m_terminalChanged.getAndSet( false );
this.terminalChangedLastFrame = this.terminalChanged.getAndSet( false );
}
public boolean hasTerminalChanged()
{
return this.m_terminalChangedLastFrame;
return this.terminalChangedLastFrame;
}
@Override
public Terminal getTerminal()
{
return this.m_terminal;
return this.terminal;
}
@Override
public boolean isColour()
{
return this.m_colour;
return this.colour;
}
public TerminalState write()
{
return new TerminalState( this.m_colour, this.m_terminal );
return new TerminalState( this.colour, this.terminal );
}
public void writeDescription( CompoundTag nbt )
{
nbt.putBoolean( "colour", this.m_colour );
if( this.m_terminal != null )
nbt.putBoolean( "colour", this.colour );
if( this.terminal != null )
{
CompoundTag terminal = new CompoundTag();
terminal.putInt( "term_width", this.m_terminal.getWidth() );
terminal.putInt( "term_height", this.m_terminal.getHeight() );
this.m_terminal.writeToNBT( terminal );
terminal.putInt( "term_width", this.terminal.getWidth() );
terminal.putInt( "term_height", this.terminal.getHeight() );
this.terminal.writeToNBT( terminal );
nbt.put( "terminal", terminal );
}
}