NPE on getItemStack()
Tschipp opened this issue ยท 2 comments
When I try to add oredict to my itemstacks by calling getItemStack() on a PartType i get a NullPointerException:
PREINITIALIZATION][CLIENT][ERROR] [contenttweaker]: Error executing {[1149:contenttweaker]: contenttweaker\parts.zs}: null
java.lang.NullPointerException
at com.teamacronymcoders.base.materialsystem.parttype.ItemPartType.getItemStack(ItemPartType.java:92)
at com.teamacronymcoders.base.materialsystem.materialparts.MaterialPart.getItemStack(MaterialPart.java:89)
at com.teamacronymcoders.contenttweaker.modules.materials.materialparts.CTMaterialPart.getItemStack(CTMaterialPart.java:49)
at contenttweaker\Parts.registerOredict(contenttweaker\parts.zs:35)
at contenttweaker\Parts.__script__(contenttweaker\parts.zs:26)
at __ZenMain__.run(contenttweaker\Parts)
at crafttweaker.runtime.CrTTweaker.loadScript(CrTTweaker.java:221)
at crafttweaker.runtime.CrTTweaker.loadScript(CrTTweaker.java:92)
at crafttweaker.runtime.CrTTweaker.loadScript(CrTTweaker.java:96)
at crafttweaker.runtime.CrTTweaker.loadScript(CrTTweaker.java:74)
at com.teamacronymcoders.contenttweaker.ContentTweaker.afterModuleHandlerInit(ContentTweaker.java:45)
at com.teamacronymcoders.base.BaseModFoundation.preInit(BaseModFoundation.java:112)
at com.teamacronymcoders.contenttweaker.ContentTweaker.preInit(ContentTweaker.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:624)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
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:219)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
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:136)
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.func_71384_a(Minecraft.java:467)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)
at net.minecraft.client.main.Main.main(SourceFile:123)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
I have these two scripts:
#priority 10
#loader contenttweaker
import mods.contenttweaker.Color;
import mods.contenttweaker.Material;
import mods.contenttweaker.MaterialPartData;
import mods.contenttweaker.MaterialSystem;
import crafttweaker.oredict.IOreDict;
static materials as Material[] = [
MaterialSystem.getMaterialBuilder().setName("Adamantine").setColor(Color.fromHex("f21a29")).build(),
MaterialSystem.getMaterialBuilder().setName("Alduorite").setColor(Color.fromHex("FF29AF9D")).build(),
MaterialSystem.getMaterialBuilder().setName("Astral Silver").setColor(Color.fromHex("FFBBD5CF")).build(),
MaterialSystem.getMaterialBuilder().setName("Atlarus").setColor(Color.fromHex("FFDABC23")).build(),
MaterialSystem.getMaterialBuilder().setName("Carmot").setColor(Color.fromHex("FFE5D868")).build(),
MaterialSystem.getMaterialBuilder().setName("Celenegil").setColor(Color.fromHex("FF86E51A")).build(),
MaterialSystem.getMaterialBuilder().setName("Deep Iron").setColor(Color.fromHex("FF4CA8E5")).build(),
MaterialSystem.getMaterialBuilder().setName("Eximite").setColor(Color.fromHex("FF5E4191")).build(),
MaterialSystem.getMaterialBuilder().setName("Ignatius").setColor(Color.fromHex("FFFF9100")).build(),
MaterialSystem.getMaterialBuilder().setName("Infuscolium").setColor(Color.fromHex("FF7F036E")).build(),
];
priority 9
#loader contenttweaker
import mods.contenttweaker.Material;
import mods.contenttweaker.MaterialPartData;
import mods.contenttweaker.MaterialPart;
import mods.contenttweaker.MaterialSystem;
import crafttweaker.oredict.IOreDict;
import scripts.contenttweaker.mats.materials;
for material in materials
{
var cluster = material.registerPart("cluster");
var sample = material.registerPart("ore_sample");
var nug = material.registerPart("nugget");
registerOredict(material, cluster);
}
function registerOredict(mat as Material, cluster as MaterialPart)
{
var name = mat.getName();
var oreEntry = oreDict.get("ore" + name);
var stack = cluster.getItemStack();
oreEntry.add(stack);
}
You're calling it in the wrong loader. Get itemstack only works in craft tweak ER scripts