diff --git a/examples/postInit/advancedrocketry.groovy b/examples/postInit/advancedrocketry.groovy index cf26c248a..b2c1354d4 100644 --- a/examples/postInit/advancedrocketry.groovy +++ b/examples/postInit/advancedrocketry.groovy @@ -2,13 +2,13 @@ // Auto generated groovyscript example file // MODS_LOADED: advancedrocketry -println 'mod \'advancedrocketry\' detected, running script' +log.info 'mod \'advancedrocketry\' detected, running script' // Centrifuge: -// Converts an input fluid into up to 12 output items and up to 4 output fluids, consuming RF +// Converts an input fluid into up to 12 output items and up to 4 output fluids, consuming RF. -// mods.advancedrocketry.centrifuge.removeAll() mods.advancedrocketry.centrifuge.removeByInput(fluid('enrichedlava')) +// mods.advancedrocketry.centrifuge.removeAll() mods.advancedrocketry.centrifuge.recipeBuilder() .fluidInput(fluid('lava') * 500) @@ -22,11 +22,11 @@ mods.advancedrocketry.centrifuge.recipeBuilder() // Chemical Reactor: -// Converts up to 2 fluids and 8 input items into up to 1 fluid and up to 4 output items, consuming RF +// Converts up to 2 fluids and 8 input items into up to 1 fluid and up to 4 output items, consuming RF. -// mods.advancedrocketry.chemical_reactor.removeAll() mods.advancedrocketry.chemical_reactor.removeByInput(item('minecraft:bone')) mods.advancedrocketry.chemical_reactor.removeByOutput(item('minecraft:leather_helmet')) +// mods.advancedrocketry.chemical_reactor.removeAll() mods.advancedrocketry.chemical_reactor.recipeBuilder() .input(item('minecraft:chorus_fruit_popped')) @@ -39,11 +39,11 @@ mods.advancedrocketry.chemical_reactor.recipeBuilder() // Crystallizer: -// Converts up to 4 input items into up to 4 output items, consuming RF +// Converts up to 4 input items into up to 4 output items, consuming RF. -// mods.advancedrocketry.crystallizer.removeAll() mods.advancedrocketry.crystallizer.removeByInput(item('libvulpes:productingot', 3)) mods.advancedrocketry.crystallizer.removeByOutput(item('libvulpes:productgem')) +// mods.advancedrocketry.crystallizer.removeAll() mods.advancedrocketry.crystallizer.recipeBuilder() .input(item('minecraft:blaze_powder') * 4) @@ -54,11 +54,11 @@ mods.advancedrocketry.crystallizer.recipeBuilder() // Cutting Machine: -// Converts up to 4 input items into up to 4 output items, consuming RF +// Converts up to 4 input items into up to 4 output items, consuming RF. -// mods.advancedrocketry.cutting_machine.removeAll() mods.advancedrocketry.cutting_machine.removeByInput(item('advancedrocketry:alienwood')) mods.advancedrocketry.cutting_machine.removeByOutput(item('minecraft:planks', 1)) +// mods.advancedrocketry.cutting_machine.removeAll() mods.advancedrocketry.cutting_machine.recipeBuilder() .input(item('minecraft:blaze_rod')) @@ -69,11 +69,11 @@ mods.advancedrocketry.cutting_machine.recipeBuilder() // Electric Arc Furnace: -// Converts input items and fluids into output items and fluids, consuming RF +// Converts input items and fluids into output items and fluids, consuming RF. -// mods.advancedrocketry.electric_arc_furnace.removeAll() mods.advancedrocketry.electric_arc_furnace.removeByInput(item('minecraft:iron_ingot')) mods.advancedrocketry.electric_arc_furnace.removeByOutput(item('libvulpes:productingot', 3)) +// mods.advancedrocketry.electric_arc_furnace.removeAll() mods.advancedrocketry.electric_arc_furnace.recipeBuilder() .input(item('minecraft:blaze_powder') * 4) @@ -84,11 +84,11 @@ mods.advancedrocketry.electric_arc_furnace.recipeBuilder() // Electrolyser: -// Converts an input fluid into up to 2 output fluids, consuming RF +// Converts an input fluid into up to 2 output fluids, consuming RF. -// mods.advancedrocketry.electrolyser.removeAll() mods.advancedrocketry.electrolyser.removeByInput(fluid('water')) // mods.advancedrocketry.electrolyser.removeByOutput(fluid('oxygen')) +// mods.advancedrocketry.electrolyser.removeAll() mods.advancedrocketry.electrolyser.recipeBuilder() .fluidInput(fluid('lava') * 10) @@ -99,11 +99,11 @@ mods.advancedrocketry.electrolyser.recipeBuilder() // Lathe: -// Converts up to 4 input items into up to 4 output items, consuming RF +// Converts up to 4 input items into up to 4 output items, consuming RF. -// mods.advancedrocketry.lathe.removeAll() mods.advancedrocketry.lathe.removeByInput(item('libvulpes:productingot', 6)) mods.advancedrocketry.lathe.removeByOutput(item('libvulpes:productrod', 4)) +// mods.advancedrocketry.lathe.removeAll() mods.advancedrocketry.lathe.recipeBuilder() .input(ore('plankWood')) @@ -114,11 +114,11 @@ mods.advancedrocketry.lathe.recipeBuilder() // Precision Assembler: -// Converts input items and fluids into output items and fluids, consuming RF +// Converts input items and fluids into output items and fluids, consuming RF. -// mods.advancedrocketry.precision_assembler.removeAll() mods.advancedrocketry.precision_assembler.removeByInput(item('minecraft:redstone_block')) mods.advancedrocketry.precision_assembler.removeByOutput(item('advancedrocketry:atmanalyser')) +// mods.advancedrocketry.precision_assembler.removeAll() mods.advancedrocketry.precision_assembler.recipeBuilder() .input(item('minecraft:fishing_rod'), item('minecraft:carrot')) @@ -129,11 +129,11 @@ mods.advancedrocketry.precision_assembler.recipeBuilder() // Precision Laser Etcher: -// Converts up to 4 input items into up to 4 output items, consuming RF +// Converts up to 4 input items into up to 4 output items, consuming RF. -// mods.advancedrocketry.precision_laser_etcher.removeAll() mods.advancedrocketry.precision_laser_etcher.removeByInput(item('minecraft:redstone_block')) mods.advancedrocketry.precision_laser_etcher.removeByOutput(item('advancedrocketry:itemcircuitplate')) +// mods.advancedrocketry.precision_laser_etcher.removeAll() mods.advancedrocketry.precision_laser_etcher.recipeBuilder() .input(item('minecraft:blaze_powder') * 4, item('advancedrocketry:wafer')) @@ -144,11 +144,11 @@ mods.advancedrocketry.precision_laser_etcher.recipeBuilder() // Rolling Machine: -// Consumes up to 1 input fluid and up to 4 input items into up to 4 output items, consuming RF +// Consumes up to 1 input fluid and up to 4 input items into up to 4 output items, consuming RF. -// mods.advancedrocketry.rolling_machine.removeAll() mods.advancedrocketry.rolling_machine.removeByInput(item('libvulpes:productplate')) mods.advancedrocketry.rolling_machine.removeByOutput(item('libvulpes:productsheet', 1)) +// mods.advancedrocketry.rolling_machine.removeAll() mods.advancedrocketry.rolling_machine.recipeBuilder() .input(item('minecraft:snow'), fluid('water') * 300) @@ -159,11 +159,11 @@ mods.advancedrocketry.rolling_machine.recipeBuilder() // Small Plate Presser: -// Converts a block right below it into output items when powered by redstone +// Converts a block right below it into output items when powered by redstone. -// mods.advancedrocketry.small_plate_presser.removeAll() mods.advancedrocketry.small_plate_presser.removeByInput(item('minecraft:iron_block')) mods.advancedrocketry.small_plate_presser.removeByOutput(item('libvulpes:productplate', 2)) +// mods.advancedrocketry.small_plate_presser.removeAll() mods.advancedrocketry.small_plate_presser.recipeBuilder() .input(item('minecraft:cobblestone')) diff --git a/examples/postInit/aether_legacy.groovy b/examples/postInit/aether_legacy.groovy index 3b5fb8790..84742272a 100644 --- a/examples/postInit/aether_legacy.groovy +++ b/examples/postInit/aether_legacy.groovy @@ -16,7 +16,6 @@ mods.aether_legacy.accessory.recipeBuilder() .register() - // Enchanter: // Enchanting is a mechanic used to create new items, as well as repair tools, armor, and weapons, using the Altar block. @@ -30,7 +29,6 @@ mods.aether_legacy.enchanter.recipeBuilder() .register() - // Enchanter Fuel: // By default, the Enchanter (Altar) takes Ambrosium Shards as fuel. Using GroovyScript, custom fuels can be added. @@ -52,7 +50,6 @@ mods.aether_legacy.freezer.recipeBuilder() .register() - // Freezer Fuel: // By default, the Freezer takes Icestone as fuel. Using GroovyScript, custom fuels can be added. diff --git a/examples/postInit/alchemistry.groovy b/examples/postInit/alchemistry.groovy index efeaaa61b..52acf4e7c 100644 --- a/examples/postInit/alchemistry.groovy +++ b/examples/postInit/alchemistry.groovy @@ -23,7 +23,6 @@ mods.alchemistry.atomizer.recipeBuilder() .register() - // Chemical Combiner: // Converts up to 9 input itemstacks into an output itemstack. @@ -110,7 +109,6 @@ mods.alchemistry.evaporator.recipeBuilder() .register() - // Liquifier: // Converts an input itemstack into an output fluidstack, consuming a set amount of power. @@ -129,4 +127,3 @@ mods.alchemistry.liquifier.recipeBuilder() .register() - diff --git a/examples/postInit/astralsorcery.groovy b/examples/postInit/astralsorcery.groovy index a05d51176..dab805b4e 100644 --- a/examples/postInit/astralsorcery.groovy +++ b/examples/postInit/astralsorcery.groovy @@ -22,7 +22,6 @@ mods.astralsorcery.chalice_interaction.recipeBuilder() .register() - // Constellation: // Create a custom Constellation. @@ -67,7 +66,6 @@ mods.astralsorcery.constellation.signatureItems() .register() - // Fountain: // Adds virtual aquifers that can be accessed via the Evershifting Fountain's Necromantic Prime. @@ -82,7 +80,6 @@ mods.astralsorcery.fountain.chanceHelper() .register() - // Grindstone: // Converts an item into an itemstack with a chance of getting twice the amount after right clicking the grindstone based // on weight. @@ -105,7 +102,6 @@ mods.astralsorcery.grindstone.recipeBuilder() .register() - // Infusion Altar: // Consumes buckets of Liquid Starlight when interacted with by a Resonating Wand to convert input items into output // itemstacks after a time. @@ -180,7 +176,6 @@ mods.astralsorcery.lightwell.recipeBuilder() .register() - // Perk Tree: // Create a custom perk with a custom effect, at a given location. diff --git a/examples/postInit/avaritia.groovy b/examples/postInit/avaritia.groovy index b78adced0..78ff97c12 100644 --- a/examples/postInit/avaritia.groovy +++ b/examples/postInit/avaritia.groovy @@ -55,4 +55,3 @@ mods.avaritia.extreme_crafting.shapelessBuilder() .register() - diff --git a/examples/postInit/betterwithmods.groovy b/examples/postInit/betterwithmods.groovy index a02511054..0a7d1cbd6 100644 --- a/examples/postInit/betterwithmods.groovy +++ b/examples/postInit/betterwithmods.groovy @@ -77,6 +77,8 @@ mods.betterwithmods.crucible.recipeBuilder() // Heat: // Creates new levels or adds new blocks to old heat levels. +// mods.betterwithmods.heat.removeAll() + mods.betterwithmods.heat.add(4, item('minecraft:redstone_block'), item('minecraft:redstone_torch')) mods.betterwithmods.heat.add(3, 'torch') diff --git a/examples/postInit/bloodmagic.groovy b/examples/postInit/bloodmagic.groovy index bf7e93dcc..cb86e01f1 100644 --- a/examples/postInit/bloodmagic.groovy +++ b/examples/postInit/bloodmagic.groovy @@ -28,7 +28,6 @@ mods.bloodmagic.alchemy_array.recipeBuilder() .register() - // Alchemy Table: // Converts up to 6 input items into an output itemstack, with configurable time, minimum tier of Blood Orb required, and // Life Essence drained from the Orb network. @@ -54,7 +53,6 @@ mods.bloodmagic.alchemy_table.recipeBuilder() .register() - // Blood Altar: // Converts an input item into an output itemstack, draining life essence from the altar at a base rate and requiring at // least a specific tier. @@ -82,7 +80,6 @@ mods.bloodmagic.blood_altar.recipeBuilder() .register() - // Meteor: // Throwing an input catalyst atop an activated Mark of the Falling Tower Ritual will spawn a meteor made of the given // components, size, explosion strength, and Life Essence cost. @@ -110,7 +107,6 @@ mods.bloodmagic.meteor.recipeBuilder() .register() - // Sacrificial: // How much Life Essence is gained when using the Sacrificial Dagger on a mob. @@ -125,7 +121,6 @@ mods.bloodmagic.sacrificial.recipeBuilder() .register() - // Tartaric Forge: // Converts up to 4 input items into an output itemstack, requiring a Tartaric gem with a minimum amount of souls, and // consuming some. @@ -150,7 +145,6 @@ mods.bloodmagic.tartaric_forge.recipeBuilder() .register() - // Tranquility: // Blocks in the area around the Tranquility Altar provide tranquility up to the Altar's cap, with reduced effect the more // of a particular type of Tranquility is provided. @@ -178,4 +172,3 @@ mods.bloodmagic.tranquility.recipeBuilder() .register() - diff --git a/examples/postInit/botania.groovy b/examples/postInit/botania.groovy index 3a2fce496..12aa14770 100644 --- a/examples/postInit/botania.groovy +++ b/examples/postInit/botania.groovy @@ -21,7 +21,6 @@ mods.botania.apothecary.recipeBuilder() .register() - // Brew Effect: // Creates a custom brew, but not a recipe for the brew. @@ -66,11 +65,9 @@ mods.botania.elven_trade.recipeBuilder() .register() - // Magnet: // Add or remove items from the magnet blacklist. - mods.botania.magnet.addToBlacklist(item('minecraft:diamond')) // Mana Infusion: @@ -89,7 +86,6 @@ mods.botania.mana_infusion.recipeBuilder() .register() - // Orechid: // Converts stone blocks into one of a few ore blocks at the cost of mana. @@ -127,7 +123,6 @@ mods.botania.pure_daisy.recipeBuilder() .register() - // Rune Altar: // Converts a items inputs into an item output at the cost of mana when a Livingrock item is thrown atop the altar and // right clicked with a Wand of the Forest. @@ -144,7 +139,6 @@ mods.botania.rune_altar.recipeBuilder() .register() - // Lexicon Knowledge: // Creates a new type of knowledge that Lexica Botania entries may be gated with. Can only be created. @@ -194,5 +188,3 @@ mods.botania.entry.entryBuilder() .register() - - diff --git a/examples/postInit/enderio.groovy b/examples/postInit/enderio.groovy index c3349f9f3..e338ee8d3 100644 --- a/examples/postInit/enderio.groovy +++ b/examples/postInit/enderio.groovy @@ -61,7 +61,6 @@ mods.enderio.enchanter.recipeBuilder() .register() - // Fluid Coolant: // Create a Coolant with a given coolant rate that produces power with a Fuel while in a Combustion Generator. @@ -153,7 +152,6 @@ mods.enderio.slice_n_splice.recipeBuilder() .register() - // Soulbinder: // Converts an input itemstack into an output itemstack, requiring one of several entities in soul vials, using energy and // giving XP. Must have a unique name. To function properly, the input entities must be allowed in Soul Vials. @@ -206,7 +204,6 @@ mods.enderio.tank.recipeBuilder() .register() - // Vat: // Converts an input fluidstack into an output itemstack at a rate based on up 2 itemstack inputs, and using power. Can be // set to require at least NORMAL or ENHANCED tiers, or to IGNORE the tier. NORMAL and IGNORE are effectively the same. diff --git a/examples/postInit/extendedcrafting.groovy b/examples/postInit/extendedcrafting.groovy index 6ca8e6c63..95ab7fb07 100644 --- a/examples/postInit/extendedcrafting.groovy +++ b/examples/postInit/extendedcrafting.groovy @@ -28,7 +28,6 @@ mods.extendedcrafting.combination_crafting.recipeBuilder() .register() - // Compression Crafting: // Converts any number of a single item into an output itemstack, with a configurable rf cost, consumption per tick amount, // catalyst, and if the catalyst is consumed. @@ -55,7 +54,6 @@ mods.extendedcrafting.compression_crafting.recipeBuilder() .register() - // Ender Crafting: // A normal crafting recipe, with the recipe being slowly crafted based on nearby Ender Alternators. @@ -92,7 +90,6 @@ mods.extendedcrafting.ender_crafting.shapelessBuilder() .register() - // Table Crafting: // A normal crafting recipe, but requiring either a specific tier, or at least a given tier, from 3x3 to 9x9. @@ -156,4 +153,3 @@ mods.extendedcrafting.table_crafting.shapelessBuilder() .register() - diff --git a/examples/postInit/extrabotany.groovy b/examples/postInit/extrabotany.groovy index 61789f364..0e764f377 100644 --- a/examples/postInit/extrabotany.groovy +++ b/examples/postInit/extrabotany.groovy @@ -23,4 +23,3 @@ mods.extrabotany.pedestal.recipeBuilder() .register() - diff --git a/examples/postInit/immersiveengineering.groovy b/examples/postInit/immersiveengineering.groovy index 6a6ee8534..18ede4d13 100644 --- a/examples/postInit/immersiveengineering.groovy +++ b/examples/postInit/immersiveengineering.groovy @@ -17,7 +17,6 @@ mods.immersiveengineering.alloy_kiln.recipeBuilder() .register() - // Arc Furnace: // Converts 1 input itemstack with up to 4 additional inputs into an output itemstack and an optional 'slag' itemstack, // taking time and using rf power. @@ -36,7 +35,6 @@ mods.immersiveengineering.arc_furnace.recipeBuilder() .register() - // Blast Furnace: // Converts an input itemstack into an output itemstack and an optional 'slag' itemstack, taking time and consuming fuel // (based on Blast Furnace Fuels). @@ -53,7 +51,6 @@ mods.immersiveengineering.blast_furnace.recipeBuilder() .register() - // Blast Furnace Fuel: // Allows an item to be used in the Blast Furnace as a fuel for the given number of ticks. @@ -66,7 +63,6 @@ mods.immersiveengineering.blast_furnace_fuel.recipeBuilder() .register() - // Blueprint Crafting: // Converts any number of input itemstacks into an output itemstack, using a blueprint with the category nbt tag as a // catalyst. @@ -83,7 +79,6 @@ mods.immersiveengineering.blueprint_crafting.recipeBuilder() .register() - // Bottling Machine: // Converts an input itemstack and fluidstack into an output itemstack. @@ -98,7 +93,6 @@ mods.immersiveengineering.bottling_machine.recipeBuilder() .register() - // Coke Oven: // Converts an input itemstack into an output itemstack over time, producing a given amount of creosote oil. @@ -114,7 +108,6 @@ mods.immersiveengineering.coke_oven.recipeBuilder() .register() - // Crusher: // Converts an input itemstack into an output itemstack with optional additional chanced item outputs, consuming energy. @@ -137,7 +130,6 @@ mods.immersiveengineering.crusher.recipeBuilder() .register() - // Excavator: // Adds a Mineral Mix with the given name, weight, fail chance, ores, and allowed dimensions. A Mineral Mix can be mined by // an Excavator Multiblock and scanned via a Core Sample Drill. @@ -165,7 +157,6 @@ mods.immersiveengineering.excavator.recipeBuilder() .register() - // Fermenter: // Converts an input itemstack into an output fluidstack with an optional output itemstack, consuming power. @@ -181,7 +172,6 @@ mods.immersiveengineering.fermenter.recipeBuilder() .register() - // Metal Press: // Converts an input itemstack into an output itemstack, with a mold catalyst, consuming power. @@ -200,7 +190,6 @@ mods.immersiveengineering.metal_press.recipeBuilder() .register() - // Mixer: // Converts any number of input itemstacks and a fluidstack into an output fluidstack, consuming power. @@ -217,7 +206,6 @@ mods.immersiveengineering.mixer.recipeBuilder() .register() - // Refinery: // Converts 2 input fluidstacks into an output fluidstack, consuming power. @@ -232,7 +220,6 @@ mods.immersiveengineering.refinery.recipeBuilder() .register() - // Squeezer: // Converts an input itemstack into either an output itemstack, fluidstack, or both, using energy. @@ -261,4 +248,3 @@ mods.immersiveengineering.squeezer.recipeBuilder() .register() - diff --git a/examples/postInit/immersivetech.groovy b/examples/postInit/immersivetech.groovy index e67f4644a..02c3b2899 100644 --- a/examples/postInit/immersivetech.groovy +++ b/examples/postInit/immersivetech.groovy @@ -2,7 +2,7 @@ // Auto generated groovyscript example file // MODS_LOADED: immersivetech -println 'mod \'immersivetech\' detected, running script' +log.info 'mod \'immersivetech\' detected, running script' // Boiler: // Converts an input fluidstack into an output fluidstack after a given amount of time in a multiblock structure when the diff --git a/examples/postInit/industrialforegoing.groovy b/examples/postInit/industrialforegoing.groovy index b43d3e355..c1f8fd595 100644 --- a/examples/postInit/industrialforegoing.groovy +++ b/examples/postInit/industrialforegoing.groovy @@ -115,4 +115,3 @@ mods.industrialforegoing.straw.recipeBuilder() .register() - diff --git a/examples/postInit/inspirations.groovy b/examples/postInit/inspirations.groovy index 7f5158fc3..3d7641d68 100644 --- a/examples/postInit/inspirations.groovy +++ b/examples/postInit/inspirations.groovy @@ -22,7 +22,6 @@ mods.inspirations.anvil_smashing.recipeBuilder() .register() - // Cauldron: // Converts up to 1 itemstack and up to 1 fluid into up to 1 itemstack or up to 1 fluid, with a boiling boolean and // variable amount of fluid consumed or produced. diff --git a/examples/postInit/pneumaticcraft.groovy b/examples/postInit/pneumaticcraft.groovy index c68fd5d28..f5eaac5ec 100644 --- a/examples/postInit/pneumaticcraft.groovy +++ b/examples/postInit/pneumaticcraft.groovy @@ -109,7 +109,6 @@ mods.pneumaticcraft.liquid_fuel.recipeBuilder() .register() - // Plastic Mixer: // Converts a fluidstack and an item with a variable damage value into each other, requiring temperature to operate the // process, optionally consuming dye, and allowing either only melting or only solidifying. @@ -212,4 +211,3 @@ mods.pneumaticcraft.xp_fluid.recipeBuilder() .register() - diff --git a/examples/postInit/primal_tech.groovy b/examples/postInit/primal_tech.groovy index 18fb9cf38..00cbd9f47 100644 --- a/examples/postInit/primal_tech.groovy +++ b/examples/postInit/primal_tech.groovy @@ -25,7 +25,6 @@ mods.primal_tech.clay_kiln.recipeBuilder() .register() - // Stone Anvil: // Converts an input item into an output itemstack after being interacted with by a player using a Stone Mallet. @@ -44,7 +43,6 @@ mods.primal_tech.stone_anvil.recipeBuilder() .register() - // Water Saw: // Converts an input item into an output itemstack after a given amount of time. Requires the block below it to be a water // source block, and the block below and behind it flowing water. @@ -66,7 +64,6 @@ mods.primal_tech.water_saw.recipeBuilder() .register() - // Wooden Basin: // Converts up to 4 items and 1000mb of fluid into an output itemstack. @@ -88,4 +85,3 @@ mods.primal_tech.wooden_basin.recipeBuilder() .register() - diff --git a/examples/postInit/prodigytech.groovy b/examples/postInit/prodigytech.groovy index b4224ca57..3f07a9352 100644 --- a/examples/postInit/prodigytech.groovy +++ b/examples/postInit/prodigytech.groovy @@ -29,8 +29,8 @@ mods.prodigytech.atomic_reshaper.recipeBuilder() // Uses an explosive, a dampener, and an optional reagent to convert items. The power value of all recipes, all explosives, // and all dampeners should be close to avoid an efficiency loss. -// mods.prodigytech.explosion_furnace.removeAll() mods.prodigytech.explosion_furnace.removeByOutput(item('prodigytech:ferramic_ingot')) +// mods.prodigytech.explosion_furnace.removeAll() mods.prodigytech.explosion_furnace.recipeBuilder() .input(ore('ingotGold'), item('minecraft:diamond')) diff --git a/examples/postInit/tconstruct.groovy b/examples/postInit/tconstruct.groovy index 940017974..21c49061a 100644 --- a/examples/postInit/tconstruct.groovy +++ b/examples/postInit/tconstruct.groovy @@ -65,7 +65,6 @@ mods.tconstruct.drying.recipeBuilder() .register() - // Entity Melting: // Allows mobs to create a bit of fluid when hurt by the Smeltery. @@ -89,7 +88,6 @@ mods.tconstruct.melting.recipeBuilder() .register() - // Smeltery Fuel: // Modifies what fluids are accepted as fuels for the Smeltery and how long each fuels the Smeltery. diff --git a/examples/postInit/techreborn.groovy b/examples/postInit/techreborn.groovy index 1f0762f80..6f0db5513 100644 --- a/examples/postInit/techreborn.groovy +++ b/examples/postInit/techreborn.groovy @@ -463,7 +463,6 @@ mods.techreborn.rolling_machine.shapelessBuilder() .register() - // Scrapbox: // Converts a scrapbox into a random itemstack output, either via manual player interaction or via a machine with a given // process time, consuming energy per tick. diff --git a/examples/postInit/thaumcraft.groovy b/examples/postInit/thaumcraft.groovy index 129ab7208..dbc39e42d 100644 --- a/examples/postInit/thaumcraft.groovy +++ b/examples/postInit/thaumcraft.groovy @@ -60,7 +60,6 @@ mods.thaumcraft.aspect.aspectBuilder() // Entity/Block Aspects: // Controls what Aspects are attached to entities or items. - mods.thaumcraft.aspect_helper.aspectBuilder() .object(item('minecraft:stone')) .stripAspects() @@ -81,7 +80,6 @@ mods.thaumcraft.aspect_helper.aspectBuilder() .register() - // Crucible: // Combines an item with any number of Aspects to drop an output itemstack, potentially requiring a specific research to be // completed. @@ -97,7 +95,6 @@ mods.thaumcraft.crucible.recipeBuilder() .register() - // Dust Trigger: // Converts a block in-world into an item, when interacting with it with Salis Mundus, potentially requiring a specific // research to be completed. @@ -139,7 +136,6 @@ mods.thaumcraft.infusion_crafting.recipeBuilder() .register() - // Lootbag: // Control what the different rarities of lootbag drop when opened. @@ -193,7 +189,6 @@ mods.thaumcraft.smelting_bonus.recipeBuilder() .register() - // Warp: // Determines if holding an item or equipping a piece of armor or a bauble gives warp, and how much warp it gives. diff --git a/examples/postInit/thermalexpansion.groovy b/examples/postInit/thermalexpansion.groovy index 449e80ed9..138401923 100644 --- a/examples/postInit/thermalexpansion.groovy +++ b/examples/postInit/thermalexpansion.groovy @@ -268,7 +268,6 @@ mods.thermalexpansion.factorizer.recipeBuilder() .register() - // Aquatic Entangler: // Controls what itemstacks can be gained and how likely each is to be obtained. diff --git a/examples/postInit/woot.groovy b/examples/postInit/woot.groovy index 052f4265f..25723fd2d 100644 --- a/examples/postInit/woot.groovy +++ b/examples/postInit/woot.groovy @@ -25,7 +25,6 @@ mods.woot.drops.recipeBuilder() .register() - // Mob Config: // Control the default values or mob-specific values for a large number of effects, a full list can be found at // `ipsis.woot.configuration.EnumConfigKey`. A full list can be viewed on @@ -85,7 +84,6 @@ mods.woot.spawning.recipeBuilder() .register() - // Stygian Iron Anvil: // Has a catalyst (which may or may not be consumed) placed on the anvil, with the input items thrown atop the base. diff --git a/gradle.properties b/gradle.properties index 7ce280222..456024f02 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,8 +4,8 @@ debug_run_ls = false debug_use_examples_folder = true debug_log_missing_lang_keys = true -debug_generate_examples = true -debug_generate_wiki = true +debug_generate_examples = false +debug_generate_wiki = false debug_generate_and_crash = false # END SECTION: development environment settings @@ -43,7 +43,7 @@ debug_extra_utilities_2 = false debug_forestry = false debug_immersive_engineering = false debug_immersive_petroleum = false -debug_immersive_technology = true +debug_immersive_technology = false debug_industrial_craft_2_classic = false debug_industrial_craft_2_experimental = false debug_industrial_foregoing = false diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java index 36d68de9b..c92c53737 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Burning.java @@ -6,7 +6,7 @@ import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.BurningRecipeCategory; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; import groovy.lang.Closure; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; @@ -15,13 +15,10 @@ import net.minecraftforge.fml.common.Optional; import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; -public class Burning extends VirtualizedRegistry { +public class Burning extends StandardListRegistry { private static final Map runningRecipes = new Object2ObjectOpenHashMap<>(); @@ -34,9 +31,8 @@ public List getRecipeWrappers() { } @Override - public void onReload() { - this.burningRecipes.addAll(getBackupRecipes()); - getScriptedRecipes().forEach(this.burningRecipes::remove); + public Collection getRecipes() { + return this.burningRecipes; } @Override @@ -45,19 +41,6 @@ public void afterScriptLoad() { this.burningRecipes.sort(Comparator.comparingInt(BurningRecipe::getTicks)); } - public void add(BurningRecipe burningRecipe) { - this.burningRecipes.add(burningRecipe); - addScripted(burningRecipe); - } - - public boolean remove(BurningRecipe burningRecipe) { - if (this.burningRecipes.remove(burningRecipe)) { - addBackup(burningRecipe); - return true; - } - return false; - } - public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java index c933057fe..4fc31e8ef 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/Explosion.java @@ -7,6 +7,7 @@ import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.ExplosionRecipeCategory; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; import groovy.lang.Closure; @@ -17,10 +18,11 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -public class Explosion extends VirtualizedRegistry { +public class Explosion extends StandardListRegistry { private final List explosionRecipes = new ArrayList<>(); @@ -31,22 +33,8 @@ public List getRecipeWrappers() { } @Override - public void onReload() { - this.explosionRecipes.addAll(getBackupRecipes()); - getScriptedRecipes().forEach(this.explosionRecipes::remove); - } - - public void add(ExplosionRecipe explosionRecipe) { - this.explosionRecipes.add(explosionRecipe); - addScripted(explosionRecipe); - } - - public boolean remove(ExplosionRecipe explosionRecipe) { - if (this.explosionRecipes.remove(explosionRecipe)) { - addBackup(explosionRecipe); - return true; - } - return false; + public Collection getRecipes() { + return this.explosionRecipes; } public RecipeBuilder recipeBuilder() { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java index 57d447070..256a7f0be 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/inworldcrafting/PistonPush.java @@ -6,7 +6,7 @@ import com.cleanroommc.groovyscript.compat.inworldcrafting.jei.PistonPushRecipeCategory; import com.cleanroommc.groovyscript.compat.vanilla.VanillaModule; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; import groovy.lang.Closure; import net.minecraft.block.state.IBlockState; @@ -17,11 +17,12 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.function.Consumer; import java.util.stream.Collectors; -public class PistonPush extends VirtualizedRegistry { +public class PistonPush extends StandardListRegistry { private final List pistonPushRecipes = new ArrayList<>(); @@ -32,22 +33,8 @@ public List getRecipeWrappers() { } @Override - public void onReload() { - this.pistonPushRecipes.addAll(getBackupRecipes()); - getScriptedRecipes().forEach(this.pistonPushRecipes::remove); - } - - public void add(PistonPushRecipe pistonPushRecipe) { - this.pistonPushRecipes.add(pistonPushRecipe); - addScripted(pistonPushRecipe); - } - - public boolean remove(PistonPushRecipe pistonPushRecipe) { - if (this.pistonPushRecipes.remove(pistonPushRecipe)) { - addBackup(pistonPushRecipe); - return true; - } - return false; + public Collection getRecipes() { + return this.pistonPushRecipes; } public RecipeBuilder recipeBuilder() { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java index 86a25d56b..fd8ce3168 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/AtomicReconstructor.java @@ -1,22 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class AtomicReconstructor extends VirtualizedRegistry { +public class AtomicReconstructor extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).energyUse(1000)"), @@ -28,10 +28,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES::remove); - ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES; } public LensConversionRecipe add(IIngredient input, ItemStack output, int energy, Lens type) { @@ -43,22 +41,9 @@ public LensConversionRecipe add(IIngredient input, ItemStack output, int energy, .register(); } - public void add(LensConversionRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(recipe); - } - - public boolean remove(LensConversionRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.remove(recipe); - return true; - } - @MethodDescription(description = "groovyscript.wiki.removeByOre", example = @Example("item('minecraft:diamond')")) public boolean removeByInput(IIngredient input) { - return ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input)); if (found) { addBackup(recipe); @@ -69,7 +54,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('actuallyadditions:block_crystal')")) public boolean removeByOutput(ItemStack output) { - return ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (matches) { addBackup(recipe); @@ -78,18 +63,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.forEach(this::addBackup); - ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java index cf1a71d57..b932879af 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/BallOfFur.java @@ -1,19 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class BallOfFur extends VirtualizedRegistry { +public class BallOfFur extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".output(item('minecraft:clay') * 32).weight(15)")) public RecipeBuilder recipeBuilder() { @@ -21,10 +21,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS::remove); - ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS; } public BallOfFurReturn add(ItemStack drop, int chance) { @@ -33,22 +31,9 @@ public BallOfFurReturn add(ItemStack drop, int chance) { return recipe; } - public void add(BallOfFurReturn recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.add(recipe); - } - - public boolean remove(BallOfFurReturn recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:feather')")) public boolean removeByOutput(ItemStack output) { - return ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = ItemStack.areItemStacksEqual(recipe.returnItem, output); if (found) { addBackup(recipe); @@ -57,18 +42,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.forEach(this::addBackup); - ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.BALL_OF_FUR_RETURN_ITEMS) - .setRemover(this::remove); - } - @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java index b93891fac..117af7992 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Compost.java @@ -1,14 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe; import net.minecraft.block.Block; @@ -17,8 +15,10 @@ import net.minecraft.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Compost extends VirtualizedRegistry { +public class Compost extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).inputDisplay(blockstate('minecraft:clay')).outputDisplay(blockstate('minecraft:diamond_block'))")) public RecipeBuilder recipeBuilder() { @@ -26,10 +26,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.COMPOST_RECIPES::remove); - ActuallyAdditionsAPI.COMPOST_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.COMPOST_RECIPES; } public CompostRecipe add(Ingredient input, Block inputDisplay, ItemStack output, Block outputDisplay) { @@ -42,22 +40,9 @@ public CompostRecipe add(Ingredient input, IBlockState inputDisplay, ItemStack o return recipe; } - public void add(CompostRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.COMPOST_RECIPES.add(recipe); - } - - public boolean remove(CompostRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.COMPOST_RECIPES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('actuallyadditions:item_canola_seed')")) public boolean removeByInput(IIngredient input) { - return ActuallyAdditionsAPI.COMPOST_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input)); if (found) { addBackup(recipe); @@ -68,7 +53,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('actuallyadditions:item_fertilizer')")) public boolean removeByOutput(ItemStack output) { - return ActuallyAdditionsAPI.COMPOST_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (matches) { addBackup(recipe); @@ -77,18 +62,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.COMPOST_RECIPES.forEach(this::addBackup); - ActuallyAdditionsAPI.COMPOST_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.COMPOST_RECIPES) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java index af4f977f1..077991f70 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Crusher.java @@ -1,22 +1,22 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Crusher extends VirtualizedRegistry { +public class Crusher extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:diamond')).chance(100)"), @@ -27,10 +27,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.CRUSHER_RECIPES::remove); - ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.CRUSHER_RECIPES; } public CrusherRecipe add(Ingredient input, ItemStack output) { @@ -43,22 +41,9 @@ public CrusherRecipe add(Ingredient input, ItemStack output, ItemStack secondary return recipe; } - public void add(CrusherRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.CRUSHER_RECIPES.add(recipe); - } - - public boolean remove(CrusherRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.CRUSHER_RECIPES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:bone')")) public boolean removeByInput(IIngredient input) { - return ActuallyAdditionsAPI.CRUSHER_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input)); if (found) { addBackup(recipe); @@ -69,7 +54,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:sugar')")) public boolean removeByOutput(ItemStack output) { - return ActuallyAdditionsAPI.CRUSHER_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutputOne(), output); if (matches) { addBackup(recipe); @@ -78,18 +63,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.CRUSHER_RECIPES.forEach(this::addBackup); - ActuallyAdditionsAPI.CRUSHER_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.CRUSHER_RECIPES) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java index 4926f94ef..f3b3fcc3f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/Empowerer.java @@ -1,14 +1,12 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; import net.minecraft.item.ItemStack; @@ -16,9 +14,10 @@ import org.jetbrains.annotations.Nullable; import java.awt.*; +import java.util.Collection; @RegistryDescription -public class Empowerer extends VirtualizedRegistry { +public class Empowerer extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".mainInput(item('minecraft:clay')).input(item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay'),item('minecraft:clay')).output(item('minecraft:diamond')).time(50).energy(1000).red(0.5).green(0.3).blue(0.2)"), @@ -31,10 +30,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.EMPOWERER_RECIPES::remove); - ActuallyAdditionsAPI.EMPOWERER_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.EMPOWERER_RECIPES; } public EmpowererRecipe add(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) { @@ -43,22 +40,9 @@ public EmpowererRecipe add(Ingredient input, ItemStack output, Ingredient modifi return recipe; } - public void add(EmpowererRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.EMPOWERER_RECIPES.add(recipe); - } - - public boolean remove(EmpowererRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.EMPOWERER_RECIPES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('actuallyadditions:item_crystal')")) public boolean removeByInput(IIngredient input) { - return ActuallyAdditionsAPI.EMPOWERER_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input)); if (found) { addBackup(recipe); @@ -69,7 +53,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('actuallyadditions:item_misc:24')")) public boolean removeByOutput(ItemStack output) { - return ActuallyAdditionsAPI.EMPOWERER_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (matches) { addBackup(recipe); @@ -78,19 +62,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.EMPOWERER_RECIPES.forEach(this::addBackup); - ActuallyAdditionsAPI.EMPOWERER_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.EMPOWERER_RECIPES) - .setRemover(this::remove); - } - - @Property(property = "input", valid = {@Comp(value = "4", type = Comp.Type.GTE), @Comp(value = "5", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java index e6fb53896..9259956dc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/NetherMiningLens.java @@ -1,19 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class NetherMiningLens extends VirtualizedRegistry { +public class NetherMiningLens extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".ore(ore('blockDiamond')).weight(100)"), @@ -24,10 +24,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.NETHERRACK_ORES::remove); - ActuallyAdditionsAPI.NETHERRACK_ORES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.NETHERRACK_ORES; } public WeightedOre add(String oreName, int weight) { @@ -36,19 +34,6 @@ public WeightedOre add(String oreName, int weight) { return recipe; } - public void add(WeightedOre recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.NETHERRACK_ORES.add(recipe); - } - - public boolean remove(WeightedOre recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.NETHERRACK_ORES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("ore('oreQuartz')")) public boolean removeByOre(OreDictIngredient ore) { return this.removeByOre(ore.getOreDict()); @@ -56,7 +41,7 @@ public boolean removeByOre(OreDictIngredient ore) { @MethodDescription(example = @Example("'oreQuartz'")) public boolean removeByOre(String oreName) { - return ActuallyAdditionsAPI.NETHERRACK_ORES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = oreName.equals(recipe.name); if (found) { addBackup(recipe); @@ -65,19 +50,6 @@ public boolean removeByOre(String oreName) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.NETHERRACK_ORES.forEach(this::addBackup); - ActuallyAdditionsAPI.NETHERRACK_ORES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.NETHERRACK_ORES) - .setRemover(this::remove); - } - - public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.NOT, value = "null")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java index c16236a90..75930b606 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/OilGen.java @@ -1,20 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class OilGen extends VirtualizedRegistry { +public class OilGen extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".fluidInput(fluid('water')).amount(1000).time(50)"), @@ -25,10 +25,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES::remove); - ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES; } public OilGenRecipe add(Fluid input, int amount, int time) { @@ -41,19 +39,6 @@ public OilGenRecipe add(String input, int amount, int time) { return recipe; } - public void add(OilGenRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.add(recipe); - } - - public boolean remove(OilGenRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("fluid('canolaoil')")) public boolean removeByInput(FluidStack fluid) { return this.removeByInput(fluid.getFluid()); @@ -66,7 +51,7 @@ public boolean removeByInput(Fluid fluid) { @MethodDescription(example = @Example("'refinedcanolaoil'")) public boolean removeByInput(String fluid) { - return ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = fluid.equals(recipe.fluidName); if (found) { addBackup(recipe); @@ -75,19 +60,6 @@ public boolean removeByInput(String fluid) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.forEach(this::addBackup); - ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.OIL_GENERATOR_RECIPES) - .setRemover(this::remove); - } - - @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java index 654a3a66e..7c9a3d2a0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/StoneMiningLens.java @@ -1,19 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.WeightedOre; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class StoneMiningLens extends VirtualizedRegistry { +public class StoneMiningLens extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".ore(ore('blockDiamond')).weight(100)"), @@ -24,10 +24,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.STONE_ORES::remove); - ActuallyAdditionsAPI.STONE_ORES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.STONE_ORES; } public WeightedOre add(String oreName, int weight) { @@ -36,19 +34,6 @@ public WeightedOre add(String oreName, int weight) { return recipe; } - public void add(WeightedOre recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.STONE_ORES.add(recipe); - } - - public boolean remove(WeightedOre recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.STONE_ORES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("ore('oreCoal')")) public boolean removeByOre(OreDictIngredient ore) { return this.removeByOre(ore.getOreDict()); @@ -56,7 +41,7 @@ public boolean removeByOre(OreDictIngredient ore) { @MethodDescription(example = @Example("'oreLapis'")) public boolean removeByOre(String oreName) { - return ActuallyAdditionsAPI.STONE_ORES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean found = oreName.equals(recipe.name); if (found) { addBackup(recipe); @@ -65,19 +50,6 @@ public boolean removeByOre(String oreName) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.STONE_ORES.forEach(this::addBackup); - ActuallyAdditionsAPI.STONE_ORES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.STONE_ORES) - .setRemover(this::remove); - } - - public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(type = Comp.Type.NOT, value = "null")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java index 306fb6f61..c8efaae2e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/actuallyadditions/TreasureChest.java @@ -1,19 +1,19 @@ package com.cleanroommc.groovyscript.compat.mods.actuallyadditions; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI; import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class TreasureChest extends VirtualizedRegistry { +public class TreasureChest extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".output(item('minecraft:clay')).weight(50).min(16).max(32)")) public RecipeBuilder recipeBuilder() { @@ -21,10 +21,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(ActuallyAdditionsAPI.TREASURE_CHEST_LOOT::remove); - ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ActuallyAdditionsAPI.TREASURE_CHEST_LOOT; } public TreasureChestLoot add(ItemStack returnItem, int chance, int minAmount, int maxAmount) { @@ -33,22 +31,9 @@ public TreasureChestLoot add(ItemStack returnItem, int chance, int minAmount, in return recipe; } - public void add(TreasureChestLoot recipe) { - if (recipe == null) return; - addScripted(recipe); - ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.add(recipe); - } - - public boolean remove(TreasureChestLoot recipe) { - if (recipe == null) return false; - addBackup(recipe); - ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:iron_ingot')")) public boolean removeByOutput(ItemStack output) { - return ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.returnItem, output); if (matches) { addBackup(recipe); @@ -57,19 +42,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.forEach(this::addBackup); - ActuallyAdditionsAPI.TREASURE_CHEST_LOOT.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ActuallyAdditionsAPI.TREASURE_CHEST_LOOT) - .setRemover(this::remove); - } - - @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedrocketry/BaseRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedrocketry/BaseRegistry.java index c6729461e..6c28931a5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedrocketry/BaseRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/advancedrocketry/BaseRegistry.java @@ -1,11 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.advancedrocketry; import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.api.documentation.annotations.Comp; +import com.cleanroommc.groovyscript.api.documentation.annotations.Property; +import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderMethodDescription; +import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderRegistrationMethod; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; @@ -15,15 +17,15 @@ import javax.annotation.Nonnull; import java.util.*; -import java.util.stream.Collectors; -public abstract class BaseRegistry extends VirtualizedRegistry { +public abstract class BaseRegistry extends StandardListRegistry { protected abstract Class getMachineClass(); + @Override @Nonnull @SuppressWarnings("unchecked") - protected List getRecipeList() { + public Collection getRecipes() { Class clazz = getMachineClass(); RecipesMachine registry = RecipesMachine.getInstance(); List recipes = registry.getRecipes(clazz); @@ -36,28 +38,8 @@ protected List getRecipeList() { return recipes; } - @Override - public void onReload() { - List recipes = getRecipeList(); - recipes.addAll(restoreFromBackup()); - recipes.removeAll(removeScripted()); - } - - public void addRecipe(IRecipe r) { - getRecipeList().add(r); - addScripted(r); - } - - public boolean removeRecipe(IRecipe r) { - if (getRecipeList().remove(r)) { - addBackup(r); - return true; - } - return false; - } - public boolean removeByFluidInput(FluidStack fluidStack) { - return getRecipeList().removeIf(r -> { + return getRecipes().removeIf(r -> { List inputFluid = r.getFluidIngredients(); if (inputFluid.stream().anyMatch(fluidIn -> fluidIn.isFluidEqual(fluidStack))) { addBackup(r); @@ -71,7 +53,7 @@ public boolean removeByInput(IIngredient inputItem) { if (inputItem instanceof FluidStack) { return removeByFluidInput((FluidStack) inputItem); } - return getRecipeList().removeIf(r -> { + return getRecipes().removeIf(r -> { List> input = r.getIngredients(); if (input.stream().anyMatch(itemStacks -> itemStacks.stream().anyMatch(inputItem))) { addBackup(r); @@ -82,7 +64,7 @@ public boolean removeByInput(IIngredient inputItem) { } public boolean removeByFluidOutput(FluidStack fluidStack) { - return getRecipeList().removeIf(r -> { + return getRecipes().removeIf(r -> { List outputFluid = r.getFluidOutputs(); if (outputFluid.stream().anyMatch(fluidOut -> fluidOut.isFluidEqual(fluidStack))) { addBackup(r); @@ -96,7 +78,7 @@ public boolean removeByOutput(IIngredient outputItem) { if (outputItem instanceof FluidStack) { return removeByFluidInput((FluidStack) outputItem); } - return getRecipeList().removeIf(r -> { + return getRecipes().removeIf(r -> { List output = r.getOutput(); if (output.stream().anyMatch(outputItem)) { addBackup(r); @@ -106,20 +88,6 @@ public boolean removeByOutput(IIngredient outputItem) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - List recipes = getRecipeList(); - recipes.forEach(this::addBackup); - recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - List recipes = getRecipeList(); - return new SimpleObjectStream<>(recipes) - .setRemover(this::removeRecipe); - } - public abstract static class RecipeBuilder extends AbstractRecipeBuilder { // still have to override the Validate method + add getRegistry method @@ -186,7 +154,7 @@ protected int getHatchesNeeded() { RecipesMachine.Recipe r = new RecipesMachine.Recipe(outputs, inputs, fluidOutputs, fluidInput, time, power, oredicts); if (outputSize > 0) r.setMaxOutputSize(outputSize); - getRegistry().addRecipe(r); + getRegistry().add(r); return r; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java index 35d100571..618716fb3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Atomizer.java @@ -7,20 +7,20 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Atomizer extends VirtualizedRegistry { +public class Atomizer extends StandardListRegistry { @Override - public void onReload() { - removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> r == recipe)); - ModRecipes.INSTANCE.getAtomizerRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ModRecipes.INSTANCE.getAtomizerRecipes(); } @RecipeBuilderDescription(example = { @@ -36,25 +36,9 @@ public AtomizerRecipe add(FluidStack input, ItemStack output) { return recipeBuilder().fluidInput(input).output(output).register(); } - public AtomizerRecipe add(AtomizerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ModRecipes.INSTANCE.getAtomizerRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(AtomizerRecipe recipe) { - if (ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example(value = "item('alchemistry:compound:7')", commented = true)) public boolean removeByOutput(IIngredient output) { - return ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -65,7 +49,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("fluid('water')")) public boolean removeByInput(FluidStack input) { - return ModRecipes.INSTANCE.getAtomizerRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().isFluidEqual(input)) { addBackup(r); return true; @@ -74,17 +58,6 @@ public boolean removeByInput(FluidStack input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.INSTANCE.getAtomizerRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.INSTANCE.getAtomizerRecipes().forEach(this::addBackup); - ModRecipes.INSTANCE.getAtomizerRecipes().clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java index cfa72919c..7f1521c66 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Combiner.java @@ -7,27 +7,26 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Combiner extends VirtualizedRegistry { +public class Combiner extends StandardListRegistry { public Combiner() { super(Alias.generateOfClass(Combiner.class).andGenerate("ChemicalCombiner")); } @Override - public void onReload() { - removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getCombinerRecipes().removeIf(r -> r == recipe)); - ModRecipes.INSTANCE.getCombinerRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ModRecipes.INSTANCE.getCombinerRecipes(); } @RecipeBuilderDescription(example = { @@ -38,25 +37,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - public CombinerRecipe add(CombinerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ModRecipes.INSTANCE.getCombinerRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(CombinerRecipe recipe) { - if (ModRecipes.INSTANCE.getCombinerRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:glowstone')")) public boolean removeByOutput(IIngredient output) { - return ModRecipes.INSTANCE.getCombinerRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -67,7 +50,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("element('carbon')")) public boolean removeByInput(IIngredient input) { - return ModRecipes.INSTANCE.getCombinerRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getInputs()) { if (input.test(itemstack)) { addBackup(r); @@ -78,17 +61,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.INSTANCE.getCombinerRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.INSTANCE.getCombinerRecipes().forEach(this::addBackup); - ModRecipes.INSTANCE.getCombinerRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "9")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java index fe29545dd..f244d82b8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Dissolver.java @@ -6,9 +6,8 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; @@ -19,16 +18,15 @@ import java.util.stream.Collectors; @RegistryDescription -public class Dissolver extends VirtualizedRegistry { +public class Dissolver extends StandardListRegistry { public Dissolver() { super(Alias.generateOfClass(Dissolver.class).andGenerate("ChemicalDissolver")); } @Override - public void onReload() { - removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getDissolverRecipes().removeIf(r -> r == recipe)); - ModRecipes.INSTANCE.getDissolverRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ModRecipes.INSTANCE.getDissolverRecipes(); } @RecipeBuilderDescription(example = { @@ -39,25 +37,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - public DissolverRecipe add(DissolverRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ModRecipes.INSTANCE.getDissolverRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(DissolverRecipe recipe) { - if (ModRecipes.INSTANCE.getDissolverRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('alchemistry:compound:1')")) public boolean removeByInput(IIngredient input) { - return ModRecipes.INSTANCE.getDissolverRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getInputs()) { if (input.test(itemstack)) { addBackup(r); @@ -68,17 +50,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.INSTANCE.getDissolverRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.INSTANCE.getDissolverRecipes().forEach(this::addBackup); - ModRecipes.INSTANCE.getDissolverRecipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java index 66e038961..ed863e2b0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Electrolyzer.java @@ -6,9 +6,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import it.unimi.dsi.fastutil.ints.IntArrayList; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -18,12 +17,11 @@ import java.util.Collection; @RegistryDescription -public class Electrolyzer extends VirtualizedRegistry { +public class Electrolyzer extends StandardListRegistry { @Override - public void onReload() { - removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getElectrolyzerRecipes().removeIf(r -> r == recipe)); - ModRecipes.INSTANCE.getElectrolyzerRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ModRecipes.INSTANCE.getElectrolyzerRecipes(); } @RecipeBuilderDescription(example = { @@ -34,25 +32,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - public ElectrolyzerRecipe add(ElectrolyzerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ModRecipes.INSTANCE.getElectrolyzerRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(ElectrolyzerRecipe recipe) { - if (ModRecipes.INSTANCE.getElectrolyzerRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("element('chlorine')")) public boolean removeByOutput(IIngredient output) { - return ModRecipes.INSTANCE.getElectrolyzerRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -65,7 +47,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example(value = "fluid('water')", commented = true)) public boolean removeByInput(FluidStack input) { - return ModRecipes.INSTANCE.getElectrolyzerRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().isFluidEqual(input)) { addBackup(r); return true; @@ -87,17 +69,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.INSTANCE.getElectrolyzerRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.INSTANCE.getElectrolyzerRecipes().forEach(this::addBackup); - ModRecipes.INSTANCE.getElectrolyzerRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "4", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java index 70f8f8611..3f781d034 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Evaporator.java @@ -6,20 +6,20 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Evaporator extends VirtualizedRegistry { +public class Evaporator extends StandardListRegistry { @Override - public void onReload() { - removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getEvaporatorRecipes().removeIf(r -> r == recipe)); - ModRecipes.INSTANCE.getEvaporatorRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ModRecipes.INSTANCE.getEvaporatorRecipes(); } @RecipeBuilderDescription(example = { @@ -35,25 +35,9 @@ public EvaporatorRecipe add(FluidStack input, ItemStack output) { return recipeBuilder().fluidInput(input).output(output).register(); } - public EvaporatorRecipe add(EvaporatorRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ModRecipes.INSTANCE.getEvaporatorRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(EvaporatorRecipe recipe) { - if (ModRecipes.INSTANCE.getEvaporatorRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('alchemistry:mineral_salt')")) public boolean removeByOutput(IIngredient output) { - return ModRecipes.INSTANCE.getEvaporatorRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -64,7 +48,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("fluid('lava')")) public boolean removeByInput(FluidStack input) { - return ModRecipes.INSTANCE.getEvaporatorRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().isFluidEqual(input)) { addBackup(r); return true; @@ -73,17 +57,6 @@ public boolean removeByInput(FluidStack input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.INSTANCE.getEvaporatorRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.INSTANCE.getEvaporatorRecipes().forEach(this::addBackup); - ModRecipes.INSTANCE.getEvaporatorRecipes().clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java index 6d3e95951..8135961ed 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/alchemistry/Liquifier.java @@ -6,20 +6,20 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Liquifier extends VirtualizedRegistry { +public class Liquifier extends StandardListRegistry { @Override - public void onReload() { - removeScripted().forEach(recipe -> ModRecipes.INSTANCE.getLiquifierRecipes().removeIf(r -> r == recipe)); - ModRecipes.INSTANCE.getLiquifierRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ModRecipes.INSTANCE.getLiquifierRecipes(); } @RecipeBuilderDescription(example = { @@ -35,25 +35,9 @@ public LiquifierRecipe add(IIngredient input, FluidStack output) { return recipeBuilder().input(input).fluidOutput(output).register(); } - public LiquifierRecipe add(LiquifierRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ModRecipes.INSTANCE.getLiquifierRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(LiquifierRecipe recipe) { - if (ModRecipes.INSTANCE.getLiquifierRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example(value = "fluid('water')", commented = true)) public boolean removeByOutput(FluidStack output) { - return ModRecipes.INSTANCE.getLiquifierRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().isFluidEqual(output)) { addBackup(r); return true; @@ -64,7 +48,7 @@ public boolean removeByOutput(FluidStack output) { @MethodDescription(example = @Example("element('water')")) public boolean removeByInput(IIngredient input) { - return ModRecipes.INSTANCE.getLiquifierRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (input.test(r.getInput())) { addBackup(r); return true; @@ -73,17 +57,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.INSTANCE.getLiquifierRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.INSTANCE.getLiquifierRecipes().forEach(this::addBackup); - ModRecipes.INSTANCE.getLiquifierRecipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java index b110fe28d..5d18a132a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/ChaliceInteraction.java @@ -1,27 +1,25 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.astralsorcery.LiquidInteractionAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import hellfirepvp.astralsorcery.common.base.LiquidInteraction; import it.unimi.dsi.fastutil.floats.FloatArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; -import java.util.List; +import java.util.Collection; @RegistryDescription -public class ChaliceInteraction extends VirtualizedRegistry { +public class ChaliceInteraction extends StandardListRegistry { - private static List getRegistry() { + @Override + public Collection getRecipes() { if (LiquidInteractionAccessor.getRegisteredInteractions() == null) { throw new IllegalStateException("Astral Sorcery Chalice Interaction getRegisteredInteractions() is not yet initialized!"); } @@ -33,34 +31,18 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(getRegistry()::remove); - restoreFromBackup().forEach(getRegistry()::add); - } - - private void add(LiquidInteraction recipe) { - addScripted(recipe); - getRegistry().add(recipe); - } @MethodDescription(type = MethodDescription.Type.ADDITION) public LiquidInteraction add(int probability, FluidStack component1, FluidStack component2, LiquidInteraction.FluidInteractionAction action) { LiquidInteraction recipe = new LiquidInteraction(probability, component1, component2, action); addScripted(recipe); - getRegistry().add(recipe); + getRecipes().add(recipe); return recipe; } - private boolean remove(LiquidInteraction recipe) { - return getRegistry().removeIf(rec -> rec.equals(recipe)); - } - @MethodDescription public void removeByInput(Fluid fluid1, Fluid fluid2) { - getRegistry().removeIf(rec -> { + getRecipes().removeIf(rec -> { if ((rec.getComponent1().getFluid().equals(fluid1) && rec.getComponent2().getFluid().equals(fluid2)) || (rec.getComponent1().getFluid().equals(fluid2) && rec.getComponent2().getFluid().equals(fluid1))) { addBackup(rec); @@ -77,7 +59,7 @@ public void removeByInput(FluidStack fluid1, FluidStack fluid2) { @MethodDescription public void removeByInput(Fluid fluid) { - getRegistry().removeIf(rec -> { + getRecipes().removeIf(rec -> { if ((rec.getComponent1().getFluid().equals(fluid) || rec.getComponent2().getFluid().equals(fluid))) { addBackup(rec); return true; @@ -93,7 +75,7 @@ public void removeByInput(FluidStack fluid) { @MethodDescription(example = @Example("item('minecraft:ice')")) public void removeByOutput(ItemStack output) { - getRegistry().removeIf(rec -> { + getRecipes().removeIf(rec -> { if (((LiquidInteractionAccessor) rec).getFluidInteractionAction().getOutputForMatching().isItemEqual(output)) { addBackup(rec); return true; @@ -102,18 +84,6 @@ public void removeByOutput(ItemStack output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(getRegistry()) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - getRegistry().forEach(this::addBackup); - getRegistry().clear(); - } - @Property(property = "fluidInput", valid = @Comp("2")) @Property(property = "output", valid = @Comp(value = "0", type = Comp.Type.GTE)) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java index bc1214710..874d3d95e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Fountain.java @@ -1,22 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.astralsorcery.FluidRarityEntryAccessor; import com.cleanroommc.groovyscript.core.mixin.astralsorcery.FluidRarityRegistryAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.IRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import hellfirepvp.astralsorcery.common.base.FluidRarityRegistry; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import org.apache.logging.log4j.Level; -import org.jetbrains.annotations.ApiStatus; + +import java.util.Collection; @RegistryDescription -public class Fountain extends VirtualizedRegistry { +public class Fountain extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".fluid(fluid('astralsorcery.liquidstarlight')).rarity(10000000).minimumAmount(4000000).variance(1000000)")) public FountainChanceHelper chanceHelper() { @@ -24,54 +23,39 @@ public FountainChanceHelper chanceHelper() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()::remove); - restoreFromBackup().forEach(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()::add); + public Collection getRecipes() { + return ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList(); } @Override public void afterScriptLoad() { // If the rarity list is empty, generating new chunks will cause a NPE. To prevent this, we add a "water" entry that will always have 0mb inside, // which causes it to be marked as empty, and thus not be interactable. - if (((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().isEmpty()) { + if (getRecipes().isEmpty()) { FluidRarityRegistry.FluidRarityEntry errorBlocker = FluidRarityEntryAccessor.createFluidRarityEntry("water", 1, 0, 0); - ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().add(errorBlocker); + getRecipes().add(errorBlocker); addScripted(errorBlocker); } } @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.add0", type = MethodDescription.Type.ADDITION) - public void add(FluidRarityRegistry.FluidRarityEntry entry) { - addScripted(entry); - ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().add(entry); - } - - @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.add1", type = MethodDescription.Type.ADDITION) public void add(FluidStack fluid, int rarity, int guaranteedAmt, int addRand) { this.add(fluid.getFluid(), rarity, guaranteedAmt, addRand); } - @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.add2", type = MethodDescription.Type.ADDITION) + @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.add1", type = MethodDescription.Type.ADDITION) public void add(Fluid fluid, int rarity, int guaranteedAmt, int addRand) { this.add(FluidRarityEntryAccessor.createFluidRarityEntry(fluid, rarity, guaranteedAmt, addRand)); } - @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove0") - public boolean remove(FluidRarityRegistry.FluidRarityEntry entry) { - addBackup(entry); - return ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().removeIf(fluidRarityEntry -> fluidRarityEntry == entry); - } - - @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove1",example = @Example("fluid('lava')")) + @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove0", example = @Example("fluid('lava')")) public void remove(FluidStack entry) { this.remove(entry.getFluid()); } - @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove2") + @MethodDescription(description = "groovyscript.wiki.astralsorcery.fountain.remove1") public void remove(Fluid entry) { - ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().removeIf(fluidRarityEntry -> { + getRecipes().removeIf(fluidRarityEntry -> { if (fluidRarityEntry.fluid != null && fluidRarityEntry.fluid.equals(entry)) { addBackup(fluidRarityEntry); return true; @@ -80,18 +64,6 @@ public void remove(Fluid entry) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList()) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().forEach(this::addBackup); - ((FluidRarityRegistryAccessor) FluidRarityRegistry.INSTANCE).getRarityList().clear(); - } - public static class FountainChanceHelper implements IRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java index 15da6e41b..b9aab88cb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/Grindstone.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import hellfirepvp.astralsorcery.common.crafting.ItemHandle; import hellfirepvp.astralsorcery.common.crafting.grindstone.GrindstoneRecipe; import hellfirepvp.astralsorcery.common.crafting.grindstone.GrindstoneRecipeRegistry; import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; + +import java.util.Collection; @RegistryDescription -public class Grindstone extends VirtualizedRegistry { +public class Grindstone extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(ore('blockDiamond')).output(item('minecraft:clay')).weight(1).secondaryChance(1.0F)"), @@ -26,16 +25,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(r -> GrindstoneRecipeRegistry.recipes.removeIf(recipe -> r == recipe)); - restoreFromBackup().forEach(GrindstoneRecipeRegistry::registerGrindstoneRecipe); - } - - private void add(GrindstoneRecipe recipe) { - addScripted(recipe); - GrindstoneRecipeRegistry.registerGrindstoneRecipe(recipe); + public Collection getRecipes() { + return GrindstoneRecipeRegistry.recipes; } @MethodDescription(description = "groovyscript.wiki.astralsorcery.grindstone.add0", type = MethodDescription.Type.ADDITION) @@ -50,14 +41,9 @@ public GrindstoneRecipe add(ItemHandle input, ItemStack output, int weight, floa return GrindstoneRecipeRegistry.registerGrindstoneRecipe(recipe); } - private boolean remove(GrindstoneRecipe recipe) { - addBackup(recipe); - return GrindstoneRecipeRegistry.recipes.remove(recipe); - } - @MethodDescription(example = @Example("item('minecraft:redstone_ore')")) public void removeByInput(ItemStack item) { - GrindstoneRecipeRegistry.recipes.removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (recipe.isValid() && recipe.matches(item)) { addBackup(recipe); return true; @@ -74,7 +60,7 @@ public void removeByOutput(OreDictIngredient ore) { @MethodDescription public void removeByOutput(ItemStack item) { - GrindstoneRecipeRegistry.recipes.removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (recipe.isValid() && recipe.getOutputForMatching().isItemEqual(item)) { addBackup(recipe); return true; @@ -83,18 +69,6 @@ public void removeByOutput(ItemStack item) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GrindstoneRecipeRegistry.recipes) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - GrindstoneRecipeRegistry.recipes.forEach(this::addBackup); - GrindstoneRecipeRegistry.recipes.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java index af8fb0dc1..cf4484923 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/astralsorcery/LightTransmutation.java @@ -1,31 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.astralsorcery; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.astralsorcery.LightOreTransmutationsAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import hellfirepvp.astralsorcery.common.base.LightOreTransmutations; import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; import javax.annotation.Nonnull; -import java.util.List; +import java.util.Collection; @RegistryDescription -public class LightTransmutation extends VirtualizedRegistry { +public class LightTransmutation extends StandardListRegistry { - private static List getRegistry() { + @Override + public Collection getRecipes() { if (LightOreTransmutationsAccessor.getRegisteredTransmutations() == null) { throw new IllegalStateException("Astral Sorcery Light Transmutation getRegisteredTransmutations() is not yet initialized!"); } - return (List) LightOreTransmutationsAccessor.getRegisteredTransmutations(); + return LightOreTransmutationsAccessor.getRegisteredTransmutations(); } @RecipeBuilderDescription(example = { @@ -35,24 +33,11 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(r -> getRegistry().removeIf(recipe -> r == recipe)); - restoreFromBackup().forEach(r -> getRegistry().add(r)); - } - - private void add(LightOreTransmutations.Transmutation recipe) { - getRegistry().add(recipe); - addScripted(recipe); - } - public LightOreTransmutations.Transmutation add(Block input, IBlockState output, @Nonnull ItemStack inputDisplay, @Nonnull ItemStack outputDisplay, double cost) { LightOreTransmutations.Transmutation recipe = new LightOreTransmutations.Transmutation(input, output, inputDisplay, outputDisplay, cost); addScripted(recipe); - getRegistry().add(recipe); + getRecipes().add(recipe); return recipe; } @@ -60,17 +45,13 @@ public LightOreTransmutations.Transmutation add(IBlockState input, IBlockState o @Nonnull ItemStack inputDisplay, @Nonnull ItemStack outputDisplay, double cost) { LightOreTransmutations.Transmutation recipe = new LightOreTransmutations.Transmutation(input, output, inputDisplay, outputDisplay, cost); addScripted(recipe); - getRegistry().add(recipe); + getRecipes().add(recipe); return recipe; } - private boolean remove(LightOreTransmutations.Transmutation recipe) { - return getRegistry().removeIf(rec -> rec.equals(recipe)); - } - @MethodDescription(example = @Example("blockstate('minecraft:sandstone')")) public void removeByInput(IBlockState block) { - getRegistry().removeIf(rec -> { + getRecipes().removeIf(rec -> { if (rec.matchesInput(block)) { addBackup(rec); return true; @@ -86,7 +67,7 @@ public void removeByInput(Block block) { @MethodDescription(example = @Example("blockstate('minecraft:cake')")) public void removeByOutput(IBlockState block) { - getRegistry().removeIf(rec -> { + getRecipes().removeIf(rec -> { if (rec.matchesOutput(block)) { addBackup(rec); return true; @@ -100,18 +81,6 @@ public void removeByOutput(Block block) { removeByOutput(block.getDefaultState()); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(getRegistry()) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - getRegistry().forEach(this::addBackup); - getRegistry().clear(); - } - public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = {@Comp(value = "null", type = Comp.Type.NOT), @Comp(value = "input", type = Comp.Type.NOT)}) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java index 91a4fa617..936d33da0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/AnvilCrafting.java @@ -7,14 +7,15 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.Ingredient; +import java.util.Collection; + @RegistryDescription -public class AnvilCrafting extends VirtualizedRegistry { +public class AnvilCrafting extends StandardListRegistry { public AnvilCrafting() { super(Alias.generateOfClass(AnvilCrafting.class).andGenerate("SoulforgedSteelAnvil")); @@ -34,30 +35,13 @@ public AnvilRecipeBuilder.Shapeless shapelessBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> r == recipe)); - AnvilCraftingManager.ANVIL_CRAFTING.addAll(restoreFromBackup()); - } - - public IRecipe add(IRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - AnvilCraftingManager.ANVIL_CRAFTING.add(recipe); - } - return recipe; - } - - public boolean remove(IRecipe recipe) { - if (AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return AnvilCraftingManager.ANVIL_CRAFTING; } @MethodDescription(example = @Example("item('betterwithmods:steel_block')")) public boolean removeByOutput(IIngredient output) { - return AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getRecipeOutput())) { addBackup(r); return true; @@ -68,7 +52,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:redstone')")) public boolean removeByInput(IIngredient input) { - return AnvilCraftingManager.ANVIL_CRAFTING.removeIf(r -> { + return getRecipes().removeIf(r -> { for (Ingredient ingredient : r.getIngredients()) { for (ItemStack item : ingredient.getMatchingStacks()) { if (input.test(item)) { @@ -81,15 +65,4 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AnvilCraftingManager.ANVIL_CRAFTING).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - AnvilCraftingManager.ANVIL_CRAFTING.forEach(this::addBackup); - AnvilCraftingManager.ANVIL_CRAFTING.clear(); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java index 56f7f7621..9ec29ea7a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Cauldron.java @@ -6,17 +6,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.stream.Collectors; @RegistryDescription -public class Cauldron extends VirtualizedRegistry { +public class Cauldron extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), @@ -28,30 +28,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> BWRegistry.CAULDRON.getRecipes().removeIf(r -> r == recipe)); - BWRegistry.CAULDRON.getRecipes().addAll(restoreFromBackup()); - } - - public CookingPotRecipe add(CookingPotRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BWRegistry.CAULDRON.getRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(CookingPotRecipe recipe) { - if (BWRegistry.CAULDRON.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BWRegistry.CAULDRON.getRecipes(); } @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public boolean removeByOutput(IIngredient output) { - return BWRegistry.CAULDRON.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -64,7 +47,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public boolean removeByInput(IIngredient input) { - return BWRegistry.CAULDRON.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (Ingredient ingredient : r.getInputs()) { for (ItemStack item : ingredient.getMatchingStacks()) { if (input.test(item)) { @@ -77,17 +60,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BWRegistry.CAULDRON.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BWRegistry.CAULDRON.getRecipes().forEach(this::addBackup); - BWRegistry.CAULDRON.getRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}) @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java index 0c40d42b5..7a79a1e62 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Crucible.java @@ -6,19 +6,19 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraftforge.items.ItemHandlerHelper; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.stream.Collectors; @RegistryDescription -public class Crucible extends VirtualizedRegistry { +public class Crucible extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), @@ -30,30 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> BWRegistry.CRUCIBLE.getRecipes().removeIf(r -> r == recipe)); - BWRegistry.CRUCIBLE.getRecipes().addAll(restoreFromBackup()); - } - - public CookingPotRecipe add(CookingPotRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BWRegistry.CRUCIBLE.getRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(CookingPotRecipe recipe) { - if (BWRegistry.CRUCIBLE.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BWRegistry.CRUCIBLE.getRecipes(); } @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public boolean removeByOutput(ItemStack output) { - return BWRegistry.CRUCIBLE.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (ItemHandlerHelper.canItemStacksStack(itemstack, output)) { addBackup(r); @@ -66,7 +49,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public boolean removeByInput(ItemStack input) { - return BWRegistry.CRUCIBLE.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (Ingredient ingredient : r.getInputs()) { if (ingredient.test(input)) { addBackup(r); @@ -82,17 +65,6 @@ public boolean removeByInput(IIngredient input) { return removeByInput(IngredientHelper.toItemStack(input)); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BWRegistry.CRUCIBLE.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BWRegistry.CRUCIBLE.getRecipes().forEach(this::addBackup); - BWRegistry.CRUCIBLE.getRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}) @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java index ee4c17748..51bf360d1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Heat.java @@ -2,39 +2,27 @@ import betterwithmods.common.registry.block.recipe.BlockIngredient; import betterwithmods.common.registry.heat.BWMHeatRegistry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Admonition; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.betterwithmods.BWMHeatRegistryAccessor; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; +import java.util.Collection; import java.util.List; @RegistryDescription( + category = RegistryDescription.Category.ENTRIES, admonition = @Admonition("groovyscript.wiki.betterwithmods.heat.note0") ) -public class Heat extends VirtualizedRegistry { +public class Heat extends StandardListRegistry { @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(recipe -> BWMHeatRegistryAccessor.getHEAT_SOURCES().removeIf(r -> r == recipe)); - BWMHeatRegistryAccessor.getHEAT_SOURCES().addAll(restoreFromBackup()); - } - - public void add(BWMHeatRegistry.HeatSource heatSource) { - BWMHeatRegistryAccessor.getHEAT_SOURCES().add(heatSource); - addScripted(heatSource); - } - - public boolean remove(BWMHeatRegistry.HeatSource heatSource) { - if (!BWMHeatRegistryAccessor.getHEAT_SOURCES().remove(heatSource)) return false; - addBackup(heatSource); - return true; + public Collection getRecipes() { + return BWMHeatRegistryAccessor.getHEAT_SOURCES(); } @MethodDescription(type = MethodDescription.Type.VALUE) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java index 7b06ae6ab..48bf894ef 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Hopper.java @@ -5,17 +5,16 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.ItemStackList; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import java.util.Collection; @RegistryDescription -public class Hopper extends VirtualizedRegistry { +public class Hopper extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".name('betterwithmods:iron_bar').input(ore('sand')).output(item('minecraft:clay')).inWorldItemOutput(item('minecraft:gold_ingot'))"), @@ -26,30 +25,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> HopperInteractions.RECIPES.removeIf(r -> r == recipe)); - HopperInteractions.RECIPES.addAll(restoreFromBackup()); - } - - public HopperInteractions.HopperRecipe add(HopperInteractions.HopperRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - HopperInteractions.RECIPES.add(recipe); - } - return recipe; - } - - public boolean remove(HopperInteractions.HopperRecipe recipe) { - if (HopperInteractions.RECIPES.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return HopperInteractions.RECIPES; } @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public boolean removeByOutput(IIngredient output) { - return HopperInteractions.RECIPES.removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -62,7 +44,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:gunpowder')")) public boolean removeByInput(IIngredient input) { - return HopperInteractions.RECIPES.removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack item : r.getInputs().getMatchingStacks()) { if (input.test(item)) { addBackup(r); @@ -73,17 +55,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(HopperInteractions.RECIPES).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - HopperInteractions.RECIPES.forEach(this::addBackup); - HopperInteractions.RECIPES.clear(); - } - @Property(property = "name", value = "groovyscript.wiki.betterwithmods.hopper.name.value", valid = @Comp(value = "null", type = Comp.Type.NOT)) @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "2", type = Comp.Type.LTE)}) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java index 58d5be489..2002d9b5c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Kiln.java @@ -7,16 +7,16 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; @RegistryDescription -public class Kiln extends VirtualizedRegistry { +public class Kiln extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).heat(2)"), @@ -27,30 +27,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> BWRegistry.KILN.getRecipes().removeIf(r -> r == recipe)); - BWRegistry.KILN.getRecipes().addAll(restoreFromBackup()); - } - - public KilnRecipe add(KilnRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BWRegistry.KILN.getRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(KilnRecipe recipe) { - if (BWRegistry.KILN.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BWRegistry.KILN.getRecipes(); } @MethodDescription(example = @Example("item('minecraft:brick')")) public boolean removeByOutput(IIngredient output) { - return BWRegistry.KILN.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -63,7 +46,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:end_stone')")) public boolean removeByInput(IIngredient input) { - return BWRegistry.KILN.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getInput().getMatchingStacks()) { if (input.test(itemstack)) { addBackup(r); @@ -74,17 +57,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BWRegistry.KILN.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BWRegistry.KILN.getRecipes().forEach(this::addBackup); - BWRegistry.KILN.getRecipes().clear(); - } - @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "3", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java index 6f951cf6f..26a8ebb70 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/MillStone.java @@ -7,23 +7,28 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.SoundEvent; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.stream.Collectors; @RegistryDescription -public class MillStone extends VirtualizedRegistry { +public class MillStone extends StandardListRegistry { public MillStone() { super(Alias.generateOfClass(MillStone.class).andGenerate("Mill")); } + @Override + public Collection getRecipes() { + return BWRegistry.MILLSTONE.getRecipes(); + } + @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16)"), @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot'), item('minecraft:gold_block'), item('minecraft:clay'))") @@ -32,31 +37,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - public void onReload() { - removeScripted().forEach(recipe -> BWRegistry.MILLSTONE.getRecipes().removeIf(r -> r == recipe)); - BWRegistry.MILLSTONE.getRecipes().addAll(restoreFromBackup()); - } - - public MillRecipe add(MillRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BWRegistry.MILLSTONE.getRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(MillRecipe recipe) { - if (BWRegistry.MILLSTONE.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:blaze_powder')")) public boolean removeByOutput(IIngredient output) { - return BWRegistry.MILLSTONE.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -69,7 +52,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:netherrack')")) public boolean removeByInput(IIngredient input) { - return BWRegistry.MILLSTONE.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (Ingredient ingredient : r.getInputs()) { for (ItemStack item : ingredient.getMatchingStacks()) { if (input.test(item)) { @@ -82,17 +65,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BWRegistry.MILLSTONE.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BWRegistry.MILLSTONE.getRecipes().forEach(this::addBackup); - BWRegistry.MILLSTONE.getRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "3", type = Comp.Type.LTE)}) @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "3", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java index 67d2cf54c..853683208 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Saw.java @@ -7,16 +7,16 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; @RegistryDescription -public class Saw extends VirtualizedRegistry { +public class Saw extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:gold_ingot') * 16)")) @RecipeBuilderMethodDescription @@ -25,30 +25,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> BWRegistry.WOOD_SAW.getRecipes().removeIf(r -> r == recipe)); - BWRegistry.WOOD_SAW.getRecipes().addAll(restoreFromBackup()); - } - - public SawRecipe add(SawRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BWRegistry.WOOD_SAW.getRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(SawRecipe recipe) { - if (BWRegistry.WOOD_SAW.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BWRegistry.WOOD_SAW.getRecipes(); } @MethodDescription(example = @Example("item('minecraft:pumpkin')")) public boolean removeByOutput(IIngredient output) { - return BWRegistry.WOOD_SAW.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -61,7 +44,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:vine')")) public boolean removeByInput(IIngredient input) { - return BWRegistry.WOOD_SAW.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getInput().getMatchingStacks()) { if (input.test(itemstack)) { addBackup(r); @@ -72,17 +55,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BWRegistry.WOOD_SAW.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BWRegistry.WOOD_SAW.getRecipes().forEach(this::addBackup); - BWRegistry.WOOD_SAW.getRecipes().clear(); - } - @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "9", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java index 12ed8a8ba..76e31be4a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/betterwithmods/Turntable.java @@ -7,53 +7,36 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; @RegistryDescription -public class Turntable extends VirtualizedRegistry { +public class Turntable extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:gold_block')).outputBlock(blockstate('minecraft:clay')).output(item('minecraft:gold_ingot') * 5).rotations(5)"), @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).rotations(2)") }) - @RecipeBuilderMethodDescription + @RecipeBuilderMethodDescription public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override - public void onReload() { - removeScripted().forEach(recipe -> BWRegistry.TURNTABLE.getRecipes().removeIf(r -> r == recipe)); - BWRegistry.TURNTABLE.getRecipes().addAll(restoreFromBackup()); - } - - public TurntableRecipe add(TurntableRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BWRegistry.TURNTABLE.getRecipes().add(recipe); - } - return recipe; - } - - public boolean remove(TurntableRecipe recipe) { - if (BWRegistry.TURNTABLE.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BWRegistry.TURNTABLE.getRecipes(); } @MethodDescription(example = @Example("item('minecraft:clay_ball')")) public boolean removeByOutput(IIngredient output) { - return BWRegistry.TURNTABLE.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -66,7 +49,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('betterwithmods:unfired_pottery')")) public boolean removeByInput(IIngredient input) { - return BWRegistry.TURNTABLE.getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getInput().getMatchingStacks()) { if (input.test(itemstack)) { addBackup(r); @@ -77,17 +60,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BWRegistry.TURNTABLE.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BWRegistry.TURNTABLE.getRecipes().forEach(this::addBackup); - BWRegistry.TURNTABLE.getRecipes().clear(); - } - @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "2", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java index ed67c8c07..68277bcb5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyArray.java @@ -2,22 +2,22 @@ import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyArray; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.bloodmagic.BloodMagicRecipeRegistrarAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class AlchemyArray extends VirtualizedRegistry { +public class AlchemyArray extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).catalyst(item('bloodmagic:slate:1')).output(item('minecraft:gold_ingot')).texture('bloodmagic:textures/models/AlchemyArrays/LightSigil.png')"), @@ -28,10 +28,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()::remove); - restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()::add); + public Collection getRecipes() { + return ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes(); } @MethodDescription(description = "groovyscript.wiki.bloodmagic.alchemy_array.add0", type = MethodDescription.Type.ADDITION) @@ -58,22 +56,9 @@ public RecipeAlchemyArray add(IIngredient input, IIngredient catalyst, ItemStack .register(); } - public void add(RecipeAlchemyArray recipe) { - if (recipe == null) return; - addScripted(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().add(recipe); - } - - public boolean remove(RecipeAlchemyArray recipe) { - if (recipe == null) return false; - addBackup(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('bloodmagic:component:13')")) public boolean removeByInput(IIngredient input) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().test(IngredientHelper.toItemStack(input)); if (found) { addBackup(recipe); @@ -92,7 +77,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('bloodmagic:slate:2')")) public boolean removeByCatalyst(IIngredient catalyst) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getCatalyst().test(IngredientHelper.toItemStack(catalyst)); if (found) { addBackup(recipe); @@ -111,7 +96,7 @@ public boolean removeByCatalyst(IIngredient catalyst) { @MethodDescription(example = @Example("item('bloodmagic:component:7'), item('bloodmagic:slate:1')")) public boolean removeByInputAndCatalyst(IIngredient input, IIngredient catalyst) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean removeRecipe = recipe.getInput().test(IngredientHelper.toItemStack(input)) && recipe.getCatalyst().test(IngredientHelper.toItemStack(catalyst)); if (removeRecipe) { addBackup(recipe); @@ -130,7 +115,7 @@ public boolean removeByInputAndCatalyst(IIngredient input, IIngredient catalyst) @MethodDescription(example = @Example("item('bloodmagic:sigil_void')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean matches = recipe.getOutput().isItemEqual(output); if (matches) { addBackup(recipe); @@ -147,19 +132,6 @@ public boolean removeByOutput(ItemStack output) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().forEach(this::addBackup); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyArrayRecipes()) - .setRemover(this::remove); - } - - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java index 03603d3af..fd2fe152b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/AlchemyTable.java @@ -2,21 +2,20 @@ import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import WayofTime.bloodmagic.api.impl.recipe.RecipeAlchemyTable; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.bloodmagic.BloodMagicRecipeRegistrarAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.NonNullList; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.Collections; @RegistryDescription( @@ -25,7 +24,7 @@ hasTitle = true, value = "groovyscript.wiki.bloodmagic.alchemy_table.note0") ) -public class AlchemyTable extends VirtualizedRegistry { +public class AlchemyTable extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond'), item('minecraft:diamond')).output(item('minecraft:clay')).ticks(100).minimumTier(2).syphon(500)"), @@ -36,10 +35,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()::remove); - restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()::add); + public Collection getRecipes() { + return ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -49,19 +46,6 @@ public RecipeAlchemyTable add(NonNullList input, ItemStack output, i return recipe; } - public void add(RecipeAlchemyTable recipe) { - if (recipe == null) return; - addScripted(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().add(recipe); - } - - public boolean remove(RecipeAlchemyTable recipe) { - if (recipe == null) return false; - addBackup(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().remove(recipe); - return true; - } - @MethodDescription public boolean removeByInput(IIngredient... input) { NonNullList inputs = NonNullList.create(); @@ -72,7 +56,7 @@ public boolean removeByInput(IIngredient... input) { @MethodDescription(example = @Example("item('minecraft:nether_wart'), item('minecraft:gunpowder')")) public boolean removeByInput(NonNullList input) { // Filters down to only recipes which have inputs that match all the input IIngredients (NOTE: a recipe with ABCD would match an input of AB) - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean removeRecipe = false; for (IIngredient match : input) { boolean foundInputMatch = false; @@ -98,7 +82,7 @@ public boolean removeByInput(NonNullList input) { @MethodDescription(example = @Example("item('minecraft:sand')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (matches) { addBackup(recipe); @@ -114,19 +98,6 @@ public boolean removeByOutput(ItemStack output) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().forEach(this::addBackup); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAlchemyRecipes()) - .setRemover(this::remove); - } - - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "6")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java index 27eba83ab..07771b4c5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/BloodAltar.java @@ -3,19 +3,19 @@ import WayofTime.bloodmagic.altar.AltarTier; import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import WayofTime.bloodmagic.api.impl.recipe.RecipeBloodAltar; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.bloodmagic.BloodMagicRecipeRegistrarAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription( admonition = { @Admonition("groovyscript.wiki.bloodmagic.blood_altar.note0"), @@ -25,7 +25,7 @@ hasTitle = true) } ) -public class BloodAltar extends VirtualizedRegistry { +public class BloodAltar extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).minimumTier(0).drainRate(5).syphon(10).consumeRate(5)"), @@ -36,10 +36,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()::remove); - restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()::add); + public Collection getRecipes() { + return ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -53,22 +51,9 @@ public RecipeBloodAltar add(IIngredient input, ItemStack output, int minimumTier .register(); } - public void add(RecipeBloodAltar recipe) { - if (recipe == null) return; - addScripted(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().add(recipe); - } - - public boolean remove(RecipeBloodAltar recipe) { - if (recipe == null) return false; - addBackup(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public boolean removeByInput(IIngredient input) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean removeRecipe = recipe.getInput().test(IngredientHelper.toItemStack(input)); if (removeRecipe) { addBackup(recipe); @@ -87,7 +72,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('bloodmagic:slate:4')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (matches) { addBackup(recipe); @@ -104,18 +89,6 @@ public boolean removeByOutput(ItemStack output) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().forEach(this::addBackup); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getAltarRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java index cea5d56e8..f041c49d7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/bloodmagic/TartaricForge.java @@ -2,16 +2,14 @@ import WayofTime.bloodmagic.api.impl.BloodMagicAPI; import WayofTime.bloodmagic.api.impl.recipe.RecipeTartaricForge; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.bloodmagic.BloodMagicRecipeRegistrarAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.NonNullList; @@ -21,7 +19,7 @@ import java.util.Collections; @RegistryDescription -public class TartaricForge extends VirtualizedRegistry { +public class TartaricForge extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot')).soulDrain(5).minimumSouls(10)"), @@ -32,10 +30,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()::remove); - restoreFromBackup().forEach(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()::add); + public Collection getRecipes() { + return ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -48,19 +44,6 @@ public RecipeTartaricForge add(Collection input, ItemStack output, .register(); } - public void add(RecipeTartaricForge recipe) { - if (recipe == null) return; - addScripted(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().add(recipe); - } - - public boolean remove(RecipeTartaricForge recipe) { - if (recipe == null) return false; - addBackup(recipe); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().remove(recipe); - return true; - } - @MethodDescription(example = { @Example("item('minecraft:cauldron'), item('minecraft:stone'), item('minecraft:dye:4'), item('minecraft:diamond')"), @Example("item('minecraft:gunpowder'), item('minecraft:redstone')") @@ -74,7 +57,7 @@ public boolean removeByInput(IIngredient... input) { @MethodDescription public boolean removeByInput(NonNullList input) { // Filters down to only recipes which have inputs that match all the input IIngredients (NOTE: a recipe with ABCD would match an input of AB) - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean removeRecipe = false; for (IIngredient match : input) { boolean foundInputMatch = false; @@ -100,7 +83,7 @@ public boolean removeByInput(NonNullList input) { @MethodDescription(example = @Example("item('bloodmagic:demon_crystal')")) public boolean removeByOutput(ItemStack output) { - if (((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean matches = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (matches) { addBackup(recipe); @@ -116,19 +99,6 @@ public boolean removeByOutput(ItemStack output) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().forEach(this::addBackup); - ((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(((BloodMagicRecipeRegistrarAccessor) BloodMagicAPI.INSTANCE.getRecipeRegistrar()).getTartaricForgeRecipes()) - .setRemover(this::remove); - } - - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "4")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java index adef4bbfa..b5ce4ccdc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Apothecary.java @@ -1,42 +1,39 @@ package com.cleanroommc.groovyscript.compat.mods.botania; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePetals; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Apothecary extends VirtualizedRegistry { +public class Apothecary extends StandardListRegistry { public Apothecary() { super(Alias.generateOfClassAnd(Apothecary.class, "PetalApothecary")); } + @Override + public Collection getRecipes() { + return BotaniaAPI.petalRecipes; + } + @RecipeBuilderDescription(example = @Example(".input(ore('blockGold'), ore('ingotIron'), item('minecraft:apple')).output(item('minecraft:golden_apple'))")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.petalRecipes::remove); - BotaniaAPI.petalRecipes.addAll(restoreFromBackup()); - } - @MethodDescription(type = MethodDescription.Type.ADDITION) public RecipePetals add(ItemStack output, IIngredient... inputs) { return recipeBuilder() @@ -45,21 +42,9 @@ public RecipePetals add(ItemStack output, IIngredient... inputs) { .register(); } - public void add(RecipePetals recipe) { - if (recipe == null) return; - addScripted(recipe); - BotaniaAPI.petalRecipes.add(recipe); - } - - public boolean remove(RecipePetals recipe) { - if (recipe == null) return false; - addBackup(recipe); - return BotaniaAPI.petalRecipes.remove(recipe); - } - @MethodDescription(example = @Example("item('botania:specialflower').withNbt(['type': 'puredaisy'])")) public boolean removeByOutput(IIngredient output) { - if (BotaniaAPI.petalRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = output.test(recipe.getOutput()); if (found) addBackup(recipe); return found; @@ -76,7 +61,7 @@ public boolean removeByOutput(IIngredient output) { public boolean removeByInput(IIngredient... inputs) { List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).collect(Collectors.toList()); - if (BotaniaAPI.petalRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> o instanceof String || i instanceof String ? o.equals(i) : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o))); if (found) addBackup(recipe); @@ -95,17 +80,6 @@ public boolean removeByInputs(IIngredient... inputs) { return removeByInput(inputs); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.petalRecipes.forEach(this::addBackup); - BotaniaAPI.petalRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BotaniaAPI.petalRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "20")}) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java index 9a8156cb0..0ff0985f7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/BrewRecipe.java @@ -1,24 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.botania; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeBrew; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class BrewRecipe extends VirtualizedRegistry { +public class BrewRecipe extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), ore('ingotGold'), ore('gemDiamond')).brew(brew('absorption'))")) public RecipeBuilder recipeBuilder() { @@ -26,27 +25,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.brewRecipes::remove); - BotaniaAPI.brewRecipes.addAll(restoreFromBackup()); - } - - public void add(RecipeBrew recipe) { - if (recipe == null) return; - addScripted(recipe); - BotaniaAPI.brewRecipes.add(recipe); - } - - public boolean remove(RecipeBrew recipe) { - if (recipe == null) return false; - addBackup(recipe); - return BotaniaAPI.brewRecipes.remove(recipe); + public Collection getRecipes() { + return BotaniaAPI.brewRecipes; } @MethodDescription(example = @Example("'speed'")) public boolean removeByOutput(String brew) { - if (BotaniaAPI.brewRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getBrew().getKey().equals(brew); if (found) addBackup(recipe); return found; @@ -68,7 +53,7 @@ public boolean removeByOutput(vazkii.botania.api.brew.Brew brew) { public boolean removeByInput(IIngredient... inputs) { List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).collect(Collectors.toList()); - if (BotaniaAPI.brewRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> (i instanceof String || o instanceof String) ? i.equals(o) : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o))); @@ -88,17 +73,6 @@ public boolean removeByInputs(IIngredient... inputs) { return removeByInput(inputs); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.brewRecipes.forEach(this::addBackup); - BotaniaAPI.brewRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BotaniaAPI.brewRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "6")}) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java index 4311be5d8..75e30631b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ElvenTrade.java @@ -1,13 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.botania; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; @@ -18,7 +16,7 @@ import java.util.List; @RegistryDescription -public class ElvenTrade extends VirtualizedRegistry { +public class ElvenTrade extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(ore('ingotGold'), ore('ingotIron')).output(item('botania:manaresource:7'))")) public RecipeBuilder recipeBuilder() { @@ -26,10 +24,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.elvenTradeRecipes::remove); - BotaniaAPI.elvenTradeRecipes.addAll(restoreFromBackup()); + public Collection getRecipes() { + return BotaniaAPI.elvenTradeRecipes; } protected Object[] convertIngredients(IIngredient[] inputs) { @@ -57,21 +53,9 @@ public RecipeElvenTrade add(ItemStack output, Collection inputs) { return recipeBuilder().input(inputs).output(output).register(); } - public void add(RecipeElvenTrade recipe) { - if (recipe == null) return; - addScripted(recipe); - BotaniaAPI.elvenTradeRecipes.add(recipe); - } - - public boolean remove(RecipeElvenTrade recipe) { - if (recipe == null) return false; - addBackup(recipe); - return BotaniaAPI.elvenTradeRecipes.remove(recipe); - } - @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('botania:dreamwood')")) public boolean removeByOutputs(ItemStack... outputs) { - if (BotaniaAPI.elvenTradeRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = Arrays.stream(outputs).allMatch(output -> recipe.getOutputs().stream().anyMatch(o -> ItemStack.areItemStacksEqual(o, output))); if (found) addBackup(recipe); return found; @@ -88,7 +72,7 @@ public boolean removeByOutputs(ItemStack... outputs) { public boolean removeByInputs(IIngredient... inputs) { List converted = Arrays.asList(convertIngredients(inputs)); List list = Arrays.asList(inputs); - if (BotaniaAPI.elvenTradeRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getInputs().stream().allMatch(input -> input instanceof String ? converted.contains(input) : list.stream().anyMatch(i -> i.test((ItemStack) input))); if (found) addBackup(recipe); @@ -102,17 +86,6 @@ public boolean removeByInputs(IIngredient... inputs) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.elvenTradeRecipes.forEach(this::addBackup); - BotaniaAPI.elvenTradeRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BotaniaAPI.elvenTradeRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "99")}) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "99")}) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java index 446f26fde..f34fd0e09 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/Lexicon.java @@ -7,6 +7,7 @@ import com.cleanroommc.groovyscript.compat.mods.botania.recipe.PageChange; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -33,13 +34,11 @@ public class Lexicon { category = RegistryDescription.Category.ENTRIES, priority = 2100 ) - public static class Category extends VirtualizedRegistry { + public static class Category extends StandardListRegistry { @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.getAllCategories()::remove); - BotaniaAPI.getAllCategories().addAll(restoreFromBackup()); + public Collection getRecipes() { + return BotaniaAPI.getAllCategories(); } @MethodDescription(description = "groovyscript.wiki.botania.category.add0", type = MethodDescription.Type.ADDITION, example = @Example("'first', resource('minecraft:textures/items/clay_ball.png'), 100")) @@ -56,19 +55,6 @@ public LexiconCategory add(String name, ResourceLocation icon) { return add(name, icon, 5); } - public void add(LexiconCategory category) { - if (category == null) return; - addScripted(category); - BotaniaAPI.addCategory(category); - } - - public boolean remove(LexiconCategory category) { - if (category == null) return false; - addBackup(category); - BotaniaAPI.getAllCategories().remove(category); - return true; - } - @MethodDescription(description = "groovyscript.wiki.botania.category.removeCategory", example = @Example("'botania.category.alfhomancy'")) public boolean remove(String name) { LexiconCategory category = Botania.getCategory(name); @@ -88,13 +74,7 @@ public boolean removeCategory(String name) { @MethodDescription(description = "groovyscript.wiki.streamRecipes", type = MethodDescription.Type.QUERY) public SimpleObjectStream streamCategories() { - return new SimpleObjectStream<>(BotaniaAPI.getAllCategories()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.getAllCategories().forEach(this::addBackup); - BotaniaAPI.getAllCategories().clear(); + return streamRecipes(); } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java index 3ff83f9d6..9f5af25cf 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/ManaInfusion.java @@ -1,23 +1,23 @@ package com.cleanroommc.groovyscript.compat.mods.botania; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipeManaInfusion; +import java.util.Collection; + @RegistryDescription( admonition = @Admonition(value = "groovyscript.wiki.botania.mana_infusion.note", type = Admonition.Type.WARNING) ) -public class ManaInfusion extends VirtualizedRegistry { +public class ManaInfusion extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(ore('ingotGold')).output(item('botania:manaresource', 1)).mana(500).catalyst(blockstate('minecraft:stone'))")) public RecipeBuilder recipeBuilder() { @@ -25,10 +25,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.manaInfusionRecipes::remove); - BotaniaAPI.manaInfusionRecipes.addAll(restoreFromBackup()); + public Collection getRecipes() { + return BotaniaAPI.manaInfusionRecipes; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -36,21 +34,9 @@ public RecipeManaInfusion add(ItemStack output, IIngredient input, int mana) { return recipeBuilder().mana(mana).output(output).input(input).register(); } - public void add(RecipeManaInfusion recipe) { - if (recipe == null) return; - addScripted(recipe); - BotaniaAPI.manaInfusionRecipes.add(recipe); - } - - public boolean remove(RecipeManaInfusion recipe) { - if (recipe == null) return false; - addBackup(recipe); - return BotaniaAPI.manaInfusionRecipes.remove(recipe); - } - @MethodDescription(example = @Example("item('botania:managlass')")) public boolean removeByOutput(ItemStack output) { - if (BotaniaAPI.manaInfusionRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = ItemStack.areItemStacksEqual(recipe.getOutput(), output); if (found) addBackup(recipe); return found; @@ -65,7 +51,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public boolean removeByInput(IIngredient input) { - if (BotaniaAPI.manaInfusionRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getInput() instanceof ItemStack ? input.test((ItemStack) recipe.getInput()) : (input instanceof OreDictIngredient && ((OreDictIngredient) input).getOreDict().equals(recipe.getInput())); if (found) addBackup(recipe); @@ -81,7 +67,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("blockstate('botania:alchemycatalyst')")) public boolean removeByCatalyst(IBlockState catalyst) { - if (BotaniaAPI.manaInfusionRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { if (recipe.getCatalyst() == null) return false; boolean found = recipe.getCatalyst().equals(catalyst); if (found) addBackup(recipe); @@ -95,17 +81,6 @@ public boolean removeByCatalyst(IBlockState catalyst) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.manaInfusionRecipes.forEach(this::addBackup); - BotaniaAPI.manaInfusionRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BotaniaAPI.manaInfusionRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java index af7273f6a..43912b0fb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/PureDaisy.java @@ -1,20 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.botania; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import org.jetbrains.annotations.Nullable; import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.recipe.RecipePureDaisy; +import java.util.Collection; + @RegistryDescription -public class PureDaisy extends VirtualizedRegistry { +public class PureDaisy extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(ore('plankWood')).output(blockstate('minecraft:clay')).time(5)")) public RecipeBuilder recipeBuilder() { @@ -22,10 +22,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.pureDaisyRecipes::remove); - BotaniaAPI.pureDaisyRecipes.addAll(restoreFromBackup()); + public Collection getRecipes() { + return BotaniaAPI.pureDaisyRecipes; } @MethodDescription(description = "groovyscript.wiki.botania.pure_daisy.add0", type = MethodDescription.Type.ADDITION) @@ -38,21 +36,9 @@ public RecipePureDaisy add(IBlockState output, IBlockState input) { return recipeBuilder().output(output).input(input).register(); } - public void add(RecipePureDaisy recipe) { - if (recipe == null) return; - addScripted(recipe); - BotaniaAPI.pureDaisyRecipes.add(recipe); - } - - public boolean remove(RecipePureDaisy recipe) { - if (recipe == null) return false; - addBackup(recipe); - return BotaniaAPI.pureDaisyRecipes.remove(recipe); - } - @MethodDescription(example = @Example("blockstate('botania:livingrock')")) public boolean removeByOutput(IBlockState output) { - if (BotaniaAPI.pureDaisyRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getOutputState().equals(output); if (found) addBackup(recipe); return found; @@ -67,7 +53,7 @@ public boolean removeByOutput(IBlockState output) { @MethodDescription public boolean removeByInput(String input) { - if (BotaniaAPI.pureDaisyRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getInput() instanceof String && recipe.getInput().equals(input); if (found) addBackup(recipe); return found; @@ -87,7 +73,7 @@ public boolean removeByInput(OreDictIngredient input) { @MethodDescription(example = @Example("blockstate('minecraft:water')")) public boolean removeByInput(IBlockState input) { - if (BotaniaAPI.pureDaisyRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = (recipe.getInput() instanceof IBlockState && recipe.getInput().equals(input)) || (recipe.getInput() instanceof Block && recipe.getInput() == input.getBlock()); if (found) addBackup(recipe); return found; @@ -105,17 +91,6 @@ public boolean removeByInput(Block input) { return removeByInput(input.getDefaultState()); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.pureDaisyRecipes.forEach(this::addBackup); - BotaniaAPI.pureDaisyRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BotaniaAPI.pureDaisyRecipes).setRemover(this::remove); - } - public class RecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "RecipePureDaisy.DEFAULT_TIME (150)", valid = @Comp(value = "0", type = Comp.Type.GTE)) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java index 195b713a9..0e1c209a5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botania/RuneAltar.java @@ -1,13 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.botania; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; @@ -16,11 +14,12 @@ import vazkii.botania.common.block.ModBlocks; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class RuneAltar extends VirtualizedRegistry { +public class RuneAltar extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(ore('gemEmerald'), item('minecraft:apple')).output(item('minecraft:diamond')).mana(500)")) public RecipeBuilder recipeBuilder() { @@ -28,10 +27,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(BotaniaAPI.runeAltarRecipes::remove); - BotaniaAPI.runeAltarRecipes.addAll(restoreFromBackup()); + public Collection getRecipes() { + return BotaniaAPI.runeAltarRecipes; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -39,21 +36,9 @@ public RecipeRuneAltar add(ItemStack output, int mana, IIngredient... inputs) { return recipeBuilder().mana(mana).output(output).input(inputs).register(); } - public void add(RecipeRuneAltar recipe) { - if (recipe == null) return; - addScripted(recipe); - BotaniaAPI.runeAltarRecipes.add(recipe); - } - - public boolean remove(RecipeRuneAltar recipe) { - if (recipe == null) return false; - addBackup(recipe); - return BotaniaAPI.runeAltarRecipes.remove(recipe); - } - @MethodDescription(example = @Example("item('botania:rune:1')")) public boolean removeByOutput(IIngredient output) { - if (BotaniaAPI.runeAltarRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = output.test(recipe.getOutput()); if (found) addBackup(recipe); return found; @@ -70,7 +55,7 @@ public boolean removeByOutput(IIngredient output) { public boolean removeByInput(IIngredient... inputs) { List converted = Arrays.stream(inputs).map(i -> i instanceof OreDictIngredient ? ((OreDictIngredient) i).getOreDict() : i.getMatchingStacks()[0]).collect(Collectors.toList()); - if (BotaniaAPI.runeAltarRecipes.removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = converted.stream().allMatch(o -> recipe.getInputs().stream().anyMatch(i -> (i instanceof String || o instanceof String) ? i.equals(o) : ItemStack.areItemStacksEqual((ItemStack) i, (ItemStack) o))); @@ -90,17 +75,6 @@ public boolean removeByInputs(IIngredient... inputs) { return removeByInput(inputs); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BotaniaAPI.runeAltarRecipes.forEach(this::addBackup); - BotaniaAPI.runeAltarRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BotaniaAPI.runeAltarRecipes).setRemover(this::remove); - } - @Property(property = "input", requirement = "groovyscript.wiki.botania.rune_altar.input.required", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botanicadditions/GaiaPlate.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botanicadditions/GaiaPlate.java index 392b9a74b..29de0e2ca 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/botanicadditions/GaiaPlate.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/botanicadditions/GaiaPlate.java @@ -4,17 +4,18 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import org.jetbrains.annotations.Nullable; import tk.zeitheron.botanicadds.api.GaiaPlateRecipes; +import java.util.Collection; + @RegistryDescription -public class GaiaPlate extends VirtualizedRegistry { +public class GaiaPlate extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:gold_ingot') * 16).mana(1000)"), @@ -25,29 +26,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - GaiaPlateRecipes.gaiaRecipes.removeAll(removeScripted()); - GaiaPlateRecipes.gaiaRecipes.addAll(restoreFromBackup()); - } - - public void add(GaiaPlateRecipes.RecipeGaiaPlate recipe) { - if (recipe != null) { - addScripted(recipe); - GaiaPlateRecipes.gaiaRecipes.add(recipe); - } - } - - public boolean remove(GaiaPlateRecipes.RecipeGaiaPlate recipe) { - if (GaiaPlateRecipes.gaiaRecipes.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return GaiaPlateRecipes.gaiaRecipes; } @MethodDescription(example = @Example("item('botanicadds:gaiasteel_ingot')")) public boolean removeByOutput(IIngredient output) { - return GaiaPlateRecipes.gaiaRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -58,7 +43,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('botania:manaresource')")) public boolean removeByInput(IIngredient input) { - return GaiaPlateRecipes.gaiaRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { for (Object ingredient : r.getInputs()) { if ((ingredient instanceof String s && (input instanceof OreDictIngredient ore && ore.getOreDict().equals(s) || OreDictionary.getOres(s, false).stream().anyMatch(input))) || (ingredient instanceof ItemStack is && input.test(is))) { @@ -70,17 +55,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GaiaPlateRecipes.gaiaRecipes).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - GaiaPlateRecipes.gaiaRecipes.forEach(this::addBackup); - GaiaPlateRecipes.gaiaRecipes.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java index 7d94dde08..71a6b961e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AlgorithmSeparator.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.AlgorithmSeparatorRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class AlgorithmSeparator extends VirtualizedRegistry { +public class AlgorithmSeparator extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:diamond'))")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(AlgorithmSeparatorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(AlgorithmSeparatorRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - AlgorithmSeparatorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - AlgorithmSeparatorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return AlgorithmSeparatorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:tanzaniteleaves')")) public boolean removeByInput(IIngredient input) { - return AlgorithmSeparatorRecipes.instance().getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { for (ISonarRecipeObject recipeInput : recipe.inputs()) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:weakeneddiamond')")) public boolean removeByOutput(IIngredient output) { - return AlgorithmSeparatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - AlgorithmSeparatorRecipes.instance().getRecipes().forEach(this::addBackup); - AlgorithmSeparatorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AlgorithmSeparatorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("2")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java index 4a57d89bc..59ce95888 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AnalysingChamber.java @@ -5,9 +5,8 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.AnalysingChamberRecipes; @@ -16,6 +15,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; /** @@ -41,12 +41,17 @@ @Admonition(value = "groovyscript.wiki.calculator.analysing_chamber.note1", type = Admonition.Type.WARNING, format = Admonition.Format.STANDARD) } ) -public class AnalysingChamber extends VirtualizedRegistry { +public class AnalysingChamber extends StandardListRegistry { public AnalysingChamber() { super(Alias.generateOfClass(AnalysingChamber.class).andGenerate("AnalyzingChamber")); } + @Override + public Collection getRecipes() { + return AnalysingChamberRecipes.instance().getRecipes(); + } + @RecipeBuilderDescription(example = { @Example(".slot(6).location(1).output(item('minecraft:diamond'))"), @Example(".slot(1).location(18).output(item('minecraft:clay'))"), @@ -55,28 +60,9 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - public void onReload() { - removeScripted().forEach(AnalysingChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(AnalysingChamberRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - AnalysingChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - AnalysingChamberRecipes.instance().getRecipes().remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('sonarcore:reinforceddirtblock')")) public boolean removeByOutput(IIngredient output) { - return AnalysingChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -89,18 +75,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - AnalysingChamberRecipes.instance().getRecipes().forEach(this::addBackup); - AnalysingChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AnalysingChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java index 627da2a45..64727179b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/AtomicCalculator.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.AtomicCalculatorRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class AtomicCalculator extends VirtualizedRegistry { +public class AtomicCalculator extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot') * 4)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(AtomicCalculatorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(AtomicCalculatorRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - AtomicCalculatorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - AtomicCalculatorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return AtomicCalculatorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:end_stone')")) public boolean removeByInput(IIngredient input) { - return AtomicCalculatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:firediamond')")) public boolean removeByOutput(IIngredient output) { - return AtomicCalculatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - AtomicCalculatorRecipes.instance().getRecipes().forEach(this::addBackup); - AtomicCalculatorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AtomicCalculatorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("3")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java index b4b45d6ff..0d2f9e735 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/BasicCalculator.java @@ -5,9 +5,8 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -15,41 +14,28 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class BasicCalculator extends VirtualizedRegistry { +public class BasicCalculator extends StandardListRegistry { public BasicCalculator() { super(Alias.generateOfClass(BasicCalculator.class).andGenerate("Calculator")); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot'))")) - public RecipeBuilder recipeBuilder() { - return new RecipeBuilder(); - } - @Override - public void onReload() { - removeScripted().forEach(CalculatorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(CalculatorRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - CalculatorRecipes.instance().getRecipes().add(recipe); + public Collection getRecipes() { + return CalculatorRecipes.instance().getRecipes(); } - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - CalculatorRecipes.instance().getRecipes().remove(recipe); - return true; + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot'))")) + public RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); } @MethodDescription(example = @Example("item('minecraft:cobblestone')")) public boolean removeByInput(IIngredient input) { - return CalculatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -64,7 +50,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:reinforcedironingot')")) public boolean removeByOutput(IIngredient output) { - return CalculatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -77,18 +63,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - CalculatorRecipes.instance().getRecipes().forEach(this::addBackup); - CalculatorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CalculatorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java index c9341fcdd..880a8305a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ConductorMast.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.ConductorMastRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.Arrays; +import java.util.Collection; @RegistryDescription -public class ConductorMast extends VirtualizedRegistry { +public class ConductorMast extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond')).value(100)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(ConductorMastRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(ConductorMastRecipes.instance().getRecipes()::add); - } - - public void add(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return; - addScripted(recipe); - ConductorMastRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return false; - addBackup(recipe); - ConductorMastRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return ConductorMastRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:firediamond')")) public boolean removeByInput(IIngredient input) { - return ConductorMastRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:material:7')")) public boolean removeByOutput(IIngredient output) { - return ConductorMastRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ConductorMastRecipes.instance().getRecipes().forEach(this::addBackup); - ConductorMastRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ConductorMastRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java index ad2b47118..288d8a79a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ExtractionChamber.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,10 +13,11 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; import java.util.List; @RegistryDescription -public class ExtractionChamber extends VirtualizedRegistry { +public class ExtractionChamber extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))"), @@ -28,27 +28,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(ExtractionChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(ExtractionChamberRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ExtractionChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ExtractionChamberRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return ExtractionChamberRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:dirt')")) public boolean removeByInput(IIngredient input) { - return ExtractionChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -63,7 +49,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:smallstone')")) public boolean removeByOutput(IIngredient output) { - return ExtractionChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -76,18 +62,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ExtractionChamberRecipes.instance().getRecipes().forEach(this::addBackup); - ExtractionChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExtractionChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java index 88ed14826..266cf4677 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FabricationChamber.java @@ -4,10 +4,9 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraftforge.registries.IForgeRegistryEntry; @@ -17,12 +16,13 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @RegistryDescription -public class FabricationChamber extends VirtualizedRegistry { +public class FabricationChamber extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('calculator:circuitboard:8').withNbt([Stable: 0, Analysed: 1])).output(item('minecraft:diamond'))"), @@ -33,27 +33,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(FabricationChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(FabricationChamberRecipes.instance().getRecipes()::add); - } - - public void add(FabricationSonarRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - FabricationChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(FabricationSonarRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - FabricationChamberRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return FabricationChamberRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:circuitboard:8').withNbt([Stable: 0, Analysed: 1])")) public boolean removeByInput(IIngredient input) { - return FabricationChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -68,7 +54,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:calculatorassembly')")) public boolean removeByOutput(IIngredient output) { - return FabricationChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -81,18 +67,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - FabricationChamberRecipes.instance().getRecipes().forEach(this::addBackup); - FabricationChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FabricationChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java index 79319ca66..6ecad35c4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/FlawlessCalculator.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class FlawlessCalculator extends VirtualizedRegistry { +public class FlawlessCalculator extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot') * 16)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(FlawlessCalculatorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(FlawlessCalculatorRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - FlawlessCalculatorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - FlawlessCalculatorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return FlawlessCalculatorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:obsidian')")) public boolean removeByInput(IIngredient input) { - return FlawlessCalculatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public boolean removeByOutput(IIngredient output) { - return FlawlessCalculatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - FlawlessCalculatorRecipes.instance().getRecipes().forEach(this::addBackup); - FlawlessCalculatorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FlawlessCalculatorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("4")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java index 8ca67edf0..470de5800 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/GlowstoneExtractor.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.GlowstoneExtractorRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.Arrays; +import java.util.Collection; @RegistryDescription -public class GlowstoneExtractor extends VirtualizedRegistry { +public class GlowstoneExtractor extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).value(100)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(GlowstoneExtractorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(GlowstoneExtractorRecipes.instance().getRecipes()::add); - } - - public void add(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return; - addScripted(recipe); - GlowstoneExtractorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return false; - addBackup(recipe); - GlowstoneExtractorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return GlowstoneExtractorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:glowstone')")) public boolean removeByInput(IIngredient input) { - return GlowstoneExtractorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -57,18 +43,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - GlowstoneExtractorRecipes.instance().getRecipes().forEach(this::addBackup); - GlowstoneExtractorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GlowstoneExtractorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java index 7b20c310b..61947c864 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/HealthProcessor.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.HealthProcessorRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.Arrays; +import java.util.Collection; @RegistryDescription -public class HealthProcessor extends VirtualizedRegistry { +public class HealthProcessor extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).value(100)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(HealthProcessorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(HealthProcessorRecipes.instance().getRecipes()::add); - } - - public void add(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return; - addScripted(recipe); - HealthProcessorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return false; - addBackup(recipe); - HealthProcessorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return HealthProcessorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:blaze_rod')")) public boolean removeByInput(IIngredient input) { - return HealthProcessorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -57,18 +43,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - HealthProcessorRecipes.instance().getRecipes().forEach(this::addBackup); - HealthProcessorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(HealthProcessorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java index 5df6de724..813969749 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/PrecisionChamber.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class PrecisionChamber extends VirtualizedRegistry { +public class PrecisionChamber extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('calculator:circuitdamaged:4'))"), @@ -27,27 +27,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(PrecisionChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(PrecisionChamberRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - PrecisionChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - PrecisionChamberRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return PrecisionChamberRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:clay')")) public boolean removeByInput(IIngredient input) { - return PrecisionChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -62,7 +48,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:soil')")) public boolean removeByOutput(IIngredient output) { - return PrecisionChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -75,18 +61,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - PrecisionChamberRecipes.instance().getRecipes().forEach(this::addBackup); - PrecisionChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(PrecisionChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("2")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java index ac654c943..40443fa38 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ProcessingChamber.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class ProcessingChamber extends VirtualizedRegistry { +public class ProcessingChamber extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(ProcessingChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(ProcessingChamberRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ProcessingChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ProcessingChamberRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return ProcessingChamberRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:circuitdamaged:4')")) public boolean removeByInput(IIngredient input) { - return ProcessingChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:circuitboard:1')")) public boolean removeByOutput(IIngredient output) { - return ProcessingChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ProcessingChamberRecipes.instance().getRecipes().forEach(this::addBackup); - ProcessingChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ProcessingChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java index 4a6d6202f..b5db81314 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ReassemblyChamber.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class ReassemblyChamber extends VirtualizedRegistry { +public class ReassemblyChamber extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(ReassemblyChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(ReassemblyChamberRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ReassemblyChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ReassemblyChamberRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return ReassemblyChamberRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:circuitdamaged:12')")) public boolean removeByInput(IIngredient input) { - return ReassemblyChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:circuitboard:13')")) public boolean removeByOutput(IIngredient output) { - return ReassemblyChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ReassemblyChamberRecipes.instance().getRecipes().forEach(this::addBackup); - ReassemblyChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ReassemblyChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java index 43d488f12..ec925f773 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RedstoneExtractor.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.RedstoneExtractorRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.Arrays; +import java.util.Collection; @RegistryDescription -public class RedstoneExtractor extends VirtualizedRegistry { +public class RedstoneExtractor extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).value(100)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(RedstoneExtractorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(RedstoneExtractorRecipes.instance().getRecipes()::add); - } - - public void add(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return; - addScripted(recipe); - RedstoneExtractorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return false; - addBackup(recipe); - RedstoneExtractorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return RedstoneExtractorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:redstone_block')")) public boolean removeByInput(IIngredient input) { - return RedstoneExtractorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -57,18 +43,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RedstoneExtractorRecipes.instance().getRecipes().forEach(this::addBackup); - RedstoneExtractorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RedstoneExtractorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java index 6e9b42271..10378d467 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/RestorationChamber.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class RestorationChamber extends VirtualizedRegistry { +public class RestorationChamber extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'))")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(RestorationChamberRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(RestorationChamberRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - RestorationChamberRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - RestorationChamberRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return RestorationChamberRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:circuitdirty:5')")) public boolean removeByInput(IIngredient input) { - return RestorationChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:circuitboard:3')")) public boolean removeByOutput(IIngredient output) { - return RestorationChamberRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RestorationChamberRecipes.instance().getRecipes().forEach(this::addBackup); - RestorationChamberRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RestorationChamberRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java index 37f3bb460..509c9e9e2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/ScientificCalculator.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class ScientificCalculator extends VirtualizedRegistry { +public class ScientificCalculator extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), item('minecraft:clay')).output(item('minecraft:gold_ingot') * 2)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(ScientificRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(ScientificRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ScientificRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ScientificRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return ScientificRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('calculator:smallamethyst')")) public boolean removeByInput(IIngredient input) { - return ScientificRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:redstoneingot')")) public boolean removeByOutput(IIngredient output) { - return ScientificRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ScientificRecipes.instance().getRecipes().forEach(this::addBackup); - ScientificRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ScientificRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java index 90339c87c..952e9a6fc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StarchExtractor.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.StarchExtractorRecipes; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.Arrays; +import java.util.Collection; @RegistryDescription -public class StarchExtractor extends VirtualizedRegistry { +public class StarchExtractor extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).value(100)")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(StarchExtractorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(StarchExtractorRecipes.instance().getRecipes()::add); - } - - public void add(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return; - addScripted(recipe); - StarchExtractorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(DefaultSonarRecipe.Value recipe) { - if (recipe == null) return false; - addBackup(recipe); - StarchExtractorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return StarchExtractorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:apple')")) public boolean removeByInput(IIngredient input) { - return StarchExtractorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -57,18 +43,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - StarchExtractorRecipes.instance().getRecipes().forEach(this::addBackup); - StarchExtractorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(StarchExtractorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java index 34dd2eae3..f83a34717 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/calculator/StoneSeparator.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import sonar.calculator.mod.common.recipes.CalculatorRecipe; @@ -14,9 +13,10 @@ import sonar.core.recipes.ISonarRecipeObject; import java.util.ArrayList; +import java.util.Collection; @RegistryDescription -public class StoneSeparator extends VirtualizedRegistry { +public class StoneSeparator extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond'), item('minecraft:diamond'))")) public RecipeBuilder recipeBuilder() { @@ -24,27 +24,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(StoneSeparatorRecipes.instance().getRecipes()::remove); - restoreFromBackup().forEach(StoneSeparatorRecipes.instance().getRecipes()::add); - } - - public void add(CalculatorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - StoneSeparatorRecipes.instance().getRecipes().add(recipe); - } - - public boolean remove(CalculatorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - StoneSeparatorRecipes.instance().getRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return StoneSeparatorRecipes.instance().getRecipes(); } @MethodDescription(example = @Example("item('minecraft:gold_ore')")) public boolean removeByInput(IIngredient input) { - return StoneSeparatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeInput : r.recipeInputs) { for (ItemStack itemStack : recipeInput.getJEIValue()) { if (input.test(itemStack)) { @@ -59,7 +45,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('calculator:reinforcedironingot')")) public boolean removeByOutput(IIngredient output) { - return StoneSeparatorRecipes.instance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { for (ISonarRecipeObject recipeOutput : r.recipeOutputs) { for (ItemStack itemStack : recipeOutput.getJEIValue()) { if (output.test(itemStack)) { @@ -72,18 +58,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - StoneSeparatorRecipes.instance().getRecipes().forEach(this::addBackup); - StoneSeparatorRecipes.instance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(StoneSeparatorRecipes.instance().getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("2")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java index 50918e234..656aa0f03 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/compactmachines/Miniaturization.java @@ -3,23 +3,24 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import it.unimi.dsi.fastutil.chars.Char2ObjectOpenHashMap; import net.minecraft.block.state.IBlockState; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import org.dave.compactmachines3.miniaturization.MultiblockRecipe; import org.dave.compactmachines3.miniaturization.MultiblockRecipes; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Miniaturization extends VirtualizedRegistry { +public class Miniaturization extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".name('diamond_rectangle').input(item('minecraft:clay')).output(item('minecraft:clay')).symmetrical().ticks(10).shape([['www', 'www']]).key('w', blockstate('minecraft:diamond_block'))"), @@ -30,26 +31,15 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> MultiblockRecipes.getRecipes().removeIf(r -> r == recipe)); - restoreFromBackup().forEach(recipe -> MultiblockRecipes.getRecipes().add(recipe)); - } - - public void add(org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe) { - addScripted(recipe); - MultiblockRecipes.getRecipes().add(recipe); - } - - public boolean remove(org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe) { - addBackup(recipe); - return MultiblockRecipes.getRecipes().removeIf(r -> r == recipe); + public Collection getRecipes() { + return MultiblockRecipes.getRecipes(); } @MethodDescription(example = @Example("item('minecraft:ender_pearl')")) public void removeByInput(ItemStack input) { - for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : MultiblockRecipes.getRecipes().stream().filter(r -> r.getCatalystStack().isItemEqual(input)).collect(Collectors.toList())) { + for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : getRecipes().stream().filter(r -> r.getCatalystStack().isItemEqual(input)).collect(Collectors.toList())) { addBackup(recipe); - MultiblockRecipes.getRecipes().removeIf(r -> r == recipe); + getRecipes().removeIf(r -> r == recipe); } } @@ -60,23 +50,12 @@ public void removeByCatalyst(ItemStack catalyst) { @MethodDescription(example = @Example("item('compactmachines3:machine:3')")) public void removeByOutput(ItemStack output) { - for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : MultiblockRecipes.getRecipes().stream().filter(r -> r.getTargetStack().isItemEqual(output)).collect(Collectors.toList())) { + for (org.dave.compactmachines3.miniaturization.MultiblockRecipe recipe : getRecipes().stream().filter(r -> r.getTargetStack().isItemEqual(output)).collect(Collectors.toList())) { addBackup(recipe); - MultiblockRecipes.getRecipes().removeIf(r -> r == recipe); + getRecipes().removeIf(r -> r == recipe); } } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - MultiblockRecipes.getRecipes().forEach(this::addBackup); - MultiblockRecipes.getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(MultiblockRecipes.getRecipes()).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Dehydrator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Dehydrator.java index f21e6c1d9..6cd2f83a6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Dehydrator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Dehydrator.java @@ -1,20 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.cyclic; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.lothrazar.cyclicmagic.CyclicContent; import com.lothrazar.cyclicmagic.block.dehydrator.RecipeDeHydrate; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Dehydrator extends VirtualizedRegistry { +public class Dehydrator extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))"), @@ -30,28 +30,13 @@ public boolean isEnabled() { } @Override - @GroovyBlacklist - public void onReload() { - RecipeDeHydrate.recipes.removeAll(removeScripted()); - RecipeDeHydrate.recipes.addAll(restoreFromBackup()); - } - - public void add(RecipeDeHydrate recipe) { - if (recipe == null) return; - addScripted(recipe); - RecipeDeHydrate.recipes.add(recipe); - } - - public boolean remove(RecipeDeHydrate recipe) { - if (recipe == null) return false; - addBackup(recipe); - RecipeDeHydrate.recipes.remove(recipe); - return true; + public Collection getRecipes() { + return RecipeDeHydrate.recipes; } @MethodDescription(example = @Example("item('minecraft:clay')")) public boolean removeByInput(IIngredient input) { - return RecipeDeHydrate.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getRecipeInput())) { addBackup(recipe); return true; @@ -62,7 +47,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:deadbush')")) public boolean removeByOutput(IIngredient output) { - return RecipeDeHydrate.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getRecipeOutput())) { addBackup(recipe); return true; @@ -71,18 +56,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RecipeDeHydrate.recipes.forEach(this::addBackup); - RecipeDeHydrate.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RecipeDeHydrate.recipes) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Hydrator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Hydrator.java index b168ff275..c6228aaa4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Hydrator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Hydrator.java @@ -1,13 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.cyclic; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.collect.Lists; import com.lothrazar.cyclicmagic.CyclicContent; import com.lothrazar.cyclicmagic.block.hydrator.RecipeHydrate; @@ -15,11 +13,12 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Hydrator extends VirtualizedRegistry { +public class Hydrator extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))"), @@ -35,28 +34,13 @@ public boolean isEnabled() { } @Override - @GroovyBlacklist - public void onReload() { - RecipeHydrate.recipes.removeAll(removeScripted()); - RecipeHydrate.recipes.addAll(restoreFromBackup()); - } - - public void add(RecipeHydrate recipe) { - if (recipe == null) return; - addScripted(recipe); - RecipeHydrate.recipes.add(recipe); - } - - public boolean remove(RecipeHydrate recipe) { - if (recipe == null) return false; - addBackup(recipe); - RecipeHydrate.recipes.remove(recipe); - return true; + public Collection getRecipes() { + return RecipeHydrate.recipes; } @MethodDescription(example = @Example("item('minecraft:dirt')")) public boolean removeByInput(IIngredient input) { - return RecipeHydrate.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (recipe.getRecipeInput().stream().anyMatch(input)) { addBackup(recipe); return true; @@ -67,7 +51,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:clay_ball')")) public boolean removeByOutput(IIngredient output) { - return RecipeHydrate.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getRecipeOutput())) { addBackup(recipe); return true; @@ -76,18 +60,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RecipeHydrate.recipes.forEach(this::addBackup); - RecipeHydrate.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RecipeHydrate.recipes) - .setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "6")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Melter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Melter.java index 6532ce26d..a6db04e33 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Melter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Melter.java @@ -1,13 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.cyclic; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.collect.Lists; import com.lothrazar.cyclicmagic.CyclicContent; import com.lothrazar.cyclicmagic.block.melter.RecipeMelter; @@ -15,11 +13,12 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Melter extends VirtualizedRegistry { +public class Melter extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:gold_ingot')).fluidOutput(fluid('water') * 175)"), @@ -35,28 +34,13 @@ public boolean isEnabled() { } @Override - @GroovyBlacklist - public void onReload() { - RecipeMelter.recipes.removeAll(removeScripted()); - RecipeMelter.recipes.addAll(restoreFromBackup()); - } - - public void add(RecipeMelter recipe) { - if (recipe == null) return; - addScripted(recipe); - RecipeMelter.recipes.add(recipe); - } - - public boolean remove(RecipeMelter recipe) { - if (recipe == null) return false; - addBackup(recipe); - RecipeMelter.recipes.remove(recipe); - return true; + public Collection getRecipes() { + return RecipeMelter.recipes; } @MethodDescription(example = @Example("item('minecraft:snow')")) public boolean removeByInput(IIngredient input) { - return RecipeMelter.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (recipe.getRecipeInput().stream().anyMatch(input)) { addBackup(recipe); return true; @@ -67,7 +51,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("fluid('amber')")) public boolean removeByOutput(IIngredient output) { - return RecipeMelter.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutputFluid())) { addBackup(recipe); return true; @@ -76,18 +60,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RecipeMelter.recipes.forEach(this::addBackup); - RecipeMelter.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RecipeMelter.recipes) - .setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "4")}) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Packager.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Packager.java index 92dcc1a0b..966eba91b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Packager.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Packager.java @@ -1,13 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.cyclic; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.collect.Lists; import com.lothrazar.cyclicmagic.CyclicContent; import com.lothrazar.cyclicmagic.block.packager.RecipePackager; @@ -15,11 +13,12 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Packager extends VirtualizedRegistry { +public class Packager extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay'))"), @@ -35,28 +34,13 @@ public boolean isEnabled() { } @Override - @GroovyBlacklist - public void onReload() { - RecipePackager.recipes.removeAll(removeScripted()); - RecipePackager.recipes.addAll(restoreFromBackup()); - } - - public void add(RecipePackager recipe) { - if (recipe == null) return; - addScripted(recipe); - RecipePackager.recipes.add(recipe); - } - - public boolean remove(RecipePackager recipe) { - if (recipe == null) return false; - addBackup(recipe); - RecipePackager.recipes.remove(recipe); - return true; + public Collection getRecipes() { + return RecipePackager.recipes; } @MethodDescription(example = @Example("item('minecraft:grass')")) public boolean removeByInput(IIngredient input) { - return RecipePackager.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (recipe.getInput().stream().anyMatch(input)) { addBackup(recipe); return true; @@ -67,7 +51,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:melon_block')")) public boolean removeByOutput(IIngredient output) { - return RecipePackager.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getRecipeOutput())) { addBackup(recipe); return true; @@ -76,18 +60,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RecipePackager.recipes.forEach(this::addBackup); - RecipePackager.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RecipePackager.recipes) - .setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "6")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Solidifier.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Solidifier.java index f4f809a4b..f8429f814 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Solidifier.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/cyclic/Solidifier.java @@ -1,13 +1,11 @@ package com.cleanroommc.groovyscript.compat.mods.cyclic; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.collect.Lists; import com.lothrazar.cyclicmagic.CyclicContent; import com.lothrazar.cyclicmagic.block.solidifier.RecipeSolidifier; @@ -15,11 +13,12 @@ import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Solidifier extends VirtualizedRegistry { +public class Solidifier extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).fluidInput(fluid('water') * 175).output(item('minecraft:gold_ingot') * 3)"), @@ -35,28 +34,13 @@ public boolean isEnabled() { } @Override - @GroovyBlacklist - public void onReload() { - RecipeSolidifier.recipes.removeAll(removeScripted()); - RecipeSolidifier.recipes.addAll(restoreFromBackup()); - } - - public void add(RecipeSolidifier recipe) { - if (recipe == null) return; - addScripted(recipe); - RecipeSolidifier.recipes.add(recipe); - } - - public boolean remove(RecipeSolidifier recipe) { - if (recipe == null) return false; - addBackup(recipe); - RecipeSolidifier.recipes.remove(recipe); - return true; + public Collection getRecipes() { + return RecipeSolidifier.recipes; } @MethodDescription(example = {@Example("item('minecraft:bucket')"), @Example("fluid('water')"),}) public boolean removeByInput(IIngredient input) { - return RecipeSolidifier.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getFluidIngredient()) || recipe.getRecipeInput().stream().anyMatch(input)) { addBackup(recipe); return true; @@ -67,7 +51,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('cyclicmagic:crystallized_obsidian')")) public boolean removeByOutput(IIngredient output) { - return RecipeSolidifier.recipes.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getRecipeOutput())) { addBackup(recipe); return true; @@ -76,18 +60,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RecipeSolidifier.recipes.forEach(this::addBackup); - RecipeSolidifier.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RecipeSolidifier.recipes) - .setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "4")}) @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java index 7a4116c8a..8d3c26e53 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMill.java @@ -1,6 +1,5 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; @@ -8,9 +7,8 @@ import com.cleanroommc.groovyscript.compat.mods.enderio.recipe.RecipeInput; import com.cleanroommc.groovyscript.compat.mods.enderio.recipe.SagRecipe; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import crazypants.enderio.base.recipe.Recipe; import crazypants.enderio.base.recipe.RecipeBonusType; import crazypants.enderio.base.recipe.RecipeLevel; @@ -21,13 +19,20 @@ import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class SagMill extends VirtualizedRegistry { +public class SagMill extends StandardListRegistry { public SagMill() { super(Alias.generateOfClassAnd(SagMill.class, "Sag").and("SAGMill")); } + @Override + public Collection getRecipes() { + return SagMillRecipeManager.getInstance().getRecipes(); + } + @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond_block')).output(item('minecraft:diamond') * 4).output(item('minecraft:clay_ball') * 2, 0.7).output(item('minecraft:gold_ingot'), 0.1).output(item('minecraft:gold_ingot'), 0.1).bonusTypeMultiply().energy(1000).tierEnhanced()"), @Example(".input(item('minecraft:clay_ball')).output(item('minecraft:diamond') * 4).output(item('minecraft:gold_ingot'), 0.1).bonusTypeChance().tierNormal()"), @@ -38,48 +43,17 @@ public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - public void add(Recipe recipe) { - SagMillRecipeManager.getInstance().addRecipe(recipe); - addScripted(recipe); - } - - public boolean remove(Recipe recipe) { - if (recipe == null) return false; - SagMillRecipeManager.getInstance().getRecipes().remove(recipe); - addBackup(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:wheat')")) public void removeByInput(ItemStack input) { Recipe recipe = (Recipe) SagMillRecipeManager.getInstance().getRecipeForInput(RecipeLevel.IGNORE, input); if (recipe == null) { GroovyLog.get().error("Can't find EnderIO Sag Mill recipe for input " + input); } else { - SagMillRecipeManager.getInstance().getRecipes().remove(recipe); + getRecipes().remove(recipe); addBackup(recipe); } } - @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(SagMillRecipeManager.getInstance().getRecipes()::remove); - restoreFromBackup().forEach(SagMillRecipeManager.getInstance().getRecipes()::add); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SagMillRecipeManager.getInstance().getRecipes()) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SagMillRecipeManager.getInstance().getRecipes().forEach(this::addBackup); - SagMillRecipeManager.getInstance().getRecipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "4")}) @Property(property = "energy", valid = @Comp(type = Comp.Type.GT, value = "0")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java index 0f5ce24a5..0acff50fb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SagMillGrinding.java @@ -1,46 +1,39 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.enderio.recipe.RecipeInput; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import crazypants.enderio.base.recipe.sagmill.GrindingBall; import crazypants.enderio.base.recipe.sagmill.SagMillRecipeManager; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class SagMillGrinding extends VirtualizedRegistry { +public class SagMillGrinding extends StandardListRegistry { public SagMillGrinding() { super(Alias.generateOfClassAnd(SagMillGrinding.class, "Grinding")); } + @Override + public Collection getRecipes() { + return SagMillRecipeManager.getInstance().getBalls(); + } + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay_ball')).chance(6.66).power(0.001).grinding(3.33).duration(10000)")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - public void add(GrindingBall recipe) { - SagMillRecipeManager.getInstance().addBall(recipe); - addScripted(recipe); - } - - public boolean remove(GrindingBall recipe) { - if (recipe == null) return false; - SagMillRecipeManager.getInstance().getBalls().remove(recipe); - addBackup(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:flint')")) public boolean remove(ItemStack grindingBall) { - for (GrindingBall ball : SagMillRecipeManager.getInstance().getBalls()) { + for (GrindingBall ball : getRecipes()) { if (ball.isInput(grindingBall)) { remove(ball); return true; @@ -49,25 +42,6 @@ public boolean remove(ItemStack grindingBall) { return false; } - @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(SagMillRecipeManager.getInstance().getBalls()::remove); - restoreFromBackup().forEach(SagMillRecipeManager.getInstance().getBalls()::add); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SagMillRecipeManager.getInstance().getBalls()) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SagMillRecipeManager.getInstance().getBalls().forEach(this::addBackup); - SagMillRecipeManager.getInstance().getBalls().clear(); - } - @Property(property = "input", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java index 0f68279e1..bb8d02e89 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/enderio/SliceNSplice.java @@ -1,6 +1,5 @@ package com.cleanroommc.groovyscript.compat.mods.enderio; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; @@ -9,28 +8,32 @@ import com.cleanroommc.groovyscript.compat.mods.enderio.recipe.RecipeInput; import com.cleanroommc.groovyscript.compat.mods.enderio.recipe.RecipeUtils; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import crazypants.enderio.base.recipe.*; -import crazypants.enderio.base.recipe.sagmill.SagMillRecipeManager; import crazypants.enderio.base.recipe.slicensplice.SliceAndSpliceRecipeManager; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collection; import java.util.Iterator; import java.util.List; @RegistryDescription -public class SliceNSplice extends VirtualizedRegistry { +public class SliceNSplice extends StandardListRegistry { public SliceNSplice() { super(Alias.generateOfClassAnd(SliceNSplice.class, "SliceAndSplice")); } + @Override + public Collection getRecipes() { + return SliceAndSpliceRecipeManager.getInstance().getRecipes(); + } + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay'), null, item('minecraft:clay')).input(null, item('minecraft:clay'), null).output(item('minecraft:gold_ingot')).energy(1000).xp(5)")) public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); @@ -45,28 +48,16 @@ public void add(ItemStack output, List input, int energy) { .register(); } - public void add(IManyToOneRecipe recipe) { - SliceAndSpliceRecipeManager.getInstance().addRecipe(recipe); - addScripted(recipe); - } - public void add(Recipe recipe) { BasicManyToOneRecipe r = new BasicManyToOneRecipe(recipe); SliceAndSpliceRecipeManager.getInstance().addRecipe(r); addScripted(r); } - public boolean remove(IManyToOneRecipe recipe) { - if (recipe == null) return false; - SagMillRecipeManager.getInstance().getRecipes().remove((Recipe) recipe); - addBackup(recipe); - return true; - } - @MethodDescription(description = "groovyscript.wiki.removeByOutput", example = @Example("item('enderio:item_material:40')")) public void remove(ItemStack output) { int count = 0; - Iterator iter = SliceAndSpliceRecipeManager.getInstance().getRecipes().iterator(); + Iterator iter = getRecipes().iterator(); while (iter.hasNext()) { IManyToOneRecipe recipe = iter.next(); if (OreDictionary.itemMatches(output, recipe.getOutput(), false)) { @@ -84,32 +75,13 @@ public void remove(ItemStack output) { public void removeByInput(List input) { IRecipe recipe = SliceAndSpliceRecipeManager.getInstance().getRecipeForInputs(RecipeLevel.IGNORE, RecipeUtils.getMachineInputs(input)); if (recipe instanceof IManyToOneRecipe) { - SliceAndSpliceRecipeManager.getInstance().getRecipes().remove(recipe); + getRecipes().remove(recipe); addBackup((IManyToOneRecipe) recipe); } else { GroovyLog.get().error("No EnderIO Slice'n'Splice recipe found for " + input); } } - @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(SliceAndSpliceRecipeManager.getInstance().getRecipes()::remove); - restoreFromBackup().forEach(SliceAndSpliceRecipeManager.getInstance().getRecipes()::add); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SliceAndSpliceRecipeManager.getInstance().getRecipes()) - .setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SliceAndSpliceRecipeManager.getInstance().getRecipes().forEach(this::addBackup); - SliceAndSpliceRecipeManager.getInstance().getRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "6")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java index 2394b6656..c4c17a08f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/MagicianTable.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import essentialcraft.api.MagicianTableRecipe; import essentialcraft.api.MagicianTableRecipes; import net.minecraft.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription(admonition = @Admonition(value = "groovyscript.wiki.essentialcraft.magician_table.note0", type = Admonition.Type.WARNING)) -public class MagicianTable extends VirtualizedRegistry { +public class MagicianTable extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('stickWood'), ore('stickWood')).output(item('minecraft:iron_ingot')).mru(500)")) public MagicianTable.RecipeBuilder recipeBuilder() { @@ -21,14 +22,13 @@ public MagicianTable.RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(MagicianTableRecipes::removeRecipe); - restoreFromBackup().forEach(MagicianTableRecipes::addRecipe); + public Collection getRecipes() { + return MagicianTableRecipes.RECIPES; } @MethodDescription(example = @Example("item('essentialcraft:genitem')")) public boolean removeByOutput(IIngredient x) { - return MagicianTableRecipes.RECIPES.removeIf(r -> { + return getRecipes().removeIf(r -> { if (x.test(r.getRecipeOutput())) { addBackup(r); return true; @@ -37,20 +37,6 @@ public boolean removeByOutput(IIngredient x) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - MagicianTableRecipes.RECIPES.forEach(this::addBackup); - MagicianTableRecipes.RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(MagicianTableRecipes.RECIPES).setRemover(r -> { - addBackup(r); - return MagicianTableRecipes.RECIPES.remove(r); - }); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "5", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java index 65974fd6c..0a2ceb768 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/RadiatingChamber.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import essentialcraft.api.RadiatingChamberRecipe; import essentialcraft.api.RadiatingChamberRecipes; import net.minecraft.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class RadiatingChamber extends VirtualizedRegistry { +public class RadiatingChamber extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:nether_star'), item('minecraft:stone')).output(item('minecraft:beacon')).time(100).mruPerTick(10.0f).upperBalance(1.5f).lowerBalance(0.25f)")) public RadiatingChamber.RecipeBuilder recipeBuilder() { @@ -21,14 +22,13 @@ public RadiatingChamber.RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(RadiatingChamberRecipes::removeRecipe); - restoreFromBackup().forEach(RadiatingChamberRecipes::addRecipe); + public Collection getRecipes() { + return RadiatingChamberRecipes.RECIPES; } @MethodDescription(example = @Example("item('essentialcraft:genitem', 42)")) public boolean removeByOutput(IIngredient x) { - return RadiatingChamberRecipes.RECIPES.removeIf(r -> { + return getRecipes().removeIf(r -> { if (x.test(r.getRecipeOutput())) { addBackup(r); return true; @@ -37,20 +37,6 @@ public boolean removeByOutput(IIngredient x) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RadiatingChamberRecipes.RECIPES.forEach(this::addBackup); - RadiatingChamberRecipes.RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RadiatingChamberRecipes.RECIPES).setRemover(r -> { - addBackup(r); - return RadiatingChamberRecipes.RECIPES.remove(r); - }); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "2", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java index 857dcf3e9..0c354981d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/essentialcraft/WindRune.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import essentialcraft.api.WindImbueRecipe; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class WindRune extends VirtualizedRegistry { +public class WindRune extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gold_block')).output(item('minecraft:diamond_block')).espe(500)")) public WindRune.RecipeBuilder recipeBuilder() { @@ -21,16 +22,15 @@ public WindRune.RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(WindImbueRecipe::removeRecipe); - WindImbueRecipe.RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return WindImbueRecipe.RECIPES; } @MethodDescription(example = @Example("item('minecraft:diamond')")) public boolean removeByInput(IIngredient x) { ItemStack[] stacks = x.getMatchingStacks(); if (stacks.length == 0) return false; - return WindImbueRecipe.RECIPES.removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.input.test(stacks[0])) { addBackup(r); return true; @@ -41,7 +41,7 @@ public boolean removeByInput(IIngredient x) { @MethodDescription(example = @Example("item('essentialcraft:air_potion')")) public boolean removeByOutput(IIngredient x) { - return WindImbueRecipe.RECIPES.removeIf(r -> { + return getRecipes().removeIf(r -> { if (x.test(r.result)) { addBackup(r); return true; @@ -50,20 +50,6 @@ public boolean removeByOutput(IIngredient x) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - WindImbueRecipe.RECIPES.forEach(this::addBackup); - WindImbueRecipe.RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(WindImbueRecipe.RECIPES).setRemover(r -> { - addBackup(r); - return WindImbueRecipe.RECIPES.remove(r); - }); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java index af5f6642a..99873254a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/BloodInfuser.java @@ -3,9 +3,8 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; @@ -18,8 +17,10 @@ import org.cyclops.evilcraft.core.recipe.custom.IngredientFluidStackAndTierRecipeComponent; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class BloodInfuser extends VirtualizedRegistry> { +public class BloodInfuser extends StandardListRegistry> { @Override public boolean isEnabled() { @@ -36,31 +37,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()::add); - } - - public void add(IRecipe recipe) { - this.add(recipe, true); - } - - public void add(IRecipe recipe, boolean add) { - if (recipe == null) return; - addScripted(recipe); - if (add) org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().add(recipe); - } - - public boolean remove(IRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().remove(recipe); - return true; + public Collection> getRecipes() { + return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes(); } @MethodDescription(example = @Example("item('evilcraft:dark_gem')")) public boolean removeByInput(ItemStack input) { - return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().getIngredient().test(input)) { addBackup(r); return true; @@ -71,7 +54,7 @@ public boolean removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('minecraft:leather')")) public boolean removeByOutput(ItemStack input) { - return org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().getIngredient().test(input)) { addBackup(r); return true; @@ -80,18 +63,6 @@ public boolean removeByOutput(ItemStack input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); - org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(org.cyclops.evilcraft.block.BloodInfuser.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) @@ -160,7 +131,7 @@ public void validate(GroovyLog.Msg msg) { new IngredientRecipeComponent(output.get(0)), new DurationXpRecipeProperties(duration, xp) ); - ModSupport.EVILCRAFT.get().bloodInfuser.add(recipe, false); + ModSupport.EVILCRAFT.get().bloodInfuser.addScripted(recipe); return recipe; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java index 916926f9f..2bc8dab32 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/evilcraft/EnvironmentalAccumulator.java @@ -3,9 +3,8 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.evilcraft.Configs; @@ -15,10 +14,11 @@ import org.cyclops.evilcraft.core.weather.WeatherType; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.Locale; @RegistryDescription -public class EnvironmentalAccumulator extends VirtualizedRegistry> { +public class EnvironmentalAccumulator extends StandardListRegistry> { @Override public boolean isEnabled() { @@ -35,31 +35,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes()::add); - } - - public void add(IRecipe recipe) { - this.add(recipe, true); - } - - public void add(IRecipe recipe, boolean add) { - if (recipe == null) return; - addScripted(recipe); - if (add) org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().add(recipe); - } - - public boolean remove(IRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().remove(recipe); - return true; + public Collection> getRecipes() { + return org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes(); } @MethodDescription(example = @Example("item('evilcraft:exalted_crafter:1')")) public boolean removeByInput(ItemStack input) { - return org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().getIngredient().test(input)) { addBackup(r); return true; @@ -70,7 +52,7 @@ public boolean removeByInput(ItemStack input) { @MethodDescription(example = @Example("item('evilcraft:exalted_crafter:2')")) public boolean removeByOutput(ItemStack input) { - return org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().getIngredient().test(input)) { addBackup(r); return true; @@ -79,18 +61,6 @@ public boolean removeByOutput(ItemStack input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); - org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(org.cyclops.evilcraft.block.EnvironmentalAccumulator.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder> { @@ -186,7 +156,7 @@ public void validate(GroovyLog.Msg msg) { new EnvironmentalAccumulatorRecipeComponent(output.get(0), outputWeather), new EnvironmentalAccumulatorRecipeProperties(duration, cooldowntime, processingspeed) ); - ModSupport.EVILCRAFT.get().environmentalAccumulator.add(recipe, false); + ModSupport.EVILCRAFT.get().environmentalAccumulator.addScripted(recipe); return recipe; } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java index df76efd1e..d7c5c21ec 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CombinationCrafting.java @@ -8,10 +8,9 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.NonNullList; @@ -22,24 +21,15 @@ @RegistryDescription( admonition = @Admonition(value = "groovyscript.wiki.extendedcrafting.combination_crafting.note0", type = Admonition.Type.INFO, format = Admonition.Format.STANDARD) ) -public class CombinationCrafting extends VirtualizedRegistry { +public class CombinationCrafting extends StandardListRegistry { public CombinationCrafting() { super(Alias.generateOfClassAnd(CombinationCrafting.class, "Combination")); } @Override - public void onReload() { - removeScripted().forEach(recipe -> CombinationRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)); - CombinationRecipeManager.getInstance().getRecipes().addAll(restoreFromBackup()); - } - - public CombinationRecipe add(CombinationRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - CombinationRecipeManager.getInstance().getRecipes().add(recipe); - } - return recipe; + public Collection getRecipes() { + return CombinationRecipeManager.getInstance().getRecipes(); } @MethodDescription(description = "groovyscript.wiki.extendedcrafting.combination_crafting.add0", type = MethodDescription.Type.ADDITION) @@ -49,12 +39,14 @@ public CombinationRecipe add(ItemStack output, long cost, Ingredient input, NonN @MethodDescription(description = "groovyscript.wiki.extendedcrafting.combination_crafting.add1", type = MethodDescription.Type.ADDITION) public CombinationRecipe add(ItemStack output, long cost, int perTick, Ingredient input, NonNullList pedestals) { - return add(new CombinationRecipe(output, cost, perTick, input, pedestals)); + CombinationRecipe recipe = new CombinationRecipe(output, cost, perTick, input, pedestals); + add(recipe); + return recipe; } @MethodDescription(example = @Example(value = "item('minecraft:gold_ingot')", commented = true)) public boolean removeByOutput(ItemStack output) { - return CombinationRecipeManager.getInstance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().equals(output)) { addBackup(r); return true; @@ -65,7 +57,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example(value = "item('minecraft:pumpkin')", commented = true)) public boolean removeByInput(ItemStack input) { - return CombinationRecipeManager.getInstance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().equals(input)) { addBackup(r); return true; @@ -79,27 +71,6 @@ public boolean removeByInput(IIngredient input) { return removeByInput(IngredientHelper.toItemStack(input)); } - public boolean remove(CombinationRecipe recipe) { - if (CombinationRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CombinationRecipeManager.getInstance().getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - CombinationRecipeManager.getInstance().getRecipes().forEach(this::addBackup); - CombinationRecipeManager.getInstance().getRecipes().clear(); - } - - @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:pumpkin')).pedestals(item('minecraft:pumpkin') * 8).output(item('minecraft:diamond') * 2).cost(100).perTick(100)"), @Example(".input(item('minecraft:pumpkin')).pedestals(item('minecraft:pumpkin'), item('minecraft:clay'), item('minecraft:clay'), item('minecraft:pumpkin')).output(item('minecraft:gold_ingot') * 2).cost(10000)") diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java index 32f94d3a9..7b2a0eb8e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/CompressionCrafting.java @@ -9,32 +9,24 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class CompressionCrafting extends VirtualizedRegistry { +public class CompressionCrafting extends StandardListRegistry { public CompressionCrafting() { super(Alias.generateOfClassAnd(CompressionCrafting.class, "Compression")); } @Override - public void onReload() { - removeScripted().forEach(recipe -> CompressorRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)); - CompressorRecipeManager.getInstance().getRecipes().addAll(restoreFromBackup()); - } - - public CompressorRecipe add(CompressorRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - CompressorRecipeManager.getInstance().getRecipes().add(recipe); - } - return recipe; + public Collection getRecipes() { + return CompressorRecipeManager.getInstance().getRecipes(); } @MethodDescription(description = "groovyscript.wiki.extendedcrafting.compression_crafting.add0", type = MethodDescription.Type.ADDITION) @@ -44,12 +36,14 @@ public CompressorRecipe add(ItemStack output, IIngredient input, int inputCount, @MethodDescription(description = "groovyscript.wiki.extendedcrafting.compression_crafting.add1", type = MethodDescription.Type.ADDITION) public CompressorRecipe add(ItemStack output, IIngredient input, int inputCount, IIngredient catalyst, boolean consumeCatalyst, int powerCost, int powerRate) { - return add(new CompressorRecipe(output, input.toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, powerCost, powerRate)); + CompressorRecipe recipe = new CompressorRecipe(output, input.toMcIngredient(), inputCount, catalyst.toMcIngredient(), consumeCatalyst, powerCost, powerRate); + add(recipe); + return recipe; } @MethodDescription(example = @Example("item('extendedcrafting:singularity:6')")) public boolean removeByOutput(ItemStack output) { - return CompressorRecipeManager.getInstance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().equals(output)) { addBackup(r); return true; @@ -60,7 +54,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('extendedcrafting:material:11')")) public boolean removeByCatalyst(IIngredient catalyst) { - return CompressorRecipeManager.getInstance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getCatalyst().equals(catalyst.toMcIngredient())) { addBackup(r); return true; @@ -71,7 +65,7 @@ public boolean removeByCatalyst(IIngredient catalyst) { @MethodDescription(example = @Example("item('minecraft:gold_ingot')")) public boolean removeByInput(IIngredient input) { - return CompressorRecipeManager.getInstance().getRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().equals(input.toMcIngredient())) { addBackup(r); return true; @@ -80,25 +74,6 @@ public boolean removeByInput(IIngredient input) { }); } - public boolean remove(CompressorRecipe recipe) { - if (CompressorRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CompressorRecipeManager.getInstance().getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - CompressorRecipeManager.getInstance().getRecipes().forEach(this::addBackup); - CompressorRecipeManager.getInstance().getRecipes().clear(); - } - @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).inputCount(100).output(item('minecraft:gold_ingot') * 7).catalyst(item('minecraft:diamond')).consumeCatalyst(true).powerCost(10000).powerRate(1000)"), @Example(".input(item('minecraft:clay') * 10).output(item('minecraft:diamond') * 2).powerCost(1000)") diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java index 072974410..93e6793c1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/EnderCrafting.java @@ -7,15 +7,15 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; +import java.util.Collection; import java.util.List; @RegistryDescription -public class EnderCrafting extends VirtualizedRegistry { +public class EnderCrafting extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".output(item('minecraft:stone')).matrix('BXX', 'X B').key('B', item('minecraft:stone')).key('X', item('minecraft:gold_ingot')).time(1).mirrored()"), @@ -34,9 +34,8 @@ public EnderRecipeBuilder.Shapeless shapelessBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> EnderCrafterRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)); - EnderCrafterRecipeManager.getInstance().getRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return EnderCrafterRecipeManager.getInstance().getRecipes(); } @MethodDescription(description = "groovyscript.wiki.extendedcrafting.ender_crafting.addShaped0", type = MethodDescription.Type.ADDITION) @@ -67,17 +66,9 @@ public IRecipe addShapeless(int time, ItemStack output, List input) .register(); } - public IRecipe add(IRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - EnderCrafterRecipeManager.getInstance().getRecipes().add(recipe); - } - return recipe; - } - @MethodDescription(example = @Example("item('extendedcrafting:material:40')")) public boolean removeByOutput(ItemStack stack) { - return EnderCrafterRecipeManager.getInstance().getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (recipe != null && recipe.getRecipeOutput().isItemEqual(stack)) { addBackup(recipe); return true; @@ -86,22 +77,4 @@ public boolean removeByOutput(ItemStack stack) { }); } - public boolean remove(IRecipe recipe) { - if (EnderCrafterRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(EnderCrafterRecipeManager.getInstance().getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - EnderCrafterRecipeManager.getInstance().getRecipes().forEach(this::addBackup); - EnderCrafterRecipeManager.getInstance().getRecipes().clear(); - } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java index 4ce63b432..ebdf85daa 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extendedcrafting/TableCrafting.java @@ -7,14 +7,14 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; +import java.util.Collection; import java.util.List; @RegistryDescription -public class TableCrafting extends VirtualizedRegistry { +public class TableCrafting extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".output(item('minecraft:stone') * 64).matrix('DLLLLLDDD', ' DNIGIND', 'DDDNIGIND', ' DLLLLLD').key('D', item('minecraft:diamond')).key('L', item('minecraft:redstone')).key('N', item('minecraft:stone')).key('I', item('minecraft:iron_ingot')).key('G', item('minecraft:gold_ingot')).tierUltimate()"), @@ -33,9 +33,8 @@ public TableRecipeBuilder.Shapeless shapelessBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> TableRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)); - TableRecipeManager.getInstance().getRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return TableRecipeManager.getInstance().getRecipes(); } @MethodDescription(description = "groovyscript.wiki.extendedcrafting.table_crafting.addShaped0", type = MethodDescription.Type.ADDITION) @@ -66,17 +65,9 @@ public ITieredRecipe addShapeless(int tier, ItemStack output, List .register(); } - public ITieredRecipe add(ITieredRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - TableRecipeManager.getInstance().getRecipes().add(recipe); - } - return recipe; - } - @MethodDescription(example = @Example("item('extendedcrafting:singularity_ultimate')")) public boolean removeByOutput(ItemStack stack) { - return TableRecipeManager.getInstance().getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (recipe != null && recipe.getRecipeOutput().isItemEqual(stack)) { addBackup(recipe); return true; @@ -85,22 +76,4 @@ public boolean removeByOutput(ItemStack stack) { }); } - public boolean remove(ITieredRecipe recipe) { - if (TableRecipeManager.getInstance().getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TableRecipeManager.getInstance().getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TableRecipeManager.getInstance().getRecipes().forEach(this::addBackup); - TableRecipeManager.getInstance().getRecipes().clear(); - } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrabotany/Pedestal.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrabotany/Pedestal.java index 601f0b19a..7381aec2a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrabotany/Pedestal.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrabotany/Pedestal.java @@ -4,21 +4,21 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.meteor.extrabotany.api.ExtraBotanyAPI; import com.meteor.extrabotany.common.crafting.recipe.RecipePedestal; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Pedestal extends VirtualizedRegistry { +public class Pedestal extends StandardListRegistry { @Override - public void onReload() { - ExtraBotanyAPI.pedestalRecipes.removeAll(removeScripted()); - ExtraBotanyAPI.pedestalRecipes.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ExtraBotanyAPI.pedestalRecipes; } @RecipeBuilderDescription(example = { @@ -34,25 +34,9 @@ public RecipePedestal add(IIngredient input, ItemStack output) { return recipeBuilder().input(input).output(output).register(); } - public RecipePedestal add(RecipePedestal recipe) { - if (recipe != null) { - addScripted(recipe); - ExtraBotanyAPI.pedestalRecipes.add(recipe); - } - return recipe; - } - - public boolean remove(RecipePedestal recipe) { - if (ExtraBotanyAPI.pedestalRecipes.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:cobblestone')")) public boolean removeByInput(IIngredient input) { - return ExtraBotanyAPI.pedestalRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (input.test(r.getInput())) { addBackup(r); return true; @@ -63,7 +47,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:flint')")) public boolean removeByOutput(IIngredient output) { - return ExtraBotanyAPI.pedestalRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -72,17 +56,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExtraBotanyAPI.pedestalRecipes).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ExtraBotanyAPI.pedestalRecipes.forEach(this::addBackup); - ExtraBotanyAPI.pedestalRecipes.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java index d9848e611..3d0d8163d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/extrautils2/Resonator.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.cleanroommc.groovyscript.sandbox.ClosureHelper; import com.rwtema.extrautils2.api.resonator.IResonatorRecipe; import com.rwtema.extrautils2.crafting.ResonatorRecipe; @@ -25,25 +24,16 @@ import java.util.Collection; @RegistryDescription -public class Resonator extends VirtualizedRegistry { +public class Resonator extends StandardListRegistry { @Override - public void onReload() { - removeScripted().forEach(recipe -> TileResonator.resonatorRecipes.removeIf(r -> r == recipe)); - TileResonator.resonatorRecipes.addAll(restoreFromBackup()); - } - - public IResonatorRecipe add(IResonatorRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - TileResonator.resonatorRecipes.add(recipe); - } - return recipe; + public Collection getRecipes() { + return TileResonator.resonatorRecipes; } @MethodDescription(example = @Example("item('extrautils2:ingredients:4')")) public boolean removeByOutput(ItemStack output) { - return TileResonator.resonatorRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (ItemHandlerHelper.canItemStacksStack(r.getOutput(), output)) { addBackup(r); return true; @@ -54,7 +44,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example("item('minecraft:quartz_block')")) public boolean removeByInput(IIngredient input) { - return TileResonator.resonatorRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (input.test(r.getInputs().get(0))) { addBackup(r); return true; @@ -63,25 +53,6 @@ public boolean removeByInput(IIngredient input) { }); } - public boolean remove(IResonatorRecipe recipe) { - if (TileResonator.resonatorRecipes.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TileResonator.resonatorRecipes).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TileResonator.resonatorRecipes.forEach(this::addBackup); - TileResonator.resonatorRecipes.clear(); - } - @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:gold_ingot')).output(item('minecraft:clay')).rainbow().energy(1000)"), @Example(".input(item('minecraft:gold_block')).output(item('minecraft:clay') * 5).energy(100)"), diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java index 24eee8d9e..f4b2d2f7b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/AlloyKiln.java @@ -1,23 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; import blusunrize.immersiveengineering.api.crafting.AlloyRecipe; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; @RegistryDescription -public class AlloyKiln extends VirtualizedRegistry { +public class AlloyKiln extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), ore('ingotGold')).output(item('minecraft:clay'))")) public RecipeBuilder recipeBuilder() { @@ -25,18 +23,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(recipe -> AlloyRecipe.recipeList.removeIf(r -> r == recipe)); - AlloyRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(AlloyRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - AlloyRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return AlloyRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -46,14 +34,6 @@ public AlloyRecipe add(ItemStack output, IIngredient input0, IIngredient input1, return recipe; } - public boolean remove(AlloyRecipe recipe) { - if (AlloyRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('immersiveengineering:metal:6')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { @@ -93,17 +73,6 @@ public void removeByInput(ItemStack input, ItemStack input1) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(AlloyRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - AlloyRecipe.recipeList.forEach(this::addBackup); - AlloyRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java index b2506e697..b6bb3fe8e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/ArcFurnace.java @@ -1,28 +1,26 @@ package com.cleanroommc.groovyscript.compat.mods.immersiveengineering; import blusunrize.immersiveengineering.api.crafting.ArcFurnaceRecipe; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ArrayUtils; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class ArcFurnace extends VirtualizedRegistry { +public class ArcFurnace extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".mainInput(item('minecraft:diamond')).input(item('minecraft:diamond'), ore('ingotGold')).output(item('minecraft:clay')).time(100).energyPerTick(100).slag(item('minecraft:gold_nugget'))")) public RecipeBuilder recipeBuilder() { @@ -30,18 +28,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(r -> ArcFurnaceRecipe.recipeList.removeIf(recipe -> recipe == r)); - ArcFurnaceRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(ArcFurnaceRecipe recipe) { - if (recipe != null) { - ArcFurnaceRecipe.recipeList.add(recipe); - addScripted(recipe); - } + public Collection getRecipes() { + return ArcFurnaceRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -52,14 +40,6 @@ public ArcFurnaceRecipe add(ItemStack output, IIngredient input, List r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('immersiveengineering:metal:7')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { @@ -69,7 +49,7 @@ public void removeByOutput(ItemStack output) { .post(); return; } - List recipes = ArcFurnaceRecipe.recipeList.stream().filter(r -> r.output != null && r.output.isItemEqual(output)).collect(Collectors.toList()); + List recipes = getRecipes().stream().filter(r -> r.output != null && r.output.isItemEqual(output)).collect(Collectors.toList()); for (ArcFurnaceRecipe recipe : recipes) { remove(recipe); } @@ -90,7 +70,7 @@ public void removeByInput(IIngredient main, List inputAndAdditives) .post(); return; } - List recipes = ArcFurnaceRecipe.recipeList.stream() + List recipes = getRecipes().stream() .filter(r -> ImmersiveEngineering.areIngredientsEquals(r.input, main) && (inputAndAdditives.stream().anyMatch(check -> Arrays.stream(r.additives).anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, check))))) .collect(Collectors.toList()); @@ -123,17 +103,6 @@ public void removeByInput(IIngredient... inputAndAdditives) { removeByInput(new ArrayList<>(Arrays.asList(inputAndAdditives))); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ArcFurnaceRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ArcFurnaceRecipe.recipeList.forEach(this::addBackup); - ArcFurnaceRecipe.recipeList.clear(); - } - @Property(property = "input", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "5", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java index 31f3240b0..716562af3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnace.java @@ -5,18 +5,18 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; +import java.util.Collection; import java.util.List; @RegistryDescription -public class BlastFurnace extends VirtualizedRegistry { +public class BlastFurnace extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).time(100).slag(item('minecraft:gold_nugget'))")) public static RecipeBuilder recipeBuilder() { @@ -24,16 +24,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> BlastFurnaceRecipe.recipeList.removeIf(r -> r == recipe)); - BlastFurnaceRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(BlastFurnaceRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BlastFurnaceRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return BlastFurnaceRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -43,14 +35,6 @@ public BlastFurnaceRecipe add(ItemStack output, IIngredient input, int time, @No return recipe; } - public boolean remove(BlastFurnaceRecipe recipe) { - if (BlastFurnaceRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('immersiveengineering:metal:8')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { @@ -91,17 +75,6 @@ public void removeByInput(ItemStack input) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BlastFurnaceRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BlastFurnaceRecipe.recipeList.forEach(this::addBackup); - BlastFurnaceRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java index f2a871596..4bdb7ffe6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BlastFurnaceFuel.java @@ -5,18 +5,18 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class BlastFurnaceFuel extends VirtualizedRegistry { +public class BlastFurnaceFuel extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).time(100)")) public static RecipeBuilder recipeBuilder() { @@ -24,16 +24,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> BlastFurnaceRecipe.blastFuels.removeIf(r -> r == recipe)); - BlastFurnaceRecipe.blastFuels.addAll(restoreFromBackup()); - } - - public void add(BlastFurnaceRecipe.BlastFurnaceFuel recipe) { - if (recipe != null) { - addScripted(recipe); - BlastFurnaceRecipe.blastFuels.add(recipe); - } + public Collection getRecipes() { + return BlastFurnaceRecipe.blastFuels; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -43,14 +35,6 @@ public BlastFurnaceRecipe.BlastFurnaceFuel add(IIngredient input, int time) { return recipe; } - public boolean remove(BlastFurnaceRecipe.BlastFurnaceFuel recipe) { - if (BlastFurnaceRecipe.blastFuels.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('immersiveengineering:material:6')")) public void removeByInput(ItemStack input) { if (IngredientHelper.isEmpty(input)) { @@ -60,7 +44,7 @@ public void removeByInput(ItemStack input) { .post(); return; } - List recipes = BlastFurnaceRecipe.blastFuels.stream().filter(r -> r.input.matches(input)).collect(Collectors.toList()); + List recipes = getRecipes().stream().filter(r -> r.input.matches(input)).collect(Collectors.toList()); for (BlastFurnaceRecipe.BlastFurnaceFuel recipe : recipes) { remove(recipe); } @@ -72,17 +56,6 @@ public void removeByInput(ItemStack input) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BlastFurnaceRecipe.blastFuels).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BlastFurnaceRecipe.blastFuels.forEach(this::addBackup); - BlastFurnaceRecipe.blastFuels.clear(); - } - @Property(property = "input", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java index a3f9151b8..6af981008 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/BottlingMachine.java @@ -7,40 +7,32 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class BottlingMachine extends VirtualizedRegistry { +public class BottlingMachine extends StandardListRegistry { public BottlingMachine() { super(Alias.generateOfClassAnd(BottlingMachine.class, "Bottling")); } - @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).fluidInput(fluid('water')).output(item('minecraft:clay'))")) - public static RecipeBuilder recipeBuilder() { - return new RecipeBuilder(); - } - @Override - public void onReload() { - removeScripted().forEach(recipe -> BottlingMachineRecipe.recipeList.removeIf(r -> r == recipe)); - BottlingMachineRecipe.recipeList.addAll(restoreFromBackup()); + public Collection getRecipes() { + return BottlingMachineRecipe.recipeList; } - public void add(BottlingMachineRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BottlingMachineRecipe.recipeList.add(recipe); - } + @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).fluidInput(fluid('water')).output(item('minecraft:clay'))")) + public static RecipeBuilder recipeBuilder() { + return new RecipeBuilder(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -50,14 +42,6 @@ public BottlingMachineRecipe add(ItemStack output, IIngredient input, FluidStack return recipe; } - public boolean remove(BottlingMachineRecipe recipe) { - if (BottlingMachineRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:potion').withNbt([Potion:'minecraft:mundane'])")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { @@ -67,7 +51,7 @@ public void removeByOutput(ItemStack output) { .post(); return; } - if (!BottlingMachineRecipe.recipeList.removeIf(recipe -> { + if (!getRecipes().removeIf(recipe -> { if (ApiUtils.stackMatchesObject(output, recipe.output, true)) { addBackup(recipe); return true; @@ -90,7 +74,7 @@ public void removeByInput(ItemStack input, FluidStack inputFluid) { .postIfNotEmpty()) { return; } - List recipes = BottlingMachineRecipe.recipeList.stream().filter(r -> ApiUtils.stackMatchesObject(input, r.input) && inputFluid.isFluidEqual(r.fluidInput)).collect(Collectors.toList()); + List recipes = getRecipes().stream().filter(r -> ApiUtils.stackMatchesObject(input, r.input) && inputFluid.isFluidEqual(r.fluidInput)).collect(Collectors.toList()); for (BottlingMachineRecipe recipe : recipes) { remove(recipe); } @@ -102,17 +86,6 @@ public void removeByInput(ItemStack input, FluidStack inputFluid) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BottlingMachineRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BottlingMachineRecipe.recipeList.forEach(this::addBackup); - BottlingMachineRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java index 07e46325d..4c1a067ab 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/CokeOven.java @@ -6,17 +6,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; @RegistryDescription -public class CokeOven extends VirtualizedRegistry { +public class CokeOven extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).time(100).creosote(50)")) public static RecipeBuilder recipeBuilder() { @@ -24,16 +24,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> CokeOvenRecipe.recipeList.removeIf(r -> r == recipe)); - CokeOvenRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(CokeOvenRecipe recipe) { - if (recipe != null) { - CokeOvenRecipe.recipeList.add(recipe); - addScripted(recipe); - } + public Collection getRecipes() { + return CokeOvenRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -43,14 +35,6 @@ public CokeOvenRecipe add(ItemStack output, IIngredient input, int time, int cre return recipe; } - public boolean remove(CokeOvenRecipe recipe) { - if (CokeOvenRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('immersiveengineering:material:6')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { @@ -80,7 +64,7 @@ public void removeByInput(ItemStack input) { .post(); return; } - if (!CokeOvenRecipe.recipeList.removeIf(recipe -> { + if (!getRecipes().removeIf(recipe -> { if (ApiUtils.stackMatchesObject(input, recipe.input)) { addBackup(recipe); return true; @@ -94,17 +78,6 @@ public void removeByInput(ItemStack input) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CokeOvenRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - CokeOvenRecipe.recipeList.forEach(this::addBackup); - CokeOvenRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java index a3875d24f..004b0ac1b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Crusher.java @@ -5,19 +5,19 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import it.unimi.dsi.fastutil.floats.FloatArrayList; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collection; import java.util.List; @RegistryDescription -public class Crusher extends VirtualizedRegistry { +public class Crusher extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).energy(100)"), @@ -28,16 +28,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> CrusherRecipe.recipeList.removeIf(r -> r == recipe)); - CrusherRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(CrusherRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - CrusherRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return CrusherRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -47,14 +39,6 @@ public CrusherRecipe add(ItemStack output, IIngredient input, int energy) { return recipe; } - public boolean remove(CrusherRecipe recipe) { - if (CrusherRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:sand')")) public void removeByOutput(ItemStack output) { if (IngredientHelper.isEmpty(output)) { @@ -93,17 +77,6 @@ public void removeByInput(ItemStack input) { list.forEach(this::addBackup); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CrusherRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - CrusherRecipe.recipeList.forEach(this::addBackup); - CrusherRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java index 60305b379..98390e815 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Fermenter.java @@ -5,18 +5,18 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; +import java.util.Collection; @RegistryDescription -public class Fermenter extends VirtualizedRegistry { +public class Fermenter extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidOutput(fluid('water')).energy(100)")) public static RecipeBuilder recipeBuilder() { @@ -24,16 +24,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> FermenterRecipe.recipeList.removeIf(r -> r == recipe)); - FermenterRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(FermenterRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - FermenterRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return FermenterRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -43,14 +35,6 @@ public FermenterRecipe add(FluidStack fluidOutput, @Nonnull ItemStack itemOutput return recipe; } - public boolean remove(FermenterRecipe recipe) { - if (FermenterRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("fluid('ethanol')")) public void removeByOutput(FluidStack fluidOutput) { if (IngredientHelper.isEmpty(fluidOutput)) { @@ -59,7 +43,7 @@ public void removeByOutput(FluidStack fluidOutput) { .error() .post(); } - if (!FermenterRecipe.recipeList.removeIf(recipe -> { + if (!getRecipes().removeIf(recipe -> { if (recipe.fluidOutput.isFluidEqual(fluidOutput)) { addBackup(recipe); return true; @@ -83,7 +67,7 @@ public void removeByInput(ItemStack input) { } FermenterRecipe recipe = FermenterRecipe.findRecipe(input); if (recipe != null) { - FermenterRecipe.recipeList.remove(recipe); + getRecipes().remove(recipe); addBackup(recipe); } else { GroovyLog.msg("Error removing Immersive Engineering Fermenter recipe") @@ -93,17 +77,6 @@ public void removeByInput(ItemStack input) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FermenterRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - FermenterRecipe.recipeList.forEach(this::addBackup); - FermenterRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) @Property(property = "fluidOutput", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java index d1d0ff9db..8aba2b4e3 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Mixer.java @@ -6,19 +6,19 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.ArrayUtils; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Mixer extends VirtualizedRegistry { +public class Mixer extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:diamond'), ore('ingotGold'), ore('ingotGold'), ore('ingotGold')).fluidInput(fluid('water')).fluidOutput(fluid('lava')).energy(100)")) public static RecipeBuilder recipeBuilder() { @@ -26,16 +26,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> MixerRecipe.recipeList.removeIf(r -> r == recipe)); - MixerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(MixerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - MixerRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return MixerRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -46,14 +38,6 @@ public MixerRecipe add(FluidStack fluidOutput, FluidStack fluidInput, int energy return recipe; } - public boolean remove(MixerRecipe recipe) { - if (MixerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("fluid('potion').withNbt([Potion:'minecraft:night_vision'])")) public void removeByOutput(FluidStack fluidOutput) { if (GroovyLog.msg("Error removing Immersive Engineering Mixer recipe") @@ -62,7 +46,7 @@ public void removeByOutput(FluidStack fluidOutput) { .postIfNotEmpty()) { return; } - if (!MixerRecipe.recipeList.removeIf(recipe -> { + if (!getRecipes().removeIf(recipe -> { if (recipe.fluidOutput.isFluidEqual(fluidOutput)) { addBackup(recipe); return true; @@ -84,7 +68,7 @@ public void removeByInput(IIngredient... itemInputs) { .postIfNotEmpty()) { return; } - List recipes = MixerRecipe.recipeList.stream().filter(r -> r.itemInputs.length == itemInputs.length && + List recipes = getRecipes().stream().filter(r -> r.itemInputs.length == itemInputs.length && Arrays.stream(itemInputs).anyMatch(check -> Arrays.stream(r.itemInputs).anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, check)))) .collect(Collectors.toList()); for (MixerRecipe recipe : recipes) { @@ -107,7 +91,7 @@ public void removeByInput(FluidStack fluidInput, IIngredient... itemInput) { .postIfNotEmpty()) { return; } - List recipes = MixerRecipe.recipeList.stream().filter(r -> fluidInput.isFluidEqual(r.fluidInput) && + List recipes = getRecipes().stream().filter(r -> fluidInput.isFluidEqual(r.fluidInput) && r.itemInputs.length == itemInput.length && Arrays.stream(itemInput).anyMatch(check -> Arrays.stream(r.itemInputs).anyMatch(target -> ImmersiveEngineering.areIngredientsEquals(target, check)))) .collect(Collectors.toList()); @@ -122,17 +106,6 @@ public void removeByInput(FluidStack fluidInput, IIngredient... itemInput) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(MixerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - MixerRecipe.recipeList.forEach(this::addBackup); - MixerRecipe.recipeList.clear(); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java index a046eded3..1b1393128 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Refinery.java @@ -4,18 +4,18 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Refinery extends VirtualizedRegistry { +public class Refinery extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".fluidInput(fluid('water'), fluid('water')).fluidOutput(fluid('lava')).energy(100)")) public static RecipeBuilder recipeBuilder() { @@ -23,16 +23,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> RefineryRecipe.recipeList.removeIf(r -> r == recipe)); - RefineryRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(RefineryRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - RefineryRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return RefineryRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -42,14 +34,6 @@ public RefineryRecipe add(FluidStack output, FluidStack input0, FluidStack input return recipe; } - public boolean remove(RefineryRecipe recipe) { - if (RefineryRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example(value = "fluid('biodiesel')", commented = true)) public void removeByOutput(FluidStack fluidOutput) { if (IngredientHelper.isEmpty(fluidOutput)) { @@ -59,7 +43,7 @@ public void removeByOutput(FluidStack fluidOutput) { .post(); return; } - if (!RefineryRecipe.recipeList.removeIf(recipe -> { + if (!getRecipes().removeIf(recipe -> { if (recipe.output.isFluidEqual(fluidOutput)) { addBackup(recipe); return true; @@ -82,7 +66,7 @@ public void removeByInput(FluidStack input0, FluidStack input1) { .postIfNotEmpty()) { return; } - List recipes = RefineryRecipe.recipeList.stream().filter(r -> (r.input0.isFluidEqual(input0) && r.input1.isFluidEqual(input1)) || (r.input0.isFluidEqual(input1) && r.input1.isFluidEqual(input0))).collect(Collectors.toList()); + List recipes = getRecipes().stream().filter(r -> (r.input0.isFluidEqual(input0) && r.input1.isFluidEqual(input1)) || (r.input0.isFluidEqual(input1) && r.input1.isFluidEqual(input0))).collect(Collectors.toList()); for (RefineryRecipe recipe : recipes) { remove(recipe); } @@ -94,17 +78,6 @@ public void removeByInput(FluidStack input0, FluidStack input1) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RefineryRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RefineryRecipe.recipeList.forEach(this::addBackup); - RefineryRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("2")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java index 0643270e4..20bdad9da 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersiveengineering/Squeezer.java @@ -5,20 +5,20 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; import javax.annotation.Nonnull; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @RegistryDescription -public class Squeezer extends VirtualizedRegistry { +public class Squeezer extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).fluidOutput(fluid('lava')).energy(100)"), @@ -30,16 +30,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> SqueezerRecipe.recipeList.removeIf(r -> r == recipe)); - SqueezerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(SqueezerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - SqueezerRecipe.recipeList.add(recipe); - } + public Collection getRecipes() { + return SqueezerRecipe.recipeList; } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -49,14 +41,6 @@ public SqueezerRecipe add(FluidStack fluidOutput, @Nonnull ItemStack itemOutput, return recipe; } - public boolean remove(SqueezerRecipe recipe) { - if (SqueezerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("fluid('plantoil')")) public void removeByOutput(FluidStack fluidOutput) { if (IngredientHelper.isEmpty(fluidOutput)) { @@ -66,7 +50,7 @@ public void removeByOutput(FluidStack fluidOutput) { .post(); return; } - if (!SqueezerRecipe.recipeList.removeIf(recipe -> { + if (!getRecipes().removeIf(recipe -> { if (fluidOutput.isFluidEqual(recipe.fluidOutput)) { addBackup(recipe); return true; @@ -89,7 +73,7 @@ public void removeByOutput(FluidStack fluidOutput, ItemStack itemOutput) { .postIfNotEmpty()) { return; } - List recipes = SqueezerRecipe.recipeList.stream().filter(r -> fluidOutput.isFluidEqual(r.fluidOutput) && r.itemOutput.isItemEqual(itemOutput)).collect(Collectors.toList()); + List recipes = getRecipes().stream().filter(r -> fluidOutput.isFluidEqual(r.fluidOutput) && r.itemOutput.isItemEqual(itemOutput)).collect(Collectors.toList()); for (SqueezerRecipe recipe : recipes) { remove(recipe); } @@ -111,7 +95,7 @@ public void removeByOutput(ItemStack itemOutput) { } // "Condition 'r.itemOutput != null' is always 'true'" is a lie. It can be null, and if it is it *will* throw an NPE if we don't check against it. @SuppressWarnings("ConstantValue") - List recipes = SqueezerRecipe.recipeList.stream().filter(r -> r != null && r.itemOutput != null && r.itemOutput.isItemEqual(itemOutput)).collect(Collectors.toList()); + List recipes = getRecipes().stream().filter(r -> r != null && r.itemOutput != null && r.itemOutput.isItemEqual(itemOutput)).collect(Collectors.toList()); for (SqueezerRecipe recipe : recipes) { remove(recipe); } @@ -141,17 +125,6 @@ public void removeByInput(ItemStack input) { } } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SqueezerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SqueezerRecipe.recipeList.forEach(this::addBackup); - SqueezerRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) @Property(property = "fluidOutput", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java index fdefd1174..762d5fb78 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivepetroleum/Distillation.java @@ -1,22 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.immersivepetroleum; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import flaxbeard.immersivepetroleum.api.crafting.DistillationRecipe; import it.unimi.dsi.fastutil.floats.FloatArrayList; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Distillation extends VirtualizedRegistry { +public class Distillation extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".fluidInput(fluid('water') * 100).fluidOutput(fluid('water') * 50, fluid('lava') * 30).output(item('minecraft:diamond'), 0.5).output(item('minecraft:clay'), 0.2).output(item('minecraft:diamond'), 0.1).output(item('minecraft:clay'), 0.5).output(item('minecraft:diamond') * 5, 0.01).time(5).energy(1000)"), @@ -27,26 +26,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(recipe -> DistillationRecipe.recipeList.removeIf(r -> r == recipe)); - DistillationRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(DistillationRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - DistillationRecipe.recipeList.add(recipe); - } - } - - public boolean remove(DistillationRecipe recipe) { - if (DistillationRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return DistillationRecipe.recipeList; } @MethodDescription(example = { @@ -54,7 +35,7 @@ public boolean remove(DistillationRecipe recipe) { @Example(value = "fluid('lubricant')", commented = true) }) public void removeByOutput(IIngredient output) { - DistillationRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (ItemStack itemstack : r.getItemOutputs()) { if (output.test(itemstack)) { addBackup(r); @@ -73,7 +54,7 @@ public void removeByOutput(IIngredient output) { @MethodDescription(example = @Example("fluid('oil')")) public void removeByInput(IIngredient input) { - DistillationRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -84,17 +65,6 @@ public void removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(DistillationRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - DistillationRecipe.recipeList.forEach(this::addBackup); - DistillationRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java index 081d129bb..4dd62d434 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Boiler.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.BoilerRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Boiler extends VirtualizedRegistry { +public class Boiler extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - BoilerRecipe.recipeList.removeAll(removeScripted()); - BoilerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(BoilerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BoilerRecipe.recipeList.add(recipe); - } - } - - public boolean remove(BoilerRecipe recipe) { - if (BoilerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BoilerRecipe.recipeList; } @MethodDescription(example = @Example("fluid('water')")) public void removeByInput(IIngredient input) { - BoilerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("fluid('steam')")) public void removeByOutput(IIngredient output) { - BoilerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BoilerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BoilerRecipe.recipeList.forEach(this::addBackup); - BoilerRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java index f2c3fa587..222cf666b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/BoilerFuel.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.BoilerRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription(category = RegistryDescription.Category.ENTRIES) -public class BoilerFuel extends VirtualizedRegistry { +public class BoilerFuel extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - BoilerRecipe.fuelList.removeAll(removeScripted()); - BoilerRecipe.fuelList.addAll(restoreFromBackup()); - } - - public void add(BoilerRecipe.BoilerFuelRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - BoilerRecipe.fuelList.add(recipe); - } - } - - public boolean remove(BoilerRecipe.BoilerFuelRecipe recipe) { - if (BoilerRecipe.fuelList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return BoilerRecipe.fuelList; } @MethodDescription(example = @Example("fluid('biodiesel')")) public void removeByInput(IIngredient input) { - BoilerRecipe.fuelList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -66,17 +47,6 @@ public void removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BoilerRecipe.fuelList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BoilerRecipe.fuelList.forEach(this::addBackup); - BoilerRecipe.fuelList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java index 6aa97fa56..74c2b5635 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/CoolingTower.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.CoolingTowerRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class CoolingTower extends VirtualizedRegistry { +public class CoolingTower extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - CoolingTowerRecipe.recipeList.removeAll(removeScripted()); - CoolingTowerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(CoolingTowerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - CoolingTowerRecipe.recipeList.add(recipe); - } - } - - public boolean remove(CoolingTowerRecipe recipe) { - if (CoolingTowerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return CoolingTowerRecipe.recipeList; } @MethodDescription(example = @Example("fluid('hot_spring_water')")) public void removeByInput(IIngredient input) { - CoolingTowerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('water')", commented = true)) public void removeByOutput(IIngredient output) { - CoolingTowerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(CoolingTowerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - CoolingTowerRecipe.recipeList.forEach(this::addBackup); - CoolingTowerRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "3")}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java index 6dd45b790..ea836bf08 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Distiller.java @@ -1,22 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.DistillerRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Distiller extends VirtualizedRegistry { +public class Distiller extends StandardListRegistry { @Override public boolean isEnabled() { @@ -32,31 +31,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - DistillerRecipe.recipeList.removeAll(removeScripted()); - DistillerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(DistillerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - DistillerRecipe.recipeList.add(recipe); - } - } - - public boolean remove(DistillerRecipe recipe) { - if (DistillerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return DistillerRecipe.recipeList; } @MethodDescription(example = @Example(value = "fluid('water')", commented = true)) public void removeByInput(IIngredient input) { - DistillerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -69,7 +50,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = {@Example("fluid('distwater')"), @Example(value = "item('immersivetech:material')", commented = true)}) public void removeByOutput(IIngredient output) { - DistillerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -86,17 +67,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(DistillerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - DistillerRecipe.recipeList.forEach(this::addBackup); - DistillerRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java index 222aa2cde..4f741066b 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/ElectrolyticCrucibleBattery.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.ElectrolyticCrucibleBatteryRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class ElectrolyticCrucibleBattery extends VirtualizedRegistry { +public class ElectrolyticCrucibleBattery extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - ElectrolyticCrucibleBatteryRecipe.recipeList.removeAll(removeScripted()); - ElectrolyticCrucibleBatteryRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(ElectrolyticCrucibleBatteryRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - ElectrolyticCrucibleBatteryRecipe.recipeList.add(recipe); - } - } - - public boolean remove(ElectrolyticCrucibleBatteryRecipe recipe) { - if (ElectrolyticCrucibleBatteryRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return ElectrolyticCrucibleBatteryRecipe.recipeList; } @MethodDescription(example = @Example("fluid('moltensalt')")) public void removeByInput(IIngredient input) { - ElectrolyticCrucibleBatteryRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('chlorine')", commented = true)) public void removeByOutput(IIngredient output) { - ElectrolyticCrucibleBatteryRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ElectrolyticCrucibleBatteryRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ElectrolyticCrucibleBatteryRecipe.recipeList.forEach(this::addBackup); - ElectrolyticCrucibleBatteryRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "3")}) @Property(property = "output", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java index b0d641d33..bac9b65e6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/GasTurbine.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.GasTurbineRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class GasTurbine extends VirtualizedRegistry { +public class GasTurbine extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - GasTurbineRecipe.recipeList.removeAll(removeScripted()); - GasTurbineRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(GasTurbineRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - GasTurbineRecipe.recipeList.add(recipe); - } - } - - public boolean remove(GasTurbineRecipe recipe) { - if (GasTurbineRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return GasTurbineRecipe.recipeList; } @MethodDescription(example = @Example("fluid('biodiesel')")) public void removeByInput(IIngredient input) { - GasTurbineRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('fluegas')",commented = true)) public void removeByOutput(IIngredient output) { - GasTurbineRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(GasTurbineRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - GasTurbineRecipe.recipeList.forEach(this::addBackup); - GasTurbineRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java index 815d45440..5d34b9890 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HeatExchanger.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.HeatExchangerRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class HeatExchanger extends VirtualizedRegistry { +public class HeatExchanger extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - HeatExchangerRecipe.recipeList.removeAll(removeScripted()); - HeatExchangerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(HeatExchangerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - HeatExchangerRecipe.recipeList.add(recipe); - } - } - - public boolean remove(HeatExchangerRecipe recipe) { - if (HeatExchangerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return HeatExchangerRecipe.recipeList; } @MethodDescription(example = @Example("fluid('fluegas')")) public void removeByInput(IIngredient input) { - HeatExchangerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("fluid('hot_spring_water')")) public void removeByOutput(IIngredient output) { - HeatExchangerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { // would iterate through r.getFluidOutputs() as with the other IE compats, but they forgot to define it so its null. if (output.test(r.fluidOutput0) || output.test(r.fluidOutput1)) { addBackup(r); @@ -78,17 +59,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(HeatExchangerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - HeatExchangerRecipe.recipeList.forEach(this::addBackup); - HeatExchangerRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("2")) @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java index 752c321ea..779941cc0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/HighPressureSteamTurbine.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.HighPressureSteamTurbineRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class HighPressureSteamTurbine extends VirtualizedRegistry { +public class HighPressureSteamTurbine extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - HighPressureSteamTurbineRecipe.recipeList.removeAll(removeScripted()); - HighPressureSteamTurbineRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(HighPressureSteamTurbineRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - HighPressureSteamTurbineRecipe.recipeList.add(recipe); - } - } - - public boolean remove(HighPressureSteamTurbineRecipe recipe) { - if (HighPressureSteamTurbineRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return HighPressureSteamTurbineRecipe.recipeList; } @MethodDescription(example = @Example("fluid('highpressuresteam')")) public void removeByInput(IIngredient input) { - HighPressureSteamTurbineRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('steam')",commented = true)) public void removeByOutput(IIngredient output) { - HighPressureSteamTurbineRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(HighPressureSteamTurbineRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - HighPressureSteamTurbineRecipe.recipeList.forEach(this::addBackup); - HighPressureSteamTurbineRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java index 5c5e1f48e..cfc9b7ec0 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/MeltingCrucible.java @@ -1,22 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; import blusunrize.immersiveengineering.api.crafting.IngredientStack; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.compat.mods.immersiveengineering.ImmersiveEngineering; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.MeltingCrucibleRecipe; import mctmods.immersivetechnology.common.Config; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class MeltingCrucible extends VirtualizedRegistry { +public class MeltingCrucible extends StandardListRegistry { @Override public boolean isEnabled() { @@ -32,31 +31,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - MeltingCrucibleRecipe.recipeList.removeAll(removeScripted()); - MeltingCrucibleRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(MeltingCrucibleRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - MeltingCrucibleRecipe.recipeList.add(recipe); - } - } - - public boolean remove(MeltingCrucibleRecipe recipe) { - if (MeltingCrucibleRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return MeltingCrucibleRecipe.recipeList; } @MethodDescription(example = @Example("item('minecraft:cobblestone')")) public void removeByInput(IIngredient input) { - MeltingCrucibleRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (IngredientStack ingredientStack : r.getItemInputs()) { if (ImmersiveEngineering.areIngredientsEquals(ingredientStack, input)) { addBackup(r); @@ -69,7 +50,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("fluid('moltensalt')")) public void removeByOutput(IIngredient output) { - MeltingCrucibleRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { // would iterate through r.getFluidOutputs() as with the other IE compats, but they forgot to define it so its null. if (output.test(r.fluidOutput)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(MeltingCrucibleRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - MeltingCrucibleRecipe.recipeList.forEach(this::addBackup); - MeltingCrucibleRecipe.recipeList.clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java index b57aa8f9f..fbac26cfc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/Radiator.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.RadiatorRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Radiator extends VirtualizedRegistry { +public class Radiator extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - RadiatorRecipe.recipeList.removeAll(removeScripted()); - RadiatorRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(RadiatorRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - RadiatorRecipe.recipeList.add(recipe); - } - } - - public boolean remove(RadiatorRecipe recipe) { - if (RadiatorRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return RadiatorRecipe.recipeList; } @MethodDescription(example = @Example("fluid('exhauststeam')")) public void removeByInput(IIngredient input) { - RadiatorRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('distwater')",commented = true)) public void removeByOutput(IIngredient output) { - RadiatorRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RadiatorRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RadiatorRecipe.recipeList.forEach(this::addBackup); - RadiatorRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java index bbfc4dd41..6bf647ca4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SolarTower.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.SolarTowerRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class SolarTower extends VirtualizedRegistry { +public class SolarTower extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - SolarTowerRecipe.recipeList.removeAll(removeScripted()); - SolarTowerRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(SolarTowerRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - SolarTowerRecipe.recipeList.add(recipe); - } - } - - public boolean remove(SolarTowerRecipe recipe) { - if (SolarTowerRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return SolarTowerRecipe.recipeList; } @MethodDescription(example = @Example("fluid('water')")) public void removeByInput(IIngredient input) { - SolarTowerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("fluid('superheatedmoltensodium')")) public void removeByOutput(IIngredient output) { - SolarTowerRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SolarTowerRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SolarTowerRecipe.recipeList.forEach(this::addBackup); - SolarTowerRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java index cf35f9c3b..fff6eb593 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/immersivetechnology/SteamTurbine.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.immersivetechnology; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import mctmods.immersivetechnology.api.crafting.SteamTurbineRecipe; import mctmods.immersivetechnology.common.Config; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class SteamTurbine extends VirtualizedRegistry { +public class SteamTurbine extends StandardListRegistry { @Override public boolean isEnabled() { @@ -31,31 +30,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - SteamTurbineRecipe.recipeList.removeAll(removeScripted()); - SteamTurbineRecipe.recipeList.addAll(restoreFromBackup()); - } - - public void add(SteamTurbineRecipe recipe) { - if (recipe != null) { - addScripted(recipe); - SteamTurbineRecipe.recipeList.add(recipe); - } - } - - public boolean remove(SteamTurbineRecipe recipe) { - if (SteamTurbineRecipe.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return SteamTurbineRecipe.recipeList; } @MethodDescription(example = @Example("fluid('steam')")) public void removeByInput(IIngredient input) { - SteamTurbineRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidInputs()) { if (input.test(fluidStack)) { addBackup(r); @@ -68,7 +49,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('exhauststeam')", commented = true)) public void removeByOutput(IIngredient output) { - SteamTurbineRecipe.recipeList.removeIf(r -> { + getRecipes().removeIf(r -> { for (FluidStack fluidStack : r.getFluidOutputs()) { if (output.test(fluidStack)) { addBackup(r); @@ -79,17 +60,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SteamTurbineRecipe.recipeList).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SteamTurbineRecipe.recipeList.forEach(this::addBackup); - SteamTurbineRecipe.recipeList.clear(); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/BioReactor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/BioReactor.java index ce0eee6b0..ba47d88e1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/BioReactor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/BioReactor.java @@ -2,26 +2,24 @@ import com.buuz135.industrial.api.recipe.BioReactorEntry; import com.buuz135.industrial.api.recipe.IReactorEntry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.base.Predicate; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class BioReactor extends VirtualizedRegistry { +public class BioReactor extends StandardListRegistry { @Override - @GroovyBlacklist - public void onReload() { - BioReactorEntry.BIO_REACTOR_ENTRIES.removeAll(removeScripted()); - BioReactorEntry.BIO_REACTOR_ENTRIES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return BioReactorEntry.BIO_REACTOR_ENTRIES; } @MethodDescription(description = "groovyscript.wiki.industrialforegoing.bio_reactor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay')")) @@ -36,22 +34,9 @@ public IReactorEntry add(ItemStack input, @Nullable Predicate nb return recipe; } - public void add(IReactorEntry recipe) { - if (recipe == null) return; - addScripted(recipe); - BioReactorEntry.BIO_REACTOR_ENTRIES.add(recipe); - } - - public boolean remove(IReactorEntry recipe) { - if (recipe == null) return false; - addBackup(recipe); - BioReactorEntry.BIO_REACTOR_ENTRIES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:wheat_seeds')")) public boolean removeByInput(IIngredient input) { - return BioReactorEntry.BIO_REACTOR_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getStack())) { addBackup(recipe); return true; @@ -60,16 +45,4 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BioReactorEntry.BIO_REACTOR_ENTRIES.forEach(this::addBackup); - BioReactorEntry.BIO_REACTOR_ENTRIES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BioReactorEntry.BIO_REACTOR_ENTRIES) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java index b993e0ab5..4d477dc33 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/Extractor.java @@ -1,29 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; import com.buuz135.industrial.api.extractor.ExtractorEntry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + @RegistryDescription -public class Extractor extends VirtualizedRegistry { +public class Extractor extends StandardListRegistry { public Extractor() { super(Alias.generateOfClass(Extractor.class).andGenerate("TreeFluidExtractor")); } @Override - @GroovyBlacklist - public void onReload() { - ExtractorEntry.EXTRACTOR_ENTRIES.removeAll(removeScripted()); - ExtractorEntry.EXTRACTOR_ENTRIES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ExtractorEntry.EXTRACTOR_ENTRIES; } @MethodDescription(description = "groovyscript.wiki.industrialforegoing.extractor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay'), fluid('lava') * 50")) @@ -38,22 +36,9 @@ public ExtractorEntry add(ItemStack input, FluidStack output, float breakChance) return recipe; } - public void add(ExtractorEntry recipe) { - if (recipe == null) return; - addScripted(recipe); - ExtractorEntry.EXTRACTOR_ENTRIES.add(recipe); - } - - public boolean remove(ExtractorEntry recipe) { - if (recipe == null) return false; - addBackup(recipe); - ExtractorEntry.EXTRACTOR_ENTRIES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:log2:1')")) public boolean removeByInput(IIngredient input) { - return ExtractorEntry.EXTRACTOR_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getItemStack())) { addBackup(recipe); return true; @@ -64,7 +49,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('latex')", commented = true)) public boolean removeByOutput(IIngredient output) { - return ExtractorEntry.EXTRACTOR_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getFluidStack())) { addBackup(recipe); return true; @@ -73,16 +58,4 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ExtractorEntry.EXTRACTOR_ENTRIES.forEach(this::addBackup); - ExtractorEntry.EXTRACTOR_ENTRIES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExtractorEntry.EXTRACTOR_ENTRIES) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java index b1d602245..000624c0d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/FluidDictionary.java @@ -1,22 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; import com.buuz135.industrial.api.recipe.FluidDictionaryEntry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + @RegistryDescription -public class FluidDictionary extends VirtualizedRegistry { +public class FluidDictionary extends StandardListRegistry { @Override - @GroovyBlacklist - public void onReload() { - FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.removeAll(removeScripted()); - FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES; } @MethodDescription(description = "groovyscript.wiki.industrialforegoing.fluid_dictionary.add0", type = MethodDescription.Type.ADDITION, example = { @@ -42,22 +40,9 @@ public FluidDictionaryEntry add(String input, String output, double ratio) { return recipe; } - public void add(FluidDictionaryEntry recipe) { - if (recipe == null) return; - addScripted(recipe); - FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.add(recipe); - } - - public boolean remove(FluidDictionaryEntry recipe) { - if (recipe == null) return false; - addBackup(recipe); - FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.remove(recipe); - return true; - } - @MethodDescription public boolean removeByInput(String fluid) { - return FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (fluid.equals(recipe.getFluidOrigin())) { addBackup(recipe); return true; @@ -73,7 +58,7 @@ public boolean removeByInput(FluidStack fluid) { @MethodDescription public boolean removeByOutput(String fluid) { - return FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (fluid.equals(recipe.getFluidResult())) { addBackup(recipe); return true; @@ -87,16 +72,4 @@ public boolean removeByOutput(FluidStack fluid) { return removeByOutput(fluid.getFluid().getName()); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.forEach(this::addBackup); - FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(FluidDictionaryEntry.FLUID_DICTIONARY_RECIPES) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java index 138dd619b..ed27ad998 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreFermenter.java @@ -1,28 +1,26 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; import com.buuz135.industrial.api.recipe.ore.OreFluidEntryFermenter; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + @RegistryDescription -public class OreFermenter extends VirtualizedRegistry { +public class OreFermenter extends StandardListRegistry { public OreFermenter() { super(Alias.generateOfClass(OreFermenter.class).andGenerate("Fermentation")); } @Override - @GroovyBlacklist - public void onReload() { - OreFluidEntryFermenter.ORE_FLUID_FERMENTER.removeAll(removeScripted()); - OreFluidEntryFermenter.ORE_FLUID_FERMENTER.addAll(restoreFromBackup()); + public Collection getRecipes() { + return OreFluidEntryFermenter.ORE_FLUID_FERMENTER; } @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreGold']), fluid('if.ore_fluid_fermented').withNbt(['Ore': 'oreGold']) * 2")) @@ -32,22 +30,9 @@ public OreFluidEntryFermenter add(FluidStack input, FluidStack output) { return recipe; } - public void add(OreFluidEntryFermenter recipe) { - if (recipe == null) return; - addScripted(recipe); - OreFluidEntryFermenter.ORE_FLUID_FERMENTER.add(recipe); - } - - public boolean remove(OreFluidEntryFermenter recipe) { - if (recipe == null) return false; - addBackup(recipe); - OreFluidEntryFermenter.ORE_FLUID_FERMENTER.remove(recipe); - return true; - } - @MethodDescription(example = @Example("fluid('if.ore_fluid_raw').withNbt([Ore: 'oreRedstone'])")) public boolean removeByInput(IIngredient input) { - return OreFluidEntryFermenter.ORE_FLUID_FERMENTER.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput())) { addBackup(recipe); return true; @@ -58,7 +43,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('if.ore_fluid_fermented').withNbt([Ore: 'oreRedstone'])", commented = true)) public boolean removeByOutput(IIngredient output) { - return OreFluidEntryFermenter.ORE_FLUID_FERMENTER.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -67,16 +52,4 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - OreFluidEntryFermenter.ORE_FLUID_FERMENTER.forEach(this::addBackup); - OreFluidEntryFermenter.ORE_FLUID_FERMENTER.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(OreFluidEntryFermenter.ORE_FLUID_FERMENTER) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java index e9754ce8d..66416ad3e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreRaw.java @@ -1,29 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; import com.buuz135.industrial.api.recipe.ore.OreFluidEntryRaw; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + @RegistryDescription -public class OreRaw extends VirtualizedRegistry { +public class OreRaw extends StandardListRegistry { public OreRaw() { super(Alias.generateOfClass(OreRaw.class).andGenerate("Washing")); } @Override - @GroovyBlacklist - public void onReload() { - OreFluidEntryRaw.ORE_RAW_ENTRIES.removeAll(removeScripted()); - OreFluidEntryRaw.ORE_RAW_ENTRIES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return OreFluidEntryRaw.ORE_RAW_ENTRIES; } @MethodDescription(type = MethodDescription.Type.ADDITION, example = { @@ -41,22 +39,9 @@ public OreFluidEntryRaw add(String ore, FluidStack input, FluidStack output) { return recipe; } - public void add(OreFluidEntryRaw recipe) { - if (recipe == null) return; - addScripted(recipe); - OreFluidEntryRaw.ORE_RAW_ENTRIES.add(recipe); - } - - public boolean remove(OreFluidEntryRaw recipe) { - if (recipe == null) return false; - addBackup(recipe); - OreFluidEntryRaw.ORE_RAW_ENTRIES.remove(recipe); - return true; - } - @MethodDescription(example = @Example(value = "'oreRedstone'", commented = true)) public boolean removeByOre(String ore) { - return OreFluidEntryRaw.ORE_RAW_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (ore.equals(recipe.getOre())) { addBackup(recipe); return true; @@ -72,7 +57,7 @@ public boolean removeByOre(OreDictIngredient ore) { @MethodDescription(example = @Example(value = "fluid('meat')", commented = true)) public boolean removeByInput(IIngredient input) { - return OreFluidEntryRaw.ORE_RAW_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput())) { addBackup(recipe); return true; @@ -83,7 +68,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "fluid('if.ore_fluid_raw').withNbt(['Ore': 'oreRedstone']),", commented = true)) public boolean removeByOutput(IIngredient output) { - return OreFluidEntryRaw.ORE_RAW_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -92,16 +77,4 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - OreFluidEntryRaw.ORE_RAW_ENTRIES.forEach(this::addBackup); - OreFluidEntryRaw.ORE_RAW_ENTRIES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(OreFluidEntryRaw.ORE_RAW_ENTRIES) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java index 14c8df88c..76871cdec 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/OreSieve.java @@ -1,29 +1,27 @@ package com.cleanroommc.groovyscript.compat.mods.industrialforegoing; import com.buuz135.industrial.api.recipe.ore.OreFluidEntrySieve; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import java.util.Collection; + @RegistryDescription -public class OreSieve extends VirtualizedRegistry { +public class OreSieve extends StandardListRegistry { public OreSieve() { super(Alias.generateOfClass(OreSieve.class).andGenerate("FluidSieving")); } @Override - @GroovyBlacklist - public void onReload() { - OreFluidEntrySieve.ORE_FLUID_SIEVE.removeAll(removeScripted()); - OreFluidEntrySieve.ORE_FLUID_SIEVE.addAll(restoreFromBackup()); + public Collection getRecipes() { + return OreFluidEntrySieve.ORE_FLUID_SIEVE; } @MethodDescription(type = MethodDescription.Type.ADDITION, example = { @@ -36,25 +34,12 @@ public OreFluidEntrySieve add(FluidStack input, ItemStack output, ItemStack siev return recipe; } - public void add(OreFluidEntrySieve recipe) { - if (recipe == null) return; - addScripted(recipe); - OreFluidEntrySieve.ORE_FLUID_SIEVE.add(recipe); - } - - public boolean remove(OreFluidEntrySieve recipe) { - if (recipe == null) return false; - addBackup(recipe); - OreFluidEntrySieve.ORE_FLUID_SIEVE.remove(recipe); - return true; - } - @MethodDescription(example = { @Example("item('minecraft:sand')"), @Example("fluid('if.pink_slime')") }) public boolean removeByInput(IIngredient input) { - return OreFluidEntrySieve.ORE_FLUID_SIEVE.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput()) || input.test(recipe.getSieveItem())) { addBackup(recipe); return true; @@ -65,7 +50,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "item('industrialforegoing:pink_slime_ingot", commented = true)) public boolean removeByOutput(IIngredient output) { - return OreFluidEntrySieve.ORE_FLUID_SIEVE.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -74,16 +59,4 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - OreFluidEntrySieve.ORE_FLUID_SIEVE.forEach(this::addBackup); - OreFluidEntrySieve.ORE_FLUID_SIEVE.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(OreFluidEntrySieve.ORE_FLUID_SIEVE) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java index 02c01784b..fa27ca3fd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/ProteinReactor.java @@ -2,26 +2,24 @@ import com.buuz135.industrial.api.recipe.IReactorEntry; import com.buuz135.industrial.api.recipe.ProteinReactorEntry; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.base.Predicate; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class ProteinReactor extends VirtualizedRegistry { +public class ProteinReactor extends StandardListRegistry { @Override - @GroovyBlacklist - public void onReload() { - ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.removeAll(removeScripted()); - ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES; } @MethodDescription(description = "groovyscript.wiki.industrialforegoing.protein_reactor.add0", type = MethodDescription.Type.ADDITION, example = @Example("item('minecraft:clay')")) @@ -36,22 +34,9 @@ public IReactorEntry add(ItemStack input, @Nullable Predicate nb return recipe; } - public void add(IReactorEntry recipe) { - if (recipe == null) return; - addScripted(recipe); - ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.add(recipe); - } - - public boolean remove(IReactorEntry recipe) { - if (recipe == null) return false; - addBackup(recipe); - ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:porkchop')")) public boolean removeByInput(IIngredient input) { - return ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getStack())) { addBackup(recipe); return true; @@ -60,16 +45,4 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.forEach(this::addBackup); - ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ProteinReactorEntry.PROTEIN_REACTOR_ENTRIES) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java index 04e7419d5..b2f0ff358 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/industrialforegoing/SludgeRefiner.java @@ -7,18 +7,17 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.core.mixin.industrialforegoing.SludgeRefinerBlockAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; +import java.util.Collection; + @RegistryDescription -public class SludgeRefiner extends VirtualizedRegistry { +public class SludgeRefiner extends StandardListRegistry { @Override - @GroovyBlacklist - public void onReload() { - SludgeEntry.SLUDGE_RECIPES.removeAll(removeScripted()); - SludgeEntry.SLUDGE_RECIPES.addAll(restoreFromBackup()); + public Collection getRecipes() { + return SludgeEntry.SLUDGE_RECIPES; } @Override @@ -35,22 +34,9 @@ public SludgeEntry add(ItemStack output, int weight) { return recipe; } - public void add(SludgeEntry recipe) { - if (recipe == null) return; - addScripted(recipe); - SludgeEntry.SLUDGE_RECIPES.add(recipe); - } - - public boolean remove(SludgeEntry recipe) { - if (recipe == null) return false; - addBackup(recipe); - SludgeEntry.SLUDGE_RECIPES.remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:clay_ball')")) public boolean removeByOutput(IIngredient output) { - return SludgeEntry.SLUDGE_RECIPES.removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getStack())) { addBackup(recipe); return true; @@ -59,16 +45,4 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - SludgeEntry.SLUDGE_RECIPES.forEach(this::addBackup); - SludgeEntry.SLUDGE_RECIPES.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(SludgeEntry.SLUDGE_RECIPES) - .setRemover(this::remove); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java index 5f3db52fe..f20a38396 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/inspirations/Cauldron.java @@ -5,9 +5,8 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.inspirations.InspirationsRegistryAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import knightminer.inspirations.library.InspirationsRegistry; import knightminer.inspirations.library.recipe.cauldron.*; import net.minecraft.item.EnumDyeColor; @@ -22,13 +21,14 @@ import slimeknights.mantle.util.RecipeMatch; import java.util.Arrays; +import java.util.Collection; import java.util.Locale; import java.util.stream.Collectors; @RegistryDescription( admonition = @Admonition("groovyscript.wiki.inspirations.cauldron.note") ) -public class Cauldron extends VirtualizedRegistry { +public class Cauldron extends StandardListRegistry { private static boolean checkRecipeMatches(ISimpleCauldronRecipe recipe, IIngredient input, ItemStack output, Object inputState, Object outputState) { // Check all relevant parts to determine if we need to match them and if they do match. @@ -135,50 +135,37 @@ public RecipeBuilder recipeBuilderDye() { } @Override - public void onReload() { - removeScripted().forEach(recipe -> InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe)); - InspirationsRegistryAccessor.getCauldronRecipes().addAll(restoreFromBackup()); - } - - public void add(ICauldronRecipe recipe) { - addScripted(recipe); - InspirationsRegistry.addCauldronRecipe(recipe); - } - - public boolean remove(ICauldronRecipe recipe) { - if (InspirationsRegistryAccessor.getCauldronRecipes().contains(recipe)) return false; - addBackup(recipe); - InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); - return true; + public Collection getRecipes() { + return InspirationsRegistryAccessor.getCauldronRecipes(); } @MethodDescription(example = @Example("item('minecraft:ghast_tear')")) public void removeByInput(IIngredient input) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() + for (ICauldronRecipe recipe : getRecipes().stream() .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, input, null, null, null)) .collect(Collectors.toList())) { addBackup(recipe); - InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); + getRecipes().remove(recipe); } } @MethodDescription(example = @Example("item('minecraft:piston')")) public void removeByOutput(ItemStack output) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() + for (ICauldronRecipe recipe : getRecipes().stream() .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, null, output, null, null)) .collect(Collectors.toList())) { addBackup(recipe); - InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); + getRecipes().remove(recipe); } } @MethodDescription public void removeByFluidInput(Fluid input) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() + for (ICauldronRecipe recipe : getRecipes().stream() .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, null, null, input, null)) .collect(Collectors.toList())) { addBackup(recipe); - InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); + getRecipes().remove(recipe); } } @@ -189,11 +176,11 @@ public void removeByFluidInput(FluidStack input) { @MethodDescription public void removeByFluidOutput(Fluid output) { - for (ICauldronRecipe recipe : InspirationsRegistryAccessor.getCauldronRecipes().stream() + for (ICauldronRecipe recipe : getRecipes().stream() .filter(r -> r instanceof ISimpleCauldronRecipe && checkRecipeMatches((ISimpleCauldronRecipe) r, null, null, null, output)) .collect(Collectors.toList())) { addBackup(recipe); - InspirationsRegistryAccessor.getCauldronRecipes().remove(recipe); + getRecipes().remove(recipe); } } @@ -202,18 +189,6 @@ public void removeByFluidOutput(FluidStack output) { removeByFluidOutput(output.getFluid()); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - InspirationsRegistryAccessor.getCauldronRecipes().forEach(this::addBackup); - InspirationsRegistryAccessor.getCauldronRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(InspirationsRegistryAccessor.getCauldronRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1"), needsOverride = true) @Property(property = "output", valid = @Comp("1"), needsOverride = true) @Property(property = "fluidInput", valid = @Comp("1"), needsOverride = true) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java index 398f62f4d..00805fed6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/DryingBasin.java @@ -3,10 +3,9 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; @@ -17,8 +16,10 @@ import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasin; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class DryingBasin extends VirtualizedRegistry> { +public class DryingBasin extends StandardListRegistry> { @Override public boolean isEnabled() { @@ -34,31 +35,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes()::add); - } - - public void add(IRecipe recipe) { - this.add(recipe, true); - } - - public void add(IRecipe recipe, boolean add) { - if (recipe == null) return; - addScripted(recipe); - if (add) BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().add(recipe); - } - - public boolean remove(IRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().remove(recipe); - return true; + public Collection> getRecipes() { + return BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes(); } @MethodDescription public boolean removeByInput(ItemStack input) { - return BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().getIngredient().test(input)) { addBackup(r); return true; @@ -69,7 +52,7 @@ public boolean removeByInput(ItemStack input) { @MethodDescription public boolean removeByOutput(ItemStack input) { - return BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().getIngredient().test(input)) { addBackup(r); return true; @@ -78,18 +61,6 @@ public boolean removeByOutput(ItemStack input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); - BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockDryingBasin.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); - } - public static class RecipeBuilder extends AbstractRecipeBuilder> { @Property("groovyscript.wiki.integrateddynamics.drying_basin.basic.value") @@ -154,20 +125,20 @@ public void validate(GroovyLog.Msg msg) { ItemStack itemInput = input.isEmpty() ? ItemStack.EMPTY : IngredientHelper.toItemStack(input.get(0)); if (basic) { - ModSupport.INTEGRATED_DYNAMICS.get().dryingBasin.add( + ModSupport.INTEGRATED_DYNAMICS.get().dryingBasin.addScripted( BlockDryingBasin.getInstance().getRecipeRegistry().registerRecipe( new IngredientAndFluidStackRecipeComponent(itemInput, true, fluidInput.getOrEmpty(0)), new IngredientAndFluidStackRecipeComponent(output.get(0), fluidOutput.getOrEmpty(0)), new DurationRecipeProperties(duration) - ), false); + )); } if (mechanical) { - ModSupport.INTEGRATED_DYNAMICS.get().mechanicalDryingBasin.add( + ModSupport.INTEGRATED_DYNAMICS.get().mechanicalDryingBasin.addScripted( BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().registerRecipe( new IngredientAndFluidStackRecipeComponent(itemInput, true, fluidInput.getOrEmpty(0)), new IngredientAndFluidStackRecipeComponent(output.getOrEmpty(0), fluidOutput.getOrEmpty(0)), new DurationRecipeProperties(duration) - ), false); + )); } return null; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java index bc52ade5d..2344006dc 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalDryingBasin.java @@ -1,8 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.integrateddynamics; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; @@ -11,8 +10,10 @@ import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasin; import org.cyclops.integrateddynamics.block.BlockMechanicalDryingBasinConfig; +import java.util.Collection; + @RegistryDescription -public class MechanicalDryingBasin extends VirtualizedRegistry> { +public class MechanicalDryingBasin extends StandardListRegistry> { @Override public boolean isEnabled() { @@ -25,31 +26,13 @@ public DryingBasin.RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes()::add); - } - - public void add(IRecipe recipe) { - this.add(recipe, true); - } - - public void add(IRecipe recipe, boolean add) { - if (recipe == null) return; - addScripted(recipe); - if (add) BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().add(recipe); - } - - public boolean remove(IRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().remove(recipe); - return true; + public Collection> getRecipes() { + return BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes(); } @MethodDescription public boolean removeByInput(ItemStack input) { - return BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().getIngredient().test(input)) { addBackup(r); return true; @@ -60,7 +43,7 @@ public boolean removeByInput(ItemStack input) { @MethodDescription public boolean removeByOutput(ItemStack input) { - return BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getOutput().getIngredient().test(input)) { addBackup(r); return true; @@ -68,16 +51,4 @@ public boolean removeByOutput(ItemStack input) { return false; }); } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); - BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockMechanicalDryingBasin.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); - } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java index 8f0d3c2ea..3d36bed97 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/MechanicalSqueezer.java @@ -1,8 +1,7 @@ package com.cleanroommc.groovyscript.compat.mods.integrateddynamics; import com.cleanroommc.groovyscript.api.documentation.annotations.*; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DurationRecipeProperties; @@ -12,8 +11,10 @@ import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezer; import org.cyclops.integrateddynamics.block.BlockMechanicalSqueezerConfig; +import java.util.Collection; + @RegistryDescription -public class MechanicalSqueezer extends VirtualizedRegistry> { +public class MechanicalSqueezer extends StandardListRegistry> { @Override public boolean isEnabled() { @@ -26,31 +27,13 @@ public Squeezer.RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes()::add); - } - - public void add(IRecipe recipe) { - this.add(recipe, true); - } - - public void add(IRecipe recipe, boolean add) { - if (recipe == null) return; - addScripted(recipe); - if (add) BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes().add(recipe); - } - - public boolean remove(IRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes().remove(recipe); - return true; + public Collection> getRecipes() { + return BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes(); } @MethodDescription public boolean removeByInput(ItemStack input) { - return BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().getIngredient().test(input)) { addBackup(r); return true; @@ -58,16 +41,4 @@ public boolean removeByInput(ItemStack input) { return false; }); } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); - BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockMechanicalSqueezer.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); - } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java index ef05a91e8..23a495c79 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/integrateddynamics/Squeezer.java @@ -3,9 +3,8 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.cyclops.cyclopscore.recipe.custom.api.IRecipe; import org.cyclops.cyclopscore.recipe.custom.component.DummyPropertiesComponent; @@ -19,10 +18,11 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; +import java.util.Collection; import java.util.List; @RegistryDescription -public class Squeezer extends VirtualizedRegistry> { +public class Squeezer extends StandardListRegistry> { @Override public boolean isEnabled() { @@ -39,31 +39,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(BlockSqueezer.getInstance().getRecipeRegistry().allRecipes()::remove); - restoreFromBackup().forEach(BlockSqueezer.getInstance().getRecipeRegistry().allRecipes()::add); - } - - public void add(IRecipe recipe) { - this.add(recipe, true); - } - - public void add(IRecipe recipe, boolean add) { - if (recipe == null) return; - addScripted(recipe); - if (add) BlockSqueezer.getInstance().getRecipeRegistry().allRecipes().add(recipe); - } - - public boolean remove(IRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - BlockSqueezer.getInstance().getRecipeRegistry().allRecipes().remove(recipe); - return true; + public Collection> getRecipes() { + return BlockSqueezer.getInstance().getRecipeRegistry().allRecipes(); } @MethodDescription public boolean removeByInput(ItemStack input) { - return BlockSqueezer.getInstance().getRecipeRegistry().allRecipes().removeIf(r -> { + return getRecipes().removeIf(r -> { if (r.getInput().getIngredient().test(input)) { addBackup(r); return true; @@ -72,18 +54,6 @@ public boolean removeByInput(ItemStack input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BlockSqueezer.getInstance().getRecipeRegistry().allRecipes().forEach(this::addBackup); - BlockSqueezer.getInstance().getRecipeRegistry().allRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(BlockSqueezer.getInstance().getRecipeRegistry().allRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) public static class RecipeBuilder extends AbstractRecipeBuilder> { @@ -166,20 +136,20 @@ public void validate(GroovyLog.Msg msg) { if (!validate()) return null; if (basic) { - ModSupport.INTEGRATED_DYNAMICS.get().squeezer.add( + ModSupport.INTEGRATED_DYNAMICS.get().squeezer.addScripted( BlockSqueezer.getInstance().getRecipeRegistry().registerRecipe( new IngredientRecipeComponent(input.get(0).toMcIngredient()), new IngredientsAndFluidStackRecipeComponent(output, fluidOutput.getOrEmpty(0)), new DummyPropertiesComponent() - ), false); + )); } if (mechanical) { - ModSupport.INTEGRATED_DYNAMICS.get().mechanicalSqueezer.add( + ModSupport.INTEGRATED_DYNAMICS.get().mechanicalSqueezer.addScripted( BlockMechanicalSqueezer.getInstance().getRecipeRegistry().registerRecipe( new IngredientRecipeComponent(input.get(0).toMcIngredient()), new IngredientsAndFluidStackRecipeComponent(output, fluidOutput.getOrEmpty(0)), new DurationRecipeProperties(duration) - ), false); + )); } return null; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java index 57b776748..c0dd12208 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Aggregator.java @@ -5,7 +5,7 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.AggRecipe; import org.jetbrains.annotations.Nullable; @@ -15,7 +15,7 @@ import java.util.stream.Collectors; @RegistryDescription -public class Aggregator extends VirtualizedRegistry { +public class Aggregator extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(ore('blockGlass'), item('minecraft:diamond')).output(item('minecraft:diamond') * 4)"), @@ -25,29 +25,14 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - private static Collection recipes() { - return LibNine.PROXY.getRecipeManager().getRecipeList(AggRecipe.class).recipes(); - } - @Override - public void onReload() { - removeScripted().forEach(recipes()::remove); - restoreFromBackup().forEach(recipes()::add); - } - - public void add(AggRecipe recipe) { - recipes().add(recipe); - addScripted(recipe); - } - - public void remove(AggRecipe recipe) { - recipes().remove(recipe); - addBackup(recipe); + public Collection getRecipes() { + return LibNine.PROXY.getRecipeManager().getRecipeList(AggRecipe.class).recipes(); } @MethodDescription(example = @Example("item('appliedenergistics2:material:45')")) public void removeByInput(IIngredient input) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (recipe.input().getInputs().stream().anyMatch(x -> Arrays.stream(input.getMatchingStacks()).anyMatch(x))) { addBackup(recipe); return true; @@ -58,7 +43,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('appliedenergistics2:material:7')")) public void removeByOutput(IIngredient output) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput().getOutput())) { addBackup(recipe); return true; @@ -67,12 +52,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - recipes().forEach(this::addBackup); - recipes().clear(); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "3")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java index f119040df..3e75b424a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Centrifuge.java @@ -5,7 +5,7 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.PurifyRecipe; import org.jetbrains.annotations.Nullable; @@ -14,7 +14,7 @@ import java.util.Collection; @RegistryDescription -public class Centrifuge extends VirtualizedRegistry { +public class Centrifuge extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(ore('blockGlass')).output(item('minecraft:diamond'))"), @@ -24,29 +24,14 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - private static Collection recipes() { - return LibNine.PROXY.getRecipeManager().getRecipeList(PurifyRecipe.class).recipes(); - } - @Override - public void onReload() { - removeScripted().forEach(recipes()::remove); - restoreFromBackup().forEach(recipes()::add); - } - - public void add(PurifyRecipe recipe) { - recipes().add(recipe); - addScripted(recipe); - } - - public void remove(PurifyRecipe recipe) { - recipes().remove(recipe); - addBackup(recipe); + public Collection getRecipes() { + return LibNine.PROXY.getRecipeManager().getRecipeList(PurifyRecipe.class).recipes(); } @MethodDescription(example = @Example("item('appliedenergistics2:material')")) public void removeByInput(IIngredient input) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (Arrays.stream(input.getMatchingStacks()).anyMatch(recipe.input().getMatcher())) { addBackup(recipe); return true; @@ -57,7 +42,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('appliedenergistics2:material:4')")) public void removeByOutput(IIngredient output) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput().getOutput())) { addBackup(recipe); return true; @@ -66,12 +51,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - recipes().forEach(this::addBackup); - recipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java index 8ff391988..5e78508e8 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Energizer.java @@ -5,7 +5,7 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.EnergizeRecipe; import org.jetbrains.annotations.Nullable; @@ -14,7 +14,7 @@ import java.util.Collection; @RegistryDescription -public class Energizer extends VirtualizedRegistry { +public class Energizer extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(ore('blockGlass')).energy(50).output(item('minecraft:diamond'))"), @@ -24,29 +24,14 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - private static Collection recipes() { - return LibNine.PROXY.getRecipeManager().getRecipeList(EnergizeRecipe.class).recipes(); - } - @Override - public void onReload() { - removeScripted().forEach(recipes()::remove); - restoreFromBackup().forEach(recipes()::add); - } - - public void add(EnergizeRecipe recipe) { - recipes().add(recipe); - addScripted(recipe); - } - - public void remove(EnergizeRecipe recipe) { - recipes().remove(recipe); - addBackup(recipe); + public Collection getRecipes() { + return LibNine.PROXY.getRecipeManager().getRecipeList(EnergizeRecipe.class).recipes(); } @MethodDescription(example = @Example(value = "item('appliedenergistics2:material')", commented = true)) public void removeByInput(IIngredient input) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (Arrays.stream(input.getMatchingStacks()).anyMatch(recipe.input().getMatcher())) { addBackup(recipe); return true; @@ -57,7 +42,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('appliedenergistics2:material:1')")) public void removeByOutput(IIngredient output) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput().getOutput())) { addBackup(recipe); return true; @@ -66,12 +51,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - recipes().forEach(this::addBackup); - recipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java index 575a440f9..ab7d9136f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/lazyae2/Etcher.java @@ -5,7 +5,7 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import io.github.phantamanta44.libnine.LibNine; import io.github.phantamanta44.threng.recipe.EtchRecipe; import org.jetbrains.annotations.Nullable; @@ -14,7 +14,7 @@ import java.util.Collection; @RegistryDescription -public class Etcher extends VirtualizedRegistry { +public class Etcher extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(ore('blockGlass')).top(item('minecraft:diamond')).bottom(item('minecraft:clay')).output(item('minecraft:diamond') * 5)"), @@ -24,29 +24,14 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - private static Collection recipes() { - return LibNine.PROXY.getRecipeManager().getRecipeList(EtchRecipe.class).recipes(); - } - @Override - public void onReload() { - removeScripted().forEach(recipes()::remove); - restoreFromBackup().forEach(recipes()::add); - } - - public void add(EtchRecipe recipe) { - recipes().add(recipe); - addScripted(recipe); - } - - public void remove(EtchRecipe recipe) { - recipes().remove(recipe); - addBackup(recipe); + public Collection getRecipes() { + return LibNine.PROXY.getRecipeManager().getRecipeList(EtchRecipe.class).recipes(); } @MethodDescription(example = @Example("item('minecraft:diamond')")) public void removeByInput(IIngredient input) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (recipe.input().getInputs().stream().anyMatch(x -> Arrays.stream(input.getMatchingStacks()).anyMatch(x))) { addBackup(recipe); return true; @@ -57,7 +42,7 @@ public void removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('appliedenergistics2:material:22')")) public void removeByOutput(IIngredient output) { - recipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput().getOutput())) { addBackup(recipe); return true; @@ -66,12 +51,6 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - recipes().forEach(this::addBackup); - recipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java index 480f1c346..7b49eefb7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/mysticalagriculture/Reprocessor.java @@ -2,19 +2,19 @@ import com.blakebr0.mysticalagriculture.crafting.ReprocessorManager; import com.blakebr0.mysticalagriculture.crafting.ReprocessorRecipe; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Reprocessor extends VirtualizedRegistry { +public class Reprocessor extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:diamond') * 3)"), @@ -25,10 +25,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - ReprocessorManager.getRecipes().removeAll(removeScripted()); - ReprocessorManager.getRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return ReprocessorManager.getRecipes(); } // public ReprocessorRecipe add(IIngredient input, ItemStack output, int amount) { @@ -44,22 +42,9 @@ public ReprocessorRecipe add(IIngredient input, ItemStack output/*, int amount, .register(); } - public void add(ReprocessorRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - ReprocessorManager.getRecipes().add(recipe); - } - - public boolean remove(ReprocessorRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - ReprocessorManager.getRecipes().remove(recipe); - return true; - } - @MethodDescription(example = @Example("item('mysticalagriculture:stone_seeds')")) public boolean removeByInput(IIngredient input) { - return ReprocessorManager.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput())) { addBackup(recipe); return true; @@ -70,7 +55,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('mysticalagriculture:dirt_essence')")) public boolean removeByOutput(IIngredient output) { - return ReprocessorManager.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -79,18 +64,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ReprocessorManager.getRecipes().forEach(this::addBackup); - ReprocessorManager.getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ReprocessorManager.getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java index 4d8d96779..fc1839cdd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Explosion.java @@ -4,18 +4,19 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import me.desht.pneumaticcraft.common.recipes.ExplosionCraftingRecipe; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription( admonition = @Admonition(value = "groovyscript.wiki.pneumaticcraft.explosion.note0", type = Admonition.Type.TIP) ) -public class Explosion extends VirtualizedRegistry { +public class Explosion extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot')).lossRate(40)"), @@ -26,24 +27,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - ExplosionCraftingRecipe.recipes.removeAll(removeScripted()); - ExplosionCraftingRecipe.recipes.addAll(restoreFromBackup()); - } - - public void add(ExplosionCraftingRecipe recipe) { - ExplosionCraftingRecipe.recipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(ExplosionCraftingRecipe recipe) { - addBackup(recipe); - return ExplosionCraftingRecipe.recipes.remove(recipe); + public Collection getRecipes() { + return ExplosionCraftingRecipe.recipes; } @MethodDescription(example = @Example("item('pneumaticcraft:compressed_iron_block')")) public boolean removeByOutput(IIngredient output) { - return ExplosionCraftingRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (output.test(entry.getOutput())) { addBackup(entry); return true; @@ -54,7 +44,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example(value = "item('minecraft:iron_block')", commented = true)) public boolean removeByInput(IIngredient input) { - return ExplosionCraftingRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (input.test(entry.getInput()) || input instanceof OreDictIngredient oreDictIngredient && oreDictIngredient.getOreDict().equals(entry.getOreDictKey())) { addBackup(entry); return true; @@ -63,17 +53,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ExplosionCraftingRecipe.recipes.forEach(this::addBackup); - ExplosionCraftingRecipe.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExplosionCraftingRecipe.recipes).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java index 3a76f5bfa..4974d4478 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/HeatFrameCooling.java @@ -4,14 +4,15 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import me.desht.pneumaticcraft.common.recipes.HeatFrameCoolingRecipe; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class HeatFrameCooling extends VirtualizedRegistry { +public class HeatFrameCooling extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay')).output(item('minecraft:gold_ingot'))"), @@ -22,24 +23,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - HeatFrameCoolingRecipe.recipes.removeAll(removeScripted()); - HeatFrameCoolingRecipe.recipes.addAll(restoreFromBackup()); - } - - public void add(HeatFrameCoolingRecipe recipe) { - HeatFrameCoolingRecipe.recipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(HeatFrameCoolingRecipe recipe) { - addBackup(recipe); - return HeatFrameCoolingRecipe.recipes.remove(recipe); + public Collection getRecipes() { + return HeatFrameCoolingRecipe.recipes; } @MethodDescription(example = @Example("item('minecraft:obsidian')")) public boolean removeByOutput(IIngredient output) { - return HeatFrameCoolingRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (output.test(entry.output)) { addBackup(entry); return true; @@ -50,7 +40,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:water_bucket')")) public boolean removeByInput(IIngredient input) { - return HeatFrameCoolingRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (entry.input.getStacks().stream().anyMatch(input)) { addBackup(entry); return true; @@ -59,17 +49,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - HeatFrameCoolingRecipe.recipes.forEach(this::addBackup); - HeatFrameCoolingRecipe.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(HeatFrameCoolingRecipe.recipes).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java index f7f170fa0..ebd893967 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PlasticMixer.java @@ -6,19 +6,20 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.pneumaticcraft.PlasticMixerRecipeAccessor; import com.cleanroommc.groovyscript.core.mixin.pneumaticcraft.PlasticMixerRegistryAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import me.desht.pneumaticcraft.common.recipes.PlasticMixerRegistry; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription( admonition = { @Admonition(value = "groovyscript.wiki.pneumaticcraft.plastic_mixer.note0", type = Admonition.Type.WARNING), @Admonition(value = "groovyscript.wiki.pneumaticcraft.plastic_mixer.note1", type = Admonition.Type.DANGER) } ) -public class PlasticMixer extends VirtualizedRegistry { +public class PlasticMixer extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".fluidInput(fluid('lava') * 100).output(item('minecraft:clay')).allowMelting().allowSolidifying().requiredTemperature(323)"), @@ -33,34 +34,23 @@ private static PlasticMixerRegistryAccessor getInstance() { } @Override - public void onReload() { - getInstance().getRecipes().removeAll(removeScripted()); - getInstance().getRecipes().addAll(restoreFromBackup()); + public Collection getRecipes() { + return getInstance().getRecipes(); } @Override public void afterScriptLoad() { getInstance().getValidFluids().clear(); getInstance().getValidItems().clear(); - for (PlasticMixerRegistry.PlasticMixerRecipe recipe : getInstance().getRecipes()) { + for (PlasticMixerRegistry.PlasticMixerRecipe recipe : getRecipes()) { getInstance().getValidFluids().add(recipe.getFluidStack().getFluid().getName()); getInstance().getValidItems().put(recipe.getItemStack().getItem(), recipe.allowMelting()); } } - public void add(PlasticMixerRegistry.PlasticMixerRecipe recipe) { - getInstance().getRecipes().add(recipe); - addScripted(recipe); - } - - public boolean remove(PlasticMixerRegistry.PlasticMixerRecipe recipe) { - addBackup(recipe); - return getInstance().getRecipes().remove(recipe); - } - @MethodDescription(example = @Example(value = "fluid('plastic')", commented = true)) public boolean removeByFluid(IIngredient fluid) { - return getInstance().getRecipes().removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (fluid.test(entry.getFluidStack())) { addBackup(entry); return true; @@ -71,7 +61,7 @@ public boolean removeByFluid(IIngredient fluid) { @MethodDescription(example = @Example(value = "item('pneumaticcraft:plastic')", commented = true)) public boolean removeByItem(IIngredient item) { - return getInstance().getRecipes().removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (item.test(entry.getItemStack())) { addBackup(entry); return true; @@ -80,17 +70,6 @@ public boolean removeByItem(IIngredient item) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - getInstance().getRecipes().forEach(this::addBackup); - getInstance().getRecipes().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(getInstance().getRecipes()).setRemover(this::remove); - } - @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java index 08d177e10..944728b7a 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/PressureChamber.java @@ -4,9 +4,8 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import me.desht.pneumaticcraft.api.recipe.IPressureChamberRecipe; import me.desht.pneumaticcraft.api.recipe.ItemIngredient; import me.desht.pneumaticcraft.common.recipes.PressureChamberRecipe; @@ -16,7 +15,7 @@ import java.util.Collection; @RegistryDescription -public class PressureChamber extends VirtualizedRegistry { +public class PressureChamber extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay') * 3).output(item('minecraft:gold_ingot')).pressure(4)"), @@ -27,24 +26,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - PressureChamberRecipe.recipes.removeAll(removeScripted()); - PressureChamberRecipe.recipes.addAll(restoreFromBackup()); - } - - public void add(IPressureChamberRecipe recipe) { - PressureChamberRecipe.recipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(IPressureChamberRecipe recipe) { - addBackup(recipe); - return PressureChamberRecipe.recipes.remove(recipe); + public Collection getRecipes() { + return PressureChamberRecipe.recipes; } @MethodDescription(example = @Example("item('minecraft:diamond')")) public boolean removeByOutput(IIngredient output) { - return PressureChamberRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (entry.getResult().stream().anyMatch(output)) { addBackup(entry); return true; @@ -55,7 +43,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:iron_block')")) public boolean removeByInput(IIngredient input) { - return PressureChamberRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (entry.getInput().stream().map(ItemIngredient::getStacks).flatMap(Collection::stream).anyMatch(input)) { addBackup(entry); return true; @@ -64,17 +52,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - PressureChamberRecipe.recipes.forEach(this::addBackup); - PressureChamberRecipe.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(PressureChamberRecipe.recipes).setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) @Property(property = "output", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java index 5f304f8a6..19d6ac28f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/Refinery.java @@ -4,17 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import me.desht.pneumaticcraft.common.recipes.RefineryRecipe; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; import java.util.Arrays; +import java.util.Collection; @RegistryDescription -public class Refinery extends VirtualizedRegistry { +public class Refinery extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".fluidInput(fluid('water') * 1000).fluidOutput(fluid('lava') * 750, fluid('lava') * 250, fluid('lava') * 100, fluid('lava') * 50)"), @@ -25,24 +25,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - RefineryRecipe.recipes.removeAll(removeScripted()); - RefineryRecipe.recipes.addAll(restoreFromBackup()); - } - - public void add(RefineryRecipe recipe) { - RefineryRecipe.recipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(RefineryRecipe recipe) { - addBackup(recipe); - return RefineryRecipe.recipes.remove(recipe); + public Collection getRecipes() { + return RefineryRecipe.recipes; } @MethodDescription(example = @Example("fluid('kerosene')")) public boolean removeByOutput(IIngredient output) { - return RefineryRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (Arrays.stream(entry.outputs).anyMatch(output::test)) { addBackup(entry); return true; @@ -53,7 +42,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example(value = "fluid('oil')", commented = true)) public boolean removeByInput(IIngredient input) { - return RefineryRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (input.test(entry.input)) { addBackup(entry); return true; @@ -62,17 +51,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RefineryRecipe.recipes.forEach(this::addBackup); - RefineryRecipe.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RefineryRecipe.recipes).setRemover(this::remove); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = {@Comp(type = Comp.Type.GTE, value = "2"), @Comp(type = Comp.Type.LTE, value = "4")}) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java index e9b3299d3..cd4abf750 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/pneumaticcraft/ThermopneumaticProcessingPlant.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import me.desht.pneumaticcraft.api.recipe.IThermopneumaticProcessingPlantRecipe; import me.desht.pneumaticcraft.common.recipes.BasicThermopneumaticProcessingPlantRecipe; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class ThermopneumaticProcessingPlant extends VirtualizedRegistry { +public class ThermopneumaticProcessingPlant extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:clay') * 3).fluidInput(fluid('water') * 100).fluidOutput(fluid('kerosene') * 100).pressure(4).requiredTemperature(323)"), @@ -24,24 +25,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - BasicThermopneumaticProcessingPlantRecipe.recipes.removeAll(removeScripted()); - BasicThermopneumaticProcessingPlantRecipe.recipes.addAll(restoreFromBackup()); - } - - public void add(IThermopneumaticProcessingPlantRecipe recipe) { - BasicThermopneumaticProcessingPlantRecipe.recipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(IThermopneumaticProcessingPlantRecipe recipe) { - addBackup(recipe); - return BasicThermopneumaticProcessingPlantRecipe.recipes.remove(recipe); + public Collection getRecipes() { + return BasicThermopneumaticProcessingPlantRecipe.recipes; } @MethodDescription(example = @Example("fluid('lpg')")) public boolean removeByOutput(IIngredient output) { - return BasicThermopneumaticProcessingPlantRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (entry instanceof BasicThermopneumaticProcessingPlantRecipe recipe && output.test(recipe.getOutputLiquid())) { addBackup(entry); return true; @@ -52,7 +42,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = {@Example("item('minecraft:coal')"), @Example("fluid('diesel')")}) public boolean removeByInput(IIngredient input) { - return BasicThermopneumaticProcessingPlantRecipe.recipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (entry instanceof BasicThermopneumaticProcessingPlantRecipe recipe && (input.test(recipe.getInputLiquid()) || input.test(recipe.getInputItem()))) { addBackup(entry); return true; @@ -61,17 +51,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - BasicThermopneumaticProcessingPlantRecipe.recipes.forEach(this::addBackup); - BasicThermopneumaticProcessingPlantRecipe.recipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(BasicThermopneumaticProcessingPlantRecipe.recipes).setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "0"), @Comp(type = Comp.Type.LTE, value = "1")}) @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/ClayKiln.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/ClayKiln.java index 1b8607e70..21fe7d66f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/ClayKiln.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/ClayKiln.java @@ -5,15 +5,16 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.primal_tech.ClayKilnRecipesAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import primal_tech.recipes.ClayKilnRecipes; +import java.util.Collection; + @RegistryDescription -public class ClayKiln extends VirtualizedRegistry { +public class ClayKiln extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).cookTime(50)"), @@ -24,16 +25,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - ClayKilnRecipesAccessor.getRecipes().removeAll(removeScripted()); - ClayKilnRecipesAccessor.getRecipes().addAll(restoreFromBackup()); - } - - public void add(ClayKilnRecipes recipe) { - if (recipe != null) { - addScripted(recipe); - ClayKilnRecipesAccessor.getRecipes().add(recipe); - } + public Collection getRecipes() { + return ClayKilnRecipesAccessor.getRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -45,17 +38,9 @@ public ClayKilnRecipes add(ItemStack output, IIngredient input, int cookTime) { .register(); } - public boolean remove(ClayKilnRecipes recipe) { - if (ClayKilnRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:gravel')")) public boolean removeByInput(IIngredient input) { - return ClayKilnRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput())) { addBackup(recipe); return true; @@ -66,7 +51,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('primal_tech:charcoal_block')")) public boolean removeByOutput(IIngredient output) { - return ClayKilnRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -75,17 +60,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ClayKilnRecipesAccessor.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ClayKilnRecipesAccessor.getRecipes().forEach(this::addBackup); - ClayKilnRecipesAccessor.getRecipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/StoneAnvil.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/StoneAnvil.java index 591a0b219..b687dbab5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/StoneAnvil.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/StoneAnvil.java @@ -5,15 +5,16 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.primal_tech.StoneAnvilRecipesAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import primal_tech.recipes.StoneAnvilRecipes; +import java.util.Collection; + @RegistryDescription -public class StoneAnvil extends VirtualizedRegistry { +public class StoneAnvil extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay'))"), @@ -24,16 +25,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - StoneAnvilRecipesAccessor.getRecipes().removeAll(removeScripted()); - StoneAnvilRecipesAccessor.getRecipes().addAll(restoreFromBackup()); - } - - public void add(StoneAnvilRecipes recipe) { - if (recipe != null) { - addScripted(recipe); - StoneAnvilRecipesAccessor.getRecipes().add(recipe); - } + public Collection getRecipes() { + return StoneAnvilRecipesAccessor.getRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -44,17 +37,9 @@ public StoneAnvilRecipes add(ItemStack output, IIngredient input) { .register(); } - public boolean remove(StoneAnvilRecipes recipe) { - if (StoneAnvilRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example(value = "item('primal_tech:flint_block')", commented = true)) public boolean removeByInput(IIngredient input) { - return StoneAnvilRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput())) { addBackup(recipe); return true; @@ -65,7 +50,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:flint')")) public boolean removeByOutput(IIngredient output) { - return StoneAnvilRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -74,17 +59,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(StoneAnvilRecipesAccessor.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - StoneAnvilRecipesAccessor.getRecipes().forEach(this::addBackup); - StoneAnvilRecipesAccessor.getRecipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WaterSaw.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WaterSaw.java index 136d4dd8f..d4d3ae35f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WaterSaw.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WaterSaw.java @@ -5,15 +5,16 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.primal_tech.WaterSawRecipesAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import primal_tech.recipes.WaterSawRecipes; +import java.util.Collection; + @RegistryDescription -public class WaterSaw extends VirtualizedRegistry { +public class WaterSaw extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).output(item('minecraft:clay')).choppingTime(50)"), @@ -24,16 +25,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - WaterSawRecipesAccessor.getRecipes().removeAll(removeScripted()); - WaterSawRecipesAccessor.getRecipes().addAll(restoreFromBackup()); - } - - public void add(WaterSawRecipes recipe) { - if (recipe != null) { - addScripted(recipe); - WaterSawRecipesAccessor.getRecipes().add(recipe); - } + public Collection getRecipes() { + return WaterSawRecipesAccessor.getRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -45,17 +38,9 @@ public WaterSawRecipes add(ItemStack output, IIngredient input, int choppingTime .register(); } - public boolean remove(WaterSawRecipes recipe) { - if (WaterSawRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = @Example("item('minecraft:log')")) public boolean removeByInput(IIngredient input) { - return WaterSawRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getInput())) { addBackup(recipe); return true; @@ -66,7 +51,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('minecraft:planks:1')")) public boolean removeByOutput(IIngredient output) { - return WaterSawRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -75,17 +60,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(WaterSawRecipesAccessor.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - WaterSawRecipesAccessor.getRecipes().forEach(this::addBackup); - WaterSawRecipesAccessor.getRecipes().clear(); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WoodenBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WoodenBasin.java index f782b6414..651801cbd 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WoodenBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/primaltech/WoodenBasin.java @@ -5,10 +5,9 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.primal_tech.WoodenBasinRecipesAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.collect.Lists; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -16,6 +15,7 @@ import primal_tech.recipes.WoodenBasinRecipes; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -23,7 +23,7 @@ @RegistryDescription( admonition = @Admonition(type = Admonition.Type.WARNING, value = "groovyscript.wiki.primal_tech.wooden_basin.note0") ) -public class WoodenBasin extends VirtualizedRegistry { +public class WoodenBasin extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond')).fluidInput(fluid('lava')).output(item('minecraft:clay'))"), @@ -34,16 +34,8 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - WoodenBasinRecipesAccessor.getRecipes().removeAll(removeScripted()); - WoodenBasinRecipesAccessor.getRecipes().addAll(restoreFromBackup()); - } - - public void add(WoodenBasinRecipes recipe) { - if (recipe != null) { - addScripted(recipe); - WoodenBasinRecipesAccessor.getRecipes().add(recipe); - } + public Collection getRecipes() { + return WoodenBasinRecipesAccessor.getRecipes(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -55,17 +47,9 @@ public WoodenBasinRecipes add(ItemStack output, FluidStack fluid, IIngredient... .register(); } - public boolean remove(WoodenBasinRecipes recipe) { - if (WoodenBasinRecipesAccessor.getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; - } - @MethodDescription(example = {@Example("fluid('lava')"), @Example(value = "item('minecraft:cobblestone')", commented = true)}) public boolean removeByInput(IIngredient input) { - return WoodenBasinRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (input.test(recipe.getFluidStack()) || Arrays.stream(recipe.getInputs()).anyMatch(x -> { if (x instanceof ItemStack is) return input.test(is); @@ -81,7 +65,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example(value = "item('minecraft:obsidian')", commented = true)) public boolean removeByOutput(IIngredient output) { - return WoodenBasinRecipesAccessor.getRecipes().removeIf(recipe -> { + return getRecipes().removeIf(recipe -> { if (output.test(recipe.getOutput())) { addBackup(recipe); return true; @@ -90,17 +74,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(WoodenBasinRecipesAccessor.getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - WoodenBasinRecipesAccessor.getRecipes().forEach(this::addBackup); - WoodenBasinRecipesAccessor.getRecipes().clear(); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "4", type = Comp.Type.LTE)}) @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java index e685ee32b..e625caa71 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/prodigytech/ExplosionFurnace.java @@ -4,15 +4,16 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import lykrast.prodigytech.common.recipe.ExplosionFurnaceManager; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class ExplosionFurnace extends VirtualizedRegistry { +public class ExplosionFurnace extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(ore('ingotGold'), item('minecraft:diamond')).craftPerReagent(8).power(160).output(item('minecraft:emerald_block'))"), @@ -23,49 +24,23 @@ public ExplosionFurnace.RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - removeScripted().forEach(this::remove); - restoreFromBackup().forEach(ExplosionFurnaceManager::addRecipe); - } - - private boolean remove(ExplosionFurnaceManager.ExplosionFurnaceRecipe recipe) { - return ExplosionFurnaceManager.RECIPES.removeIf(recipe::equals); - } - - private boolean backupAndRemove(ExplosionFurnaceManager.ExplosionFurnaceRecipe recipe) { - if (remove(recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return ExplosionFurnaceManager.RECIPES; } public void addRecipe(ExplosionFurnaceManager.ExplosionFurnaceRecipe x) { - addScripted(x); - ExplosionFurnaceManager.addRecipe(x); + add(x); } @MethodDescription(example = @Example("item('prodigytech:ferramic_ingot')")) public void removeByOutput(ItemStack output) { - ExplosionFurnaceManager.RECIPES.removeIf(r -> { + getRecipes().removeIf(r -> { if (!r.getOutput().isItemEqual(output)) return false; addBackup(r); return true; }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ExplosionFurnaceManager.RECIPES.forEach(this::addBackup); - ExplosionFurnaceManager.removeAllRecipes(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ExplosionFurnaceManager.RECIPES) - .setRemover(this::backupAndRemove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "2")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java index ecc968631..0ab3b9fc4 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/projecte/Transmutation.java @@ -1,20 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.projecte; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import moze_intel.projecte.utils.WorldTransmutations; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import org.apache.commons.lang3.tuple.ImmutablePair; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Transmutation extends VirtualizedRegistry { +public class Transmutation extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(blockstate('minecraft:end_stone')).output(blockstate('minecraft:diamond_block'), blockstate('minecraft:gold_block'))"), @@ -26,28 +26,13 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - WorldTransmutations.getWorldTransmutations().removeAll(removeScripted()); - WorldTransmutations.getWorldTransmutations().addAll(restoreFromBackup()); - } - - public void add(WorldTransmutations.Entry recipe) { - addScripted(recipe); - WorldTransmutations.getWorldTransmutations().add(recipe); - } - - public boolean remove(WorldTransmutations.Entry recipe) { - if (WorldTransmutations.getWorldTransmutations().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return WorldTransmutations.getWorldTransmutations(); } @MethodDescription(example = @Example("blockstate('minecraft:wool')")) public boolean removeByInput(IBlockState input) { - return WorldTransmutations.getWorldTransmutations().removeIf(r -> { + return getRecipes().removeIf(r -> { if (input.equals(r.input)) { addBackup(r); return true; @@ -58,7 +43,7 @@ public boolean removeByInput(IBlockState input) { @MethodDescription(example = @Example("blockstate('minecraft:dirt')")) public boolean removeByOutput(IBlockState output) { - return WorldTransmutations.getWorldTransmutations().removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.equals(r.outputs.getKey()) || output.equals(r.outputs.getValue())) { addBackup(r); return true; @@ -67,17 +52,6 @@ public boolean removeByOutput(IBlockState output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(WorldTransmutations.getWorldTransmutations()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - WorldTransmutations.getWorldTransmutations().forEach(this::addBackup); - WorldTransmutations.getWorldTransmutations().clear(); - } - public static class RecipeBuilder extends AbstractRecipeBuilder { @Property(valid = @Comp(value = "null", type = Comp.Type.NOT), ignoresInheritedMethods = true) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java index 8de952f11..fe22e79df 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/roots/LifeEssence.java @@ -3,27 +3,21 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import epicsquid.roots.init.ModRecipes; import net.minecraft.entity.EntityLivingBase; import net.minecraftforge.fml.common.registry.EntityEntry; +import java.util.Collection; + @RegistryDescription( category = RegistryDescription.Category.ENTRIES ) -public class LifeEssence extends VirtualizedRegistry> { +public class LifeEssence extends StandardListRegistry> { @Override - public void onReload() { - removeScripted().forEach(ModRecipes.getLifeEssenceList()::remove); - restoreFromBackup().forEach(ModRecipes.getLifeEssenceList()::add); - } - - @MethodDescription(type = MethodDescription.Type.ADDITION) - public void add(Class clazz) { - ModRecipes.getLifeEssenceList().add(clazz); - addScripted(clazz); + public Collection> getRecipes() { + return ModRecipes.getLifeEssenceList(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -36,31 +30,14 @@ public void add(EntityEntry entity) { add((Class) entity.getEntityClass()); } - @MethodDescription(example = @Example("entity('minecraft:sheep')")) - public boolean remove(Class clazz) { - if (!ModRecipes.getLifeEssenceList().remove(clazz)) return false; - addBackup(clazz); - return true; - } - @MethodDescription public boolean remove(EntityLivingBase entity) { return remove(entity.getClass()); } - @MethodDescription + @MethodDescription(example = @Example("entity('minecraft:sheep')")) public boolean remove(EntityEntry entity) { return remove((Class) entity.getEntityClass()); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ModRecipes.getLifeEssenceList().forEach(this::addBackup); - ModRecipes.getLifeEssenceList().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream> streamRecipes() { - return new SimpleObjectStream<>(ModRecipes.getLifeEssenceList()).setRemover(this::remove); - } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java index b1018f668..886566ae7 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/Alchemy.java @@ -5,9 +5,8 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraftforge.fluids.FluidRegistry; @@ -21,12 +20,17 @@ import java.util.Collection; @RegistryDescription -public class Alchemy extends VirtualizedRegistry { +public class Alchemy extends StandardListRegistry { public Alchemy() { super(Alias.generateOfClass(Alchemy.class).andGenerate("Condenser")); } + @Override + public Collection getRecipes() { + return Recipes.condenserRecipes; + } + @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:stone'), item('minecraft:gold_ingot')).output(item('minecraft:clay') * 4).time(20)"), @Example(value = ".input(item('minecraft:stone'), item('minecraft:gold_ingot'), item('minecraft:diamond')).bottle(item('minecraft:torch')).advanced().effect(new PotionEffect(potion('minecraft:night_vision'), 3600, 1))", imports = "net.minecraft.potion.PotionEffect"), @@ -37,25 +41,10 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - public void onReload() { - Recipes.condenserRecipes.removeAll(removeScripted()); - Recipes.condenserRecipes.addAll(restoreFromBackup()); - } - - public void add(ICondenserRecipe recipe) { - Recipes.condenserRecipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(ICondenserRecipe recipe) { - addBackup(recipe); - return Recipes.condenserRecipes.remove(recipe); - } @MethodDescription(example = @Example("item('rustic:elixir').withNbt(['ElixirEffects': [['Effect': 'minecraft:night_vision', 'Duration': 3600, 'Amplifier': 0]]])")) public boolean removeByOutput(IIngredient output) { - return Recipes.condenserRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (output.test(entry.getResult())) { addBackup(entry); return true; @@ -66,7 +55,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('minecraft:sugar')")) public boolean removeByInput(IIngredient input) { - return Recipes.condenserRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (entry.getInputs().stream().flatMap(Collection::stream).anyMatch(input)) { addBackup(entry); return true; @@ -75,17 +64,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - Recipes.condenserRecipes.forEach(this::addBackup); - Recipes.condenserRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Recipes.condenserRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(value = "1", type = Comp.Type.GTE), @Comp(value = "2 or 3", type = Comp.Type.LTE)}) @Property(property = "fluidInput", defaultValue = "fluid('water') * 125", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) @Property(property = "output", valid = {@Comp(value = "0", type = Comp.Type.GTE), @Comp(value = "1", type = Comp.Type.LTE)}) diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java index 1b792a4df..c89f04d0e 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/BrewingBarrel.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import org.jetbrains.annotations.Nullable; import rustic.common.crafting.BrewingBarrelRecipe; import rustic.common.crafting.IBrewingBarrelRecipe; import rustic.common.crafting.Recipes; +import java.util.Collection; + @RegistryDescription -public class BrewingBarrel extends VirtualizedRegistry { +public class BrewingBarrel extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".fluidInput(fluid('ironberryjuice')).fluidOutput(fluid('lava'))"), @@ -24,24 +25,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - Recipes.brewingRecipes.removeAll(removeScripted()); - Recipes.brewingRecipes.addAll(restoreFromBackup()); - } - - public void add(IBrewingBarrelRecipe recipe) { - Recipes.brewingRecipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(IBrewingBarrelRecipe recipe) { - addBackup(recipe); - return Recipes.brewingRecipes.remove(recipe); + public Collection getRecipes() { + return Recipes.brewingRecipes; } @MethodDescription(example = @Example("fluid('ale')")) public boolean removeByOutput(IIngredient output) { - return Recipes.brewingRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (output.test(entry.getOuput())) { addBackup(entry); return true; @@ -52,7 +42,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("fluid('ironberryjuice')")) public boolean removeByInput(IIngredient input) { - return Recipes.brewingRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (input.test(entry.getInput())) { addBackup(entry); return true; @@ -61,17 +51,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - Recipes.brewingRecipes.forEach(this::addBackup); - Recipes.brewingRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Recipes.brewingRecipes).setRemover(this::remove); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java index a0e899536..f8a609045 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/CrushingTub.java @@ -4,17 +4,18 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; import rustic.common.crafting.CrushingTubRecipe; import rustic.common.crafting.ICrushingTubRecipe; import rustic.common.crafting.Recipes; +import java.util.Collection; + @RegistryDescription -public class CrushingTub extends VirtualizedRegistry { +public class CrushingTub extends StandardListRegistry { @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:stone')).fluidOutput(fluid('lava') * 50)"), @@ -25,24 +26,13 @@ public static RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - Recipes.crushingTubRecipes.removeAll(removeScripted()); - Recipes.crushingTubRecipes.addAll(restoreFromBackup()); - } - - public void add(ICrushingTubRecipe recipe) { - Recipes.crushingTubRecipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(ICrushingTubRecipe recipe) { - addBackup(recipe); - return Recipes.crushingTubRecipes.remove(recipe); + public Collection getRecipes() { + return Recipes.crushingTubRecipes; } @MethodDescription(example = {@Example("fluid('ironberryjuice')"), @Example("item('minecraft:sugar')")}) public boolean removeByOutput(IIngredient output) { - return Recipes.crushingTubRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (output.test(entry.getResult()) || output.test(entry.getByproduct())) { addBackup(entry); return true; @@ -53,7 +43,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("item('rustic:wildberries')")) public boolean removeByInput(IIngredient input) { - return Recipes.crushingTubRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (input.test(entry.getInput())) { addBackup(entry); return true; @@ -62,17 +52,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - Recipes.crushingTubRecipes.forEach(this::addBackup); - Recipes.crushingTubRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Recipes.crushingTubRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "fluidOutput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java index 034cbbcff..73ed44ab2 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/rustic/EvaporatingBasin.java @@ -5,20 +5,26 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import org.jetbrains.annotations.Nullable; import rustic.common.crafting.IEvaporatingBasinRecipe; import rustic.common.crafting.Recipes; +import java.util.Collection; + @RegistryDescription -public class EvaporatingBasin extends VirtualizedRegistry { +public class EvaporatingBasin extends StandardListRegistry { public EvaporatingBasin() { super(Alias.generateOfClass(EvaporatingBasin.class).andGenerate("DryingBasin")); } + @Override + public Collection getRecipes() { + return Recipes.evaporatingRecipes; + } + @RecipeBuilderDescription(example = { @Example(".fluidInput(fluid('water') * 200).output(item('minecraft:clay'))"), @Example(".fluidInput(fluid('lava') * 50).output(item('minecraft:iron_ingot'))") @@ -27,31 +33,15 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - public void onReload() { - Recipes.evaporatingRecipes.removeAll(removeScripted()); - Recipes.evaporatingRecipes.addAll(restoreFromBackup()); - } - @Override public void afterScriptLoad() { Recipes.evaporatingRecipesMap.clear(); - Recipes.evaporatingRecipes.forEach(recipe -> Recipes.evaporatingRecipesMap.put(recipe.getFluid(), recipe)); - } - - public void add(IEvaporatingBasinRecipe recipe) { - Recipes.evaporatingRecipes.add(recipe); - addScripted(recipe); - } - - public boolean remove(IEvaporatingBasinRecipe recipe) { - addBackup(recipe); - return Recipes.evaporatingRecipes.remove(recipe); + getRecipes().forEach(recipe -> Recipes.evaporatingRecipesMap.put(recipe.getFluid(), recipe)); } @MethodDescription(example = @Example(value = "item('rustic:dust_tiny_iron')", commented = true)) public boolean removeByOutput(IIngredient output) { - return Recipes.evaporatingRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (output.test(entry.getOutput())) { addBackup(entry); return true; @@ -62,7 +52,7 @@ public boolean removeByOutput(IIngredient output) { @MethodDescription(example = @Example("fluid('ironberryjuice')")) public boolean removeByInput(IIngredient input) { - return Recipes.evaporatingRecipes.removeIf(entry -> { + return getRecipes().removeIf(entry -> { if (input.test(entry.getInput())) { addBackup(entry); return true; @@ -71,17 +61,6 @@ public boolean removeByInput(IIngredient input) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - Recipes.evaporatingRecipes.forEach(this::addBackup); - Recipes.evaporatingRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Recipes.evaporatingRecipes).setRemover(this::remove); - } - @Property(property = "output", valid = @Comp("1")) @Property(property = "fluidInput", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java index 6e2133ec0..847e9b7c1 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/HighOven.java @@ -4,12 +4,10 @@ import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; -import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeRegistry; import com.cleanroommc.groovyscript.core.mixin.tcomplement.TCompRegistryAccessor; import com.cleanroommc.groovyscript.core.mixin.tconstruct.MeltingRecipeAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.google.common.collect.ImmutableMap; import knightminer.tcomplement.library.steelworks.*; import net.minecraft.item.ItemStack; @@ -19,9 +17,10 @@ import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; +import java.util.Collection; import java.util.Map; -public class HighOven extends MeltingRecipeRegistry { +public class HighOven extends StandardListRegistry { public final Fuel fuel = new Fuel(); public final Heating heating = new Heating(); @@ -31,11 +30,15 @@ public MeltingRecipeBuilder recipeBuilder() { return new MeltingRecipeBuilder(this, "Tinkers Complement High Oven override"); } + @Override + public Collection getRecipes() { + return TCompRegistryAccessor.getHighOvenOverrides(); + } + @Override @GroovyBlacklist public void onReload() { - removeScripted().forEach(TCompRegistryAccessor.getHighOvenOverrides()::remove); - restoreFromBackup().forEach(TCompRegistryAccessor.getHighOvenOverrides()::add); + super.onReload(); fuel.onReload(); heating.onReload(); mixing.onReload(); @@ -47,22 +50,8 @@ public MeltingRecipe add(IIngredient input, FluidStack output, int temp) { return recipe; } - @Override - public void add(MeltingRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TCompRegistryAccessor.getHighOvenOverrides().add(recipe); - } - - public boolean remove(MeltingRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TCompRegistryAccessor.getHighOvenOverrides().remove(recipe); - return true; - } - public boolean removeByOutput(FluidStack output) { - if (TCompRegistryAccessor.getHighOvenOverrides().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.output.isFluidEqual(output); if (found) addBackup(recipe); return found; @@ -77,7 +66,7 @@ public boolean removeByOutput(FluidStack output) { public boolean removeByInput(IIngredient input) { NonNullList list = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TCompRegistryAccessor.getHighOvenOverrides().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(list).isPresent(); if (found) addBackup(recipe); list.clear(); @@ -94,7 +83,7 @@ public boolean removeByInput(IIngredient input) { public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { NonNullList list = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TCompRegistryAccessor.getHighOvenOverrides().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(list).isPresent() && recipe.output.isFluidEqual(output); if (found) addBackup(recipe); list.clear(); @@ -109,38 +98,15 @@ public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { return false; } - public void removeAll() { - TCompRegistryAccessor.getHighOvenOverrides().forEach(this::addBackup); - TCompRegistryAccessor.getHighOvenOverrides().forEach(TCompRegistryAccessor.getHighOvenOverrides()::remove); - } - - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TCompRegistryAccessor.getHighOvenOverrides()).setRemover(this::remove); - } - - public static class Mixing extends VirtualizedRegistry { + public static class Mixing extends StandardListRegistry { public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override - public void onReload() { - removeScripted().forEach(TCompRegistryAccessor.getMixRegistry()::remove); - restoreFromBackup().forEach(TCompRegistryAccessor.getMixRegistry()::add); - } - - public void add(IMixRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TCompRegistryAccessor.getMixRegistry().add(recipe); - } - - public boolean remove(IMixRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TCompRegistryAccessor.getMixRegistry().remove(recipe); - return true; + public Collection getRecipes() { + return TCompRegistryAccessor.getMixRegistry(); } public boolean removeByOutput(FluidStack output) { @@ -158,7 +124,7 @@ public boolean removeByOutput(FluidStack output) { } public boolean removeByInput(FluidStack input) { - if (TCompRegistryAccessor.getMixRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { HighOvenFilter recipe1 = (recipe instanceof HighOvenFilter) ? (HighOvenFilter) recipe : null; boolean found = recipe1 != null && recipe1.getInput().isFluidEqual(input); if (found) addBackup(recipe); @@ -173,7 +139,7 @@ public boolean removeByInput(FluidStack input) { } public boolean removeByInputAndOutput(FluidStack input, FluidStack output) { - if (TCompRegistryAccessor.getMixRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { HighOvenFilter recipe1 = (recipe instanceof HighOvenFilter) ? (HighOvenFilter) recipe : null; boolean found = recipe1 != null && recipe1.getInput().isFluidEqual(input) && recipe1.getOutput().isFluidEqual(output); if (found) addBackup(recipe); @@ -188,7 +154,7 @@ public boolean removeByInputAndOutput(FluidStack input, FluidStack output) { } public boolean removeByAdditives(Map additives) { - if (TCompRegistryAccessor.getMixRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { MixRecipe recipe1 = (recipe instanceof MixRecipe) ? (MixRecipe) recipe : null; if (recipe1 != null) { for (Map.Entry entry : additives.entrySet()) { @@ -212,15 +178,6 @@ public boolean removeByAdditive(MixAdditive type, IIngredient item) { return removeByAdditives(ImmutableMap.of(type, item)); } - public void removeAll() { - TCompRegistryAccessor.getMixRegistry().forEach(this::addBackup); - TCompRegistryAccessor.getMixRegistry().forEach(TCompRegistryAccessor.getMixRegistry()::remove); - } - - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TCompRegistryAccessor.getMixRegistry()).setRemover(this::remove); - } - public class RecipeBuilder extends AbstractRecipeBuilder { private int temp = 300; @@ -291,16 +248,15 @@ public void validate(GroovyLog.Msg msg) { } } - public static class Heating extends VirtualizedRegistry { + public static class Heating extends StandardListRegistry { public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override - public void onReload() { - removeScripted().forEach(TCompRegistryAccessor.getHeatRegistry()::remove); - restoreFromBackup().forEach(TCompRegistryAccessor.getHeatRegistry()::add); + public Collection getRecipes() { + return TCompRegistryAccessor.getHeatRegistry(); } public IHeatRecipe add(FluidStack input, FluidStack output, int temp) { @@ -309,21 +265,8 @@ public IHeatRecipe add(FluidStack input, FluidStack output, int temp) { return recipe; } - public void add(IHeatRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TCompRegistryAccessor.getHeatRegistry().add(recipe); - } - - public boolean remove(IHeatRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TCompRegistryAccessor.getHeatRegistry().remove(recipe); - return true; - } - public boolean removeByInput(FluidStack input) { - if (TCompRegistryAccessor.getHeatRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().isFluidEqual(input); if (found) addBackup(recipe); return found; @@ -337,7 +280,7 @@ public boolean removeByInput(FluidStack input) { } public boolean removeByOutput(FluidStack output) { - if (TCompRegistryAccessor.getHeatRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getOutput().isFluidEqual(output); if (found) addBackup(recipe); return found; @@ -351,7 +294,7 @@ public boolean removeByOutput(FluidStack output) { } public boolean removeByInputAndOutput(FluidStack input, FluidStack output) { - if (TCompRegistryAccessor.getHeatRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getInput().isFluidEqual(input) && recipe.getOutput().isFluidEqual(output); if (found) addBackup(recipe); return found; @@ -364,15 +307,6 @@ public boolean removeByInputAndOutput(FluidStack input, FluidStack output) { return false; } - public void removeAll() { - TCompRegistryAccessor.getHeatRegistry().forEach(this::addBackup); - TCompRegistryAccessor.getHeatRegistry().forEach(TCompRegistryAccessor.getHeatRegistry()::remove); - } - - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TCompRegistryAccessor.getHeatRegistry()).setRemover(this::remove); - } - public class RecipeBuilder extends AbstractRecipeBuilder { private int temp = 300; @@ -408,17 +342,15 @@ public void validate(GroovyLog.Msg msg) { } } - public static class Fuel extends VirtualizedRegistry { + public static class Fuel extends StandardListRegistry { public RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(TCompRegistryAccessor.getHighOvenFuels()::remove); - restoreFromBackup().forEach(TCompRegistryAccessor.getHighOvenFuels()::add); + public Collection getRecipes() { + return TCompRegistryAccessor.getHighOvenFuels(); } public HighOvenFuel add(IIngredient item, int time, int rate) { @@ -427,21 +359,8 @@ public HighOvenFuel add(IIngredient item, int time, int rate) { return fuel; } - public void add(HighOvenFuel fuel) { - if (fuel == null) return; - addScripted(fuel); - TCompRegistryAccessor.getHighOvenFuels().add(fuel); - } - - public boolean remove(HighOvenFuel fuel) { - if (fuel == null) return false; - addBackup(fuel); - TCompRegistryAccessor.getHighOvenFuels().remove(fuel); - return true; - } - public boolean removeByItem(IIngredient item) { - if (TCompRegistryAccessor.getHighOvenFuels().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.matches(item.getMatchingStacks()[0]); if (found) addBackup(recipe); return found; @@ -454,15 +373,6 @@ public boolean removeByItem(IIngredient item) { return false; } - public void removeAll() { - TCompRegistryAccessor.getHighOvenFuels().forEach(this::addBackup); - TCompRegistryAccessor.getHighOvenFuels().forEach(TCompRegistryAccessor.getHighOvenFuels()::remove); - } - - public SimpleObjectStream streamFuels() { - return new SimpleObjectStream<>(TCompRegistryAccessor.getHighOvenFuels()).setRemover(this::remove); - } - public class RecipeBuilder extends AbstractRecipeBuilder { private int time = 1; diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java index b60b96e9e..234cdae20 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tcomplement/Melter.java @@ -5,17 +5,19 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.compat.mods.tcomplement.recipe.IngredientBlacklist; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; -import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeRegistry; import com.cleanroommc.groovyscript.core.mixin.tcomplement.TCompRegistryAccessor; import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.registry.AbstractReloadableStorage; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import knightminer.tcomplement.library.IBlacklist; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; -public class Melter extends MeltingRecipeRegistry { +import java.util.Collection; + +public class Melter extends StandardListRegistry { @GroovyBlacklist protected final AbstractReloadableStorage backupStorage = new AbstractReloadableStorage<>(); @@ -24,12 +26,16 @@ public MeltingRecipeBuilder recipeBuilder() { return new MeltingRecipeBuilder(this, "Tinkers Complement Melter override"); } + @Override + public Collection getRecipes() { + return TCompRegistryAccessor.getMeltingOverrides(); + } + @Override @GroovyBlacklist public void onReload() { - removeScripted().forEach(TCompRegistryAccessor.getMeltingOverrides()::remove); + super.onReload(); backupStorage.removeScripted().forEach(TCompRegistryAccessor.getMeltingBlacklist()::remove); - restoreFromBackup().forEach(TCompRegistryAccessor.getMeltingOverrides()::add); backupStorage.restoreFromBackup().forEach(TCompRegistryAccessor.getMeltingBlacklist()::add); } @@ -45,26 +51,12 @@ public MeltingRecipe add(IIngredient input, FluidStack output, int temp) { return recipe; } - @Override - public void add(MeltingRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TCompRegistryAccessor.getMeltingOverrides().add(recipe); - } - public void addBlacklist(IBlacklist blacklist) { if (blacklist == null) return; backupStorage.addScripted(blacklist); TCompRegistryAccessor.getMeltingBlacklist().add(blacklist); } - public boolean remove(MeltingRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TCompRegistryAccessor.getMeltingOverrides().remove(recipe); - return true; - } - public boolean removeBlacklist(IBlacklist blacklist) { if (blacklist == null) return false; backupStorage.addBackup(blacklist); @@ -88,7 +80,7 @@ public boolean removeFromBlacklist(ItemStack item) { public boolean removeByInput(IIngredient input) { NonNullList list = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TCompRegistryAccessor.getMeltingOverrides().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(list).isPresent(); list.clear(); if (found) addBackup(recipe); @@ -104,7 +96,7 @@ public boolean removeByInput(IIngredient input) { } public boolean removeByOutput(FluidStack stack) { - if (TCompRegistryAccessor.getMeltingOverrides().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.output.isFluidEqual(stack); if (found) addBackup(recipe); return found; @@ -119,7 +111,7 @@ public boolean removeByOutput(FluidStack stack) { public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { NonNullList list = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TCompRegistryAccessor.getMeltingOverrides().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.output.isFluidEqual(output) && recipe.input.matches(list).isPresent(); list.clear(); if (found) addBackup(recipe); @@ -134,11 +126,6 @@ public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { return false; } - public void removeAll() { - TCompRegistryAccessor.getMeltingOverrides().forEach(this::addBackup); - TCompRegistryAccessor.getMeltingOverrides().forEach(TCompRegistryAccessor.getMeltingOverrides()::remove); - } - public void removeAllBlacklists() { TCompRegistryAccessor.getMeltingBlacklist().forEach(backupStorage::addBackup); TCompRegistryAccessor.getMeltingBlacklist().forEach(TCompRegistryAccessor.getMeltingBlacklist()::remove); @@ -147,8 +134,4 @@ public void removeAllBlacklists() { public SimpleObjectStream streamBlacklists() { return new SimpleObjectStream<>(TCompRegistryAccessor.getMeltingBlacklist()).setRemover(this::removeBlacklist); } - - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TCompRegistryAccessor.getMeltingOverrides()).setRemover(this::remove); - } } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGeneratorRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGeneratorRegistry.java index 75a2202ca..991cecebb 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGeneratorRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGeneratorRegistry.java @@ -1,48 +1,28 @@ package com.cleanroommc.groovyscript.compat.mods.techreborn; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import reborncore.api.praescriptum.fuels.Fuel; import reborncore.api.praescriptum.fuels.FuelHandler; -public abstract class AbstractGeneratorRegistry extends VirtualizedRegistry { +import java.util.Collection; + +public abstract class AbstractGeneratorRegistry extends StandardListRegistry { abstract FuelHandler handler(); @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - handler().getFuels().removeAll(removeScripted()); - handler().getFuels().addAll(restoreFromBackup()); - } - - public void add(Fuel recipe) { - if (recipe != null) { - addScripted(recipe); - recipe.register(); - } - } - - public boolean remove(Fuel recipe) { - if (handler().getFuels().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return handler().getFuels(); } @MethodDescription public void removeByInput(IIngredient input) { - handler().getFuels().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (recipe.getInputIngredients().stream().map(x -> x.ingredient).anyMatch(x -> { if (x instanceof ItemStack itemStack) return input.test(itemStack); if (x instanceof FluidStack fluidStack) return input.test(fluidStack); @@ -56,15 +36,4 @@ public void removeByInput(IIngredient input) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(handler().getFuels()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - handler().getFuels().forEach(this::addBackup); - handler().getFuels().clear(); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGenericTechRebornRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGenericTechRebornRegistry.java index 0602514c1..a918f2228 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGenericTechRebornRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractGenericTechRebornRegistry.java @@ -1,76 +1,35 @@ package com.cleanroommc.groovyscript.compat.mods.techreborn; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.documentation.annotations.Example; -import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import org.jetbrains.annotations.ApiStatus; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import reborncore.api.recipe.IBaseRecipeType; import reborncore.api.recipe.RecipeHandler; import reborncore.common.recipes.RecipeTranslator; -public abstract class AbstractGenericTechRebornRegistry extends VirtualizedRegistry { +import java.util.Collection; + +public abstract class AbstractGenericTechRebornRegistry extends StandardListRegistry { abstract String reference(); @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - removeScripted().forEach(recipe -> RecipeHandler.recipeList.removeIf(r -> r == recipe)); - RecipeHandler.recipeList.addAll(restoreFromBackup()); - } - - public void add(IBaseRecipeType recipe) { - if (recipe != null) { - addScripted(recipe); - RecipeHandler.recipeList.add(recipe); - } - } - - public boolean remove(IBaseRecipeType recipe) { - if (RecipeHandler.recipeList.removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return RecipeHandler.getRecipeClassFromName(reference()); } public void removeByInput(IIngredient input) { - RecipeHandler.recipeList.removeIf(recipe -> { - if (recipe.getRecipeName().equals(reference())) { - if (recipe.getInputs().stream().map(RecipeTranslator::getStackFromObject).anyMatch(input)) { - addBackup(recipe); - return true; - } + getRecipes().removeIf(recipe -> { + if (recipe.getInputs().stream().map(RecipeTranslator::getStackFromObject).anyMatch(input)) { + addBackup(recipe); + return true; } return false; }); } public void removeByOutput(IIngredient output) { - RecipeHandler.recipeList.removeIf(recipe -> { - if (recipe.getRecipeName().equals(reference())) { - if (recipe.getOutputs().stream().anyMatch(output)) { - addBackup(recipe); - return true; - } - } - return false; - }); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(RecipeHandler.getRecipeClassFromName(reference())).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - RecipeHandler.recipeList.removeIf(recipe -> { - if (recipe.getRecipeName().equals(reference())) { + getRecipes().removeIf(recipe -> { + if (recipe.getOutputs().stream().anyMatch(output)) { addBackup(recipe); return true; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractPraescriptumRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractPraescriptumRegistry.java index 45c675cc2..a005bce34 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractPraescriptumRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/techreborn/AbstractPraescriptumRegistry.java @@ -1,50 +1,29 @@ package com.cleanroommc.groovyscript.compat.mods.techreborn; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.IIngredient; -import com.cleanroommc.groovyscript.api.documentation.annotations.Example; import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; -import org.jetbrains.annotations.ApiStatus; import reborncore.api.praescriptum.recipes.Recipe; import reborncore.api.praescriptum.recipes.RecipeHandler; import java.util.Arrays; +import java.util.Collection; -public abstract class AbstractPraescriptumRegistry extends VirtualizedRegistry { +public abstract class AbstractPraescriptumRegistry extends StandardListRegistry { abstract RecipeHandler handler(); @Override - @GroovyBlacklist - @ApiStatus.Internal - public void onReload() { - handler().getRecipes().removeAll(removeScripted()); - handler().getRecipes().addAll(restoreFromBackup()); - } - - public void add(Recipe recipe) { - if (recipe != null) { - addScripted(recipe); - recipe.register(); - } - } - - public boolean remove(Recipe recipe) { - if (handler().getRecipes().removeIf(r -> r == recipe)) { - addBackup(recipe); - return true; - } - return false; + public Collection getRecipes() { + return handler().getRecipes(); } @MethodDescription public void removeByInput(IIngredient input) { - handler().getRecipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (recipe.getInputIngredients().stream().map(x -> x.ingredient).anyMatch(x -> { if (x instanceof ItemStack itemStack) return input.test(itemStack); if (x instanceof FluidStack fluidStack) return input.test(fluidStack); @@ -60,7 +39,7 @@ public void removeByInput(IIngredient input) { @MethodDescription public void removeByOutput(IIngredient output) { - handler().getRecipes().removeIf(recipe -> { + getRecipes().removeIf(recipe -> { if (Arrays.stream(recipe.getItemOutputs()).anyMatch(output) || Arrays.stream(recipe.getFluidOutputs()).anyMatch(output::test)) { addBackup(recipe); return true; @@ -69,15 +48,4 @@ public void removeByOutput(IIngredient output) { }); } - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(handler().getRecipes()).setRemover(this::remove); - } - - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - handler().getRecipes().forEach(this::addBackup); - handler().getRecipes().clear(); - } - } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java index c0548d99e..211df699f 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/MoonlightForge.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.shiroroku.theaurorian.Recipes.MoonlightForgeRecipe; import com.shiroroku.theaurorian.Recipes.MoonlightForgeRecipeHandler; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class MoonlightForge extends VirtualizedRegistry { +public class MoonlightForge extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:stone_sword'), item('minecraft:diamond')).output(item('minecraft:diamond_sword'))")) public RecipeBuilder recipeBuilder() { @@ -21,29 +22,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - restoreFromBackup().forEach(MoonlightForgeRecipeHandler::addRecipe); - removeScripted().forEach(r -> MoonlightForgeRecipeHandler.allRecipes.removeIf(u -> u.equals(r))); - } - - public void add(MoonlightForgeRecipe recipe) { - addScripted(recipe); - MoonlightForgeRecipeHandler.addRecipe(recipe); - } - - public boolean remove(MoonlightForgeRecipe recipe) { - return MoonlightForgeRecipeHandler.allRecipes.removeIf(r -> { - if (r.equals(recipe)) { - addBackup(recipe); - return true; - } - return false; - }); + public Collection getRecipes() { + return MoonlightForgeRecipeHandler.allRecipes; } @MethodDescription(example = @Example("item('theaurorian:moonstonesword'), item('theaurorian:aurorianiteingot')")) public boolean removeByInput(IIngredient input, IIngredient catalyst) { - return MoonlightForgeRecipeHandler.allRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (input.test(r.getInput1()) && catalyst.test(r.getInput2())) { addBackup(r); return true; @@ -54,7 +39,7 @@ public boolean removeByInput(IIngredient input, IIngredient catalyst) { @MethodDescription(example = @Example("item('theaurorian:queenschipper')")) public boolean removeByOutput(IIngredient output) { - return MoonlightForgeRecipeHandler.allRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -63,17 +48,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - MoonlightForgeRecipeHandler.allRecipes.forEach(this::addBackup); - MoonlightForgeRecipeHandler.allRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(MoonlightForgeRecipeHandler.allRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("2")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java index c177069dc..b35b5024d 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/theaurorian/Scrapper.java @@ -4,16 +4,17 @@ import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.ModSupport; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import com.shiroroku.theaurorian.Recipes.ScrapperRecipe; import com.shiroroku.theaurorian.Recipes.ScrapperRecipeHandler; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; + @RegistryDescription -public class Scrapper extends VirtualizedRegistry { +public class Scrapper extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:stone_sword')).output(item('minecraft:cobblestone'))")) public RecipeBuilder recipeBuilder() { @@ -21,29 +22,13 @@ public RecipeBuilder recipeBuilder() { } @Override - public void onReload() { - restoreFromBackup().forEach(ScrapperRecipeHandler::addRecipe); - removeScripted().forEach(r -> ScrapperRecipeHandler.allRecipes.removeIf(u -> u.equals(r))); - } - - public void add(ScrapperRecipe recipe) { - addScripted(recipe); - ScrapperRecipeHandler.addRecipe(recipe); - } - - public boolean remove(ScrapperRecipe recipe) { - return ScrapperRecipeHandler.allRecipes.removeIf(r -> { - if (r.equals(recipe)) { - addBackup(recipe); - return true; - } - return false; - }); + public Collection getRecipes() { + return ScrapperRecipeHandler.allRecipes; } @MethodDescription(example = @Example("item('minecraft:iron_sword')")) public boolean removeByInput(IIngredient input) { - return ScrapperRecipeHandler.allRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (input.test(r.getInput())) { addBackup(r); return true; @@ -54,7 +39,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription(example = @Example("item('theaurorian:scrapaurorianite')")) public boolean removeByOutput(IIngredient output) { - return ScrapperRecipeHandler.allRecipes.removeIf(r -> { + return getRecipes().removeIf(r -> { if (output.test(r.getOutput())) { addBackup(r); return true; @@ -63,17 +48,6 @@ public boolean removeByOutput(IIngredient output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - ScrapperRecipeHandler.allRecipes.forEach(this::addBackup); - ScrapperRecipeHandler.allRecipes.clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(ScrapperRecipeHandler.allRecipes).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java index 0caf11fe2..bbe457dca 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Alloying.java @@ -1,21 +1,20 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.Nullable; import slimeknights.tconstruct.library.smeltery.AlloyRecipe; import java.util.Arrays; +import java.util.Collection; import java.util.List; @RegistryDescription -public class Alloying extends VirtualizedRegistry { +public class Alloying extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".fluidOutput(fluid('iron') * 3).fluidInput(fluid('clay') * 1,fluid('lava') * 2)")) public RecipeBuilder recipeBuilder() { @@ -23,10 +22,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(TinkerRegistryAccessor.getAlloyRegistry()::remove); - restoreFromBackup().forEach(TinkerRegistryAccessor.getAlloyRegistry()::add); + public Collection getRecipes() { + return TinkerRegistryAccessor.getAlloyRegistry(); } @MethodDescription(type = MethodDescription.Type.ADDITION, example = @Example("fluid('lava') * 144, fluid('water') * 500, fluid('iron') * 5, fluid('clay') * 60")) @@ -36,22 +33,9 @@ public AlloyRecipe add(FluidStack output, FluidStack... inputs) { return recipe; } - public void add(AlloyRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TinkerRegistryAccessor.getAlloyRegistry().add(recipe); - } - - public boolean remove(AlloyRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TinkerRegistryAccessor.getAlloyRegistry().remove(recipe); - return true; - } - @MethodDescription(example = @Example("fluid('pigiron')")) public boolean removeByOutput(FluidStack output) { - if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getResult().isFluidEqual(output); if (found) addBackup(recipe); return found; @@ -67,7 +51,7 @@ public boolean removeByOutput(FluidStack output) { @MethodDescription(description = "groovyscript.wiki.tconstruct.alloying.removeByInputs", example = @Example("fluid('cobalt')*2,fluid('ardite')*2")) public boolean removeByInputs(FluidStack... inputs) { List list = Arrays.asList(inputs); - if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.matches(list) > 0; if (found) addBackup(recipe); return found; @@ -83,7 +67,7 @@ public boolean removeByInputs(FluidStack... inputs) { @MethodDescription(example = @Example("fluid('knightslime')*72,fluid('iron')*72,fluid('stone')*144,fluid('purpleslime')*125")) public boolean removeByInputsAndOutput(FluidStack output, FluidStack... inputs) { List list = Arrays.asList(inputs); - if (TinkerRegistryAccessor.getAlloyRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getResult().isFluidEqual(output) && recipe.matches(list) > 0; if (found) addBackup(recipe); return found; @@ -96,17 +80,6 @@ public boolean removeByInputsAndOutput(FluidStack output, FluidStack... inputs) return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TinkerRegistryAccessor.getAlloyRegistry().forEach(this::addBackup); - TinkerRegistryAccessor.getAlloyRegistry().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TinkerRegistryAccessor.getAlloyRegistry()).setRemover(this::remove); - } - @Property(property = "fluidInput", valid = {@Comp(value = "2", type = Comp.Type.GTE), @Comp(value = "Integer.MAX_VALUE", type = Comp.Type.LTE)}) @Property(property = "fluidOutput", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java index 8d0f29906..db252e993 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingBasin.java @@ -1,15 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -17,8 +15,10 @@ import slimeknights.tconstruct.library.smeltery.CastingRecipe; import slimeknights.tconstruct.library.smeltery.ICastingRecipe; +import java.util.Collection; + @RegistryDescription -public class CastingBasin extends VirtualizedRegistry { +public class CastingBasin extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".fluidInput(fluid('water')).output(item('minecraft:dirt')).cast(item('minecraft:cobblestone')).coolingTime(40)")) public RecipeBuilder recipeBuilder() { @@ -30,28 +30,13 @@ public CastingBasin() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(TinkerRegistryAccessor.getBasinCastRegistry()::remove); - restoreFromBackup().forEach(TinkerRegistryAccessor.getBasinCastRegistry()::add); - } - - public void add(ICastingRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TinkerRegistryAccessor.getBasinCastRegistry().add(recipe); - } - - public boolean remove(ICastingRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TinkerRegistryAccessor.getBasinCastRegistry().remove(recipe); - return true; + public Collection getRecipes() { + return TinkerRegistryAccessor.getBasinCastRegistry(); } @MethodDescription(example = @Example("item('minecraft:iron_block')")) public boolean removeByOutput(ItemStack output) { - if (TinkerRegistryAccessor.getBasinCastRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = ItemStack.areItemStacksEqual(recipe.getResult(ItemStack.EMPTY, FluidRegistry.WATER), output); if (found) addBackup(recipe); return found; @@ -66,7 +51,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example("fluid('clay')")) public boolean removeByInput(FluidStack input) { - if (TinkerRegistryAccessor.getBasinCastRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getFluid(ItemStack.EMPTY, input.getFluid()).isFluidEqual(input); if (found) addBackup(recipe); return found; @@ -82,7 +67,7 @@ public boolean removeByInput(FluidStack input) { @MethodDescription(example = @Example("item('minecraft:planks:0')")) public boolean removeByCast(IIngredient cast) { ItemStack castStack = cast.getMatchingStacks()[0]; - if (TinkerRegistryAccessor.getBasinCastRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.matches(castStack, recipe.getFluid(castStack, FluidRegistry.WATER).getFluid()); if (found) addBackup(recipe); return found; @@ -95,17 +80,6 @@ public boolean removeByCast(IIngredient cast) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TinkerRegistryAccessor.getBasinCastRegistry().forEach(this::addBackup); - TinkerRegistryAccessor.getBasinCastRegistry().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TinkerRegistryAccessor.getBasinCastRegistry()).setRemover(this::remove); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java index 3e15466d6..0b79b67a5 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/CastingTable.java @@ -1,15 +1,13 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -17,8 +15,10 @@ import slimeknights.tconstruct.library.smeltery.CastingRecipe; import slimeknights.tconstruct.library.smeltery.ICastingRecipe; +import java.util.Collection; + @RegistryDescription -public class CastingTable extends VirtualizedRegistry { +public class CastingTable extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".fluidInput(fluid('lava') * 50).output(item('minecraft:diamond')).coolingTime(750).consumesCast(true).cast(ore('gemEmerald'))")) public RecipeBuilder recipeBuilder() { @@ -30,28 +30,13 @@ public CastingTable() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(TinkerRegistryAccessor.getTableCastRegistry()::remove); - restoreFromBackup().forEach(TinkerRegistryAccessor.getTableCastRegistry()::add); - } - - public void add(ICastingRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TinkerRegistryAccessor.getTableCastRegistry().add(recipe); - } - - public boolean remove(ICastingRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TinkerRegistryAccessor.getTableCastRegistry().remove(recipe); - return true; + public Collection getRecipes() { + return TinkerRegistryAccessor.getTableCastRegistry(); } @MethodDescription(example = @Example("item('minecraft:gold_ingot')")) public boolean removeByOutput(ItemStack output) { - if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getResult(ItemStack.EMPTY, FluidRegistry.WATER).isItemEqual(output); if (found) addBackup(recipe); return found; @@ -66,7 +51,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription(example = @Example("fluid('iron')")) public boolean removeByInput(FluidStack input) { - if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getFluid(ItemStack.EMPTY, input.getFluid()).isFluidEqual(input); if (found) addBackup(recipe); return found; @@ -81,7 +66,7 @@ public boolean removeByInput(FluidStack input) { @MethodDescription(example = @Example("item('minecraft:bucket')")) public boolean removeByCast(IIngredient cast) { - if (TinkerRegistryAccessor.getTableCastRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.matches(cast.getMatchingStacks()[0], recipe.getFluid(cast.getMatchingStacks()[0], FluidRegistry.WATER).getFluid()); if (found) addBackup(recipe); return found; @@ -94,17 +79,6 @@ public boolean removeByCast(IIngredient cast) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TinkerRegistryAccessor.getTableCastRegistry().forEach(this::addBackup); - TinkerRegistryAccessor.getTableCastRegistry().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TinkerRegistryAccessor.getTableCastRegistry()).setRemover(this::remove); - } - @Property(property = "fluidInput", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java index 017be0918..d4bfc0588 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Drying.java @@ -1,21 +1,21 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.*; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import org.jetbrains.annotations.Nullable; import slimeknights.tconstruct.library.DryingRecipe; +import java.util.Collection; + @RegistryDescription -public class Drying extends VirtualizedRegistry { +public class Drying extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:clay')).output(item('minecraft:dirt')).time(45)")) public RecipeBuilder recipeBuilder() { @@ -23,10 +23,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(TinkerRegistryAccessor.getDryingRegistry()::remove); - restoreFromBackup().forEach(TinkerRegistryAccessor.getDryingRegistry()::add); + public Collection getRecipes() { + return TinkerRegistryAccessor.getDryingRegistry(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -36,23 +34,10 @@ public DryingRecipe add(IIngredient input, ItemStack output, int time) { return recipe; } - public void add(DryingRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TinkerRegistryAccessor.getDryingRegistry().add(recipe); - } - - public boolean remove(DryingRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TinkerRegistryAccessor.getDryingRegistry().remove(recipe); - return true; - } - @MethodDescription public boolean removeByInput(IIngredient input) { NonNullList matching = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TinkerRegistryAccessor.getDryingRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(matching).isPresent(); if (found) addBackup(recipe); return found; @@ -67,7 +52,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription public boolean removeByOutput(ItemStack output) { - if (TinkerRegistryAccessor.getDryingRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = ItemStack.areItemStacksEqual(recipe.output, output); if (found) addBackup(recipe); return found; @@ -83,7 +68,7 @@ public boolean removeByOutput(ItemStack output) { @MethodDescription public boolean removeByInputAndOutput(IIngredient input, ItemStack output) { NonNullList matching = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TinkerRegistryAccessor.getDryingRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(matching).isPresent() && ItemStack.areItemStacksEqual(recipe.output, output); if (found) addBackup(recipe); return found; @@ -96,17 +81,6 @@ public boolean removeByInputAndOutput(IIngredient input, ItemStack output) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TinkerRegistryAccessor.getDryingRegistry().forEach(this::addBackup); - TinkerRegistryAccessor.getDryingRegistry().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TinkerRegistryAccessor.getDryingRegistry()).setRemover(this::remove); - } - @Property(property = "input", valid = @Comp("1")) @Property(property = "output", valid = @Comp("1")) public class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java index 007ad223a..f6f179845 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/Melting.java @@ -1,6 +1,5 @@ package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct; -import com.cleanroommc.groovyscript.api.GroovyBlacklist; import com.cleanroommc.groovyscript.api.GroovyLog; import com.cleanroommc.groovyscript.api.IIngredient; import com.cleanroommc.groovyscript.api.documentation.annotations.Example; @@ -8,16 +7,17 @@ import com.cleanroommc.groovyscript.api.documentation.annotations.RecipeBuilderDescription; import com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription; import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeBuilder; -import com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe.MeltingRecipeRegistry; import com.cleanroommc.groovyscript.core.mixin.tconstruct.TinkerRegistryAccessor; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import net.minecraft.item.ItemStack; import net.minecraft.util.NonNullList; import net.minecraftforge.fluids.FluidStack; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; +import java.util.Collection; + @RegistryDescription -public class Melting extends MeltingRecipeRegistry { +public class Melting extends StandardListRegistry { @RecipeBuilderDescription(example = @Example(".input(item('minecraft:gravel')).fluidOutput(fluid('lava') * 25).time(80)")) public RecipeBuilder recipeBuilder() { @@ -25,10 +25,8 @@ public RecipeBuilder recipeBuilder() { } @Override - @GroovyBlacklist - public void onReload() { - removeScripted().forEach(TinkerRegistryAccessor.getMeltingRegistry()::remove); - restoreFromBackup().forEach(TinkerRegistryAccessor.getMeltingRegistry()::add); + public Collection getRecipes() { + return TinkerRegistryAccessor.getMeltingRegistry(); } @MethodDescription(type = MethodDescription.Type.ADDITION) @@ -38,24 +36,10 @@ public MeltingRecipe add(IIngredient input, FluidStack output, int temp) { return recipe; } - @Override - public void add(MeltingRecipe recipe) { - if (recipe == null) return; - addScripted(recipe); - TinkerRegistryAccessor.getMeltingRegistry().add(recipe); - } - - public boolean remove(MeltingRecipe recipe) { - if (recipe == null) return false; - addBackup(recipe); - TinkerRegistryAccessor.getMeltingRegistry().remove(recipe); - return true; - } - @MethodDescription public boolean removeByInput(IIngredient input) { NonNullList matching = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TinkerRegistryAccessor.getMeltingRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(matching).isPresent(); if (found) addBackup(recipe); return found; @@ -70,7 +54,7 @@ public boolean removeByInput(IIngredient input) { @MethodDescription public boolean removeByOutput(FluidStack output) { - if (TinkerRegistryAccessor.getMeltingRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.getResult().isFluidEqual(output); if (found) addBackup(recipe); return found; @@ -86,7 +70,7 @@ public boolean removeByOutput(FluidStack output) { @MethodDescription public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { NonNullList matching = NonNullList.from(ItemStack.EMPTY, input.getMatchingStacks()); - if (TinkerRegistryAccessor.getMeltingRegistry().removeIf(recipe -> { + if (getRecipes().removeIf(recipe -> { boolean found = recipe.input.matches(matching).isPresent() && recipe.getResult().isFluidEqual(output); if (found) addBackup(recipe); return found; @@ -99,17 +83,6 @@ public boolean removeByInputAndOutput(IIngredient input, FluidStack output) { return false; } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - TinkerRegistryAccessor.getMeltingRegistry().forEach(this::addBackup); - TinkerRegistryAccessor.getMeltingRegistry().clear(); - } - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(TinkerRegistryAccessor.getMeltingRegistry()).setRemover(this::remove); - } - public static class RecipeBuilder extends MeltingRecipeBuilder { public RecipeBuilder(Melting melting) { diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java index 5c49a1bad..6ead57bca 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeBuilder.java @@ -9,6 +9,7 @@ import com.cleanroommc.groovyscript.core.mixin.tconstruct.MeltingRecipeAccessor; import com.cleanroommc.groovyscript.helper.ingredient.OreDictIngredient; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import org.jetbrains.annotations.Nullable; import slimeknights.mantle.util.RecipeMatch; import slimeknights.tconstruct.library.smeltery.MeltingRecipe; @@ -18,7 +19,7 @@ public class MeltingRecipeBuilder extends AbstractRecipeBuilder { @Property(defaultValue = "300", valid = @Comp(value = "1", type = Comp.Type.GTE)) private int temp = 300; - private final MeltingRecipeRegistry registry; + private final StandardListRegistry registry; private final String recipeName; public static RecipeMatch recipeMatchFromIngredient(IIngredient ingredient, int amount) { @@ -30,7 +31,7 @@ public static RecipeMatch recipeMatchFromIngredient(IIngredient ingredient) { return recipeMatchFromIngredient(ingredient, 1); } - public MeltingRecipeBuilder(MeltingRecipeRegistry registry, String recipeName) { + public MeltingRecipeBuilder(StandardListRegistry registry, String recipeName) { this.registry = registry; this.recipeName = recipeName; } diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java deleted file mode 100644 index 001e8f69a..000000000 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/tinkersconstruct/recipe/MeltingRecipeRegistry.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.cleanroommc.groovyscript.compat.mods.tinkersconstruct.recipe; - -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; -import slimeknights.tconstruct.library.smeltery.MeltingRecipe; - -public abstract class MeltingRecipeRegistry extends VirtualizedRegistry { - - public abstract void add(MeltingRecipe recipe); -} diff --git a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java index b6e9faa89..5dec7036c 100644 --- a/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java +++ b/src/main/java/com/cleanroommc/groovyscript/compat/mods/woot/StygianIronAnvil.java @@ -5,16 +5,16 @@ import com.cleanroommc.groovyscript.compat.mods.ModSupport; import com.cleanroommc.groovyscript.core.mixin.woot.AnvilManagerAccessor; import com.cleanroommc.groovyscript.helper.Alias; -import com.cleanroommc.groovyscript.helper.SimpleObjectStream; import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper; import com.cleanroommc.groovyscript.helper.recipe.AbstractRecipeBuilder; -import com.cleanroommc.groovyscript.registry.VirtualizedRegistry; +import com.cleanroommc.groovyscript.registry.StandardListRegistry; import ipsis.Woot; import ipsis.woot.crafting.AnvilRecipe; import ipsis.woot.crafting.IAnvilRecipe; import net.minecraft.item.ItemStack; import org.jetbrains.annotations.Nullable; +import java.util.Collection; import java.util.stream.Collectors; @RegistryDescription( @@ -23,12 +23,17 @@ @Admonition(value = "groovyscript.wiki.woot.stygian_iron_anvil.note1", type = Admonition.Type.WARNING) } ) -public class StygianIronAnvil extends VirtualizedRegistry { +public class StygianIronAnvil extends StandardListRegistry { public StygianIronAnvil() { super(Alias.generateOfClassAnd(StygianIronAnvil.class, "Anvil")); } + @Override + public Collection getRecipes() { + return Woot.anvilManager.getRecipes(); + } + @RecipeBuilderDescription(example = { @Example(".input(item('minecraft:diamond'),item('minecraft:diamond'),item('minecraft:diamond')).base(item('minecraft:gold_ingot')).output(item('minecraft:clay')).preserveBase(true)"), @Example(".input(item('minecraft:diamond'), item('minecraft:gold_ingot'), item('minecraft:iron_ingot'), item('minecraft:diamond_block'), item('minecraft:gold_block'), item('minecraft:iron_bars'), item('minecraft:magma')).base(item('minecraft:clay')).output(item('minecraft:clay')).preserveBase()") @@ -37,36 +42,19 @@ public static RecipeBuilder recipeBuilder() { return new RecipeBuilder(); } - @Override - public void onReload() { - removeScripted().forEach(Woot.anvilManager.getRecipes()::remove); - Woot.anvilManager.getRecipes().addAll(restoreFromBackup()); - } - @Override public void afterScriptLoad() { // Recalculate valid base items ((AnvilManagerAccessor) Woot.anvilManager).getValidBaseItems().clear(); - Woot.anvilManager.getRecipes().forEach(x -> { + getRecipes().forEach(x -> { if (((AnvilManagerAccessor) Woot.anvilManager).getValidBaseItems().contains(x.getBaseItem())) return; ((AnvilManagerAccessor) Woot.anvilManager).getValidBaseItems().add(x.getBaseItem()); }); } - public void add(IAnvilRecipe recipe) { - Woot.anvilManager.getRecipes().add(recipe); - addScripted(recipe); - } - - public boolean remove(IAnvilRecipe recipe) { - Woot.anvilManager.getRecipes().remove(recipe); - addBackup(recipe); - return true; - } - @MethodDescription(example = @Example("item('minecraft:iron_bars')")) public boolean removeByBase(ItemStack base) { - return Woot.anvilManager.getRecipes().removeIf(x -> { + return getRecipes().removeIf(x -> { if (ItemStack.areItemsEqual(x.getBaseItem(), base)) { addBackup(x); return true; @@ -77,7 +65,7 @@ public boolean removeByBase(ItemStack base) { @MethodDescription(example = @Example("item('woot:stygianironplate')")) public boolean removeByOutput(ItemStack output) { - return Woot.anvilManager.getRecipes().removeIf(x -> { + return getRecipes().removeIf(x -> { if (ItemStack.areItemsEqual(x.getCopyOutput(), output)) { addBackup(x); return true; @@ -86,19 +74,6 @@ public boolean removeByOutput(ItemStack output) { }); } - @MethodDescription(priority = 2000, example = @Example(commented = true)) - public void removeAll() { - Woot.anvilManager.getRecipes().forEach(this::addBackup); - Woot.anvilManager.getRecipes().clear(); - } - - - @MethodDescription(type = MethodDescription.Type.QUERY) - public SimpleObjectStream streamRecipes() { - return new SimpleObjectStream<>(Woot.anvilManager.getRecipes()) - .setRemover(this::remove); - } - @Property(property = "input", valid = {@Comp(type = Comp.Type.GTE, value = "1"), @Comp(type = Comp.Type.LTE, value = "Integer.MAX_VALUE")}) @Property(property = "output", valid = @Comp("1")) public static class RecipeBuilder extends AbstractRecipeBuilder { diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java b/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java index 16b0ae4e8..d880f51c6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/Exporter.java @@ -11,11 +11,15 @@ import java.io.File; import java.io.IOException; +import java.lang.reflect.AnnotatedType; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; +import java.util.function.Function; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -24,17 +28,32 @@ public class Exporter { private static final String INDEX_FILE_NAME = "index.md"; private static final String NAV_FILE_NAME = "!navigation.md"; private static final String PRINT_MOD_DETECTED = "log.info 'mod \\'%s\\' detected, running script'"; - private static final Pattern CLASS_NAME_PATTERN = Pattern.compile("(?>\\b)(?>[a-zA-Z0-9]+\\.)+([a-zA-Z0-9$]+)"); + private static final Pattern CLASS_NAME_PATTERN = Pattern.compile("(?>\\b)(?>[a-zA-Z0-9_]+\\.)+([a-zA-Z0-9_$]+)"); public static String simpleSignature(Method method) { - String signature = Arrays.stream(method.getAnnotatedParameterTypes()).map(x -> simpleSignature(x.getType().getTypeName())).collect(Collectors.joining(", ")); - return method.isVarArgs() ? convertVarArgs(signature) : signature; + return adjustVarArgs(method, signature(method, Exporter::simpleSignature)); + } + + public static String simpleSignature(Method method, Map types) { + return adjustVarArgs(method, signature(method, param -> Exporter.simpleSignature(types.getOrDefault(param, param)))); + } + + private static String signature(Method method, Function parseParameterFunction) { + return Arrays.stream(method.getAnnotatedParameterTypes()) + .map(AnnotatedType::getType) + .map(Type::getTypeName) + .map(parseParameterFunction) + .collect(Collectors.joining(", ")); } public static String simpleSignature(String name) { return CLASS_NAME_PATTERN.matcher(name).replaceAll("$1").replaceAll("\\$", "."); } + private static String adjustVarArgs(Method method, String signature) { + return method.isVarArgs() ? convertVarArgs(signature) : signature; + } + private static String convertVarArgs(String name) { return name.substring(0, name.lastIndexOf("[]")) + "..." + name.substring(name.lastIndexOf("[]") + 2); } diff --git a/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java b/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java index 6e87fed2b..ef9b644a6 100644 --- a/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java +++ b/src/main/java/com/cleanroommc/groovyscript/documentation/Registry.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.text.WordUtils; import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -24,6 +25,7 @@ public class Registry { private final String reference; private final Class registryClass; private final RegistryDescription description; + private final Map types; private final List recipeBuilderMethods; private final EnumMap> methods = new EnumMap<>(MethodDescription.Type.class); private final List imports; @@ -35,6 +37,7 @@ public Registry(GroovyContainer mod, INamed r this.reference = String.format("mods.%s.%s", mod.getModId(), registry.getName()); this.registryClass = registry.getClass(); this.description = registryClass.getAnnotation(RegistryDescription.class); + this.types = generateTypes(registryClass); List recipeBuilderMethods = new ArrayList<>(); Map> methods = new EnumMap<>(MethodDescription.Type.class); @@ -63,6 +66,23 @@ public Registry(GroovyContainer mod, INamed r this.imports = imports; } + /** + * @return gathers the generic information and pairs the generic type symbol with the type being used as the generic. + */ + private static Map generateTypes(Class registryClass) { + var types = new HashMap(); + if (registryClass.getGenericSuperclass() instanceof ParameterizedType parameterizedType) { + if (parameterizedType.getRawType() instanceof Class typeClass) { + var parameters = typeClass.getTypeParameters(); + var args = parameterizedType.getActualTypeArguments(); + for (int i = 0; i < parameters.length && i < args.length; i++) { + types.put(parameters[i].toString(), args[i].getTypeName()); + } + } + } + return types; + } + private static List sortGrSRecipeBuilderDescriptionMethods(List methods) { methods.sort((left, right) -> ComparisonChain.start() .compareFalseFirst(left.isAnnotationPresent(RecipeBuilderDescription.class), right.isAnnotationPresent(RecipeBuilderDescription.class)) @@ -130,8 +150,13 @@ public String exampleBlock() { private String documentMethodDescriptionType(MethodDescription.Type type) { StringBuilder out = new StringBuilder(); - for (Method method : methods.get(type)) out.append(examples(method)); - if (!methods.get(type).isEmpty()) out.append("\n"); + var hasExamples = false; + for (var entry : methods.get(type)) { + var examples = examples(entry); + out.append(examples); + if (!hasExamples && !examples.isEmpty()) hasExamples = true; + } + if (hasExamples) out.append("\n"); return out.toString(); } @@ -298,7 +323,7 @@ private String methodDescription(Method method) { return String.format("- %s:\n\n%s", Documentation.translate(lang), new CodeBlockBuilder() - .line(methodExample(method, Exporter.simpleSignature(method))) + .line(methodExample(method, Exporter.simpleSignature(method, types))) .indentation(1) .toString()); } diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java b/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java index 565e67657..b3c0ddc39 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/ForgeRegistryWrapper.java @@ -13,6 +13,18 @@ import java.util.Collection; import java.util.Objects; +/** + * Class for controlling the storage of reloadable compat stored in Forge Registries. + *

+ * To document this class, the annotation {@link com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription @RegistryDescription} + * exists. This annotation must exist for the registry to be documented via GroovyScript. + *

+ * Anything that isn't a Forge Registry should be handled via {@link VirtualizedRegistry} or an inheriting class instead. + * + * @param the forge registry entry being stored and reloaded + * @see com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription @RegistryDescription + * @see VirtualizedRegistry + */ public class ForgeRegistryWrapper> extends NamedRegistry implements IScriptReloadable { private final IForgeRegistry registry; diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java b/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java index 9fe4702aa..d4a8ea460 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/NamedRegistry.java @@ -10,6 +10,19 @@ import java.util.Locale; import java.util.stream.Collectors; +/** + * Controls the name and aliases of registries. + *

+ * If the empty constructor is used or null is passed in, the method {@link Alias#generateOfClass(Object)} will be called + * with {@code this} as the parameter to create the list of aliases. + *

+ * If the aliases generated from this are undesired or do not contain all desired aliases, a collection of strings may be passed in instead. + * It is suggested to use {@link Alias} to generate this list. + *

+ * The name will be the first parameter of the aliases, in lower case form. + * + * @see Alias + */ public abstract class NamedRegistry implements INamed { protected final String name; diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/StandardListRegistry.java b/src/main/java/com/cleanroommc/groovyscript/registry/StandardListRegistry.java new file mode 100644 index 000000000..2d675a951 --- /dev/null +++ b/src/main/java/com/cleanroommc/groovyscript/registry/StandardListRegistry.java @@ -0,0 +1,63 @@ +package com.cleanroommc.groovyscript.registry; + +import com.cleanroommc.groovyscript.api.GroovyBlacklist; +import com.cleanroommc.groovyscript.api.documentation.annotations.Example; +import com.cleanroommc.groovyscript.api.documentation.annotations.MethodDescription; +import com.cleanroommc.groovyscript.helper.SimpleObjectStream; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; + +/** + * Boilerplate code for a registry where the registry is a mutable Collection that stores recipes of type {@link R}. + * Will automatically handle {@link #add(R)}, {@link #remove(R)}, {@link #removeAll()}, {@link #streamRecipes()}, and {@link #onReload()}. + *

+ * Note that {@link R} should not register itself on initialization, or the recipe may be added to the recipe list multiple times. + * + * @param the recipe type being stored and reloaded + */ +public abstract class StandardListRegistry extends VirtualizedRegistry { + + public StandardListRegistry() { + this(null); + } + + public StandardListRegistry(@Nullable Collection aliases) { + super(aliases); + } + + public abstract Collection getRecipes(); + + @Override + @GroovyBlacklist + @ApiStatus.Internal + public void onReload() { + var recipes = getRecipes(); + recipes.removeAll(removeScripted()); + recipes.addAll(restoreFromBackup()); + } + + @MethodDescription(type = MethodDescription.Type.ADDITION, description = "groovyscript.wiki.add_to_list", priority = 500) + public boolean add(R recipe) { + return recipe != null && getRecipes().add(recipe) && addScripted(recipe); + } + + @MethodDescription(description = "groovyscript.wiki.remove_from_list", priority = 500) + public boolean remove(R recipe) { + return recipe != null && getRecipes().removeIf(r -> r == recipe) && addBackup(recipe); + } + + @MethodDescription(priority = 2000, example = @Example(commented = true)) + public void removeAll() { + var recipes = getRecipes(); + recipes.forEach(this::addBackup); + recipes.clear(); + } + + @MethodDescription(type = MethodDescription.Type.QUERY) + public SimpleObjectStream streamRecipes() { + return new SimpleObjectStream<>(getRecipes()).setRemover(this::remove); + } + +} diff --git a/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java b/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java index 546edecd4..cb6ecf186 100644 --- a/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java +++ b/src/main/java/com/cleanroommc/groovyscript/registry/VirtualizedRegistry.java @@ -7,6 +7,33 @@ import java.util.Collection; +/** + * Class for controlling the storage of reloadable compat. + *

+ * When reloading, should first remove all added recipes, then add all removed recipes. + * This should recreate the state prior to any script modifications. + * If it does not recreate the state prior to any script modifications, + * the {@link com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription @RegistryDescription} annotation + * should set the {@link com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription#reloadability reloadability} to + * {@link com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription.Reloadability#FLAWED Reloadability.FLAWED} or + * {@link com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription.Reloadability#DISABLED Reloadability.DISABLED}. + *

+ * To document this class, the annotation {@link com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription @RegistryDescription} + * exists. This annotation must exist for the registry to be documented via GroovyScript. + *

+ * In some situations, more than one type can be used to reload via the creation of + * a new field using {@link AbstractReloadableStorage}. This field should be private and final. + *

+ * Forge Registries should be handled via {@link ForgeRegistryWrapper}. + * Basic collections of recipes should be handled via {@link StandardListRegistry}, to reduce boilerplate. + * + * @param the recipe type being stored and reloaded + * @see com.cleanroommc.groovyscript.api.documentation.annotations.RegistryDescription @RegistryDescription + * @see NamedRegistry + * @see AbstractReloadableStorage + * @see ForgeRegistryWrapper + * @see StandardListRegistry + */ public abstract class VirtualizedRegistry extends NamedRegistry implements IScriptReloadable { private final AbstractReloadableStorage recipeStorage; @@ -47,13 +74,13 @@ public Collection getScriptedRecipes() { } @GroovyBlacklist - public void addBackup(R recipe) { - recipeStorage.addBackup(recipe); + public boolean addBackup(R recipe) { + return recipeStorage.addBackup(recipe); } @GroovyBlacklist - public void addScripted(R recipe) { - recipeStorage.addScripted(recipe); + public boolean addScripted(R recipe) { + return recipeStorage.addScripted(recipe); } @GroovyBlacklist diff --git a/src/main/resources/assets/groovyscript/lang/en_us.lang b/src/main/resources/assets/groovyscript/lang/en_us.lang index 6ff631740..09d9eee75 100644 --- a/src/main/resources/assets/groovyscript/lang/en_us.lang +++ b/src/main/resources/assets/groovyscript/lang/en_us.lang @@ -77,6 +77,9 @@ groovyscript.wiki.recipe_builder_note=Don't know what a builder is? Check [the b groovyscript.wiki.required_mods.title=Required Mods groovyscript.wiki.required_mods.desc=This compat requires the following mods to be loaded groovyscript.wiki.not_fully_documented=This compat is not fully documented. Some or all of its features are not present on the wiki. View the source code to gain an accurate understanding of the compat. +groovyscript.wiki.add_to_list=Add the given recipe to the recipe list +groovyscript.wiki.remove_from_list=Removes the given recipe from the recipe list + groovyscript.wiki.requires=Requires %s. groovyscript.wiki.default=(Default `%s`). @@ -359,16 +362,14 @@ groovyscript.wiki.astralsorcery.constellation.removeAll=Removes all Constellatio groovyscript.wiki.astralsorcery.fountain.title=Fountain groovyscript.wiki.astralsorcery.fountain.description=Adds virtual aquifers that can be accessed via the Evershifting Fountain's Necromantic Prime. -groovyscript.wiki.astralsorcery.fountain.add0=Adds an existing `FluidRarityEntry` to the registry +groovyscript.wiki.astralsorcery.fountain.add0=Adds recipes in the format `fluid`, `rarity`, `guaranteedAmt`, `addRand` groovyscript.wiki.astralsorcery.fountain.add1=Adds recipes in the format `fluid`, `rarity`, `guaranteedAmt`, `addRand` -groovyscript.wiki.astralsorcery.fountain.add2=Adds recipes in the format `fluid`, `rarity`, `guaranteedAmt`, `addRand` groovyscript.wiki.astralsorcery.fountain.variance.value=Sets the maximum amount of additional fluid that can be generated in a chunk groovyscript.wiki.astralsorcery.fountain.minimumAmount.value=Sets the minimum amount of fluid in a chunk groovyscript.wiki.astralsorcery.fountain.fluid.value=Sets the fluid being generated groovyscript.wiki.astralsorcery.fountain.rarity.value=Sets the frequency the fluid generates in a chunk -groovyscript.wiki.astralsorcery.fountain.remove0=Removes an existing `FluidRarityEntry` -groovyscript.wiki.astralsorcery.fountain.remove1=Removes an entry matching the given `FluidStack` -groovyscript.wiki.astralsorcery.fountain.remove2=Removes an entry matching the given `Fluid` +groovyscript.wiki.astralsorcery.fountain.remove0=Removes an entry matching the given `FluidStack` +groovyscript.wiki.astralsorcery.fountain.remove1=Removes an entry matching the given `Fluid` groovyscript.wiki.astralsorcery.grindstone.title=Grindstone groovyscript.wiki.astralsorcery.grindstone.description=Converts an item into an itemstack with a chance of getting twice the amount after right clicking the grindstone based on weight.