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

I want to make my custom entity spawn naturally in a nether fortress, but I have no idea how. I found out that structure modifiers exist but I can't find any information about them.

There are structure settings, but there is currently no way to modify them without overriding the value. The best you can do is have your specific entity check if they are in a structure within the registered predicate via SpawnPlacementRegisterEvent.

  • Author

I've been trying many different ways and I found a way, but it doesn't work with Forge, only Fabric, probably because of the way Forge registers things.

@Mixin(NetherFortressStructure.class)
public abstract class NetherFortressStructureMixin {
    @SuppressWarnings("unchecked")
    @Redirect(method = "<clinit>", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/random/WeightedRandomList;create([Lnet/minecraft/util/random/WeightedEntry;)Lnet/minecraft/util/random/WeightedRandomList;"))
    private static <E extends WeightedEntry> WeightedRandomList<E> redirectSpawnerData(E[] array) {
        ArrayList<E> list = new ArrayList<>(List.of(array));
        list.add((E) new MobSpawnSettings.SpawnerData(ModEntityTypes.WILDFIRE.get(), 5, 1, 1));
        return WeightedRandomList.create(list);
    }
}

It tells me "Registry Object not present" with the ModEntityTypes.WILDFIRE.get().

Is there a way I can fix this, and is this even a good way to do this?

Also how do I check if the spawn location is inside a structure if the mixin way fails?

On 1/22/2023 at 11:40 AM, Kaboom Roads said:

It tells me "Registry Object not present" with the ModEntityTypes.WILDFIRE.get().

Well yeah, mixins are applied manually and vanilla entries are added before mods are even loaded. This generally wouldn't work on Fabric too, but since you can initialize registry objects whenever you want, you typically don't encounter it.

On 1/22/2023 at 11:40 AM, Kaboom Roads said:

Is there a way I can fix this, and is this even a good way to do this?

I can think of a way that involves getting the specific item list from the weighted random, and replacing the immutable list with another to append the entry that would need to be done after registries (so probably common setup), but I would recommend against it as there are probably some side effects I would be neglecting.

On 1/22/2023 at 11:40 AM, Kaboom Roads said:

Also how do I check if the spawn location is inside a structure if the mixin way fails?

SpawnPlacementRegisterEvent and check if the position is in a structure. See LocationPredicate

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.