From 971c719a9f2c88749ddcc773f37b92f36ce20444 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 19 May 2017 11:47:27 +0100 Subject: [PATCH] Add some sanity checks to Palette.readFromNBT Printers use a Terminal to store the page currently being printed. Printers saved in an older version of ComputerCraft would be missing the term_palette field, resulting in an NPE when loading the tile. --- src/main/java/dan200/computercraft/shared/util/Palette.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/dan200/computercraft/shared/util/Palette.java b/src/main/java/dan200/computercraft/shared/util/Palette.java index 057688500..f215adddc 100644 --- a/src/main/java/dan200/computercraft/shared/util/Palette.java +++ b/src/main/java/dan200/computercraft/shared/util/Palette.java @@ -89,8 +89,11 @@ public class Palette public void readFromNBT( NBTTagCompound nbt ) { + if( !nbt.hasKey( "term_palette" ) ) return; int[] rgb8 = nbt.getIntArray( "term_palette" ); + if( rgb8.length != colours.length ) return; + for(int i = 0; i < colours.length; ++i) { colours[i] = decodeRGB8( rgb8[i] );