From 94ecb00e4ea932c32e9a07b0031bacfb3468d07f Mon Sep 17 00:00:00 2001 From: Virtuoel Date: Sun, 5 Apr 2020 17:07:54 +0300 Subject: [PATCH] Use public fluid tag container getter instead of reflection (#552) --- .../fabricmc/fabric/api/tag/TagRegistry.java | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java index d84e52434..d08bf6d58 100644 --- a/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java +++ b/fabric-tag-extensions-v0/src/main/java/net/fabricmc/fabric/api/tag/TagRegistry.java @@ -16,8 +16,6 @@ package net.fabricmc.fabric.api.tag; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.util.function.Supplier; import net.minecraft.block.Block; @@ -53,35 +51,10 @@ public final class TagRegistry { } public static Tag fluid(Identifier id) { - return create(id, TagRegistry::getFluidTagContainer); + return create(id, FluidTags::getContainer); } public static Tag item(Identifier id) { return create(id, ItemTags::getContainer); } - - private static Field fluidTagContainer; - - private static TagContainer getFluidTagContainer() { - if (fluidTagContainer == null) { - for (Field f : FluidTags.class.getDeclaredFields()) { - if ((f.getModifiers() & Modifier.STATIC) != 0 && f.getType() == TagContainer.class) { - f.setAccessible(true); - fluidTagContainer = f; - break; - } - } - - if (fluidTagContainer == null) { - throw new RuntimeException("Could not find FluidTags.container!"); - } - } - - try { - //noinspection unchecked - return (TagContainer) fluidTagContainer.get(null); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not access FluidTags.container (" + fluidTagContainer.getName() + ")!", e); - } - } }