Skip to content

Commit

Permalink
Removed Misleading methods
Browse files Browse the repository at this point in the history
  • Loading branch information
LudoCrypt committed Dec 13, 2020
1 parent 5aaf5a3 commit 9a15e99
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 109 deletions.
27 changes: 4 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -32,25 +30,14 @@ 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
}
}

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()
}

Expand All @@ -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
}
Expand All @@ -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.
}
}
23 changes: 8 additions & 15 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,24 +18,21 @@
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);
check(PerorateEnd.MIDLANDS_BIOME_SOURCE);
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);

Expand All @@ -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!!!!");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
42 changes: 23 additions & 19 deletions src/main/java/net/ludocrypt/perorate/world/PerorateEnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,22 +29,32 @@ public class PerorateEnd {
public static final Map<RegistryKey<Biome>, Biome.MixedNoisePoint> BARRENS_NOISE_POINTS = new HashMap<>();

public static void addCenterBiome(RegistryKey<Biome> 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, 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, 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, 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, Biome.MixedNoisePoint noise) {
Preconditions.checkNotNull(biome, "biome is null");
Preconditions.checkNotNull(noise, "noise is null");
BARRENS_NOISE_POINTS.put(biome, noise);
}

Expand Down Expand Up @@ -109,59 +119,53 @@ public static ChunkGenerator createEndGenerator(Registry<Biome> biomeRegistry, R
});
}

// Adds biomes to all non-center areas
@Deprecated
public static void addEndBiomeWithWeight(RegistryKey<Biome> 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);
addSmallIslandsBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness);
addBarrensBiomeWithWeight(biomeKey, noisePoint, weight, temperature, humidity, altitude, weirdness);
}

// Adds biomes to all biomes that (would've) had land
@Deprecated
public static void addLandBiomeWithWeight(RegistryKey<Biome> 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<Biome> 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<Biome> 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<Biome> 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<Biome> 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<Biome> 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));
}
}

}
1 change: 1 addition & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"mixins": [
"perorate.mixins.json"
],
"accessWidener": "perorate.accesswidener",
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/perorate.accesswidener
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions src/main/resources/perorate.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
"DimensionTypeMixin",
"MultiNoiseBiomeSourceAccessor",
"MultiNoiseBiomeSourcePresetAccessor",
"MixedNoisePointAccessor"
"MultiNoiseBiomeSourceAccessor"
],
"client": [
],
Expand Down

0 comments on commit 9a15e99

Please sign in to comment.