Polymorph

From the Fear Nightfall wiki · Polymorph
Polymorph

Polymorph is a utility mod that lets the player choose which result a crafting grid, furnace, blast furnace, smoker, Crafter or smithing table produces when more than one recipe matches the same inputs. Vanilla silently uses the first matching recipe. Polymorph adds a button above the output slot that opens a list of the matching results. It adds no items, blocks, entities, recipes or worldgen.

Overview

Polymorph is a recipe-selection tweak rather than a content mod. It changes the recipe-lookup code of several vanilla containers and leaves recipes, loot, tags and progression untouched. In Fear Nightfall it helps where several mods add crafting, cooking or smithing recipes that accept the same ingredients: the player can pick the intended result from the list rather than receiving the first match. The selector is available from the first craft in any world.

The mod's behaviour is described under Polymorph and its changes to the game under Polymorph. Its place in the pack's mod set is listed on the Mod List page.

Content

Polymorph adds no items, blocks, mobs, structures, biomes, loot, trades, enchantments, effects or advancements, and it has no recipes of its own. The item, mob and structure tables used on other mod pages therefore do not apply here.

It adds the following interface and command content:

  • Output selector. A button sits above the output slot of each supported container. Clicking it opens a list of the matching results, with the current selection marked. The list shows at most 15 entries, plus the current selection.
  • /polymorph conflicts. An operator command with permission level 2. It scans every CRAFTING, SMELTING, BLASTING, SMOKING and SMITHING recipe for overlapping inputs, writes the groups to logs/polymorph-conflicts.log, and reports the count in chat. It is a diagnostic only and does not change recipe behaviour. Command handling in general is covered on Gamerules and Commands.

The selector appears on these vanilla containers:

Polymorph does not add a block or item for any of these containers. They keep their vanilla recipes and output slots.

Mechanics

The selection logic works in three places, depending on the container.

Crafting grid. When the grid input changes, the game asks Polymorph for the player's selected recipe. If no recipe is selected, the first match from vanilla's recipe lookup is used. A selection is tied to the id of the matching recipe and is kept while the grid input does not change. Choosing a different entry re-assembles the output and sends the updated result to the client.

Furnaces, blast furnaces and smokers. Each furnace-family block entity keeps its own selection in a data attachment that is saved with the block entity. The stored list is cleared when the input slot becomes empty. This check runs every 5 server ticks, and only for furnaces that a player is watching.

Crafter. Works like the furnace family. Choosing a new recipe refreshes the open Crafter's result.

Smithing table. Polymorph keeps the full list of matching smithing recipes and uses the player's selection as the output when one exists. If no recipe matches, the server sends an empty recipe list to the client so that the client list stays in sync.

Selection rules. The chosen recipe is the one the player picked. If none is picked, the first recipe with a non-empty output is used, and recipes whose output is empty are skipped. Custom recipes have their output recomputed with assemble, so each entry in the list shows the actual result.

Persistence. The player's last selection is stored in the player's save data. Furnace and Crafter selections are stored in the block entity's data, so they persist with the block.

Caching. A player's selection is cached for the current game tick and is only read on the server thread. Ingredient matching uses a per-owner cache of 10 entries, keyed by the input item and its components. The cache is cleared when the recipe manager reloads, for example after /reload.

Progression. None. The selector is available from the first craft.

Changes to vanilla

Polymorph changes how the game picks a recipe result, but only when more than one recipe matches. The differences a player will notice are:

  • Output selector on containers. Every container screen with an output slot gets a selector button in the same position. Clicks that land on the button are consumed and do not reach the slot beneath it.
  • First match is still the default. If no recipe is selected, the output is the same as in vanilla, so recipes that never conflict behave as before.
  • Crafting-grid cache bypass. Vanilla keeps a cache of crafting-grid lookups. Polymorph replaces that path with a direct, uncached lookup, so each change to the grid does a full recipe search. The cost is inferred to be small at the recipe counts in this pack.
  • Smithing output. The smithing table's output uses the player's chosen recipe rather than the first match.
  • Furnace-family and Crafter lookups. During a block entity's tick, a recipe lookup for a furnace, blast furnace, smoker or Crafter uses that block entity's selection when it has one, and otherwise falls back to vanilla.
  • Player data. Every player gains a data attachment that stores the selection, which adds a small amount of NBT to each player's save data.
  • Chat message. The success message for /polymorph conflicts names logs/conflicts.log, but the command writes logs/polymorph-conflicts.log. The second name is the file to open.

The mod does not change items, blocks, tags, loot tables, worldgen or recipes. For the pack's other changes to the base game, see Changes to Vanilla.

In Fear Nightfall

The pack ships Polymorph as a single jar with no configuration. The pack's change log does not record any change to Polymorph itself, so it runs with the mod's defaults. Its effect on the pack depends on how many recipes the other mods add, since every conflict between them gives the selector something to resolve.

The pack includes JEI. The jar also contains integration code for JEI, EMI, REI and FastBench. The EMI, REI and FastBench parts are optional. Those mods are not in this pack, so those integrations are inactive.

The selector is drawn by a client-side widget, so players need the mod installed on their client to see the button. On a multiplayer server the selection itself is handled by the server, and the client mod is the only requirement on the player's side. Server operators can run /polymorph conflicts (permission level 2) to list recipe overlaps in the pack before players report them.

The mod has no progression tie-in. For how the pack is structured, see the Progression Guide.