Fixed modded overworld biomes not spawning [1.16.x] (#6990)

This commit is contained in:
Xerousso 2020-07-28 01:10:42 +04:00 committed by GitHub
parent 9d84b5df31
commit 27798c5804
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 128 additions and 2 deletions

View file

@ -0,0 +1,59 @@
--- a/net/minecraft/world/gen/layer/BiomeLayer.java
+++ b/net/minecraft/world/gen/layer/BiomeLayer.java
@@ -28,12 +28,28 @@
private static final int[] field_202746_t = new int[]{field_202730_d, field_202729_c, field_202741_o, field_202736_j};
private static final int[] field_202747_u = new int[]{field_202731_e, field_202731_e, field_202731_e, field_202742_p};
private int[] field_151623_c = field_202744_r;
+ private java.util.List<net.minecraftforge.common.BiomeManager.BiomeEntry>[] biomes = new java.util.ArrayList[net.minecraftforge.common.BiomeManager.BiomeType.values().length];
public BiomeLayer(boolean p_i232147_1_) {
- if (p_i232147_1_) {
- this.field_151623_c = field_202743_q;
+ for (net.minecraftforge.common.BiomeManager.BiomeType type : net.minecraftforge.common.BiomeManager.BiomeType.values()) {
+ com.google.common.collect.ImmutableList<net.minecraftforge.common.BiomeManager.BiomeEntry> biomesToAdd = net.minecraftforge.common.BiomeManager.getBiomes(type);
+ if (biomes[type.ordinal()] == null) biomes[type.ordinal()] = new java.util.ArrayList<net.minecraftforge.common.BiomeManager.BiomeEntry>();
+ if (biomesToAdd != null) biomes[type.ordinal()].addAll(biomesToAdd);
}
+ int desertIdx = net.minecraftforge.common.BiomeManager.BiomeType.DESERT.ordinal();
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76769_d, 30));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_150588_X, 20));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10));
+ if (p_i232147_1_) {
+ biomes[desertIdx].clear();
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76769_d, 10));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76767_f, 10));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76770_e, 10));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76780_h, 10));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76772_c, 10));
+ biomes[desertIdx].add(new net.minecraftforge.common.BiomeManager.BiomeEntry(Biomes.field_76768_g, 10));
+ }
}
public int func_202726_a(INoiseRandom p_202726_1_, int p_202726_2_) {
@@ -46,21 +62,21 @@
return p_202726_1_.func_202696_a(3) == 0 ? field_202733_g : field_202734_h;
}
- return this.field_151623_c[p_202726_1_.func_202696_a(this.field_151623_c.length)];
+ return Registry.field_212624_m.func_148757_b(net.minecraftforge.common.BiomeManager.getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.DESERT, p_202726_1_).biome);
case 2:
if (i > 0) {
return field_202732_f;
}
- return field_202745_s[p_202726_1_.func_202696_a(field_202745_s.length)];
+ return Registry.field_212624_m.func_148757_b(net.minecraftforge.common.BiomeManager.getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.WARM, p_202726_1_).biome);
case 3:
if (i > 0) {
return field_202737_k;
}
- return field_202746_t[p_202726_1_.func_202696_a(field_202746_t.length)];
+ return Registry.field_212624_m.func_148757_b(net.minecraftforge.common.BiomeManager.getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.COOL, p_202726_1_).biome);
case 4:
- return field_202747_u[p_202726_1_.func_202696_a(field_202747_u.length)];
+ return Registry.field_212624_m.func_148757_b(net.minecraftforge.common.BiomeManager.getWeightedBiomeEntry(net.minecraftforge.common.BiomeManager.BiomeType.ICY, p_202726_1_).biome);
default:
return field_202735_i;
}

View file

@ -29,6 +29,7 @@ import net.minecraft.world.biome.Biomes;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.gen.INoiseRandom;
import javax.annotation.Nullable;
@ -154,6 +155,16 @@ public class BiomeManager
}
}
public static BiomeEntry getWeightedBiomeEntry(BiomeType type, INoiseRandom context)
{
List<BiomeEntry> biomeList = biomes[type.ordinal()];
int totalWeight = WeightedRandom.getTotalWeight(biomeList);
int weight = isTypeListModded(type) ? context.random(totalWeight) : context.random(totalWeight / 10) * 10;
return WeightedRandom.getRandomItem(biomeList, weight);
}
private static class TrackedList<E> extends ArrayList<E>
{
private static final long serialVersionUID = 1L;

View file

@ -0,0 +1,55 @@
package net.minecraftforge.debug.world;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biome.Category;
import net.minecraft.world.biome.Biome.RainType;
import net.minecraft.world.biome.BiomeAmbience;
import net.minecraft.world.biome.MoodSoundAmbience;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraftforge.common.BiomeManager;
import net.minecraftforge.common.BiomeManager.BiomeEntry;
import net.minecraftforge.common.BiomeManager.BiomeType;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
@Mod(value = ModdedOverworldBiomesTest.MOD_ID)
public class ModdedOverworldBiomesTest
{
public static final String MOD_ID = "modded_overworld_biomes_test";
public static final boolean ENABLE = true;
private static DeferredRegister<Biome> BIOMES = DeferredRegister.create(ForgeRegistries.BIOMES, MOD_ID);
private static RegistryObject<Biome> redBiome = BIOMES.register("red_biome", () -> new Biome(new Biome.Builder()
.surfaceBuilder(SurfaceBuilder.DEFAULT, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG).precipitation(RainType.RAIN)
.depth(1f).scale(1f).temperature(1f).downfall(1f).category(Category.PLAINS)
.func_235097_a_(new BiomeAmbience.Builder().func_235246_b_(4159204).func_235248_c_(329011)
.func_235239_a_(12638463).func_235243_a_(MoodSoundAmbience.field_235027_b_).func_235238_a_())
.parent((String) null))
{
@Override
public int getGrassColor(double posX, double posZ)
{
return 0xff0000;
}
});
public ModdedOverworldBiomesTest()
{
if (ENABLE) {
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
IEventBus modBus = FMLJavaModLoadingContext.get().getModEventBus();
BIOMES.register(modBus);
}
}
private void setup(final FMLCommonSetupEvent event)
{
BiomeManager.addBiome(BiomeType.WARM, new BiomeEntry(redBiome.get(), 200));
}
}

View file

@ -10,7 +10,6 @@ loaderVersion="[28,)"
[[mods]]
modId="farmland_trample_test"
[[mods]]
modId="neighbor_notify_event_test"
[[mods]]
modId="block_place_event_test"
@ -71,4 +70,6 @@ loaderVersion="[28,)"
[[mods]]
modId="ender_mask_test"
[[mods]]
modId="raid_enum_test"
modId="raid_enum_test"
[[mods]]
modId="modded_overworld_biomes_test"