Jump to content

Recommended Posts

Posted (edited)

I've setup a very simple mod for Forge 1.16.3 where I'm trying to implement the new mobs shown into the Mob Vote. But when I try to summon an entity I get this error
 

[23:22:02] [Server thread/WARN] [minecraft/EntityType]: Exception loading entity: 
java.lang.NullPointerException: null
    at net.minecraft.entity.ai.attributes.AttributeModifierManager.func_233795_c_(AttributeModifierManager.java:67) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.LivingEntity.func_233637_b_(LivingEntity.java:1849) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.LivingEntity.getMaxHealth(LivingEntity.java:1610) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.LivingEntity.<init>(LivingEntity.java:209) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.MobEntity.<init>(MobEntity.java:108) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.entity.CreatureEntity.<init>(CreatureEntity.java:13) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.AgeableEntity.<init>(AgeableEntity.java:21) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.passive.AnimalEntity.<init>(AnimalEntity.java:37) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.passive.CowEntity.<init>(CowEntity.java:35) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at com.mobvote.entity.MoobloomEntity.<init>(MoobloomEntity.java:19) ~[main/:?] {re:classloading}
    at net.minecraft.entity.EntityType.create(EntityType.java:448) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.EntityType.lambda$loadEntityUnchecked$1(EntityType.java:459) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at java.util.Optional.map(Optional.java:215) ~[?:1.8.0_221] {}
    at net.minecraft.entity.EntityType.loadEntityUnchecked(EntityType.java:458) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.EntityType.loadEntity(EntityType.java:516) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.entity.EntityType.func_220335_a(EntityType.java:498) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.command.impl.SummonCommand.summonEntity(SummonCommand.java:50) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at net.minecraft.command.impl.SummonCommand.lambda$register$1(SummonCommand.java:34) ~[forge-1.16.3-34.1.0_mapped_snapshot_20200514-1.16-recomp.jar:?] {re:classloading}
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:262) ~[brigadier-1.0.17.jar:?] {re:classloading}
    at net.minecraft.command.Commands.handleCommand(Commands.java:222) ~[?:?] {re:classloading}
    at net.minecraft.network.play.ServerPlayNetHandler.handleSlashCommand(ServerPlayNetHandler.java:1079) ~[?:?] {re:classloading}
    at net.minecraft.network.play.ServerPlayNetHandler.processChatMessage(ServerPlayNetHandler.java:1059) ~[?:?] {re:classloading}
    at net.minecraft.network.play.client.CChatMessagePacket.processPacket(CChatMessagePacket.java:40) ~[?:?] {re:classloading}
    at net.minecraft.network.play.client.CChatMessagePacket.processPacket(CChatMessagePacket.java:8) ~[?:?] {re:classloading}
    at net.minecraft.network.PacketThreadUtil.lambda$checkThreadAndEnqueue$0(PacketThreadUtil.java:19) ~[?:?] {re:classloading}
    at net.minecraft.util.concurrent.TickDelayedTask.run(TickDelayedTask.java:20) ~[?:?] {re:classloading}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[?:?] {re:classloading}
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:754) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:156) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.driveOneInternal(MinecraftServer.java:737) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.driveOne(MinecraftServer.java:731) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.drainTasks(ThreadTaskExecutor.java:97) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.runScheduledTasks(MinecraftServer.java:716) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:663) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.lambda$func_240784_a_$0(MinecraftServer.java:230) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_221] {}


The entity is just an extension to the Cow, and it's class is this
 

/**
 * Moobloom Entity
 */
public class MoobloomEntity extends CowEntity {

    /**
     * Constructor. Set the Entity Type and the World
     *
     * @param type Entity Type
     * @param worldIn World
     */
    public MoobloomEntity(EntityType<? extends CowEntity> type, World worldIn) {
        super(type, worldIn);
    }
}

Which is registerd like this
 

/**
     * Entity Registry
     */
    public static final DeferredRegister<EntityType<?>> ENTITY_REGISTRY = DeferredRegister.create(ForgeRegistries.ENTITIES, MobVote.MOD_ID);

public static final RegistryObject<EntityType<MoobloomEntity>> MOOBLOOM_ENTITY = ENTITY_REGISTRY.register("moobloom",
            () -> EntityType.Builder.create(MoobloomEntity::new, EntityClassification.CREATURE)
                            .size(0.9f, 1.4f)
                            .build(new ResourceLocation(MobVote.MOD_ID, "moobloom").toString()));


The register method for the Entity Registry is called from the mod constructor
 

public MobVote() {
        final IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();

        MobVoteEntities.ENTITY_REGISTRY.register(modEventBus);
        MinecraftForge.EVENT_BUS.register(this);
    }

 

I used to do this in 1.15.2, has something changed in 1.16 or am I missing something?

Edited by JimiIT92
solved

Don't blame me if i always ask for your help. I just want to learn to be better :)

Posted

So that's mandatory now... Ok, registering attributes using the enqueWork method works. Thank you for the help :)

Don't blame me if i always ask for your help. I just want to learn to be better :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.