Fabric End Biome API support
This commit is contained in:
parent
74e9adf42e
commit
f5b297b1bc
4 changed files with 58 additions and 1 deletions
|
@ -0,0 +1,30 @@
|
||||||
|
package ru.betterend.mixin.common;
|
||||||
|
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.BuiltinRegistries;
|
||||||
|
import net.minecraft.util.registry.RegistryKey;
|
||||||
|
import net.minecraft.world.biome.Biome;
|
||||||
|
import net.minecraft.world.biome.BiomeKeys;
|
||||||
|
import ru.betterend.BetterEnd;
|
||||||
|
import ru.betterend.registry.EndBiomes;
|
||||||
|
|
||||||
|
@Mixin(InternalBiomeData.class)
|
||||||
|
public class InternalBiomeDataMixin {
|
||||||
|
@Inject(method = "addEndBiomeReplacement", at = @At("TAIL"))
|
||||||
|
private static void beAddIslandsBiomeFromFabric(RegistryKey<Biome> replaced, RegistryKey<Biome> variant, double weight, CallbackInfo info) {
|
||||||
|
if (replaced == BiomeKeys.SMALL_END_ISLANDS) {
|
||||||
|
Biome biome = BuiltinRegistries.BIOME.get(variant);
|
||||||
|
Identifier id = BuiltinRegistries.BIOME.getId(biome);
|
||||||
|
EndBiomes.FABRIC_VOID.add(id);
|
||||||
|
if (BetterEnd.isDevEnvironment()) {
|
||||||
|
System.out.println("Added " + id + " from Fabric small islands biome map");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,6 +14,7 @@ import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -45,6 +46,7 @@ import ru.betterend.world.generator.BiomeType;
|
||||||
public class EndBiomes {
|
public class EndBiomes {
|
||||||
private static final HashMap<Identifier, EndBiome> ID_MAP = Maps.newHashMap();
|
private static final HashMap<Identifier, EndBiome> ID_MAP = Maps.newHashMap();
|
||||||
private static final HashMap<Biome, EndBiome> CLIENT = Maps.newHashMap();
|
private static final HashMap<Biome, EndBiome> CLIENT = Maps.newHashMap();
|
||||||
|
public static final Set<Identifier> FABRIC_VOID = Sets.newHashSet();
|
||||||
|
|
||||||
public static final BiomePicker LAND_BIOMES = new BiomePicker();
|
public static final BiomePicker LAND_BIOMES = new BiomePicker();
|
||||||
public static final BiomePicker VOID_BIOMES = new BiomePicker();
|
public static final BiomePicker VOID_BIOMES = new BiomePicker();
|
||||||
|
@ -89,6 +91,7 @@ public class EndBiomes {
|
||||||
VOID_BIOMES.clearMutables();
|
VOID_BIOMES.clearMutables();
|
||||||
|
|
||||||
Map<String, JsonObject> configs = Maps.newHashMap();
|
Map<String, JsonObject> configs = Maps.newHashMap();
|
||||||
|
|
||||||
biomeRegistry.forEach((biome) -> {
|
biomeRegistry.forEach((biome) -> {
|
||||||
if (biome.getCategory() == Category.THEEND) {
|
if (biome.getCategory() == Category.THEEND) {
|
||||||
Identifier id = biomeRegistry.getId(biome);
|
Identifier id = biomeRegistry.getId(biome);
|
||||||
|
@ -101,7 +104,7 @@ public class EndBiomes {
|
||||||
}
|
}
|
||||||
float fog = 1F;
|
float fog = 1F;
|
||||||
float chance = 1F;
|
float chance = 1F;
|
||||||
boolean isVoid = false;
|
boolean isVoid = FABRIC_VOID.contains(id);
|
||||||
boolean hasCaves = true;
|
boolean hasCaves = true;
|
||||||
JsonElement element = config.get(id.getPath());
|
JsonElement element = config.get(id.getPath());
|
||||||
if (element != null && element.isJsonObject()) {
|
if (element != null && element.isJsonObject()) {
|
||||||
|
@ -234,6 +237,7 @@ public class EndBiomes {
|
||||||
parent.addSubBiome(biome);
|
parent.addSubBiome(biome);
|
||||||
SUBBIOMES.add(biome);
|
SUBBIOMES.add(biome);
|
||||||
ID_MAP.put(biome.getID(), biome);
|
ID_MAP.put(biome.getID(), biome);
|
||||||
|
addLandBiomeToFabricApi(biome);
|
||||||
}
|
}
|
||||||
return biome;
|
return biome;
|
||||||
}
|
}
|
||||||
|
@ -249,6 +253,12 @@ public class EndBiomes {
|
||||||
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
if (Configs.BIOME_CONFIG.getBoolean(biome.getID(), "enabled", true)) {
|
||||||
addToPicker(biome, type);
|
addToPicker(biome, type);
|
||||||
ID_MAP.put(biome.getID(), biome);
|
ID_MAP.put(biome.getID(), biome);
|
||||||
|
if (type == BiomeType.LAND) {
|
||||||
|
addLandBiomeToFabricApi(biome);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addVoidBiomeToFabricApi(biome);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return biome;
|
return biome;
|
||||||
}
|
}
|
||||||
|
@ -292,6 +302,18 @@ public class EndBiomes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addLandBiomeToFabricApi(EndBiome biome) {
|
||||||
|
float weight = biome.getGenChanceImmutable();
|
||||||
|
RegistryKey<Biome> key = BuiltinRegistries.BIOME.getKey(biome.getBiome()).get();
|
||||||
|
InternalBiomeData.addEndBiomeReplacement(BiomeKeys.END_HIGHLANDS, key, weight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addVoidBiomeToFabricApi(EndBiome biome) {
|
||||||
|
float weight = biome.getGenChanceImmutable();
|
||||||
|
RegistryKey<Biome> key = BuiltinRegistries.BIOME.getKey(biome.getBiome()).get();
|
||||||
|
InternalBiomeData.addEndBiomeReplacement(BiomeKeys.SMALL_END_ISLANDS, key, weight);
|
||||||
|
}
|
||||||
|
|
||||||
public static EndBiome getFromBiome(Biome biome) {
|
public static EndBiome getFromBiome(Biome biome) {
|
||||||
return ID_MAP.getOrDefault(biomeRegistry.getId(biome), END);
|
return ID_MAP.getOrDefault(biomeRegistry.getId(biome), END);
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,6 +170,10 @@ public class EndBiome {
|
||||||
return this.genChance;
|
return this.genChance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getGenChanceImmutable() {
|
||||||
|
return this.genChanceUnmutable;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasCaves() {
|
public boolean hasCaves() {
|
||||||
return hasCaves;
|
return hasCaves;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"ServerPlayerEntityMixin",
|
"ServerPlayerEntityMixin",
|
||||||
"ChorusPlantFeatureMixin",
|
"ChorusPlantFeatureMixin",
|
||||||
"BubbleColumnBlockMixin",
|
"BubbleColumnBlockMixin",
|
||||||
|
"InternalBiomeDataMixin",
|
||||||
"ChorusFlowerBlockMixin",
|
"ChorusFlowerBlockMixin",
|
||||||
"LandPathNodeMakerMixin",
|
"LandPathNodeMakerMixin",
|
||||||
"ChorusPlantBlockMixin",
|
"ChorusPlantBlockMixin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue