mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-08 09:23:00 +00:00
Fix computer and monitor syncing.
This commit is contained in:
@@ -7,6 +7,7 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.network.client.TerminalState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class ClientTerminal implements ITerminal
|
||||
{
|
||||
@@ -56,6 +57,17 @@ public class ClientTerminal implements ITerminal
|
||||
}
|
||||
}
|
||||
|
||||
public void readDescription(CompoundTag nbt) {
|
||||
this.m_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);
|
||||
} else {
|
||||
this.deleteTerminal();
|
||||
}
|
||||
}
|
||||
|
||||
private void resizeTerminal( int width, int height )
|
||||
{
|
||||
if( m_terminal == null )
|
||||
|
||||
@@ -7,6 +7,7 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.network.client.TerminalState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@@ -82,4 +83,15 @@ public class ServerTerminal implements ITerminal
|
||||
{
|
||||
return new TerminalState( m_colour, m_terminal );
|
||||
}
|
||||
|
||||
public void writeDescription(CompoundTag nbt) {
|
||||
nbt.putBoolean("colour", this.m_colour);
|
||||
if (this.m_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);
|
||||
nbt.put("terminal", terminal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,15 +80,6 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final BlockEntityUpdateS2CPacket toUpdatePacket()
|
||||
{
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
writeDescription( nbt );
|
||||
return new BlockEntityUpdateS2CPacket( pos, 0, nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toClientTag(CompoundTag compoundTag) {
|
||||
writeDescription(compoundTag);
|
||||
@@ -99,13 +90,4 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
|
||||
public void fromClientTag(CompoundTag compoundTag) {
|
||||
readDescription(compoundTag);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toInitialChunkDataTag()
|
||||
{
|
||||
CompoundTag tag = super.toInitialChunkDataTag();
|
||||
writeDescription( tag );
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user