From 68bf3a71dc1a68933057ae4d0b9cdaff47577a64 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 24 May 2019 18:32:56 +0100 Subject: [PATCH] Lazilly instantiate the terminal packet This means we don't create an NBT tag every tick if the screen is updating, unless we actually need to. --- .../computercraft/shared/computer/core/ServerComputer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index 49060ef92..f5799af28 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -175,12 +175,13 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput FMLCommonHandler handler = FMLCommonHandler.instance(); if( handler != null ) { - IMessage packet = createTerminalPacket(); + IMessage packet = null; MinecraftServer server = handler.getMinecraftServerInstance(); for( EntityPlayerMP player : server.getPlayerList().getPlayers() ) { if( isInteracting( player ) ) { + if( packet == null ) packet = createTerminalPacket(); NetworkHandler.sendToPlayer( player, packet ); } }