-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to 1.21 Ported to NeoForge Fix for MC-177381 Added /dumpstructuresets command Pushed the 4096 chunk limit to max. integer
- Loading branch information
Showing
42 changed files
with
480 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,51 @@ | ||
# MultiLoader Template | ||
|
||
This project provides a Gradle project template that can compile mods for multiple modloaders using a common sourceset. This project does not require any third party libraries or dependencies. If you have any questions or want to discuss the project join our [Discord](https://discord.myceliummod.network). | ||
|
||
## Getting Started | ||
|
||
### IntelliJ IDEA | ||
This guide will show how to import the MultiLoader Template into IntelliJ IDEA. The setup process is roughly equivalent to setting up the modloaders independently and should be very familiar to anyone who has worked with their MDKs. | ||
|
||
1. Clone or download this repository to your computer. | ||
2. Configure the project by editing the `group`, `mod_name`, `mod_author`, and `mod_id` properties in the `gradle.properties` file. You will also need to change the `rootProject.name` property in `settings.gradle`, this should match the folder name of your project, or else IDEA may complain. | ||
3. Open the template's root folder as a new project in IDEA. This is the folder that contains this README file and the gradlew executable. | ||
4. If your default JVM/JDK is not Java 21 you will encounter an error when opening the project. This error is fixed by going to `File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Gradle JVM` and changing the value to a valid Java 21 JVM. You will also need to set the Project SDK to Java 21. This can be done by going to `File > Project Structure > Project SDK`. Once both have been set open the Gradle tab in IDEA and click the refresh button to reload the project. | ||
5. Open the Gradle tab in IDEA if it has not already been opened. Navigate to `Your Project > Common > Tasks > vanilla gradle > decompile`. Run this task to decompile Minecraft. | ||
6. Open your Run/Debug Configurations. Under the Application category there should now be options to run NeoForge and Fabric projects. Select one of the client options and try to run it. | ||
7. Assuming you were able to run the game in step 7 your workspace should now be set up. | ||
|
||
### Eclipse | ||
While it is possible to use this template in Eclipse it is not recommended. During the development of this template multiple critical bugs and quirks related to Eclipse were found at nearly every level of the required build tools. While we continue to work with these tools to report and resolve issues support for projects like these are not there yet. For now Eclipse is considered unsupported by this project. The development cycle for build tools is notoriously slow so there are no ETAs available. | ||
|
||
## Development Guide | ||
When using this template the majority of your mod is developed in the Common project. The Common project is compiled against the vanilla game and is used to hold code that is shared between the different loader-specific versions of your mod. The Common project has no knowledge or access to ModLoader specific code, apis, or concepts. Code that requires something from a specific loader must be done through the project that is specific to that loader, such as the NeoForge or Fabric project. | ||
|
||
Loader specific projects such as the NeoForge and Fabric project are used to load the Common project into the game. These projects also define code that is specific to that loader. Loader specific projects can access all of the code in the Common project. It is important to remember that the Common project can not access code from loader specific projects. | ||
|
||
## Removing Platforms and Loaders | ||
While the MultiLoader Template includes support for many platforms and loaders you can easily remove support for the ones you don't need. This can be done by deleting the subproject folder and then removing it from the `settings.gradle` file. For example if you wanted to remove support for Forge you would follow the following steps. | ||
|
||
1. Delete the subproject folder. For example, delete `MultiLoader-Template/forge`. | ||
2. Remove the project from `settings.gradle`. For example, remove `include("forge")`. | ||
# <img src="media/icon_small.png" width="128" title="Sparse Structs Icon" style="vertical-align: middle"> Sparse Structures | ||
A simple and configurable mod that makes all (even datapacks and modded) structures more spread out (or more common!), essentially making them rarer/easier to find. Useful in big modpacks with a lot of structures mod to encourage exploration and make the experience more challenging or balanced. | ||
|
||
> Notice: this does not alter the generation of ores/geodes or other features of this kind, and alters very slightly the terrain and trees (not enough to be an issue to most players). | ||
## Examples | ||
 | ||
|
||
### In a modded environment: | ||
 | ||
 | ||
<details><summary>Structure Mods in the picture :</summary> | ||
Tidal towns, Explorify, all Yung's mods, Just Another Structure Pack, MVS, Explorations, Towns and Towers, Dungeons and Taverns... | ||
</details> | ||
|
||
## Features | ||
* **Configurable** : you can change the rarity of all individual structures, even from mods and datapacks. | ||
* **MC-177381 fix** : fixes the bug where `/locate` returns an incorrect distance between the player and the structure. | ||
* **Dump Structure Sets** : you can dump all structure sets to a file in the right format for the config using `/dumpstructuresets`. | ||
* **No separation limit** : In vanilla, the separation between structures is limited to 4096 chunks (65k blocks). This mod removes this limit, allowing structures to be even more spread out (if for any reason you need structures to be that rare). | ||
|
||
## Configuration | ||
The config can be found in the `config` folder of your instance, and is named `sparsestructures.json5`. It contains the following options : | ||
* `spreadFactor` : the factor by which the separation and spacing of structures should be multiplied. The default value is `2`, which means that structures will be twice as rare. If you want structures to be more common, you can set this value to `0.5` for example. | ||
* ⚠️ **Warning** : a very low value (like `0.01`) makes the world generation process considerably slower (and your world will become filled with overlapping structures). | ||
* `customSpreadFactors` : a list of custom spread factors for specific structures. The default value makes the mansion twice as rare as an example (which has no effects with a global `spreadFactor` of 2). If you want to change the spread factor of a structure, you can add an entry to this list. Each entry is a JSON object with two fields : `name` (the name of the structure) and `spreadFactor` (the spread factor of the structure). Here's an example : | ||
```json5 | ||
{ | ||
"name": "minecraft:mansion", | ||
"spreadFactor": 2 | ||
} | ||
// More detailed info can be found inside the config file | ||
``` | ||
> Tip: you can dump all structure sets to a file in the right format by using the custom command `/dumpstructuresets` | ||
For now, you have to restart the game for the config to be reloaded. This behavior may change in the future. | ||
|
||
## Dependencies | ||
This mod doesn't have any (not even fabric-api). | ||
|
||
## Future Updates | ||
* Ban specific structures from generating | ||
* World-specific configs | ||
* Support for frequency-based structure generation | ||
* Support for structure tags in the config | ||
* *Open an issue on this project's repo if you have any suggestion!* | ||
* *~~Add a config~~* (added in v2.0) | ||
|
||
## Credits | ||
Icon made with [Gimp](https://www.gimp.org/) using [Twemoji](https://github.com/twitter/twemoji) and [FiraCode](https://github.com/tonsky/FiraCode) | ||
[Multiloader Template](https://github.com/jaredlll08/MultiLoader-Template) by jaredlll08 |
31 changes: 0 additions & 31 deletions
31
common/src/main/java/com/example/examplemod/CommonClass.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
common/src/main/java/com/example/examplemod/Constants.java
This file was deleted.
Oops, something went wrong.
19 changes: 0 additions & 19 deletions
19
common/src/main/java/com/example/examplemod/mixin/MixinMinecraft.java
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
common/src/main/java/io/github/maxencedc/sparsestructures/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.maxencedc.sparsestructures; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
public class Constants { | ||
|
||
public static final String MOD_ID = "sparsestructures"; | ||
public static final String MOD_NAME = "Sparse Structures"; | ||
public static final Logger LOG = LoggerFactory.getLogger(MOD_NAME); | ||
public static final String CONFIG_RESOURCE_NAME = "sparse-structures-default-config.json5"; | ||
public static final String CONFIG_FILENAME = "sparsestructures.json5"; | ||
public static final Path CONFIG_FILE_PATH = Path.of("config", CONFIG_FILENAME); | ||
} |
19 changes: 19 additions & 0 deletions
19
common/src/main/java/io/github/maxencedc/sparsestructures/CustomSpreadFactors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.github.maxencedc.sparsestructures; | ||
|
||
public class CustomSpreadFactors { | ||
public String structure; | ||
public double factor; | ||
|
||
public CustomSpreadFactors(String structure, double factor) { | ||
this.structure = structure; | ||
this.factor = factor; | ||
} | ||
|
||
public String structure() { | ||
return this.structure; | ||
} | ||
|
||
public double factor() { | ||
return this.factor; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
common/src/main/java/io/github/maxencedc/sparsestructures/SparseStructuresCommon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.github.maxencedc.sparsestructures; | ||
|
||
import io.github.maxencedc.sparsestructures.platform.Services; | ||
|
||
import java.io.InputStream; | ||
import java.nio.file.StandardCopyOption; | ||
import java.nio.file.Files; | ||
|
||
import com.google.gson.Gson; | ||
|
||
import static io.github.maxencedc.sparsestructures.Constants.CONFIG_FILE_PATH; | ||
import static io.github.maxencedc.sparsestructures.Constants.CONFIG_RESOURCE_NAME; | ||
|
||
public class SparseStructuresCommon { | ||
public static SparseStructuresConfig config; | ||
|
||
public static void init() { | ||
|
||
if (Services.PLATFORM.isModLoaded(Constants.MOD_ID)) { | ||
|
||
if (!CONFIG_FILE_PATH.toFile().exists()) { | ||
try (InputStream in = SparseStructuresCommon.class.getClassLoader().getResourceAsStream(CONFIG_RESOURCE_NAME)) { | ||
if (in == null) throw new IllegalStateException("Failed to load SparseStructure's default config \"" + CONFIG_RESOURCE_NAME +"\""); | ||
Files.createDirectories(CONFIG_FILE_PATH); | ||
Files.copy(in, CONFIG_FILE_PATH, StandardCopyOption.REPLACE_EXISTING); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
try (final InputStream in = Files.newInputStream(CONFIG_FILE_PATH)) { | ||
config = new Gson().fromJson(new java.io.InputStreamReader(in), SparseStructuresConfig.class); | ||
} catch (Exception e) { | ||
throw new RuntimeException("SparseStructure's config file is malformed! If you don't know what's causing this, delete the config file and restart the game."); | ||
} | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/io/github/maxencedc/sparsestructures/SparseStructuresConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.maxencedc.sparsestructures; | ||
|
||
import java.util.List; | ||
|
||
public class SparseStructuresConfig { | ||
public double spreadFactor; | ||
public double spreadFactor() { return this.spreadFactor; } | ||
public List<CustomSpreadFactors> customSpreadFactors; | ||
public List<CustomSpreadFactors> customSpreadFactors() { return this.customSpreadFactors; } | ||
public SparseStructuresConfig(double spreadFactor, List<CustomSpreadFactors> customSpreadFactors) | ||
{ | ||
this.spreadFactor = spreadFactor; | ||
this.customSpreadFactors = customSpreadFactors; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
common/src/main/java/io/github/maxencedc/sparsestructures/StructureSetsSet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.github.maxencedc.sparsestructures; | ||
|
||
import java.util.SortedSet; | ||
import java.util.TreeSet; | ||
|
||
public class StructureSetsSet { | ||
public static SortedSet<String> structureSets = new TreeSet<>(); | ||
|
||
public static void addStructureSet(String structureSet) { | ||
structureSets.add(structureSet); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
.../src/main/java/io/github/maxencedc/sparsestructures/command/DumpStructureSetsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package io.github.maxencedc.sparsestructures.command; | ||
|
||
import com.mojang.brigadier.CommandDispatcher; | ||
import io.github.maxencedc.sparsestructures.Constants; | ||
import io.github.maxencedc.sparsestructures.StructureSetsSet; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.network.chat.Component; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
import static net.minecraft.commands.Commands.literal; | ||
|
||
|
||
public class DumpStructureSetsCommand { | ||
|
||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { | ||
|
||
dispatcher.register( | ||
literal("dumpstructuresets") | ||
.requires(cs -> cs.hasPermission(2)) | ||
.executes(context -> { | ||
context.getSource().sendSuccess(() -> Component.literal("Dumping structure set..."), false); | ||
String fileName = new SimpleDateFormat("'structure_sets_dump_'yy_MM_dd_HH_mm'.txt'").format(new Date()); | ||
try { | ||
dumpStructureSets(fileName); | ||
context.getSource().sendSuccess(() -> Component.literal("Structure sets dumped to: `" + Paths.get(Constants.MOD_ID, fileName) + "`\n(if you're on a server, this is dumped in the server's files)"), false); | ||
return 1; | ||
} catch (IOException e) { | ||
context.getSource().sendSuccess(() -> Component.literal("Failed to dump structure sets, check logs for error"), false); | ||
Constants.LOG.error("Failed to dump structure sets", e); | ||
return 0; | ||
} | ||
}) | ||
); | ||
} | ||
|
||
private static void dumpStructureSets(String fileName) throws IOException { | ||
Path dumpPath = Path.of(Constants.MOD_ID); | ||
StringBuilder dump = new StringBuilder(); | ||
StructureSetsSet.structureSets.forEach(s -> dump.append("{\n \"structure\": \"").append(s).append("\",\n \"factor\": 1//REPLACE WITH YOUR CUSTOM SPREADING FACTOR HERE\n},\n")); | ||
Files.createDirectories(dumpPath); | ||
Files.writeString(dumpPath.resolve(fileName), dump.toString()); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common/src/main/java/io/github/maxencedc/sparsestructures/mixin/FixLocateDistance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.github.maxencedc.sparsestructures.mixin; | ||
|
||
import net.minecraft.server.commands.LocateCommand; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
|
||
@Mixin(LocateCommand.class) | ||
public class FixLocateDistance { | ||
|
||
/** | ||
* @author Maxence | ||
* @reason Fix the distance calculation (MC-177381) | ||
*/ | ||
@Overwrite | ||
private static float dist(int pos1x, int pos1z, int pos2x, int pos2z) { | ||
double d = pos2x - pos1x; | ||
double e = pos2z - pos1z; | ||
return (float) Math.hypot(d, e); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...example/examplemod/platform/Services.java → ...c/sparsestructures/platform/Services.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...od/platform/services/IPlatformHelper.java → ...es/platform/services/IPlatformHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
common/src/main/resources/sparse-structures-default-config.json5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// ### THE MOD REQUIRES A RESTART OF THE GAME TO APPLY CHANGES ### | ||
{ | ||
// this is the main spread factor (default is 2) | ||
// | ||
// tips : a spread factor can be a decimal number (such as 1.5) | ||
// a spread factor of 1 means all structure's placement are not modified (useful if you want to use only custom spread factors) | ||
// a spread factor above 1 means all structures are rarer | ||
// a spread factor below 1 means all structure are more common | ||
"spreadFactor": 2, | ||
|
||
// this is a list of custom spread factors | ||
"customSpreadFactors": [ | ||
// example of the mansion being doubled in rarity (the mod's default) | ||
{ | ||
"structure": "minecraft:mansion", | ||
"factor": 2 | ||
}, | ||
// add the structures you want to modify in the format: | ||
// { | ||
// "structure": "namespace:structure_name", | ||
// "factor": number | ||
// }, | ||
// where "structure" is a structure_set or the name of a structure | ||
// /!\ if you put the name of a structure, all structures in its set will be modified | ||
// (example : "minecraft:village_plains" will modify all structures in the "villages" set) | ||
// see https://minecraft.wiki/w/Tutorials/Custom_structures#Structure_Set for more info | ||
// | ||
// tip : you can dump all structure sets in a file by running the custom command /dumpstructuresets | ||
// tip : the same spread factors rules apply here | ||
] | ||
} |
8 changes: 4 additions & 4 deletions
8
...src/main/resources/examplemod.mixins.json → ...in/resources/sparsestructures.mixins.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.