-
Notifications
You must be signed in to change notification settings - Fork 17
Recycling
The Recycling system is an attempt at a versatile and balanced "uncrafting" API. If you wish to get the results of recycling an Item, you can do this like so:
RecyclingOutputs outputs = RecyclingManager.getRecyclingOutputs(level, stack);This returns a RecyclingOutputs object, which is a list of Item Stacks and the expected counts of each. This can be interpreted as a guaranteed count plus a chance at another, and you can roll for these results like so:
outputs.rollStacks(level.random);By default the RecyclingOutputs will include a 100% return, so you get back exactly the average number of Items used to craft the Item being recycled (even if that number is a fraction). But, it is recommended for balance you reduce this output. For example, this will only return 25% of the input Items on average:
outputs.multiplyAll(0.25f).rollStacks(level.random);The Library tries to automatically produce sensible recycling outputs for vanilla and modded Items. It attempts to do this by:
- Checking if there is a Direct Recycling Recipe for the Item Stack, and if so getting its
RecyclingOutputsdirectly and go to step 4 - Checking for any Recipes that produce the Item Stack and implement
IRecyclableRecipe, and if so try and getting itsRecyclingOutputsdirectly and go to step 4 - Checking for any other Recipes whose Recipe Types are
#petrolpark:recyclable, and trying to find inverses for every Ingredient that Recipe has - Applying Recipe Outputs Modifiers to any
RecyclingResultsfrom the previous three steps
This is the Library's solution to there being multiple ways to craft an Item.
Implementing IRecyclableRecipe provides the greatest control, but is unnecessary if you will just find the inverses of each Ingredient. If your Recipe is simple like this, you can simply Tag the RecipeType with petrolpark:recyclable. By default minecraft:crafting is the only member of this Tag.
Flags than can be applied to Item Stacks and other objects and will propagate through crafting
Timers that can be attached to Item Stacks to modify them after a given time, no matter what Inventory they are in
A way for mods to detect groupings of Players and store information on these groupings
Manipulation of Loot Table randomness and other RNG to give desired Items
Additional inventory and hotbar slots for the Player
Blocks and Items that have variants craftable from any mod's wood
Data-driven modifications to existing Loot Tables with greater versatility than NeoForge Global Loot Modifiers
Data-driven changes to the world (give Items, XP, unlock Villager Trades)
Levelable "Shops" shared between Teams giving Rewards for randomly-generated Item requests
Additional implementations of vanilla's Number Providers used in Loot Tables and Advancements
Extension of NeoForge Ingredients to include descriptions and Loot Table forcing
Work with automatically-detected "compression" Recipes (e.g. Nuggets <-> Ingots <-> Blocks)
Recycling (page under construction)
Balanced and versatile "uncrafting" API
Gating Recipes for vanilla and modded Items behind Item unlocks
1.3.1, 1.3.2, 1.3.3, 1.3.4
1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.4.7, 1.4.8, 1.4.9, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.14, 1.4.15, 1.4.16, 1.4.17, 1.4.18, 1.4.19, 1.4.20, 1.4.21, 1.4.22, 1.4.23, 1.4.24, 1.4.25, 1.4.26