Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Im trying to add my attributes but they are not Registering

 

Main Class:

@Mod(test.MOD_ID)
@Mod.EventBusSubscriber(modid = test.MOD_ID, bus = Bus.MOD)
public class test
{
    public static final Logger LOGGER = LogManager.getLogger();
    public static final String MOD_ID = "test";

    public test() {
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientEvent);

        MinecraftForge.EVENT_BUS.register(modEventBus);
    }

    public void clientEvent(final FMLClientSetupEvent event){

    }



    public static void onRegisterEntities(final RegistryEvent.Register<EntityType<?>> event){
    }

    @SubscribeEvent
    public static void setup(final FMLCommonSetupEvent event) {
          DeferredWorkQueue.runLater(()->
         {
        GlobalEntityTypeAttributes.put(EntityInit.test_entity, TestEntity.setAttributes().create());
        });

    }
}

 

ModEntities:

@ObjectHolder(test.MOD_ID)
@Mod.EventBusSubscriber(modid = "test", bus = Mod.EventBusSubscriber.Bus.MOD)
public class EntityInit
{

  public static EntityType<TestEntity> test_entity = null;

  @SubscribeEvent
  public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
    event.getRegistry().register(EntityType.Builder.create(TestEntity::new, EntityClassification.CREATURE).size(1.0f, 2.f).build(new ResourceLocation(test.MOD_ID, "test_entity").toString()).setRegistryName("test_entity"));
  }
}

 

TestEntity:

public class TestEntity extends MobEntity {


    public TestEntity(EntityType<? extends MobEntity> p_i48576_1_, World p_i48576_2_) {
        super(p_i48576_1_, p_i48576_2_);

    }

    public static AttributeModifierMap.MutableAttribute setAttributes() {
        return MobEntity.func_233666_p_()
                .createMutableAttribute(Attributes.MAX_HEALTH, 100.0D)
                .createMutableAttribute(Attributes.MOVEMENT_SPEED, 0.25D);
    }

    @Nullable @Override
    protected SoundEvent getDeathSound()
    {
        return SoundEvents.BLOCK_ANVIL_DESTROY;
    }

 

Renderer:

public class TestEntityRenderer extends MobRenderer<TestEntity, TestEntityModdel<TestEntity>>
{

    protected static final ResourceLocation TEXTURE = new ResourceLocation(test.MOD_ID,"textures/entity/test_entity.png");

    public TestEntityRender(EntityRendererManager renderManagerIn)
    {super(renderManagerIn, new TestEntityModel(), 1.0f);}

    @Override public ResourceLocation getEntityTexture(TestEntity entity){return TEXTURE;}
}

 

Edited by UserMC123

  • Author

I tried to use DeferredRegister And they work but when I package my mod in to a .jar file and launch the game with it installed I get this

 

Test Mod (test) encountered an error during the common_setup event phase

 

And in the crash report I see this.

 

---- Minecraft Crash Report ----
// There are four lights!

Time: 12/15/20 3:20 PM
Description: Mod loading error has occurred

java.lang.Exception: Mod Loading has failed
    at net.minecraftforge.fml.CrashReportExtender.dumpModLoadingCrashReport(CrashReportExtender.java:85) [?:?] {re:classloading}
    at net.minecraftforge.fml.client.ClientModLoader.completeModLoading(ClientModLoader.java:188) [?:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.lambda$null$1(Minecraft.java:508) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft$$Lambda$3860/1126454617.run(Unknown Source) [?:?] {}
    at net.minecraft.util.Util.func_215077_a(SourceFile:404) [?:?] {re:classloading}
    at net.minecraft.client.Minecraft.lambda$new$2(Minecraft.java:504) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft$$Lambda$3572/1610803524.accept(Unknown Source) [?:?] {}
    at net.minecraft.client.gui.ResourceLoadProgressGui.func_230430_a_(ResourceLoadProgressGui.java:113) [?:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.renderer.GameRenderer.func_195458_a(GameRenderer.java:480) [?:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.func_195542_b(Minecraft.java:976) [?:?] {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.4-35.1.10.jar:35.1] {}
    at net.minecraftforge.fml.loading.FMLClientLaunchProvider$$Lambda$426/474933596.call(Unknown Source) [forge-1.16.4-35.1.10.jar:35.1] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.6.jar:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.6.jar:?] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at java.util.Objects.requireNonNull(Objects.java:290) ~[?:1.8.0_51] {}
-- MOD test --
Details:
    Mod File: modid-1.0.jar
    Failure message: Test Mod (test) encountered an error during the common_setup event phase
        java.lang.NullPointerException: Registry Object not present: test:test_entity
    Mod Version: 1.0
    Mod Issue URL: http://my.issue.tracker/
    Exception message: java.lang.NullPointerException: Registry Object not present: test:test_entity
Stacktrace:
    at java.util.Objects.requireNonNull(Objects.java:290) ~[?:1.8.0_51] {}
    at net.minecraftforge.fml.RegistryObject.get(RegistryObject.java:120) ~[?:?] {re:classloading}
    at com.test.testMod.util.ForgeEvents.EntityRenderer.registerEntityRenders(EntityRenderer.java:76) ~[?:1.0] 

 

  • Author

Fixed it. the problem was I had the wrong version of forge.

 

I needed to have:

[[dependencies.test]]
    modId="forge"
    mandatory=true
    versionRange="[35,)"
    ordering="NONE"
    side="BOTH"
[[dependencies.test]]
    modId="minecraft"
    mandatory=true
    versionRange="[1.16.4,1.17)"
    ordering="NONE"
    side="BOTH"

I had:

 

[[dependencies.test]]
    modId="forge"
    mandatory=true
    versionRange="[35,)"
    ordering="NONE"
    side="BOTH"
[[dependencies.test]]
    modId="minecraft"
    mandatory=true
    versionRange="[1.16.4,1.17)"
    ordering="NONE"
    side="BOTH"
  • UserMC123 changed the title to [SOLVED] [1.16.4] Entity Attributes not Registering

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.