mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-21 20:50:28 -04:00
19w36a some biome changes
This commit is contained in:
parent
b4f62fb5a7
commit
413f3d6055
6 changed files with 39 additions and 48 deletions
|
@ -13,7 +13,7 @@ def ENV = System.getenv()
|
|||
|
||||
class Globals {
|
||||
static def baseVersion = "0.3.2"
|
||||
static def mcVersion = "19w35a"
|
||||
static def mcVersion = "19w36a"
|
||||
static def yarnVersion = "+build.1"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
archivesBaseName = "fabric-biomes-v1"
|
||||
version = getSubprojectVersion(project, "0.1.0")
|
||||
version = getSubprojectVersion(project, "0.1.1")
|
||||
|
|
|
@ -23,7 +23,10 @@ import net.minecraft.util.registry.Registry;
|
|||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.layer.BiomeLayers;
|
||||
import net.minecraft.world.biome.source.VanillaLayeredBiomeSource;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -40,17 +43,18 @@ public final class InternalBiomeData {
|
|||
private static final Map<Biome, WeightedBiomePicker> OVERWORLD_EDGE_MAP = new HashMap<>();
|
||||
private static final Map<Biome, VariantTransformer> OVERWORLD_VARIANT_TRANSFORMERS = new HashMap<>();
|
||||
private static final Map<Biome, Biome> OVERWORLD_RIVER_MAP = new HashMap<>();
|
||||
private static final List<Biome> OVERWORLD_INJECTED_BIOMES = new ArrayList<>();
|
||||
|
||||
private static final Set<Biome> SPAWN_BIOMES = new HashSet<>();
|
||||
|
||||
private static Method injectBiomeMethod = null;
|
||||
|
||||
public static void addOverworldContinentalBiome(OverworldClimate climate, Biome biome, double weight) {
|
||||
Preconditions.checkArgument(climate != null, "Climate is null");
|
||||
Preconditions.checkArgument(biome != null, "Biome is null");
|
||||
Preconditions.checkArgument(!Double.isNaN(weight), "Weight is NaN");
|
||||
Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (%s)", weight);
|
||||
OVERWORLD_MODDED_CONTINENTAL_BIOME_PICKERS.computeIfAbsent(climate, k -> new WeightedBiomePicker()).addBiome(biome, weight);
|
||||
OVERWORLD_INJECTED_BIOMES.add(biome);
|
||||
injectOverworldBiome(biome);
|
||||
}
|
||||
|
||||
public static void addOverworldHillsBiome(Biome primary, Biome hills, double weight) {
|
||||
|
@ -59,7 +63,7 @@ public final class InternalBiomeData {
|
|||
Preconditions.checkArgument(!Double.isNaN(weight), "Weight is NaN");
|
||||
Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (%s)", weight);
|
||||
OVERWORLD_HILLS_MAP.computeIfAbsent(primary, biome -> DefaultHillsData.injectDefaultHills(primary, new WeightedBiomePicker())).addBiome(hills, weight);
|
||||
OVERWORLD_INJECTED_BIOMES.add(hills);
|
||||
injectOverworldBiome(hills);
|
||||
}
|
||||
|
||||
public static void addOverworldShoreBiome(Biome primary, Biome shore, double weight) {
|
||||
|
@ -68,7 +72,7 @@ public final class InternalBiomeData {
|
|||
Preconditions.checkArgument(!Double.isNaN(weight), "Weight is NaN");
|
||||
Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (%s)", weight);
|
||||
OVERWORLD_SHORE_MAP.computeIfAbsent(primary, biome -> new WeightedBiomePicker()).addBiome(shore, weight);
|
||||
OVERWORLD_INJECTED_BIOMES.add(shore);
|
||||
injectOverworldBiome(shore);
|
||||
}
|
||||
|
||||
public static void addOverworldEdgeBiome(Biome primary, Biome edge, double weight) {
|
||||
|
@ -77,7 +81,7 @@ public final class InternalBiomeData {
|
|||
Preconditions.checkArgument(!Double.isNaN(weight), "Weight is NaN");
|
||||
Preconditions.checkArgument(weight > 0.0, "Weight is less than or equal to 0.0 (%s)", weight);
|
||||
OVERWORLD_EDGE_MAP.computeIfAbsent(primary, biome -> new WeightedBiomePicker()).addBiome(edge, weight);
|
||||
OVERWORLD_INJECTED_BIOMES.add(edge);
|
||||
injectOverworldBiome(edge);
|
||||
}
|
||||
|
||||
public static void addOverworldBiomeReplacement(Biome replaced, Biome variant, double chance, OverworldClimate[] climates) {
|
||||
|
@ -85,14 +89,14 @@ public final class InternalBiomeData {
|
|||
Preconditions.checkArgument(variant != null, "Variant biome is null");
|
||||
Preconditions.checkArgument(chance > 0 && chance <= 1, "Chance is not greater than 0 or less than or equal to 1");
|
||||
OVERWORLD_VARIANT_TRANSFORMERS.computeIfAbsent(replaced, biome -> new VariantTransformer()).addBiome(variant, chance, climates);
|
||||
OVERWORLD_INJECTED_BIOMES.add(variant);
|
||||
injectOverworldBiome(variant);
|
||||
}
|
||||
|
||||
public static void setOverworldRiverBiome(Biome primary, Biome river) {
|
||||
Preconditions.checkArgument(primary != null, "Primary biome is null");
|
||||
OVERWORLD_RIVER_MAP.put(primary, river);
|
||||
if (river != null) {
|
||||
OVERWORLD_INJECTED_BIOMES.add(river);
|
||||
injectOverworldBiome(river);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,8 +105,17 @@ public final class InternalBiomeData {
|
|||
SPAWN_BIOMES.add(biome);
|
||||
}
|
||||
|
||||
public static List<Biome> getOverworldInjectedBiomes() {
|
||||
return OVERWORLD_INJECTED_BIOMES;
|
||||
private static void injectOverworldBiome(Biome biome) {
|
||||
try {
|
||||
if (injectBiomeMethod == null) {
|
||||
injectBiomeMethod = VanillaLayeredBiomeSource.class.getDeclaredMethod("fabric_injectBiome", Biome.class);
|
||||
injectBiomeMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
injectBiomeMethod.invoke(null, biome);
|
||||
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | InvocationTargetException e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Set<Biome> getSpawnBiomes() {
|
||||
|
|
|
@ -16,17 +16,18 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.biomes;
|
||||
|
||||
import net.fabricmc.fabric.impl.biomes.InternalBiomeData;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.VanillaLayeredBiomeSource;
|
||||
import net.minecraft.world.gen.feature.StructureFeature;
|
||||
import org.spongepowered.asm.mixin.*;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -39,39 +40,16 @@ public class MixinVanillaLayeredBiomeSource {
|
|||
@Shadow
|
||||
@Final
|
||||
@Mutable
|
||||
private Biome[] biomes;
|
||||
private static Set<Biome> biomes;
|
||||
|
||||
@Unique
|
||||
private int injectionCount;
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "hasStructureFeature")
|
||||
private void hasStructureFeature(CallbackInfoReturnable<Boolean> info) {
|
||||
updateInjections();
|
||||
@Inject(method = "<clinit>", at = @At("RETURN"))
|
||||
private static void cinit(CallbackInfo info){
|
||||
biomes = new HashSet<>(biomes);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "getTopMaterials")
|
||||
private void getTopMaterials(CallbackInfoReturnable<Set<BlockState>> info) {
|
||||
updateInjections();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void updateInjections() {
|
||||
List<Biome> injectedBiomes = InternalBiomeData.getOverworldInjectedBiomes();
|
||||
int currentSize = injectedBiomes.size();
|
||||
if (this.injectionCount < currentSize) {
|
||||
List<Biome> toInject = injectedBiomes.subList(injectionCount, currentSize - 1);
|
||||
|
||||
Biome[] oldBiomes = this.biomes;
|
||||
this.biomes = new Biome[oldBiomes.length + toInject.size()];
|
||||
System.arraycopy(oldBiomes, 0, this.biomes, 0, oldBiomes.length);
|
||||
|
||||
int index = oldBiomes.length;
|
||||
for (Biome injected : toInject) {
|
||||
biomes[index++] = injected;
|
||||
}
|
||||
|
||||
injectionCount += toInject.size();
|
||||
}
|
||||
//Called via reflection
|
||||
private static void fabric_injectBiome(Biome biome) {
|
||||
biomes.add(biome);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
archivesBaseName = "fabric-rendering-v0"
|
||||
version = getSubprojectVersion(project, "0.1.1")
|
||||
version = getSubprojectVersion(project, "0.1.2")
|
||||
|
||||
dependencies {
|
||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||
|
|
|
@ -31,7 +31,7 @@ public abstract class ColorProviderRegistryImpl<T, Provider, Underlying> impleme
|
|||
public static final ColorProviderRegistryImpl<Block, BlockColorProvider, BlockColors> BLOCK = new ColorProviderRegistryImpl<Block, BlockColorProvider, BlockColors>() {
|
||||
@Override
|
||||
void registerUnderlying(BlockColors map, BlockColorProvider mapper, Block block) {
|
||||
map.register(mapper, block);
|
||||
map.registerColorProvider(mapper, block);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue