diff --git a/build.gradle b/build.gradle index 62083f9..8fb844a 100644 --- a/build.gradle +++ b/build.gradle @@ -10,17 +10,15 @@ archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +minecraft { + accessWidener "src/main/resources/perorate.accesswidener" +} + 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}" - - // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. - // You may need to force-disable transitiveness on them. } processResources { @@ -32,15 +30,7 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. it.options.encoding = "UTF-8" - - // The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too - // JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used. - // We'll use that if it's available, but otherwise we'll use the older option. def targetVersion = 8 if (JavaVersion.current().isJava9Compatible()) { it.options.release = targetVersion @@ -48,9 +38,6 @@ tasks.withType(JavaCompile).configureEach { } java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. withSourcesJar() } @@ -60,11 +47,9 @@ jar { } } -// configure the maven publication publishing { publications { mavenJava(MavenPublication) { - // add all the jars that should be included when publishing to maven artifact(remapJar) { builtBy remapJar } @@ -73,10 +58,6 @@ publishing { } } } - - // Select the repositories you want to publish to - // To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`. repositories { - // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. } } diff --git a/gradle.properties b/gradle.properties index acbc12b..6ddd29c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,10 @@ -# Done to increase the memory available to gradle. - org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx1G -# Fabric Properties - # check these on https://fabricmc.net/use - minecraft_version=1.16.4 - yarn_mappings=1.16.4+build.7 - loader_version=0.10.8 +minecraft_version=1.16.4 +yarn_mappings=1.16.4+build.7 +loader_version=0.10.8 +fabric_version=0.28.1+1.16 -# Mod Properties - mod_version = 1.0.3 - maven_group = net.ludocrypt - archives_base_name = perorate - -# Dependencies - # currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api - fabric_version=0.25.1+build.416-1.16 +mod_version = 1.1.0 +maven_group = net.ludocrypt +archives_base_name = perorate \ No newline at end of file diff --git a/src/main/java/net/ludocrypt/perorate/mixin/MixedNoisePointAccessor.java b/src/main/java/net/ludocrypt/perorate/mixin/MixedNoisePointAccessor.java deleted file mode 100644 index 37ba8e5..0000000 --- a/src/main/java/net/ludocrypt/perorate/mixin/MixedNoisePointAccessor.java +++ /dev/null @@ -1,25 +0,0 @@ -package net.ludocrypt.perorate.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.world.biome.Biome; - -@Mixin(Biome.MixedNoisePoint.class) -public interface MixedNoisePointAccessor { - - @Accessor("temperature") - float temperature(); - - @Accessor("humidity") - float humidity(); - - @Accessor("altitude") - float altitude(); - - @Accessor("weirdness") - float weirdness(); - - @Accessor("weight") - float weight(); -} diff --git a/src/main/java/net/ludocrypt/perorate/mixin/MultiNoiseBiomeSourcePresetAccessor.java b/src/main/java/net/ludocrypt/perorate/mixin/MultiNoiseBiomeSourcePresetAccessor.java deleted file mode 100644 index 3b4e643..0000000 --- a/src/main/java/net/ludocrypt/perorate/mixin/MultiNoiseBiomeSourcePresetAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.ludocrypt.perorate.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import net.minecraft.util.Identifier; -import net.minecraft.world.biome.source.MultiNoiseBiomeSource; - -@Mixin(MultiNoiseBiomeSource.Preset.class) -public interface MultiNoiseBiomeSourcePresetAccessor { - @Accessor("id") - public Identifier id(); -} diff --git a/src/main/java/net/ludocrypt/perorate/util/NoiseCollisionChecker.java b/src/main/java/net/ludocrypt/perorate/util/NoiseCollisionChecker.java index 62698d2..4005b0b 100644 --- a/src/main/java/net/ludocrypt/perorate/util/NoiseCollisionChecker.java +++ b/src/main/java/net/ludocrypt/perorate/util/NoiseCollisionChecker.java @@ -10,7 +10,6 @@ import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback; import net.fabricmc.fabric.mixin.biome.MultiNoiseBiomeSourceAccessor; -import net.ludocrypt.perorate.mixin.MultiNoiseBiomeSourcePresetAccessor; import net.ludocrypt.perorate.world.PerorateEnd; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.world.biome.Biome; @@ -19,13 +18,11 @@ public class NoiseCollisionChecker { public static void init() { - check(PerorateEnd.CENTER_BIOME_SOURCE); check(PerorateEnd.HIGHLANDS_BIOME_SOURCE); check(PerorateEnd.MIDLANDS_BIOME_SOURCE); check(PerorateEnd.SMALL_ISLANDS_BIOME_SOURCE); check(PerorateEnd.BARRENS_BIOME_SOURCE); - RegistryEntryAddedCallback.event(BuiltinRegistries.BIOME).register(((i, identifier, biome) -> { check(PerorateEnd.CENTER_BIOME_SOURCE); check(PerorateEnd.HIGHLANDS_BIOME_SOURCE); @@ -33,10 +30,9 @@ public static void init() { check(PerorateEnd.SMALL_ISLANDS_BIOME_SOURCE); check(PerorateEnd.BARRENS_BIOME_SOURCE); })); - } - private static void check(MultiNoiseBiomeSource.Preset biomeSourcePreset) { + public static void check(MultiNoiseBiomeSource.Preset biomeSourcePreset) { MultiNoiseBiomeSource biomeSource = biomeSourcePreset.getBiomeSource(BuiltinRegistries.BIOME, 0L); @@ -54,7 +50,7 @@ private static void check(MultiNoiseBiomeSource.Preset biomeSourcePreset) { Biome prev = noisePoints.put(noisePoint, biome); if (prev != null) { - System.out.println("WARNING: " + biome + " and " + prev + " have the same mixed noise point in source of " + ((MultiNoiseBiomeSourcePresetAccessor) biomeSourcePreset).id() + toString(noisePoint) + "! They won't generate properly!!!!"); + System.out.println("WARNING: " + biome + " and " + prev + " have the same mixed noise point in source of " + biomeSourcePreset.id + toString(noisePoint) + "! They won't generate properly!!!!"); } } } diff --git a/src/main/java/net/ludocrypt/perorate/world/EndMultiNoiseBiomeSource.java b/src/main/java/net/ludocrypt/perorate/world/EndMultiNoiseBiomeSource.java index 22d303d..ebac225 100644 --- a/src/main/java/net/ludocrypt/perorate/world/EndMultiNoiseBiomeSource.java +++ b/src/main/java/net/ludocrypt/perorate/world/EndMultiNoiseBiomeSource.java @@ -84,12 +84,8 @@ public Biome getBiomeForNoiseGen(int biomeX, int biomeY, int biomeZ) { } } - public boolean seedMatches(long seed) { - return this.seed == seed; - } - public boolean matches(long seed, MultiNoiseBiomeSource centerBiome, MultiNoiseBiomeSource highlandsBiome, MultiNoiseBiomeSource midlandsBiome, MultiNoiseBiomeSource smallIslandsBiome, MultiNoiseBiomeSource barrensBiome) { - return this.seed == seed && this.centerBiome == centerBiome && this.highlandsBiome == highlandsBiome && this.midlandsBiome == midlandsBiome && this.smallIslandsBiome == smallIslandsBiome && this.barrensBiome == barrensBiome; + return this.seed == seed && this.centerBiome.matchesInstance(seed) && this.highlandsBiome.matchesInstance(seed) && this.midlandsBiome.matchesInstance(seed) && this.smallIslandsBiome.matchesInstance(seed) && this.barrensBiome.matchesInstance(seed); } // Stolen Shamelessly from lithium. diff --git a/src/main/java/net/ludocrypt/perorate/world/PerorateEnd.java b/src/main/java/net/ludocrypt/perorate/world/PerorateEnd.java index be88bf0..f5fcc85 100644 --- a/src/main/java/net/ludocrypt/perorate/world/PerorateEnd.java +++ b/src/main/java/net/ludocrypt/perorate/world/PerorateEnd.java @@ -7,9 +7,9 @@ import java.util.Optional; import java.util.function.Supplier; +import com.google.common.base.Preconditions; import com.mojang.datafixers.util.Pair; -import net.ludocrypt.perorate.mixin.MixedNoisePointAccessor; import net.ludocrypt.perorate.mixin.MultiNoiseBiomeSourceAccessor; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -29,22 +29,32 @@ public class PerorateEnd { public static final Map, Biome.MixedNoisePoint> BARRENS_NOISE_POINTS = new HashMap<>(); public static void addCenterBiome(RegistryKey biome, Biome.MixedNoisePoint noise) { + Preconditions.checkNotNull(biome, "biome is null"); + Preconditions.checkNotNull(noise, "noise is null"); CENTER_NOISE_POINTS.put(biome, noise); } public static void addHighlandsBiome(RegistryKey biome, Biome.MixedNoisePoint noise) { + Preconditions.checkNotNull(biome, "biome is null"); + Preconditions.checkNotNull(noise, "noise is null"); HIGHLANDS_NOISE_POINTS.put(biome, noise); } public static void addMidlandsBiome(RegistryKey biome, Biome.MixedNoisePoint noise) { + Preconditions.checkNotNull(biome, "biome is null"); + Preconditions.checkNotNull(noise, "noise is null"); MIDLANDS_NOISE_POINTS.put(biome, noise); } public static void addSmallIslandsBiome(RegistryKey biome, Biome.MixedNoisePoint noise) { + Preconditions.checkNotNull(biome, "biome is null"); + Preconditions.checkNotNull(noise, "noise is null"); SMALL_ISLANDS_NOISE_POINTS.put(biome, noise); } public static void addBarrensBiome(RegistryKey biome, Biome.MixedNoisePoint noise) { + Preconditions.checkNotNull(biome, "biome is null"); + Preconditions.checkNotNull(noise, "noise is null"); BARRENS_NOISE_POINTS.put(biome, noise); } @@ -109,7 +119,7 @@ public static ChunkGenerator createEndGenerator(Registry biomeRegistry, R }); } - // Adds biomes to all non-center areas + @Deprecated public static void addEndBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { addHighlandsBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness); addMidlandsBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness); @@ -117,51 +127,45 @@ public static void addEndBiomeWithWeight(RegistryKey biomeKey, Biome.Mixe addBarrensBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness); } - // Adds biomes to all biomes that (would've) had land + @Deprecated public static void addLandBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { addHighlandsBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness); addMidlandsBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness); addBarrensBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness); } - // Adds biomes to the Center + @Deprecated public static void addCenterBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { - MixedNoisePointAccessor noise = ((MixedNoisePointAccessor) noisePoint); for (int i = 0; i < weight; i++) { - addCenterBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noise.temperature() : (1 / weight) * i + noise.temperature(), !humidity ? noise.humidity() : (1 / weight) * i + noise.humidity(), !altitude ? noise.altitude() : (1 / weight) * i + noise.altitude(), !weirdness ? noise.weirdness() : (1 / weight) * i + noise.weirdness(), noise.weight())); + addCenterBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noisePoint.temperature : (1 / weight) * i + noisePoint.temperature, !humidity ? noisePoint.humidity : (1 / weight) * i + noisePoint.humidity, !altitude ? noisePoint.altitude : (1 / weight) * i + noisePoint.altitude, !weirdness ? noisePoint.weirdness : (1 / weight) * i + noisePoint.weirdness, noisePoint.weight)); } } - // Adds biomes to the Highlands + @Deprecated public static void addHighlandsBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { - MixedNoisePointAccessor noise = ((MixedNoisePointAccessor) noisePoint); for (int i = 0; i < weight; i++) { - addHighlandsBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noise.temperature() : (1 / weight) * i + noise.temperature(), !humidity ? noise.humidity() : (1 / weight) * i + noise.humidity(), !altitude ? noise.altitude() : (1 / weight) * i + noise.altitude(), !weirdness ? noise.weirdness() : (1 / weight) * i + noise.weirdness(), noise.weight())); + addHighlandsBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noisePoint.temperature : (1 / weight) * i + noisePoint.temperature, !humidity ? noisePoint.humidity : (1 / weight) * i + noisePoint.humidity, !altitude ? noisePoint.altitude : (1 / weight) * i + noisePoint.altitude, !weirdness ? noisePoint.weirdness : (1 / weight) * i + noisePoint.weirdness, noisePoint.weight)); } } - // Adds biomes to the Midlands + @Deprecated public static void addMidlandsBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { - MixedNoisePointAccessor noise = ((MixedNoisePointAccessor) noisePoint); for (int i = 0; i < weight; i++) { - addMidlandsBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noise.temperature() : (1 / weight) * i + noise.temperature(), !humidity ? noise.humidity() : (1 / weight) * i + noise.humidity(), !altitude ? noise.altitude() : (1 / weight) * i + noise.altitude(), !weirdness ? noise.weirdness() : (1 / weight) * i + noise.weirdness(), noise.weight())); + addMidlandsBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noisePoint.temperature : (1 / weight) * i + noisePoint.temperature, !humidity ? noisePoint.humidity : (1 / weight) * i + noisePoint.humidity, !altitude ? noisePoint.altitude : (1 / weight) * i + noisePoint.altitude, !weirdness ? noisePoint.weirdness : (1 / weight) * i + noisePoint.weirdness, noisePoint.weight)); } } - // Adds biomes to the Small Islands + @Deprecated public static void addSmallIslandsBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { - MixedNoisePointAccessor noise = ((MixedNoisePointAccessor) noisePoint); for (int i = 0; i < weight; i++) { - addSmallIslandsBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noise.temperature() : (1 / weight) * i + noise.temperature(), !humidity ? noise.humidity() : (1 / weight) * i + noise.humidity(), !altitude ? noise.altitude() : (1 / weight) * i + noise.altitude(), !weirdness ? noise.weirdness() : (1 / weight) * i + noise.weirdness(), noise.weight())); + addSmallIslandsBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noisePoint.temperature : (1 / weight) * i + noisePoint.temperature, !humidity ? noisePoint.humidity : (1 / weight) * i + noisePoint.humidity, !altitude ? noisePoint.altitude : (1 / weight) * i + noisePoint.altitude, !weirdness ? noisePoint.weirdness : (1 / weight) * i + noisePoint.weirdness, noisePoint.weight)); } } - // Adds biomes to the Barrens + @Deprecated public static void addBarrensBiomeWithWeight(RegistryKey biomeKey, Biome.MixedNoisePoint noisePoint, int weight, boolean temperature, boolean humidity, boolean altitude, boolean weirdness) { - MixedNoisePointAccessor noise = ((MixedNoisePointAccessor) noisePoint); for (int i = 0; i < weight; i++) { - addBarrensBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noise.temperature() : (1 / weight) * i + noise.temperature(), !humidity ? noise.humidity() : (1 / weight) * i + noise.humidity(), !altitude ? noise.altitude() : (1 / weight) * i + noise.altitude(), !weirdness ? noise.weirdness() : (1 / weight) * i + noise.weirdness(), noise.weight())); + addBarrensBiome(biomeKey, new Biome.MixedNoisePoint(!temperature ? noisePoint.temperature : (1 / weight) * i + noisePoint.temperature, !humidity ? noisePoint.humidity : (1 / weight) * i + noisePoint.humidity, !altitude ? noisePoint.altitude : (1 / weight) * i + noisePoint.altitude, !weirdness ? noisePoint.weirdness : (1 / weight) * i + noisePoint.weirdness, noisePoint.weight)); } } - } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index ac967a4..8b23752 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,6 +22,7 @@ "mixins": [ "perorate.mixins.json" ], + "accessWidener": "perorate.accesswidener", "depends": { "fabricloader": ">=0.7.4", "fabric": "*", diff --git a/src/main/resources/perorate.accesswidener b/src/main/resources/perorate.accesswidener new file mode 100644 index 0000000..9e8bf3c --- /dev/null +++ b/src/main/resources/perorate.accesswidener @@ -0,0 +1,7 @@ +accessWidener v1 named +accessible field net/minecraft/world/biome/source/MultiNoiseBiomeSource$Preset id Lnet/minecraft/util/Identifier; +accessible field net/minecraft/world/biome/Biome$MixedNoisePoint temperature F +accessible field net/minecraft/world/biome/Biome$MixedNoisePoint humidity F +accessible field net/minecraft/world/biome/Biome$MixedNoisePoint altitude F +accessible field net/minecraft/world/biome/Biome$MixedNoisePoint weirdness F +accessible field net/minecraft/world/biome/Biome$MixedNoisePoint weight F \ No newline at end of file diff --git a/src/main/resources/perorate.mixins.json b/src/main/resources/perorate.mixins.json index 0d819d0..4061034 100644 --- a/src/main/resources/perorate.mixins.json +++ b/src/main/resources/perorate.mixins.json @@ -5,9 +5,7 @@ "compatibilityLevel": "JAVA_8", "mixins": [ "DimensionTypeMixin", - "MultiNoiseBiomeSourceAccessor", - "MultiNoiseBiomeSourcePresetAccessor", - "MixedNoisePointAccessor" + "MultiNoiseBiomeSourceAccessor" ], "client": [ ],