-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling FeatureSet related entities in 1.20.3/4 (#16)
* Fix handling FeatureSet related entities. * Add 1.20.4 to build.yml * Turns out jsut need to enable the feature set in the server.properties * Remove the server.properties Lets not enable feature sets since they could change alot of stuff on use. The other fix in the PR still works as it makes it so that the entities don't show up as player type, just as unknow if we can't get them. * Use the same way of getting the entity in all parts of the generator. This should help deal with entities from features, since using the factory directly gets around the feature check. * Would be helpful to call the function correctly...
- Loading branch information
Showing
33 changed files
with
2,153 additions
and
1 deletion.
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
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 @@ | ||
plugins { | ||
id 'fabric-loom' | ||
} | ||
|
||
dependencies { | ||
// To change the versions see the gradle.properties file | ||
minecraft "com.mojang:minecraft:${project.minecraft_version}" | ||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" | ||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" | ||
|
||
// Fabric API. This is technically optional, but you probably want it anyway. | ||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" | ||
} | ||
|
||
processResources { | ||
filteringCharset "UTF-8" | ||
|
||
filesMatching("fabric.mod.json") { | ||
expand "version": project.version | ||
} | ||
} | ||
|
||
tasks.withType(JavaCompile).configureEach { | ||
it.options.encoding = "UTF-8" | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
} |
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,8 @@ | ||
# Fabric Properties | ||
# check these on https://modmuss50.me/fabric.html | ||
minecraft_version=1.20.4 | ||
yarn_mappings=1.20.4+build.3 | ||
loader_version=0.15.3 | ||
# Dependencies | ||
# check this on https://modmuss50.me/fabric.html | ||
fabric_version=0.92.0+1.20.4 |
14 changes: 14 additions & 0 deletions
14
1.20.4/src/main/java/dev/u9g/minecraftdatagenerator/Main.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,14 @@ | ||
package dev.u9g.minecraftdatagenerator; | ||
|
||
import net.fabricmc.api.ModInitializer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class Main implements ModInitializer { | ||
public static final Logger LOGGER = LoggerFactory.getLogger("mc-data-gen-serv"); | ||
|
||
@Override | ||
public void onInitialize() { | ||
|
||
} | ||
} |
317 changes: 317 additions & 0 deletions
317
1.20.4/src/main/java/dev/u9g/minecraftdatagenerator/generators/BiomesDataGenerator.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,317 @@ | ||
package dev.u9g.minecraftdatagenerator.generators; | ||
|
||
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonObject; | ||
import dev.u9g.minecraftdatagenerator.mixin.TheEndBiomeDataAccessor; | ||
import dev.u9g.minecraftdatagenerator.util.DGU; | ||
import net.fabricmc.fabric.api.biome.v1.NetherBiomes; | ||
import net.minecraft.registry.DynamicRegistryManager; | ||
import net.minecraft.registry.Registry; | ||
import net.minecraft.registry.RegistryKey; | ||
import net.minecraft.registry.RegistryKeys; | ||
import net.minecraft.util.Identifier; | ||
import net.minecraft.world.biome.Biome; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class BiomesDataGenerator implements IDataGenerator { | ||
private static final Set<RegistryKey<Biome>> END_BIOMES = new HashSet<>(); | ||
|
||
static { | ||
END_BIOMES.addAll(TheEndBiomeDataAccessor.END_BIOMES_MAP().keySet()); | ||
END_BIOMES.addAll(TheEndBiomeDataAccessor.END_BARRENS_MAP().keySet()); | ||
END_BIOMES.addAll(TheEndBiomeDataAccessor.END_MIDLANDS_MAP().keySet()); | ||
} | ||
|
||
private static String guessBiomeDimensionFromCategory(Biome biome, String biomeName) { | ||
var key = DGU.getWorld().getRegistryManager().get(RegistryKeys.BIOME).getKey(biome).orElseThrow(); | ||
if (NetherBiomes.canGenerateInNether(key)) { | ||
return "nether"; | ||
} else if (END_BIOMES.contains(key) || biomeName.startsWith("end_")) { | ||
return "end"; | ||
} | ||
return "overworld"; | ||
} | ||
|
||
private static String guessCategoryBasedOnName(String name, String dimension) { | ||
if (dimension.equals("nether")) { | ||
return "nether"; | ||
} else if (dimension.equals("end")) { | ||
return "the_end"; | ||
} | ||
|
||
if (name.contains("end")) { | ||
System.out.println(); | ||
} | ||
|
||
if (name.contains("hills")) { | ||
return "extreme_hills"; | ||
} else if (name.contains("ocean")) { | ||
return "ocean"; | ||
} else if (name.contains("plains")) { | ||
return "plains"; | ||
} else if (name.contains("ice") || name.contains("frozen")) { | ||
return "ice"; | ||
} else if (name.contains("jungle")) { | ||
return "jungle"; | ||
} else if (name.contains("desert")) { | ||
return "desert"; | ||
} else if (name.contains("forest") || name.contains("grove")) { | ||
return "forest"; | ||
} else if (name.contains("taiga")) { | ||
return "taiga"; | ||
} else if (name.contains("swamp")) { | ||
return "swamp"; | ||
} else if (name.contains("river")) { | ||
return "river"; | ||
} else if (name.equals("the_end")) { | ||
return "the_end"; | ||
} else if (name.contains("mushroom")) { | ||
return "mushroom"; | ||
} else if (name.contains("beach") || name.equals("stony_shore")) { | ||
return "beach"; | ||
} else if (name.contains("savanna")) { | ||
return "savanna"; | ||
} else if (name.contains("badlands")) { | ||
return "mesa"; | ||
} else if (name.contains("peaks") || name.equals("snowy_slopes") || name.equals("meadow")) { | ||
return "mountain"; | ||
} else if (name.equals("the_void")) { | ||
return "none"; | ||
} else if (name.contains("cave") || name.equals("deep_dark")) { | ||
return "underground"; | ||
} else { | ||
System.out.println("Unable to find biome category for biome with name: '" + name + "'"); | ||
return "none"; | ||
} | ||
} | ||
|
||
private static int getBiomeColorFor(String biomeName) { | ||
switch (biomeName) { | ||
case "the_void" -> { | ||
return 0; | ||
} | ||
case "plains" -> { | ||
return 9286496; | ||
} | ||
case "sunflower_plains" -> { | ||
return 11918216; | ||
} | ||
case "snowy_plains" -> { | ||
return 16777215; | ||
} | ||
case "ice_spikes" -> { | ||
return 11853020; | ||
} | ||
case "desert" -> { | ||
return 16421912; | ||
} | ||
case "swamp" -> { | ||
return 522674; | ||
} | ||
case "forest" -> { | ||
return 353825; | ||
} | ||
case "flower_forest" -> { | ||
return 2985545; | ||
} | ||
case "birch_forest" -> { | ||
return 3175492; | ||
} | ||
case "dark_forest" -> { | ||
return 4215066; | ||
} | ||
case "old_growth_birch_forest" -> { | ||
return 5807212; | ||
} | ||
case "old_growth_pine_taiga" -> { | ||
return 5858897; | ||
} | ||
case "old_growth_spruce_taiga" -> { | ||
return 8490617; | ||
} | ||
case "taiga" -> { | ||
return 747097; | ||
} | ||
case "snowy_taiga" -> { | ||
return 3233098; | ||
} | ||
case "savanna" -> { | ||
return 12431967; | ||
} | ||
case "savanna_plateau" -> { | ||
return 10984804; | ||
} | ||
case "windswept_hills" -> { | ||
return 6316128; | ||
} | ||
case "windswept_gravelly_hills" -> { | ||
return 8947848; | ||
} | ||
case "windswept_forest" -> { | ||
return 2250012; | ||
} | ||
case "windswept_savanna" -> { | ||
return 15063687; | ||
} | ||
case "jungle" -> { | ||
return 5470985; | ||
} | ||
case "sparse_jungle" -> { | ||
return 6458135; | ||
} | ||
case "bamboo_jungle" -> { | ||
return 7769620; | ||
} | ||
case "badlands" -> { | ||
return 14238997; | ||
} | ||
case "eroded_badlands" -> { | ||
return 16739645; | ||
} | ||
case "wooded_badlands" -> { | ||
return 11573093; | ||
} | ||
case "meadow" -> { | ||
return 9217136; | ||
} | ||
case "grove" -> { | ||
return 14675173; | ||
} | ||
case "snowy_slopes" -> { | ||
return 14348785; | ||
} | ||
case "frozen_peaks" -> { | ||
return 15399931; | ||
} | ||
case "jagged_peaks" -> { | ||
return 14937325; | ||
} | ||
case "stony_peaks" -> { | ||
return 13750737; | ||
} | ||
case "river" -> { | ||
return 255; | ||
} | ||
case "frozen_river" -> { | ||
return 10526975; | ||
} | ||
case "beach" -> { | ||
return 16440917; | ||
} | ||
case "snowy_beach" -> { | ||
return 16445632; | ||
} | ||
case "stony_shore" -> { | ||
return 10658436; | ||
} | ||
case "warm_ocean" -> { | ||
return 172; | ||
} | ||
case "lukewarm_ocean" -> { | ||
return 144; | ||
} | ||
case "deep_lukewarm_ocean" -> { | ||
return 64; | ||
} | ||
case "ocean" -> { | ||
return 112; | ||
} | ||
case "deep_ocean" -> { | ||
return 48; | ||
} | ||
case "cold_ocean" -> { | ||
return 2105456; | ||
} | ||
case "deep_cold_ocean" -> { | ||
return 2105400; | ||
} | ||
case "frozen_ocean" -> { | ||
return 7368918; | ||
} | ||
case "deep_frozen_ocean" -> { | ||
return 4210832; | ||
} | ||
case "mushroom_fields" -> { | ||
return 16711935; | ||
} | ||
case "dripstone_caves" -> { | ||
return 12690831; | ||
} | ||
case "lush_caves" -> { | ||
return 14652980; | ||
} | ||
case "nether_wastes" -> { | ||
return 12532539; | ||
} | ||
case "warped_forest" -> { | ||
return 4821115; | ||
} | ||
case "crimson_forest" -> { | ||
return 14485512; | ||
} | ||
case "soul_sand_valley" -> { | ||
return 6174768; | ||
} | ||
case "basalt_deltas" -> { | ||
return 4208182; | ||
} | ||
case "the_end" -> { | ||
return 8421631; | ||
} | ||
case "end_highlands" -> { | ||
return 12828041; | ||
} | ||
case "end_midlands" -> { | ||
return 15464630; | ||
} | ||
case "small_end_islands" -> { | ||
return 42; | ||
} | ||
case "end_barrens" -> { | ||
return 9474162; | ||
} | ||
} | ||
System.out.println("Don't know the color of biome: '" + biomeName + "'"); | ||
return 0; | ||
} | ||
|
||
public static JsonObject generateBiomeInfo(Registry<Biome> registry, Biome biome) { | ||
JsonObject biomeDesc = new JsonObject(); | ||
Identifier registryKey = registry.getKey(biome).orElseThrow().getValue(); | ||
String localizationKey = String.format("biome.%s.%s", registryKey.getNamespace(), registryKey.getPath()); | ||
String name = registryKey.getPath(); | ||
biomeDesc.addProperty("id", registry.getRawId(biome)); | ||
biomeDesc.addProperty("name", name); | ||
String dimension = guessBiomeDimensionFromCategory(biome, name); | ||
biomeDesc.addProperty("category", guessCategoryBasedOnName(name, dimension)); | ||
biomeDesc.addProperty("temperature", biome.getTemperature()); | ||
//biomeDesc.addProperty("precipitation", biome.getPrecipitation().getName());// - removed in 1.19.4 | ||
biomeDesc.addProperty("has_precipitation", biome.hasPrecipitation()); | ||
//biomeDesc.addProperty("depth", biome.getDepth()); - Doesn't exist anymore in minecraft source | ||
biomeDesc.addProperty("dimension", dimension); | ||
biomeDesc.addProperty("displayName", DGU.translateText(localizationKey)); | ||
biomeDesc.addProperty("color", getBiomeColorFor(registryKey.getPath())); | ||
//biomeDesc.addProperty("rainfall", biome.getDownfall());// - removed in 1.19.4 | ||
|
||
return biomeDesc; | ||
} | ||
|
||
@Override | ||
public String getDataName() { | ||
return "biomes"; | ||
} | ||
|
||
@Override | ||
public JsonArray generateDataJson() { | ||
JsonArray biomesArray = new JsonArray(); | ||
DynamicRegistryManager registryManager = DGU.getWorld().getRegistryManager(); | ||
Registry<Biome> biomeRegistry = registryManager.get(RegistryKeys.BIOME); | ||
|
||
biomeRegistry.stream() | ||
.map(biome -> generateBiomeInfo(biomeRegistry, biome)) | ||
.forEach(biomesArray::add); | ||
return biomesArray; | ||
} | ||
} |
Oops, something went wrong.