[Change] Change handling of End Biomes once more. (EndSource will consider Barrens and MainIsland biomes as well now)

This commit is contained in:
Frank 2022-07-02 14:33:52 +02:00
parent e411dc10d9
commit e35fe997c1
15 changed files with 714 additions and 334 deletions

View file

@ -1,40 +0,0 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.interfaces.TheEndBiomeDataAccessor;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.fabricmc.fabric.impl.biome.TheEndBiomeData;
import net.fabricmc.fabric.impl.biome.WeightedPicker;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Map;
@Mixin(value = TheEndBiomeData.class, remap = false)
public class TheEndBiomeDataMixin implements TheEndBiomeDataAccessor {
@Shadow
@Final
private static Map<ResourceKey<Biome>, WeightedPicker<ResourceKey<Biome>>> END_BIOMES_MAP;
@Shadow
@Final
private static Map<ResourceKey<Biome>, WeightedPicker<ResourceKey<Biome>>> END_MIDLANDS_MAP;
@Shadow
@Final
private static Map<ResourceKey<Biome>, WeightedPicker<ResourceKey<Biome>>> END_BARRENS_MAP;
public boolean bcl_canGenerateAsEndBiome(ResourceKey<Biome> key) {
return END_BIOMES_MAP != null && END_BIOMES_MAP.containsKey(key);
}
public boolean bcl_canGenerateAsEndMidlandBiome(ResourceKey<Biome> key) {
return END_MIDLANDS_MAP != null && END_MIDLANDS_MAP.containsKey(key);
}
public boolean bcl_canGenerateAsEndBarrensBiome(ResourceKey<Biome> key) {
return END_BARRENS_MAP != null && END_BARRENS_MAP.containsKey(key);
}
}

View file

@ -0,0 +1,64 @@
package org.betterx.bclib.mixin.common;
import org.betterx.bclib.api.v2.generator.TheEndBiomesHelper;
import org.betterx.bclib.api.v2.levelgen.biomes.BCLBiome;
import org.betterx.bclib.api.v2.levelgen.biomes.InternalBiomeAPI;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.level.biome.Biome;
import net.fabricmc.fabric.api.biome.v1.TheEndBiomes;
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;
@Mixin(value = TheEndBiomes.class, remap = false)
public class TheEndBiomesMixin {
@Inject(method = "addBarrensBiome", at = @At("HEAD"))
private static void bcl_registerBarrens(
ResourceKey<Biome> highlands,
ResourceKey<Biome> barrens,
double weight,
CallbackInfo ci
) {
TheEndBiomesHelper.add(InternalBiomeAPI.OTHER_END_BARRENS, barrens);
}
@Inject(method = "addMidlandsBiome", at = @At("HEAD"))
private static void bcl_registerMidlands(
ResourceKey<Biome> highlands,
ResourceKey<Biome> midlands,
double weight,
CallbackInfo ci
) {
BCLBiome highland = InternalBiomeAPI.wrapNativeBiome(highlands, InternalBiomeAPI.OTHER_END_LAND);
BCLBiome midland = InternalBiomeAPI.wrapNativeBiome(midlands, InternalBiomeAPI.OTHER_END_LAND);
if (highland != null) {
highland.addEdge(midland);
}
TheEndBiomesHelper.add(InternalBiomeAPI.OTHER_END_LAND, midlands);
}
@Inject(method = "addSmallIslandsBiome", at = @At("HEAD"))
private static void bcl_registerSmallIslands(
ResourceKey<Biome> biome, double weight, CallbackInfo ci
) {
TheEndBiomesHelper.add(InternalBiomeAPI.OTHER_END_VOID, biome);
}
@Inject(method = "addHighlandsBiome", at = @At("HEAD"))
private static void bcl_registerHighlands(
ResourceKey<Biome> biome, double weight, CallbackInfo ci
) {
TheEndBiomesHelper.add(InternalBiomeAPI.OTHER_END_LAND, biome);
}
@Inject(method = "addMainIslandBiome", at = @At("HEAD"))
private static void bcl_registerMainIsnalnd(
ResourceKey<Biome> biome, double weight, CallbackInfo ci
) {
TheEndBiomesHelper.add(InternalBiomeAPI.OTHER_END_CENTER, biome);
}
}