Jump to content

Recommended Posts

Posted

I will use Forge 47.1.0 for Minecraft 1.20.1 as the example (offical mappings channel).

In MinecraftServer$createLevels, vanilla use the following code to add spawners for overworld:

List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(serverleveldata));

I think it useful to post an event here to add spawners for overworld, and other dimensions. For example:

List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(serverleveldata));
//change begin
AddCustomSpawnersEvent event = new AddCustomSpawnersEvent(ImmutableList.<CustomSpawner>builder().addAll(list), LevelStem.OVERWORLD);
MinecraftForge.EVENT_BUS.post(event);
LevelStem levelstem = registry.get(LevelStem.OVERWORLD);
ServerLevel serverlevel = new ServerLevel(this, this.executor, this.storageSource, serverleveldata, Level.OVERWORLD, levelstem, p_129816_, flag, j, event.getCustomSpawnerBuilder().build(), true, (RandomSequences)null);
//change end

//...

for(Map.Entry<ResourceKey<LevelStem>, LevelStem> entry : registry.entrySet()) {
   ResourceKey<LevelStem> resourcekey = entry.getKey();
   if (resourcekey != LevelStem.OVERWORLD) {
      ResourceKey<Level> resourcekey1 = ResourceKey.create(Registries.DIMENSION, resourcekey.location());
      DerivedLevelData derivedleveldata = new DerivedLevelData(this.worldData, serverleveldata);
//change begin
      AddCustomSpawnersEvent event = new AddCustomSpawnersEvent(ImmutableList.<CustomSpawner>builder(), resourcekey);
      MinecraftForge.EVENT_BUS.post(event);
      ServerLevel serverlevel1 = new ServerLevel(this, this.executor, this.storageSource, derivedleveldata, resourcekey1, entry.getValue(), p_129816_, flag, j, event.getCustomSpawnerBuilder().build(), false, randomsequences);
//change end
      worldborder.addListener(new BorderChangeListener.DelegateBorderChangeListener(serverlevel1.getWorldBorder()));
      this.levels.put(resourcekey1, serverlevel1);
      net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.level.LevelEvent.Load(levels.get(resourcekey)));
   }
}

Now the only way I can add custom spawners is to inject constructor of ServerLevel and modify final member customSpawners.

Posted

This isn't a bad idea, we typically have these things go through the GitHub PR system. However couple questions. All spawners get is a tick method. Why not use our level tick event?

The only information that spawners get is (this.spawnEnemies, this.spawnFriendlies), which are private fields, so we could add getters. 

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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