Hey dawg! I think I might be able to help you out with your issue here. I say might because I don't know about 1.16.x or any later version, but I know how to do this kind of thing for 1.12.2 forge. Basically, in the pre-init or init (I don't really remember which one) you just gotta' Okay, ykw, I just downloaded the 1.14.4 1.20.1 minecraft mdk. I think I actually can help you here. So, the 1.12.2 method actually doesn't work with 1.20.1 minecraft or later. Probably not too far before either. I see two options here for ya': First, it's important to note that the game stores its spawn data for structures in, well, the Structures class. Here, the game initializes an instance of each Structure class and registers them with the BootstrapContext using its bootstrap function. Each instance of a Structure class is registered with a StructureSettings class as an argument. One of the arguments, the one that you're probably going to be particularly interested in here, would be the spawnOverrides argument. For this argument, the game uses a Map between MOB_CATEGORIES and StructureSpawnOverride. StructureSpawnOverride is essentially the juice of it here. It contains almost everything you would need to control how your custom mob spawns in Pillager Outposts. Now, if you want to change how the Structure class for the pillager outposts is registered with the BootstrapContext in the bootstrap function, you're going to want to change where the function's caller gets the function and replace it with your own custom version of this function. How might you do this? This is where it gets a little tricky. The bootstrap function for the structures class is referenced in VanillaRegistries.BUILDER. However, unfortunately, this field is private and final, so you can't directly change it with reflections, but you can still access it with reflections. Now the VanillaRegistries.BUILDER field is of the type RegistrySetBuilder, which uses a private final field "entires", which is set as a List<RegistrySetBuilder.RegistryStub<?>> type. So here, you could use reflections to access this list field and remove the entry for the structures bootstrap. Then you might be able to create your own structures class and add change the bootstrap function to reflect the changes you wish. Then finally, simply re-add the Structure entry that you made to the list, and you should be completely done! Keep in mind, I haven't actually tested this, so I'm not sure if it would actually work, and even if it did work it's really unorthodox, so I would recommend trying this next idea. When the game is deciding whether or not to spawn an entity, if the entity is registered with the SpawnPlacements class, is uses the function you specify in the entity class to determine whether or not the entity can spawn in a certain spot. For example, the guardian cannot spawn on a block that is exposed to light from underwater because of this function. So what you could do is make a checkSelfSpawnRules function for your mob and register it with the SpawnPlacements function. Then, you could have your checkSelfSpawnRules function take into account if the block it's trying to spawn on is near a Pillager Outpost. Finally, you can get the coordinates to the chunk of your block and iterate through the ServerLevels in your MinecraftServer class and get their chunk sources and test if the chunk source has the chunk of your block position. If it does, you can then get the StructureManager from the ServerLevel. In there should be some very helpful functions for you to use. Although this is a bit more orthodox, it might be a bit laggy. It's really up to you which of these options you choose. If you need some additional clarification then please let me know, I would be happy to help you out! Also let me know if any of these options hit your goals for what your looking for here or not. If not then just let me know; I could probably find another method you could try.
By
Jackson Perr · 1 hour ago 1 hr
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.