From 3e568b864e7fa961de1353fe447ee08276e6124f Mon Sep 17 00:00:00 2001 From: Ivorius Date: Sat, 4 Feb 2017 18:29:42 +0100 Subject: [PATCH] Replace listSubtypes with listSupertypes to match the intended behavior. (#3564) --- .../common/BiomeDictionary.java | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java index 18e3545052..deb1014d67 100644 --- a/src/main/java/net/minecraftforge/common/BiomeDictionary.java +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -172,14 +172,14 @@ public class BiomeDictionary { Preconditions.checkArgument(ForgeRegistries.BIOMES.containsValue(biome), "Cannot add types to unregistered biome %s", biome); - List subTypes = listSubTypes(types); + Collection supertypes = listSupertypes(types); - for (Type type : subTypes) + for (Type type : supertypes) { type.biomes.add(biome); } - getBiomeInfo(biome).types.addAll(subTypes); + getBiomeInfo(biome).types.addAll(supertypes); } /** @@ -212,7 +212,7 @@ public class BiomeDictionary { for (Type type : getTypes(biomeA)) { - if (containsType(getTypes(biomeB), type)) + if (getTypes(biomeB).contains(type)) { return true; } @@ -375,35 +375,24 @@ public class BiomeDictionary } } - private static boolean containsType(Set types, Type type) + private static Collection listSupertypes(Type... types) { - if (type.hasSubTypes()) - { - return !Collections.disjoint(types, type.subTypes); - } - else - { - return types.contains(type); - } - } + Set supertypes = new HashSet(); + Deque next = new ArrayDeque(); + Collections.addAll(next, types); - private static List listSubTypes(Type... types) - { - List subTags = new ArrayList(); - - for (Type type : types) + while (!next.isEmpty()) { - if (type.hasSubTypes()) + Type type = next.remove(); + + for (Type sType : Type.byName.values()) { - subTags.addAll(type.subTypes); - } - else - { - subTags.add(type); + if (type.subTypes.contains(type) && supertypes.add(sType)) + next.add(sType); } } - return subTags; + return supertypes; } private static void registerVanillaBiomes()