mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 03:10:54 -04:00
20w28a Biome Module fixes (#874)
* 20w28a biome module fixes * update version to 0.3.0 * major version bump to 1.0.0 * Update mappings * Fix nether biome test's * Fix nether biome's on the server Closes https://github.com/FabricMC/fabric/issues/861 * Accessor name changes Co-authored-by: modmuss50 <modmuss50@gmail.com>
This commit is contained in:
parent
fde2bb23c4
commit
08834d9e76
17 changed files with 219 additions and 49 deletions
build.gradle
fabric-biomes-v1
build.gradle
settings.gradlesrc
main
java/net/fabricmc/fabric
api/biomes/v1
impl/biome
mixin/biome
resources
testmod/java/net/fabricmc/fabric/test/biome
|
@ -20,7 +20,7 @@ def ENV = System.getenv()
|
|||
class Globals {
|
||||
static def baseVersion = "0.14.3"
|
||||
static def mcVersion = "20w28a"
|
||||
static def yarnVersion = "+build.2"
|
||||
static def yarnVersion = "+build.11"
|
||||
}
|
||||
|
||||
version = Globals.baseVersion + "+" + (ENV.BUILD_NUMBER ? ("build." + ENV.BUILD_NUMBER) : "local") + "-" + getBranch()
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
archivesBaseName = "fabric-biomes-v1"
|
||||
version = getSubprojectVersion(project, "0.2.7")
|
||||
version = getSubprojectVersion(project, "1.0.0")
|
||||
|
|
|
@ -27,12 +27,13 @@ public final class NetherBiomes {
|
|||
private NetherBiomes() { }
|
||||
|
||||
/**
|
||||
* Adds a biome to the Nether generator. Biomes must set their own noise values in the {@link Biome.MixedNoisePoint} class for the biome to properly generate.
|
||||
* Adds a biome to the Nether generator.
|
||||
*
|
||||
* @param biome The biome to add. Must not be null.
|
||||
* @param mixedNoisePoint data about the given {@link Biome}'s spawning information in the nether.
|
||||
* @see Biome.MixedNoisePoint
|
||||
*/
|
||||
public static void addNetherBiome(Biome biome) {
|
||||
InternalBiomeData.addNetherBiome(biome);
|
||||
public static void addNetherBiome(Biome biome, Biome.MixedNoisePoint mixedNoisePoint) {
|
||||
InternalBiomeData.addNetherBiome(biome, mixedNoisePoint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Set;
|
|||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.layer.BiomeLayers;
|
||||
|
@ -50,6 +50,7 @@ public final class InternalBiomeData {
|
|||
private static final Map<Biome, Biome> OVERWORLD_RIVER_MAP = new HashMap<>();
|
||||
|
||||
private static final Set<Biome> NETHER_BIOMES = new HashSet<>();
|
||||
private static final Map<Biome, Biome.MixedNoisePoint> NETHER_BIOME_NOISE_POINTS = new HashMap<>();
|
||||
|
||||
private static final Set<Biome> SPAWN_BIOMES = new HashSet<>();
|
||||
|
||||
|
@ -126,9 +127,11 @@ public final class InternalBiomeData {
|
|||
}
|
||||
}
|
||||
|
||||
public static void addNetherBiome(Biome biome) {
|
||||
public static void addNetherBiome(Biome biome, Biome.MixedNoisePoint spawnNoisePoint) {
|
||||
Preconditions.checkArgument(biome != null, "Biome is null");
|
||||
Preconditions.checkArgument(spawnNoisePoint != null, "Biome.MixedNoisePoint is null");
|
||||
NETHER_BIOMES.add(biome);
|
||||
NETHER_BIOME_NOISE_POINTS.put(biome, spawnNoisePoint);
|
||||
}
|
||||
|
||||
public static Set<Biome> getSpawnBiomes() {
|
||||
|
@ -163,6 +166,10 @@ public final class InternalBiomeData {
|
|||
return Collections.unmodifiableSet(NETHER_BIOMES);
|
||||
}
|
||||
|
||||
public static Map<Biome, Biome.MixedNoisePoint> getNetherBiomeNoisePoints() {
|
||||
return NETHER_BIOME_NOISE_POINTS;
|
||||
}
|
||||
|
||||
private static class DefaultHillsData {
|
||||
private static final ImmutableMap<Biome, Biome> DEFAULT_HILLS;
|
||||
|
||||
|
@ -171,7 +178,7 @@ public final class InternalBiomeData {
|
|||
|
||||
if (defaultHill != null) {
|
||||
picker.addBiome(defaultHill, 1);
|
||||
} else if (BiomeLayers.areSimilar(Registry.BIOME.getRawId(base), Registry.BIOME.getRawId(Biomes.WOODED_BADLANDS_PLATEAU))) {
|
||||
} else if (BiomeLayers.areSimilar(BuiltinRegistries.BIOME.getRawId(base), BuiltinRegistries.BIOME.getRawId(Biomes.WOODED_BADLANDS_PLATEAU))) {
|
||||
picker.addBiome(Biomes.BADLANDS, 1);
|
||||
} else if (base == Biomes.DEEP_OCEAN || base == Biomes.DEEP_LUKEWARM_OCEAN || base == Biomes.DEEP_COLD_OCEAN) {
|
||||
picker.addBiome(Biomes.PLAINS, 1);
|
||||
|
|
|
@ -20,12 +20,16 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.gen.GeneratorOptions;
|
||||
|
||||
import net.fabricmc.fabric.api.biomes.v1.OverworldClimate;
|
||||
import net.fabricmc.fabric.mixin.biome.DimensionOptionsAccessor;
|
||||
import net.fabricmc.fabric.mixin.biome.DimensionTypeAccessor;
|
||||
|
||||
/**
|
||||
* Internal utilities used for biome sampling.
|
||||
|
@ -54,11 +58,11 @@ public final class InternalBiomeUtils {
|
|||
if (mainBiomeId == secondaryBiomeId) { // for efficiency, determine if the ids are equal first
|
||||
return false;
|
||||
} else {
|
||||
Biome secondaryBiome = Registry.BIOME.get(secondaryBiomeId);
|
||||
Biome mainBiome = Registry.BIOME.get(mainBiomeId);
|
||||
Biome secondaryBiome = BuiltinRegistries.BIOME.get(secondaryBiomeId);
|
||||
Biome mainBiome = BuiltinRegistries.BIOME.get(mainBiomeId);
|
||||
|
||||
boolean isUnsimilar = secondaryBiome.hasParent() ? !(mainBiomeId == Registry.BIOME.getRawId(Registry.BIOME.get(new Identifier(secondaryBiome.getParent())))) : true;
|
||||
isUnsimilar = isUnsimilar && (mainBiome.hasParent() ? !(secondaryBiomeId == Registry.BIOME.getRawId(Registry.BIOME.get(new Identifier(mainBiome.getParent())))) : true);
|
||||
boolean isUnsimilar = secondaryBiome.hasParent() ? !(mainBiomeId == BuiltinRegistries.BIOME.getRawId(BuiltinRegistries.BIOME.get(new Identifier(secondaryBiome.getParent())))) : true;
|
||||
isUnsimilar = isUnsimilar && (mainBiome.hasParent() ? !(secondaryBiomeId == BuiltinRegistries.BIOME.getRawId(BuiltinRegistries.BIOME.get(new Identifier(mainBiome.getParent())))) : true);
|
||||
|
||||
return isUnsimilar;
|
||||
}
|
||||
|
@ -76,7 +80,7 @@ public final class InternalBiomeUtils {
|
|||
}
|
||||
|
||||
private static boolean isOceanBiome(int id) {
|
||||
Biome biome = Registry.BIOME.get(id);
|
||||
Biome biome = BuiltinRegistries.BIOME.get(id);
|
||||
return biome != null && biome.getCategory() == Biome.Category.OCEAN;
|
||||
}
|
||||
|
||||
|
@ -111,10 +115,10 @@ public final class InternalBiomeUtils {
|
|||
VariantTransformer transformer = overworldVariantTransformers.get(existing);
|
||||
|
||||
if (transformer != null) {
|
||||
return Registry.BIOME.getRawId(transformer.transformBiome(existing, random, climate));
|
||||
return BuiltinRegistries.BIOME.getRawId(transformer.transformBiome(existing, random, climate));
|
||||
}
|
||||
|
||||
return Registry.BIOME.getRawId(existing);
|
||||
return BuiltinRegistries.BIOME.getRawId(existing);
|
||||
}
|
||||
|
||||
public static void injectBiomesIntoClimate(LayerRandomnessSource random, int[] vanillaArray, OverworldClimate climate, IntConsumer result) {
|
||||
|
@ -134,7 +138,7 @@ public final class InternalBiomeUtils {
|
|||
if (reqWeightSum < vanillaArray.length) {
|
||||
// Vanilla biome; look it up from the vanilla array and transform accordingly.
|
||||
|
||||
result.accept(transformBiome(random, Registry.BIOME.get(vanillaArray[(int) reqWeightSum]), climate));
|
||||
result.accept(transformBiome(random, BuiltinRegistries.BIOME.get(vanillaArray[(int) reqWeightSum]), climate));
|
||||
} else {
|
||||
// Modded biome; use a binary search, and then transform accordingly.
|
||||
|
||||
|
@ -143,4 +147,8 @@ public final class InternalBiomeUtils {
|
|||
result.accept(transformBiome(random, found.getBiome(), climate));
|
||||
}
|
||||
}
|
||||
|
||||
public static void recreateChunkGenerators(GeneratorOptions generatorOptions) {
|
||||
((DimensionOptionsAccessor) (Object) generatorOptions.getDimensionMap().get(DimensionOptions.NETHER)).setChunkGenerator(DimensionTypeAccessor.createNetherGenerator(generatorOptions.getSeed()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.biome;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.world.dimension.DimensionOptions;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
||||
@Mixin(DimensionOptions.class)
|
||||
public interface DimensionOptionsAccessor {
|
||||
@Accessor
|
||||
void setChunkGenerator(ChunkGenerator generatorOptions);
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.biome;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.gen.chunk.ChunkGenerator;
|
||||
|
||||
@Mixin(DimensionType.class)
|
||||
public interface DimensionTypeAccessor {
|
||||
@Invoker("createNetherGenerator")
|
||||
static ChunkGenerator createNetherGenerator(long seed) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.layer.AddEdgeBiomesLayer;
|
||||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
|
@ -37,12 +37,12 @@ import net.fabricmc.fabric.impl.biome.InternalBiomeUtils;
|
|||
public class MixinAddEdgeBiomesLayer {
|
||||
@Inject(at = @At("HEAD"), method = "sample", cancellable = true)
|
||||
private void sample(LayerRandomnessSource rand, int north, int east, int south, int west, int center, CallbackInfoReturnable<Integer> info) {
|
||||
Biome centerBiome = Registry.BIOME.get(center);
|
||||
Biome centerBiome = BuiltinRegistries.BIOME.get(center);
|
||||
|
||||
if (InternalBiomeData.getOverworldShores().containsKey(centerBiome) && InternalBiomeUtils.neighborsOcean(north, east, south, west)) {
|
||||
info.setReturnValue(Registry.BIOME.getRawId(InternalBiomeData.getOverworldShores().get(centerBiome).pickRandom(rand)));
|
||||
info.setReturnValue(BuiltinRegistries.BIOME.getRawId(InternalBiomeData.getOverworldShores().get(centerBiome).pickRandom(rand)));
|
||||
} else if (InternalBiomeData.getOverworldEdges().containsKey(centerBiome) && InternalBiomeUtils.isEdge(north, east, south, west, center)) {
|
||||
info.setReturnValue(Registry.BIOME.getRawId(InternalBiomeData.getOverworldEdges().get(centerBiome).pickRandom(rand)));
|
||||
info.setReturnValue(BuiltinRegistries.BIOME.getRawId(InternalBiomeData.getOverworldEdges().get(centerBiome).pickRandom(rand)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,9 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.layer.AddHillsLayer;
|
||||
import net.minecraft.world.biome.layer.BiomeLayers;
|
||||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
|
@ -47,7 +48,7 @@ public class MixinAddHillsLayer {
|
|||
final int biomeId = biomeSampler.sample(chunkX, chunkZ);
|
||||
int noiseSample = noiseSampler.sample(chunkX, chunkZ);
|
||||
int processedNoiseSample = (noiseSample - 2) % 29;
|
||||
final Biome biome = Registry.BIOME.get(biomeId);
|
||||
final Biome biome = BuiltinRegistries.BIOME.get(biomeId);
|
||||
|
||||
WeightedBiomePicker hillPicker = InternalBiomeData.getOverworldHills().get(biome);
|
||||
|
||||
|
@ -58,12 +59,12 @@ public class MixinAddHillsLayer {
|
|||
}
|
||||
|
||||
if (rand.nextInt(3) == 0 || processedNoiseSample == 0) {
|
||||
int biomeReturn = Registry.BIOME.getRawId(hillPicker.pickRandom(rand));
|
||||
int biomeReturn = BuiltinRegistries.BIOME.getRawId(hillPicker.pickRandom(rand));
|
||||
Biome parent;
|
||||
|
||||
if (processedNoiseSample == 0 && biomeReturn != biomeId) {
|
||||
parent = Biome.getModifiedBiome(Registry.BIOME.get(biomeReturn));
|
||||
biomeReturn = parent == null ? biomeId : Registry.BIOME.getRawId(parent);
|
||||
parent = Biomes.method_30360(BuiltinRegistries.BIOME.get(biomeReturn));
|
||||
biomeReturn = parent == null ? biomeId : BuiltinRegistries.BIOME.getRawId(parent);
|
||||
}
|
||||
|
||||
if (biomeReturn != biomeId) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.layer.AddRiversLayer;
|
||||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
|
@ -46,14 +46,14 @@ public class MixinAddRiversLayer {
|
|||
@Inject(at = @At("HEAD"), method = "sample", cancellable = true)
|
||||
private void sample(LayerRandomnessSource rand, LayerSampler landSampler, LayerSampler riverSampler, int x, int z, CallbackInfoReturnable<Integer> info) {
|
||||
int landBiomeId = landSampler.sample(x, z);
|
||||
Biome landBiome = Registry.BIOME.get(landBiomeId);
|
||||
Biome landBiome = BuiltinRegistries.BIOME.get(landBiomeId);
|
||||
|
||||
int riverBiomeId = riverSampler.sample(x, z);
|
||||
Map<Biome, Biome> overworldRivers = InternalBiomeData.getOverworldRivers();
|
||||
|
||||
if (overworldRivers.containsKey(landBiome) && riverBiomeId == RIVER_ID) {
|
||||
Biome riverBiome = overworldRivers.get(landBiome);
|
||||
info.setReturnValue(riverBiome == null ? landBiomeId : Registry.BIOME.getRawId(riverBiome));
|
||||
info.setReturnValue(riverBiome == null ? landBiomeId : BuiltinRegistries.BIOME.getRawId(riverBiome));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.biome;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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 net.minecraft.server.dedicated.MinecraftDedicatedServer;
|
||||
import net.minecraft.server.dedicated.ServerPropertiesLoader;
|
||||
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeUtils;
|
||||
|
||||
@Mixin(MinecraftDedicatedServer.class)
|
||||
public class MixinMinecraftDedicatedServer {
|
||||
@Shadow
|
||||
@Final
|
||||
private ServerPropertiesLoader propertiesLoader;
|
||||
|
||||
@Inject(method = "setupServer", at = @At("HEAD"))
|
||||
public void setupServer(CallbackInfoReturnable<Boolean> cir) {
|
||||
InternalBiomeUtils.recreateChunkGenerators(propertiesLoader.getPropertiesHandler().generatorOptions);
|
||||
}
|
||||
}
|
|
@ -18,9 +18,8 @@ package net.fabricmc.fabric.mixin.biome;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
@ -33,12 +32,21 @@ import net.minecraft.world.biome.source.MultiNoiseBiomeSource;
|
|||
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
|
||||
|
||||
@Mixin(MultiNoiseBiomeSource.class)
|
||||
public class MixinTheNetherDimension {
|
||||
@Inject(method = "method_28467", at = @At("RETURN"), cancellable = true)
|
||||
private static void method_28467(long l, CallbackInfoReturnable<MultiNoiseBiomeSource> info) {
|
||||
List<Biome> newList = new ArrayList<>(info.getReturnValue().method_28443());
|
||||
newList.addAll(InternalBiomeData.getNetherBiomes());
|
||||
MultiNoiseBiomeSource multiNoiseBiomeSource = new MultiNoiseBiomeSource(l, newList.stream().flatMap((biome) -> biome.streamNoises().map((point) -> Pair.of(point, biome))).collect(ImmutableList.toImmutableList()), Optional.of(MultiNoiseBiomeSource.Preset.NETHER));
|
||||
info.setReturnValue(multiNoiseBiomeSource);
|
||||
public class MixinMultiNoiseBiomeSource {
|
||||
@Inject(method = "method_28467", at = @At("RETURN"))
|
||||
private static void modifyNoisePoints(long l, CallbackInfoReturnable<MultiNoiseBiomeSource> cir) {
|
||||
MultiNoiseBiomeSource returnedSource = cir.getReturnValue();
|
||||
|
||||
// collect existing noise points in non-immutable map
|
||||
List<Pair<Biome.MixedNoisePoint, Supplier<Biome>>> existingPoints = new ArrayList<>(((MultiNoiseBiomeSourceAccessor) returnedSource).getBiomePoints());
|
||||
|
||||
// add fabric biome noise point data to list && BiomeSource biome list
|
||||
InternalBiomeData.getNetherBiomeNoisePoints().forEach((biome, noisePoint) -> {
|
||||
existingPoints.add(Pair.of(noisePoint, () -> biome));
|
||||
returnedSource.getBiomes().add(biome);
|
||||
});
|
||||
|
||||
// modify MultiNoiseBiomeSource list with updated data
|
||||
((MultiNoiseBiomeSourceAccessor) returnedSource).setBiomePoints(existingPoints);
|
||||
}
|
||||
}
|
|
@ -24,10 +24,10 @@ import org.spongepowered.asm.mixin.injection.At;
|
|||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
import net.minecraft.world.biome.layer.SetBaseBiomesLayer;
|
||||
import net.minecraft.world.biome.layer.util.LayerRandomnessSource;
|
||||
|
||||
import net.fabricmc.fabric.api.biomes.v1.OverworldClimate;
|
||||
import net.fabricmc.fabric.impl.biome.InternalBiomeUtils;
|
||||
|
@ -96,7 +96,7 @@ public class MixinSetBaseBiomesLayer {
|
|||
@Inject(at = @At("RETURN"), method = "sample", cancellable = true)
|
||||
private void transformVariants(LayerRandomnessSource random, int value, CallbackInfoReturnable<Integer> info) {
|
||||
int biomeId = info.getReturnValueI();
|
||||
Biome biome = Registry.BIOME.get(biomeId);
|
||||
Biome biome = BuiltinRegistries.BIOME.get(biomeId);
|
||||
|
||||
// Determine what special case this is...
|
||||
OverworldClimate climate;
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package net.fabricmc.fabric.mixin.biome;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.source.MultiNoiseBiomeSource;
|
||||
|
||||
@Mixin(MultiNoiseBiomeSource.class)
|
||||
public interface MultiNoiseBiomeSourceAccessor {
|
||||
@Accessor
|
||||
List<Pair<Biome.MixedNoisePoint, Supplier<Biome>>> getBiomePoints();
|
||||
|
||||
@Accessor
|
||||
void setBiomePoints(List<Pair<Biome.MixedNoisePoint, Supplier<Biome>>> list);
|
||||
}
|
|
@ -3,13 +3,17 @@
|
|||
"package": "net.fabricmc.fabric.mixin.biome",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
"DimensionOptionsAccessor",
|
||||
"DimensionTypeAccessor",
|
||||
"MixinAddEdgeBiomesLayer",
|
||||
"MixinAddHillsLayer",
|
||||
"MixinAddRiversLayer",
|
||||
"MixinBiomeSource",
|
||||
"MixinSetBaseBiomesLayer",
|
||||
"MixinTheNetherDimension",
|
||||
"MixinVanillaLayeredBiomeSource"
|
||||
"MixinMinecraftDedicatedServer",
|
||||
"MixinMultiNoiseBiomeSource",
|
||||
"MixinVanillaLayeredBiomeSource",
|
||||
"MultiNoiseBiomeSourceAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
|
@ -17,22 +17,26 @@
|
|||
package net.fabricmc.fabric.test.biome;
|
||||
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.BuiltinRegistries;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.Biomes;
|
||||
import net.minecraft.world.biome.CrimsonForestBiome;
|
||||
import net.minecraft.world.biome.PlainsBiome;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.biomes.v1.NetherBiomes;
|
||||
import net.fabricmc.fabric.api.biomes.v1.OverworldBiomes;
|
||||
|
||||
public class FabricBiomeTest implements ModInitializer {
|
||||
public static final String MOD_ID = "fabric-biome-api-v1-testmod";
|
||||
|
||||
@Override public void onInitialize() {
|
||||
TestCrimsonForestBiome biome = Registry.register(Registry.BIOME, new Identifier(MOD_ID, "test_crimson_forest"), new TestCrimsonForestBiome());
|
||||
NetherBiomes.addNetherBiome(Biomes.BEACH);
|
||||
NetherBiomes.addNetherBiome(biome);
|
||||
}
|
||||
CrimsonForestBiome biome = Registry.register(BuiltinRegistries.BIOME, new Identifier(MOD_ID, "test_crimson_forest"), new CrimsonForestBiome());
|
||||
NetherBiomes.addNetherBiome(Biomes.BEACH, new Biome.MixedNoisePoint(0.0F, 0.5F, 0.0F, 0.0F, 0.1F));
|
||||
NetherBiomes.addNetherBiome(biome, new Biome.MixedNoisePoint(0.0F, 0.5F, 0.0F, 0.0F, 0.275F));
|
||||
|
||||
public class TestCrimsonForestBiome extends CrimsonForestBiome {
|
||||
PlainsBiome customPlains = Registry.register(BuiltinRegistries.BIOME, new Identifier(MOD_ID, "custom_plains"), new PlainsBiome());
|
||||
OverworldBiomes.addBiomeVariant(Biomes.PLAINS, customPlains, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ rootProject.name = "fabric-api"
|
|||
|
||||
include 'fabric-api-base'
|
||||
|
||||
//include 'fabric-biomes-v1'
|
||||
include 'fabric-biomes-v1'
|
||||
include 'fabric-blockrenderlayer-v1'
|
||||
include 'fabric-commands-v0'
|
||||
include 'fabric-command-api-v1'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue