title: How to fix Minecraft 1.12 Null pointer exception error with entities?
body: <p>I've been trying to fix it for ages, im stumped, everytime i open it it crashes with the same error message "java.lang.NullPointerException", heres the full error message:</p>
  
  <pre><code>net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from The Human Tools Mod (sword)
  Caused by: java.lang.NullPointerException
      at net.minecraftforge.fml.common.registry.EntityRegistry.doModEntityRegistration(EntityRegistry.java:207)
      at net.minecraftforge.fml.common.registry.EntityRegistry.registerModEntity(EntityRegistry.java:192)
      at com.example.examplemod.init.EntityInit.registerEntity(EntityInit.java:18)
      at com.example.examplemod.init.EntityInit.registerEntities(EntityInit.java:13)
      at com.example.examplemod.util.handlers.RegistryHandler.preInitRegistries(RegistryHandler.java:62)
      at com.example.examplemod.util.ExampleMod.preInit(ExampleMod.java:44)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:626)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
      at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
      at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
      at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
      at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
      at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
      at com.google.common.eventbus.EventBus.post(EventBus.java:217)
      at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218)
      at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
      at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
      at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
      at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
      at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
      at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
      at com.google.common.eventbus.EventBus.post(EventBus.java:217)
      at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135)
      at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627)
      at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
      at net.minecraft.client.Minecraft.init(Minecraft.java:513)
      at net.minecraft.client.Minecraft.run(Minecraft.java:421)
      at net.minecraft.client.main.Main.main(Main.java:118)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
      at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
      at GradleStart.main(GradleStart.java:25)**
  </code></pre>
  
  <p>as well as some of my code:</p>
  
  <p>the code that is trying to register the entity:</p>
  
  <pre><code>public class EntityInit
  {
      public static void registerEntities()
      {
          registerEntity("human", EntityHuman.class, ExampleMod.ENTITY_HUMAN, 50, 3093151, 16287108);
      }
  
      private static void registerEntity(String name, Class&lt;? extends Entity&gt; entity, int id, int range, int color1, int color2 )
      {
          EntityRegistry.registerModEntity(new ResourceLocation("sword:" + name), entity, name, id, ExampleMod.instance, range, 1, true, color1, color2);
      }
  }
  </code></pre>