1.16 fix for nether biomes (#658)

* 20w22a support for nether biomes

* Apply suggestions from code review

Co-authored-by: Joseph Burton <burtonjae@hotmail.co.uk>

* Checked style and bumped version

* Fixed some testmods

* Made TestCrimsonForestBiome an inner class in FabricBiomeTest

Co-authored-by: Joseph Burton <burtonjae@hotmail.co.uk>
This commit is contained in:
Hugman 2020-06-05 12:28:09 +02:00 committed by GitHub
parent dff23fa481
commit d6bf72d59b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 8 deletions

View file

@ -18,12 +18,14 @@ package net.fabricmc.fabric.mixin.biome;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
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;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.MultiNoiseBiomeSource;
@ -32,11 +34,11 @@ import net.fabricmc.fabric.impl.biome.InternalBiomeData;
@Mixin(MultiNoiseBiomeSource.class)
public class MixinTheNetherDimension {
@ModifyArg(method = "method_28467", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource;<init>(JLjava/util/List;Ljava/util/Optional;)V"))
private static List<Pair<Biome.MixedNoisePoint, Biome>> modifyNetherBiomes(List<Pair<Biome.MixedNoisePoint, Biome>> list) {
// the provided set is immutable, so we construct our own
List<Pair<Biome.MixedNoisePoint, Biome>> newList = new ArrayList<>(list);
newList.addAll(InternalBiomeData.getNetherBiomes().stream().flatMap((biome) -> biome.streamNoises().map((point) -> Pair.of(point, biome))).collect(ImmutableList.toImmutableList()));
return newList;
@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.class_5305.field_24723));
info.setReturnValue(multiNoiseBiomeSource);
}
}

View file

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

View file

@ -0,0 +1,38 @@
/*
* 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.test.biome;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.CrimsonForestBiome;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biomes.v1.NetherBiomes;
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);
}
public class TestCrimsonForestBiome extends CrimsonForestBiome {
}
}

View file

@ -0,0 +1,16 @@
{
"schemaVersion": 1,
"id": "fabric-biomes-v1-testmod",
"name": "Fabric Biomes (v1) Test Mod",
"version": "1.0.0",
"environment": "*",
"license": "Apache-2.0",
"depends": {
"fabric-biomes-v1": "*"
},
"entrypoints": {
"main": [
"net.fabricmc.fabric.test.biome.FabricBiomeTest"
]
}
}