From aa0e1883d1089e543519883f8971d6a82b91816d Mon Sep 17 00:00:00 2001 From: SquidDev Date: Tue, 9 Apr 2019 16:32:20 +0100 Subject: [PATCH] Add check for if item/block registration has failed If mod loading fails, we'll continue to load colour handlers. As blocks/items have not been registered, then we'll throw an NPE. See MinecraftForge/MinecraftForge#5682. Somewhat fixes #168. --- .../java/dan200/computercraft/client/ClientRegistry.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/dan200/computercraft/client/ClientRegistry.java b/src/main/java/dan200/computercraft/client/ClientRegistry.java index ff4bcfd66..48bd06443 100644 --- a/src/main/java/dan200/computercraft/client/ClientRegistry.java +++ b/src/main/java/dan200/computercraft/client/ClientRegistry.java @@ -121,6 +121,12 @@ public final class ClientRegistry @SubscribeEvent public static void onItemColours( ColorHandlerEvent.Item event ) { + if( ComputerCraft.Items.disk == null || ComputerCraft.Blocks.turtleNormal == null ) + { + ComputerCraft.log.warn( "Block/item registration has failed. Skipping registration of item colours." ); + return; + } + event.getItemColors().register( ( stack, layer ) -> layer == 1 ? ((ItemDisk) stack.getItem()).getColour( stack ) : 0xFFFFFF, ComputerCraft.Items.disk