Posted January 22, 20232 yr 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.
January 22, 20232 yr 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.
January 22, 20232 yr 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?
January 24, 20232 yr 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.