Experimental nether biomes API ()

* Add nether biomes API

* Update fabric-biomes-v1.mixins.json

* fixed license

* smarter injection point

* Apply suggestions from coderbot's review

Co-Authored-By: coderbot16 <coderbot16@gmail.com>

* fix code style

* remove redundant import

* improve docs and update yarn version

* Apply suggestions from code review

Co-Authored-By: coderbot16 <coderbot16@gmail.com>
Co-Authored-By: Juuxel <6596629+Juuxel@users.noreply.github.com>

* bump version

* mark classes as final

* Changes from modmuss's review

add 1.16 dependency, merge NetherBiomesImpl into InternalBiomeData, fix code style, and fix mixin target

* Update build.gradle

* Update API to inform users that it is experimental

* remove beta annotion

* optimize imports

Co-authored-by: coderbot16 <coderbot16@gmail.com>
Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>
This commit is contained in:
SuperCoder79 2020-02-10 12:05:19 -05:00 committed by GitHub
parent cfa5f8f26a
commit b7436ccac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 97 additions and 3 deletions
build.gradle
fabric-biomes-v1

View file

@ -14,7 +14,7 @@ def ENV = System.getenv()
class Globals {
static def baseVersion = "0.4.31"
static def mcVersion = "20w06a"
static def yarnVersion = "+build.1"
static def yarnVersion = "+build.8"
}
import org.apache.commons.codec.digest.DigestUtils

View file

@ -1,2 +1,2 @@
archivesBaseName = "fabric-biomes-v1"
version = getSubprojectVersion(project, "0.1.5")
version = getSubprojectVersion(project, "0.2.0")

View file

@ -0,0 +1,40 @@
/*
* 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.api.biomes.v1;
import net.minecraft.world.biome.Biome;
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
/**
* API that exposes the internals of Minecraft's nether biome code.
*/
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.
*
* @deprecated Experimental feature, may be removed or changed without further notice due to potential changes to Nether biomes in subsequent snapshots.
* @param biome The biome to add. Must not be null.
* @see Biome.MixedNoisePoint
*/
@Deprecated
public static void addNetherBiome(Biome biome) {
InternalBiomeData.addNetherBiome(biome);
}
}

View file

@ -18,6 +18,7 @@ package net.fabricmc.fabric.impl.biome;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
@ -48,6 +49,8 @@ public final class InternalBiomeData {
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 Set<Biome> NETHER_BIOMES = new HashSet<>();
private static final Set<Biome> SPAWN_BIOMES = new HashSet<>();
private static Method injectBiomeMethod = null;
@ -123,6 +126,11 @@ public final class InternalBiomeData {
}
}
public static void addNetherBiome(Biome biome) {
Preconditions.checkArgument(biome != null, "Biome is null");
NETHER_BIOMES.add(biome);
}
public static Set<Biome> getSpawnBiomes() {
return SPAWN_BIOMES;
}
@ -151,6 +159,10 @@ public final class InternalBiomeData {
return OVERWORLD_VARIANT_TRANSFORMERS;
}
public static Set<Biome> getNetherBiomes() {
return Collections.unmodifiableSet(NETHER_BIOMES);
}
private static class DefaultHillsData {
private static final ImmutableMap<Biome, Biome> DEFAULT_HILLS;

View file

@ -0,0 +1,40 @@
/*
* 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.HashSet;
import java.util.Set;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.TheNetherDimension;
import net.fabricmc.fabric.impl.biome.InternalBiomeData;
@Mixin(TheNetherDimension.class)
public class MixinTheNetherDimension {
@ModifyArg(method = "createChunkGenerator", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/source/MultiNoiseBiomeSourceConfig;withBiomes(Ljava/util/Set;)Lnet/minecraft/world/biome/source/MultiNoiseBiomeSourceConfig;"))
protected Set<Biome> modifyNetherBiomes(Set<Biome> set) {
// the provided set is immutable, so we construct our own
Set<Biome> newSet = new HashSet<>(set);
newSet.addAll(InternalBiomeData.getNetherBiomes());
return newSet;
}
}

View file

@ -8,6 +8,7 @@
"MixinAddRiversLayer",
"MixinBiomeSource",
"MixinSetBaseBiomesLayer",
"MixinTheNetherDimension",
"MixinVanillaLayeredBiomeSource"
],
"injectors": {

View file

@ -16,7 +16,8 @@
"FabricMC"
],
"depends": {
"fabricloader": ">=0.4.0"
"fabricloader": ">=0.4.0",
"minecraft": ">=1.16-alpha.20.6.a"
},
"description": "Hooks for adding biomes to the default world generator.",
"mixins": [