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

1.16.x Entity Attributes not being registered


Recommended Posts

Hi, I am trying to add a custom entity, however whenever I try to summon the entity I keep receiving the following error.

[10:19:35] [Server thread/WARN] [minecraft/EntityType]: Exception loading entity: 
java.lang.NullPointerException: null
	at net.minecraft.entity.ai.attributes.AttributeModifierManager.getAttributeValue(AttributeModifierManager.java:67) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.getAttributeValue(LivingEntity.java:1849) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.getMaxHealth(LivingEntity.java:1610) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:209) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.MobEntity.<init>(MobEntity.java:108) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.AgeableEntity.<init>(AgeableEntity.java:21) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.passive.AnimalEntity.<init>(AnimalEntity.java:37) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.passive.CowEntity.<init>(CowEntity.java:35) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at me.minecraft.star.entities.TestEntity.<init>(TestEntity.java:15) ~[main/:?] {re:classloading}
	at net.minecraft.entity.EntityType.create(EntityType.java:448) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
	at net.minecraft.entity.EntityType.lambda$loadEntityUnchecked$1(EntityType.java:459) ~[forge-1.16.4-35.1.4_mapped_snapshot_20201028-1.16.3-recomp.jar:?] {re:classloading}
//removed excess
	at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:721) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:667) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:233) ~[forge:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282] {}
[10:19:35] [Render thread/INFO] [minecraft/NewChatGui]: [CHAT] Unable to summon entity

I have tried multiple different methods but for some reason the entity attributes are not being set correctly. I am currently using the method suggested in the topic below with no success. 

https://forums.minecraftforge.net/topic/87597-1161-custom-entity-attributes/

 

Code:

Main class:

@Mod(Main.MODID)
public class Main {
	//Removed excess
    private void setup(final FMLCommonSetupEvent event)
    {
    	LOGGER.info("STAR - Setup Complete");
    	DeferredWorkQueue.runLater(() -> {
            GlobalEntityTypeAttributes.put(EntityRegister.TESTENTITY_TYPE, TestEntity.setCustomAttributes().create());
        });
    }
	
}

Entity Class:

public class TestEntity extends CowEntity {
	//Removed Excess
	
	public static AttributeModifierMap.MutableAttribute setCustomAttributes() {
        return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MOVEMENT_SPEED,  (double)0.5F).createMutableAttribute(Attributes.MAX_HEALTH, 20.0D).createMutableAttribute(Attributes.ATTACK_DAMAGE, 5.0D);
    }
}

I am using a deferred register method to register entities and it seems to be registering them successfully in the output. It also appears in the commands autofill.

Any help would be greatly appreciated :)

Link to post
Share on other sites
  • 3 weeks later...

Okay, so I've tried to add it as a subscribe event but it does not appear to exist. I'm using forge-1.16.4-35.1.4 in the eclipse IDE.

Here is the event I created:

    @SubscribeEvent
    public void entityAttributeCreationEvent(EntityAttributeCreationEvent event) { //EntityAttributeCreateEvent cannot be resolved to a type
    	
    }

There don't seem to be any import candidates.

Link to post
Share on other sites

Thanks for all your help. Here is the method that seems to register the attributes correctly.

Entity Class:

public class TestEntity extends CowEntity {

	public static final String REG = "simple_entity";
	public static final EntityType<TestEntity> TYPE = EntityType.Builder.<TestEntity>of(TestEntity::new, EntityClassification.MISC)
			.sized(0.98F, 0.7F)
			.clientTrackingRange(8)
			.build(REG);
	public static final AttributeModifierMap MAP = AttributeModifierMap.builder().add(Attributes.MAX_HEALTH, 20.0)
			.add(Attributes.MOVEMENT_SPEED, 20.0)
			.add(Attributes.FOLLOW_RANGE, 20.0)
			.build();
	
	public TestEntity(EntityType<? extends CowEntity> p_i48567_1_, World p_i48567_2_) {
		super(p_i48567_1_, p_i48567_2_);
		this.setNoAi(true);
		
	}
}	

Main Class:

@Mod(Main.MODID)
public class Main {
  	//trim
	public Main() {
		IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();
		bus.register(this.getClass());
		//trim
		LOGGER.info("STAR has been initialised");
	}
	//trim

    @SubscribeEvent
	public static void entityAttributeCreationEvent(EntityAttributeCreationEvent event) {
    	LOGGER.info("STAR - Entity Attribute Event");
		event.put(TestEntity.TYPE, TestEntity.MAP);
	}

	//trim
}

Now I seem to have an error where there is no defined ai for the entity causing a ticking crash but I'll make a separate topic for that.

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

    • My build.gradle:  buildscript { repositories { maven { url = 'https://files.minecraftforge.net/maven' } mavenCentral() jcenter() } dependencies { classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true } } plugins { id 'com.github.johnrengelman.shadow' version '6.1.0' } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' apply plugin: 'maven-publish' version = '1.0' group = 'com.tatuck.coordinateslocator' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'tatuckcoordslocator' java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8. println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch')) minecraft { mappings channel: 'official', version: '1.16.5' runs { client { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } } server { workingDirectory project.file('run/server') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' mods { examplemod { source sourceSets.main } } setForceExit(false) } data { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' args '--mod', 'examplemod', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') mods { examplemod { source sourceSets.main } } } } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } dependencies { minecraft 'net.minecraftforge:forge:1.16.5-36.1.0' compile 'org.mongodb:mongodb-driver-sync:4.2.3' shadow 'org.mongodb:mongodb-driver-sync:4.2.3' shadow 'org.mongodb:bson:4.2.3' // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } // Example for how to get properties into the manifest for reading by the runtime.. jar { manifest { attributes([ "Specification-Title": "examplemod", "Specification-Vendor": "examplemodsareus", "Specification-Version": "1", // We are version 1 of ourselves "Implementation-Title": project.name, "Implementation-Version": "${version}", "Implementation-Vendor" :"examplemodsareus", "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } // Example configuration to allow publishing using the maven-publish task // This is the preferred method to reobfuscate your jar file jar.finalizedBy('reobfJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing //publish.dependsOn('reobfJar') publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file:///${project.projectDir}/mcmodsrepo" } } } shadowJar { configurations = [project.configurations.shadow] } reobf { shadowJar {} }   Update:  I have tried again and now it is showing me this error: Description: mouseClicked event handler java.lang.NoSuchMethodError: net.minecraft.client.Minecraft.getInstance()Lnet/minecraft/client/Minecraft; at com.tatuck.coordinateslocator.TatuckCoordinatesLocator.onSound(TatuckCoordinatesLocator.java:43) ~[?:1.0] {re:classloading} at net.minecraftforge.eventbus.ASMEventHandler_0_TatuckCoordinatesLocator_onSound_PlaySoundEvent.invoke(.dynamic) ~[?:?] {} at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus$$Lambda$2544/1439945495.invoke(Unknown Source) ~[?:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {} at net.minecraftforge.client.ForgeHooksClient.playSound(ForgeHooksClient.java:282) ~[?:?] {re:classloading} at net.minecraft.client.audio.SoundEngine.func_148611_c(SoundEngine.java:271) ~[?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.audio.SoundHandler.func_147682_a(SoundHandler.java:136) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.widget.Widget.func_230988_a_(Widget.java:198) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.widget.Widget.func_231044_a_(Widget.java:135) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.INestedGuiEventHandler.func_231044_a_(SourceFile:27) ~[?:?] {re:classloading} at net.minecraft.client.gui.screen.MainMenuScreen.func_231044_a_(MainMenuScreen.java:288) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.func_198033_b(MouseHelper.java:87) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper$$Lambda$3917/1046211253.run(Unknown Source) ~[?:?] {} at net.minecraft.client.gui.screen.Screen.func_231153_a_(Screen.java:427) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.func_198023_a(MouseHelper.java:85) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.func_228030_c_(MouseHelper.java:175) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper$$Lambda$3916/2087758561.run(Unknown Source) ~[?:?] {} at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(SourceFile:94) ~[?:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.MouseHelper.func_228028_b_(MouseHelper.java:174) ~[?:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper$$Lambda$3530/1682774881.invoke(Unknown Source) ~[?:?] {} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwWaitEventsTimeout(GLFW.java:3174) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at com.mojang.blaze3d.systems.RenderSystem.limitDisplayFPS(SourceFile:127) ~[?:?] {re:classloading} at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:999) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:607) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) [?:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51] {} at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51] {} at net.minecraftforge.fml.loading.FMLClientLaunchProvider.lambda$launchService$0(FMLClientLaunchProvider.java:51) [forge-1.16.5-36.1.0.jar:36.1] {} at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$438/1260043537.call(Unknown Source) [forge-1.16.5-36.1.0.jar:36.1] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}  
    • Im working on a mod, but i dont know how i can make crops in Minecraft 1.16.Can somebody help me by making for example a tutorial?
    • I have tried but for some reason Minecraft doesn't detect the compiled mod. I don't think it is giving me an error because I have checked the logs but I found nothing.
    • https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/#the-version-checker
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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