Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.4] GlobalEntityTypeAttributes problem


Recommended Posts

Hello. I am getting this crash on right click with a spawn egg:
 

[00:17:29] [Server thread/FATAL] [minecraft/ThreadTaskExecutor]: Error executing task on Server
java.lang.NullPointerException: null
	at net.minecraft.entity.ai.attributes.AttributeModifierManager.getAttributeValue(AttributeModifierManager.java:67) ~[forge:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.getAttributeValue(LivingEntity.java:1849) ~[forge:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.getMaxHealth(LivingEntity.java:1610) ~[forge:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:209) ~[forge:?] {re:classloading}
	at net.minecraft.entity.MobEntity.<init>(MobEntity.java:108) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13) ~[forge:?] {re:classloading}
	at net.minecraft.entity.monster.MonsterEntity.<init>(MonsterEntity.java:29) ~[forge:?] {re:classloading}
	at testmod.entity.testentity.EntityTest.<init>(EntityTest.java:40) ~[?:?] {re:classloading}


From what I can tell, this means it doesn't have custom attributes, namely MaxHealth. I am registering them like so:

In my Mod file:

//in constructor
	FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setupCustomAttributes);



private void setupCustomAttributes(final ParallelDispatchEvent event)
{
    event.enqueueWork(() -> {
        System.out.println("CALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLED");
        GlobalEntityTypeAttributes.put(ModEntities.ENTITY_TEST.get(), EntityTest.setCustomAttributes().create());
    });
}


In my Entity class 

public class EntityTest extends MonsterEntity {

  public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
     return MonsterEntity.func_233666_p_()
           .createMutableAttribute(Attributes.MAX_HEALTH, 100.0D)
           .createMutableAttribute(Attributes.MOVEMENT_SPEED, 1D);
  }
}


In my ModEntities class

public class ModEntities
{
	public static final RegistryObject<EntityType<EntityTest>> ENTITY_TEST = registerEntityAndEgg(() -> EntityType.Builder.create(EntityTest::new, EntityClassification.MISC)
			.size(1.5f, 2.25f)
			.build(new ResourceLocation(TestMod.MOD_ID, "test_entity").toString()), "test_entity", EntityTest.COLOR1, EntityTest.COLOR2);
	
	public static final <T extends Entity> RegistryObject<EntityType<T>> registerEntityAndEgg (Supplier<EntityType<T>> entityTypeSupplier, String name, int color, int color2)
	{
		RegistryObject<EntityType<T>> registeryEntity = Registration.ENTITIES.register(name, entityTypeSupplier);
		
		//TODO: STORE?
		RegistryObject<Item> SPAWN_EGG = Registration.ITEMS.register(
				"spawn_egg_" + name,
				() -> new SpawnEggItem(entityTypeSupplier.get(), color, color2, new Item.Properties().group(ItemGroup.MATERIALS)));
	
		return registeryEntity;
	}
}


And finally my registration class:

public class Registration
{
	public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, TestMod.MOD_ID);
	public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, TestMod.MOD_ID);
	
	public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, TheUpsideDownMod.MOD_ID);
	
	public static void register()
	{
		IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
		
		BLOCKS.register(modEventBus);
		ITEMS.register(modEventBus);
		
		ENTITIES.register(modEventBus);
		
	}
}


The method IS called as determined by breakpoints and my output call. 

I am not sure what is up here. I am not sure how to test any further than my output and breakpoint checks. Should I update to 1.16.5 and try again?
 

Edited by SubliminallySublime
Code correction
Link to post
Share on other sites
2 hours ago, SubliminallySublime said:

private void setupCustomAttributes(final ParallelDispatchEvent event)

This makes zero sense. This means you will receive all subclasses of this event, which makes this event handler meaningless. Use FMLCommonSetupEvent.

 

Additionally: Do not put a DeferredRegister and its registry entries in separate classes. A DeferredRegister field should be private.

  • Like 1
Link to post
Share on other sites
7 hours ago, diesieben07 said:

This makes zero sense. This means you will receive all subclasses of this event, which makes this event handler meaningless. Use FMLCommonSetupEvent.

 

Additionally: Do not put a DeferredRegister and its registry entries in separate classes. A DeferredRegister field should be private.

Thank you!  I was not aware FMLCommonSetupEvent had an enque event I could access. I am getting a different crash now but I think I can solve it.

I am also correcting my DeferredRegister design. Thank you.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I would start with a video like this one https://www.youtube.com/watch?v=x08i64ftpDY  
    • I am currently using DataGenerators and an ItemProvider to dynamically create each Json file, and even though this successfully runs using runData there is no actual texture when in game. Any Ideas?
    • Trying to figure out the cause of this, unsure what it is i get this error anytime i launch a custom mod pack i created,looked to see if there was invalid depndencies or missing mods, couldnt see anything https://pastebin.com/2ZxW8SVc
    • 1.12 is no longer supported on this forum. Please update to a modern version of Minecraft to receive support.
    • If someone know what to do pls help me do i need to reinstall mods or delete some?   ---- Minecraft Crash Report ---- WARNING: coremods are present:   Quark Plugin (Quark-r1.6-178.jar)   SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.1.9.jar)   ForgelinPlugin (Forgelin-1.8.4.jar)   MovingWorldCore (movingworld-1.12-6.353-full.jar)   MekanismCoremod (Mekanism-1.12.2-9.8.3.390.jar)   MicdoodlePlugin (MicdoodleCore-1.12.2-4.0.2.280.jar)   TransformLoader (DynamicSurroundings-1.12.2-3.6.2.1.jar)   FutureMC (future-mc-1.12.2-0.2.6.1.jar) Contact their authors BEFORE contacting forge // You should try our sister game, Minceraft! Time: 4/11/21 11:03 PM Description: There was a severe problem during mod loading that has caused the game to fail net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from �3Dynamic Surroundings (dsurround) Caused by: java.lang.ExceptionInInitializerError   at org.orecruncher.dsurround.registry.RegistryManager.initialize(RegistryManager.java:103)   at org.orecruncher.dsurround.proxy.Proxy.loadCompleted(Proxy.java:92)   at org.orecruncher.dsurround.ModBase.loadCompleted(ModBase.java:178)   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:498)   at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)   at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   at java.lang.reflect.Method.invoke(Method.java:498)   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:498)   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.initializeMods(Loader.java:757)   at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)   at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:535)   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:498)   at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)   at net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.IllegalArgumentException: No enum constant net.minecraft.util.SoundCategory.DS_FOOTSTEPS   at java.lang.Enum.valueOf(Enum.java:238)   at net.minecraft.util.SoundCategory.valueOf(SourceFile:8)   at org.orecruncher.dsurround.registry.sound.SoundRegistry.<clinit>(SoundRegistry.java:67)   ... 43 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:   Minecraft Version: 1.12.2   Operating System: Windows 10 (amd64) version 10.0   Java Version: 1.8.0_271, Oracle Corporation   Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation   Memory: 2114811232 bytes (2016 MB) / 4294967296 bytes (4096 MB) up to 16777216000 bytes (16000 MB)   JVM Flags: 10 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx16000M -Xms4096M -Xss1M -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M   IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0   FML: MCP 9.42 Powered by Forge 14.23.5.2854 39 mods loaded, 39 mods active   States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored   | State  | ID                                           | Version           | Source                                        | Signature                                |   |:------ |:-------------------------------------------- |:----------------- |:--------------------------------------------- |:---------------------------------------- |   | LCHIJA | minecraft                                    | 1.12.2            | minecraft.jar                                 | None                                     |   | LCHIJA | mcp                                          | 9.42              | minecraft.jar                                 | None                                     |   | LCHIJA | FML                                          | 8.0.99.99         | forge-1.12.2-14.23.5.2854.jar                 | e3c3d50c7c986df74c645c0ac54639741c90a557 |   | LCHIJA | forge                                        | 14.23.5.2854      | forge-1.12.2-14.23.5.2854.jar                 | e3c3d50c7c986df74c645c0ac54639741c90a557 |   | LCHIJA | micdoodlecore                                |                   | minecraft.jar                                 | None                                     |   | LCHIJA | com.elytradev.movingworld.common.asm.coremod |                   | minecraft.jar                                 | None                                     |   | LCHIJA | aether_legacy                                | 1.5.3             | aether-1.12.2-v1.5.3.jar                      | None                                     |   | LCHIJA | jei                                          | 4.16.1.301        | jei_1.12.2-4.16.1.301.jar                     | None                                     |   | LCHIJA | quark                                        | r1.6-178          | Quark-r1.6-178.jar                            | None                                     |   | LCHIJA | autoreglib                                   | 1.3-32            | AutoRegLib-1.3-32.jar                         | None                                     |   | LCHIJA | backpack                                     | 3.0.2             | backpack-3.0.2-1.12.2.jar                     | None                                     |   | LCHIJA | bettercaves                                  | 1.12.2            | bettercaves-1.12.2-2.0.4.jar                  | None                                     |   | LCHIJA | bettermineshafts                             | 1.12.2-2.2.1      | BetterMineshaftsForge-1.12.2-2.2.1.jar        | None                                     |   | LCHIJA | bibliocraft                                  | 2.4.5             | BiblioCraft[v2.4.5][MC1.12.2].jar             | None                                     |   | LCHIJA | biomesoplenty                                | 7.0.1.2443        | BiomesOPlenty-1.12.2-7.0.1.2443-universal.jar | None                                     |   | LCHIJA | chameleon                                    | 1.12-4.1.3        | Chameleon-1.12-4.1.3.jar                      | None                                     |   | LCHIJA | chesttransporter                             | 2.8.8             | ChestTransporter-1.12.2-2.8.8.jar             | None                                     |   | LCHIJA | mantle                                       | 1.12-1.3.3.55     | Mantle-1.12-1.3.3.55.jar                      | None                                     |   | LCHIJA | twilightforest                               | 3.11.1021         | twilightforest-1.12.2-3.11.1021-universal.jar | None                                     |   | LCHIJA | tconstruct                                   | 1.12.2-2.13.0.183 | TConstruct-1.12.2-2.13.0.183.jar              | None                                     |   | LCHIJA | conarm                                       | 1.2.5.10          | conarm-1.12.2-1.2.5.10.jar                    | b33d2c8df492beff56d1bbbc92da49b8ab7345a1 |   | LCHIJA | movingworld                                  | 1.12-6.353        | movingworld-1.12-6.353-full.jar               | None                                     |   | LCHIJA | davincisvessels                              | @DVESSELSVER@     | davincisvessels-1.12-6.340-full.jar           | None                                     |   | LCHIJA | galacticraftcore                             | 4.0.2.280         | GalacticraftCore-1.12.2-4.0.2.280.jar         | None                                     |   | LCHIJA | orelib                                       | 3.6.0.1           | OreLib-1.12.2-3.6.0.1.jar                     | 7a2128d395ad96ceb9d9030fbd41d035b435753a |   | LCHIJE | dsurround                                    | 3.6.2.1           | DynamicSurroundings-1.12.2-3.6.2.1.jar        | 7a2128d395ad96ceb9d9030fbd41d035b435753a |   | LCHIJ  | fastleafdecay                                | v14               | FastLeafDecay-v14.jar                         | None                                     |   | LCHIJ  | forgelin                                     | 1.8.4             | Forgelin-1.8.4.jar                            | None                                     |   | LCHIJ  | futuremc                                     | 0.2.6             | future-mc-1.12.2-0.2.6.1.jar                  | None                                     |   | LCHIJ  | galacticraftplanets                          | 4.0.2.280         | Galacticraft-Planets-1.12.2-4.0.2.280.jar     | None                                     |   | LCHIJ  | gravestone                                   | 1.10.1            | gravestone-1.10.1.jar                         | None                                     |   | LCHIJ  | waila                                        | 1.8.26            | Hwyla-1.8.26-B41_1.12.2.jar                   | None                                     |   | LCHIJ  | ironchest                                    | 1.12.2-7.0.67.844 | ironchest-1.12.2-7.0.72.847.jar               | None                                     |   | LCHIJ  | mekanism                                     | 1.12.2-9.8.3.390  | Mekanism-1.12.2-9.8.3.390.jar                 | None                                     |   | LCHIJ  | stevekung's_lib                              | 1.1.9             | SteveKunG's-Lib-1.12.2-1.1.9.jar              | None                                     |   | LCHIJ  | moreplanets                                  | 2.2.1             | More-Planets-1.12.2-2.2.1-GC280.jar           | None                                     |   | LCHIJ  | stg                                          | 1.12.2-1.2.3      | stg-1.12.2-1.2.3.jar                          | None                                     |   | LCHIJ  | storagedrawers                               | 1.12.2-5.4.0      | StorageDrawers-1.12.2-5.4.0.jar               | None                                     |   | LCHIJ  | waystones                                    | 4.1.0             | Waystones_1.12.2-4.1.0.jar                    | None                                     |   Loaded coremods (and transformers):  Quark Plugin (Quark-r1.6-178.jar)   vazkii.quark.base.asm.ClassTransformer SteveKunGLibPlugin (SteveKunG's-Lib-1.12.2-1.1.9.jar)    ForgelinPlugin (Forgelin-1.8.4.jar)    MovingWorldCore (movingworld-1.12-6.353-full.jar)    MekanismCoremod (Mekanism-1.12.2-9.8.3.390.jar)   mekanism.coremod.KeybindingMigrationHelper MicdoodlePlugin (MicdoodleCore-1.12.2-4.0.2.280.jar)   micdoodle8.mods.miccore.MicdoodleTransformer TransformLoader (DynamicSurroundings-1.12.2-3.6.2.1.jar)    FutureMC (future-mc-1.12.2-0.2.6.1.jar)   thedarkcolour.futuremc.asm.CoreTransformer   GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 465.89' Renderer: 'NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2'   Pulsar/tconstruct loaded Pulses:      - TinkerCommons (Enabled/Forced)     - TinkerWorld (Enabled/Not Forced)     - TinkerTools (Enabled/Not Forced)     - TinkerHarvestTools (Enabled/Forced)     - TinkerMeleeWeapons (Enabled/Forced)     - TinkerRangedWeapons (Enabled/Forced)     - TinkerModifiers (Enabled/Forced)     - TinkerSmeltery (Enabled/Not Forced)     - TinkerGadgets (Enabled/Not Forced)     - TinkerOredict (Enabled/Forced)     - TinkerIntegration (Enabled/Forced)     - TinkerFluids (Enabled/Forced)     - TinkerMaterials (Enabled/Forced)     - TinkerModelRegister (Enabled/Forced)     - wailaIntegration (Enabled/Not Forced)     - quarkIntegration (Enabled/Not Forced) [23:03:47] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:func_179870_a:553]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Piotroxx\AppData\Roaming\Crystal-Launcher\instances\u.PiotroxxPack1\.minecraft\crash-reports\crash-2021-04-11_23.03.47-client.txt  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.