Skip to content

Commit b8699c5

Browse files
committed
Remove unnecessary reflection #change "Remove some unnecessary reflection throwing errors" #release beta
1 parent 2bfda63 commit b8699c5

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
org.gradle.jvmargs=-Xmx1G
22

3-
mod_version=1.0.0
3+
mod_version=1.0.1
44
maven_group=com.terraformersmc
55
archive_name=cinderscapes
66

7-
minecraft_version=1.16
8-
yarn_mappings=1.16+build.1
7+
minecraft_version=1.16.1
8+
yarn_mappings=1.16.1+build.4
99
loader_version=0.8.8+build.202
1010
fabric_version=0.13.1+build.370-1.16
1111
terraform_version=1.6.10+build.21
@@ -23,7 +23,7 @@ default_release_type=beta
2323
# CurseForge Metadata
2424
curseforge_slug=cinderscapes
2525
curseforge_id=391429
26-
curseforge_game_versions=1.16, Fabric
26+
curseforge_game_versions=1.16.1, Fabric
2727
curseforge_required_dependencies=fabric-api
2828
curseforge_optional_dependencies=
2929

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.terraformersmc.cinderscapes.mixin;
2+
3+
import net.minecraft.world.biome.Biome;
4+
import org.spongepowered.asm.mixin.Mixin;
5+
import org.spongepowered.asm.mixin.gen.Accessor;
6+
7+
import java.util.List;
8+
9+
@Mixin(Biome.class)
10+
public interface BiomeAccessor {
11+
@Accessor
12+
List<Biome.MixedNoisePoint> getNoisePoints();
13+
}
Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package com.terraformersmc.cinderscapes.util;
22

3+
import com.terraformersmc.cinderscapes.mixin.BiomeAccessor;
34
import net.fabricmc.fabric.api.event.registry.RegistryEntryAddedCallback;
4-
import net.minecraft.text.TranslatableText;
55
import net.minecraft.util.registry.Registry;
66
import net.minecraft.world.biome.Biome;
77

8-
import java.lang.reflect.Field;
98
import java.util.HashMap;
109
import java.util.List;
1110
import java.util.Map;
1211

1312
//TODO: Check
1413
@SuppressWarnings("unchecked")
1514
public class NoiseCollisionChecker {
16-
private static Map<Biome, Long> Hashes = new HashMap<>();
15+
private static final Map<Biome, Long> HASHES = new HashMap<>();
1716

1817
public static void init() {
1918
for (Biome biome : Registry.BIOME) {
@@ -30,28 +29,22 @@ public static void init() {
3029
}
3130

3231
private static void check(Biome biome) {
33-
//use cursed reflection to make sure no biomes have noise collisions
34-
try {
35-
Field noisePoints = Biome.class.getDeclaredField("noisePoints");
36-
noisePoints.setAccessible(true);
37-
List<Biome.MixedNoisePoint> points = (List<Biome.MixedNoisePoint>) noisePoints.get(biome);
38-
//biomes can have multiple noise points so we hash all of them
39-
long hash = 0;
40-
for (Biome.MixedNoisePoint point : points) {
41-
hash += point.hashCode();
32+
List<Biome.MixedNoisePoint> points = ((BiomeAccessor) biome).getNoisePoints();
33+
//biomes can have multiple noise points so we hash all of them
34+
long hash = 0;
35+
for (Biome.MixedNoisePoint point : points) {
36+
hash += point.hashCode();
37+
}
38+
39+
// ensure the biomes have distinct hashes
40+
long finalHash = hash;
41+
HASHES.forEach((cachedBiome, biomeHash) -> {
42+
if (finalHash == biomeHash) {
43+
System.out.println("WARNING: " + biome.getTranslationKey() + " and " + cachedBiome.getTranslationKey() + " have the same mixed noise points! They won't generate properly!!!!");
4244
}
45+
});
46+
47+
HASHES.put(biome, hash);
4348

44-
// ensure the biomes have distinct hashes
45-
long finalHash = hash;
46-
Hashes.forEach((cachedBiome, biomeHash) -> {
47-
if (finalHash == biomeHash) {
48-
System.out.println("WARNING: " + biome.getTranslationKey() + " and " + cachedBiome.getTranslationKey() + " have the same mixed noise points! They won't generate properly!!!!");
49-
}
50-
});
51-
52-
Hashes.put(biome, hash);
53-
} catch (NoSuchFieldException | IllegalAccessException e) {
54-
e.printStackTrace();
55-
}
5649
}
5750
}

src/main/resources/cinderscapes.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"package": "com.terraformersmc.cinderscapes.mixin",
44
"compatibilityLevel": "JAVA_8",
55
"mixins": [
6+
"BiomeAccessor",
67
"ServerWorldMixin"
78
],
89
"client": [

src/main/resources/fabric.mod.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"NeusFear",
1010
"TerraformersMC"
1111
],
12+
"contributors": [
13+
"SuperCoder79",
14+
"Prospector"
15+
],
1216
"contact": {
1317
"sources": "https://github.com/TerraformersMC/Cinderscapes"
1418
},

0 commit comments

Comments
 (0)