From 1dc421e6a43429edb32a554197329b38caf8f4e0 Mon Sep 17 00:00:00 2001 From: Alex O'Neill <35673674+alcatrazEscapee@users.noreply.github.com> Date: Wed, 20 Oct 2021 15:10:13 -0400 Subject: [PATCH] Add `BiomeDictionary#hasType(String)` (#8157) --- .../common/BiomeDictionary.java | 13 +++++++++++++ .../debug/block/BlockEntityOnLoadTest.java | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/main/java/net/minecraftforge/common/BiomeDictionary.java b/src/main/java/net/minecraftforge/common/BiomeDictionary.java index c96cb8ca4f..d1225a48a5 100644 --- a/src/main/java/net/minecraftforge/common/BiomeDictionary.java +++ b/src/main/java/net/minecraftforge/common/BiomeDictionary.java @@ -156,6 +156,19 @@ public class BiomeDictionary return t; } + /** + * Checks if a type instance exists for a given name. Does not have any side effects if a type does not already exist. + * This can be used for checking if a user-defined type is valid, for example, in a codec which accepts biome dictionary names. + * @param name The name. + * @return {@code true} if a type exists with this name. + * + * @see #getType(String, Type...) #getType for type naming conventions. + */ + public static boolean hasType(String name) + { + return byName.containsKey(name.toUpperCase()); + } + /** * @return An unmodifiable collection of all current biome types. */ diff --git a/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java b/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java index ea13b08001..a71dcea324 100644 --- a/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java +++ b/src/test/java/net/minecraftforge/debug/block/BlockEntityOnLoadTest.java @@ -1,3 +1,22 @@ +/* + * Minecraft Forge + * Copyright (c) 2016-2021. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + package net.minecraftforge.debug.block; import net.minecraft.core.BlockPos;