From ce0f5b7a78f09880b06b011ec6ae7fd79cd9175c Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 7 Jul 2025 05:37:31 -0400 Subject: [PATCH] Improve biome detection imports --- .../npcs/client/gui/SubGuiNpcBiomes.java | 19 +++++++++++++++++++ .../java/noppes/npcs/scripted/NpcAPI.java | 10 ++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java index 76b5d8150..8c262cb79 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java @@ -2,6 +2,7 @@ package noppes.npcs.client.gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; import noppes.npcs.client.gui.util.GuiCustomScroll; import noppes.npcs.client.gui.util.GuiNpcButton; import noppes.npcs.client.gui.util.GuiNpcLabel; @@ -9,7 +10,9 @@ import noppes.npcs.client.gui.util.SubGuiInterface; import noppes.npcs.controllers.data.SpawnData; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class SubGuiNpcBiomes extends SubGuiInterface { private SpawnData data; @@ -45,7 +48,15 @@ public class SubGuiNpcBiomes extends SubGuiInterface { addLabel(new GuiNpcLabel(2, "spawning.spawningBiomes", guiLeft + 200, guiTop + 4)); List biomes = new ArrayList(); + Set allBiomes = new HashSet(); + for (BiomeDictionary.Type type : BiomeDictionary.Type.values()) { + allBiomes.addAll(BiomeDictionary.getBiomesForType(type)); + } for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { + if (base != null) + allBiomes.add(base); + } + for (BiomeGenBase base : allBiomes) { if (base != null && base.biomeName != null && !data.biomes.contains(base.biomeName)) { biomes.add(base.biomeName); } @@ -82,7 +93,15 @@ public class SubGuiNpcBiomes extends SubGuiInterface { } if (button.id == 3) { data.biomes.clear(); + Set allBiomes = new HashSet(); + for (BiomeDictionary.Type type : BiomeDictionary.Type.values()) { + allBiomes.addAll(BiomeDictionary.getBiomesForType(type)); + } for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { + if (base != null) + allBiomes.add(base); + } + for (BiomeGenBase base : allBiomes) { if (base != null) { data.biomes.add(base.biomeName); } diff --git a/src/main/java/noppes/npcs/scripted/NpcAPI.java b/src/main/java/noppes/npcs/scripted/NpcAPI.java index 76a9936c2..d19c809bf 100644 --- a/src/main/java/noppes/npcs/scripted/NpcAPI.java +++ b/src/main/java/noppes/npcs/scripted/NpcAPI.java @@ -32,6 +32,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; import noppes.npcs.CustomNpcs; import noppes.npcs.NoppesUtilServer; import noppes.npcs.api.*; @@ -277,7 +279,15 @@ public class NpcAPI extends AbstractNpcAPI { @Override public String[] getAllBiomeNames() { List biomes = new ArrayList<>(); + Set allBiomes = new HashSet(); + for (Type type : BiomeDictionary.Type.values()) { + allBiomes.addAll(BiomeDictionary.getBiomesForType(type)); + } for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { + if (base != null) + allBiomes.add(base); + } + for (BiomeGenBase base : allBiomes) { if (base != null && base.biomeName != null) { biomes.add(base.biomeName); }