Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/net/neoforged/neoforge/client/ClientHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import net.neoforged.neoforge.forge.snapshots.ForgeSnapshotsModClient;
import net.neoforged.neoforge.gametest.GameTestHooks;
import net.neoforged.neoforge.internal.versions.neoforge.NeoForgeVersion;
import net.neoforged.neoforge.network.configuration.CheckExtensibleEnums;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
Expand All @@ -104,7 +105,6 @@
import org.joml.Vector3f;
import xyz.bluspring.kilt.injections.client.gui.screens.MenuScreensInjection;
import xyz.bluspring.kilt.injections.client.renderer.ShaderInstanceInjection;
import xyz.bluspring.kilt.injections.world.inventory.RecipeBookTypeInjection;

import net.minecraft.FileUtil;
import net.minecraft.client.Camera;
Expand Down Expand Up @@ -1128,7 +1128,7 @@ public static List<Component> getEffectTooltip(EffectRenderingInventoryScreen<?>
return event.getTooltip();
}

private static final ExtensionInfo RECIPE_BOOK_TYPE_EXTENSION_INFO = RecipeBookTypeInjection.getExtensionInfo();
private static final ExtensionInfo RECIPE_BOOK_TYPE_EXTENSION_INFO = CheckExtensibleEnums.getEnumExtensionInfo(RecipeBookType.class);
private static final RecipeBookType[] RECIPE_BOOK_TYPES = RecipeBookType.values();
private static RecipeBookType @Nullable [] cachedFilteredTypes = null;

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/net/neoforged/neoforge/common/CommonHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import net.neoforged.neoforge.event.level.NoteBlockEvent;
import net.neoforged.neoforge.event.level.block.CropGrowEvent;
import net.neoforged.neoforge.fluids.FluidType;
import net.neoforged.neoforge.network.configuration.CheckExtensibleEnums;
import net.neoforged.neoforge.registries.NeoForgeRegistries;
import net.neoforged.neoforge.resource.ResourcePackLoader;
import net.neoforged.neoforge.server.ServerLifecycleHooks;
Expand All @@ -111,7 +112,6 @@
import xyz.bluspring.kilt.injections.nbt.CompoundTagInjection;
import xyz.bluspring.kilt.injections.nbt.ListTagInjection;
import xyz.bluspring.kilt.injections.world.entity.ai.attributes.AttributeSupplierBuilderInjection;
import xyz.bluspring.kilt.injections.world.inventory.RecipeBookTypeInjection;

import net.minecraft.ChatFormatting;
import net.minecraft.ResourceLocationException;
Expand Down Expand Up @@ -1660,13 +1660,18 @@ public static boolean tryDispenseShearsHarvestBlock(BlockSource source, ItemStac
}

public static Map<RecipeBookType, Pair<String, String>> buildRecipeBookTypeTagFields(Map<RecipeBookType, Pair<String, String>> vanillaMap) {
ExtensionInfo extInfo = RecipeBookTypeInjection.getExtensionInfo();
ExtensionInfo extInfo = CheckExtensibleEnums.getEnumExtensionInfo(RecipeBookType.class);
if (extInfo.extended()) {
vanillaMap = new HashMap<>(vanillaMap);
for (RecipeBookType type : RecipeBookType.values()) {
if (type.ordinal() < extInfo.vanillaCount()) {
continue;
}
//Kilt: Fabric mods might already have added themselves here.
if (vanillaMap.containsKey(type)) {
LOGGER.warn("Existing tag fields found for non-vanilla RecipeBookType enum {} {}. These will be used instead of the NeoForge (Kilt) defaults.", type, vanillaMap.get(type));
continue;
}
Comment thread
BluSpring marked this conversation as resolved.
String name = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, type.name());
vanillaMap.put(type, Pair.of("is" + name + "GuiOpen", "is" + name + "FilteringCraftable"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static synchronized Map<String, EnumEntry> getEnumEntries() {
return enumEntries;
}

private static ExtensionInfo getEnumExtensionInfo(Class<? extends Enum<?>> enumClass) {
public static ExtensionInfo getEnumExtensionInfo(Class<? extends Enum<?>> enumClass) {
try {
Method mth = enumClass.getDeclaredMethod("getExtensionInfo");
return (ExtensionInfo) mth.invoke(null);
Expand Down
Loading