Repurposed Structures (Neoforge/Forge)

Repurposed Structures (Neoforge/Forge)

57M Downloads

1.16.4 v2.3.0 and v2.3.2 mod compatibility issue with finding Strongholds

trunksbomb opened this issue · 7 comments

commented

Lothrazar/Cyclic#1517

Cyclic has an item, the Solid Ender Eye, which is a reusable version of the Ender Eye for finding Strongholds. It calls the same function that the Ender Eye normally calls to find a Stronghold. Another user in the comments for that issue has narrowed it down to this mod, since it apparently replaces the Stronghold generation with its own version causing the vanilla function for locating a stronghold to no longer work.

I imagine that this would be an issue with any mod that uses the vanilla function for locating a Stronghold. Any way you could make the vanilla function still work with yours, or if you could provide an API for other mods to find your structures?

commented

The reason my stronghold is a completely separate structure is because it has some fundamental differences than normal strongholds such as silverfish blocks, more spawners, and can be set to be super massive. However, if one looks at the config, it is possible to have both my stronghold and vanilla's in the same world which is why I rather keep the locate command separate so to help show it is two completely separate structures and let people be able to find which one they want.

As for the eyes of ender, I mixin into the vanilla eye of ender to allow it to look up vanilla stronghold, repurposed structures stonebrick stronghold, and repurposed structures nether stronghold and return the closest one. Especially as with other mods (like World Blender) or datapacks, it is possible to even allow all 3 strongholds to spawn in a single world!
https://github.com/TelepathicGrunt/RepurposedStructures/blob/master/src/main/java/com/telepathicgrunt/repurposedstructures/mixin/EnderEyeStrongholdLocatingMixin.java

From what it seems like, your soul eye actually overrode the method I mixin into and so, it loses the functionality I add to the Eye of Ender. Though this isn't too hard to fix.
https://github.com/Lothrazar/Cyclic/blob/bbb19bfd2e802eee301cf48c0a98a68b167ffc6d/src/main/java/com/lothrazar/cyclic/item/endereye/ItemEnderEyeReuse.java#L27

To have your item find my strongholds, you can copy my mixin code to get the location of both the RS Stonebrick and RS Nether stronghold along with vanilla's and just check which one is closest (be sure to do a ModList.get().isLoaded(modid) check before attempting to check for my strongholds). Hmm. You may not even need to depend on my mod at all. Just grab the dynamic registry from the world and then go into StructureFeature registry in that and then feed it the resource location of my strongholds to get it from the registry and feed it into chunkGenerator.locateStructure(world, <stronghold>), playerPos, 100, false)

let me know if you need help!

commented

Oh wait, I thought you were the cyclic dev lol. i'll go poke them about this

commented

Thanks for the info. I do help out with the mod but I'm not the author. I can PR a fix, though, just depends on which one of us gets to it first.

commented

You register your stronghold feature here

public static final RegistryObject<Structure<NoFeatureConfig>> STONEBRICK_STRONGHOLD = registerStructure("stronghold_stonebrick", () -> (new RSStonebrickStrongholdStructure(NoFeatureConfig.CODEC)));

And your Mod ID is

public static final String MODID = "repurposed_structures";

Here's how I'm looking for you:

  private static final String RS_MODID = "repurposed_structures";
  private static final String RS_STRONGHOLD_ID = "stronghold_stonebrick";

...

System.out.println("Checking for existence of Repurposed Structures");
      Structure<?> structureToFind = Structure.STRONGHOLD;
      if (ModList.get().isLoaded(RS_MODID)) {
        System.out.println("RS is loaded");
        RegistryObject<Structure<?>> rsStructure = RegistryObject.of(new ResourceLocation(RS_MODID, RS_STRONGHOLD_ID), ForgeRegistries.STRUCTURE_FEATURES);
        if (rsStructure.isPresent()) {
          structureToFind = rsStructure.get();
          System.out.println("RS Stronghold feature was registered");
        }
        else {
          System.out.println("But no RS Stronghold feature was registered");
        }
      }
      else
        System.out.println("RS not loaded");

The log shows that your mod is loaded, but says that your feature isn't registered. I think I'm doing something wrong with how I'm looking for your feature though. It's definitely registered as repurposed_structures:stronghold_stonebrick, though, I verified it's in a dump of ForgeRegistries.STRUCTURE_FEATURES.

I believe this is the line where I'm doing something wrong.

RegistryObject<Structure<?>> rsStructure = RegistryObject.of(new ResourceLocation(RS_MODID, RS_STRONGHOLD_ID), ForgeRegistries.STRUCTURE_FEATURES);
commented

Instead of registry object, try and grab the structure directly from the registry itself. I'm not entirely sure how RegistryObject.o works but getting something from the registry itself should work safely. If the mod isnt on, the structure returned should be null too. Try this (with resource locations as a field)

        ForgeRegistries.STRUCTURE_FEATURES.getValue(new ResourceLocation("repurposed_structures:stronghold_stonebrick"));
        ForgeRegistries.STRUCTURE_FEATURES.getValue(new ResourceLocation("repurposed_structures:stronghold_nether"));
commented

I just changed it after that post and got it working.

cyclic_endereyefix

commented

All set, thanks for the help again.