Mods / Metal Recycling

Tags: #Crafting #QoL #Tweak
Author: ilan
Side: Server
Created: Jun 15th 2024 at 7:17 AM
Last modified: Jan 26th at 9:26 AM
Downloads: 4787
Follow Unfollow 143

Latest release (for outdated Vintage Story v1.20.3):
metalrecycling_1.2.0.zip  1-click install


Ever wish you could recycle those bits of metal you seem to "waste" when you make chisels or the like? Well, now you can!

Using the "split" ability on work items now has a chance of giving you a metal bit in return - by default this starts at 50%, but the chance goes down with every metal bit you successfully recover.

 

Smith away, and rejoice!

 

This mod is configurable using the MetalRecycling.json configuration file:

  • MetalRecyclingChance - The chance that a metal bit will be returned when splitting metal on the anvil. Defaults to 0.5 (50%).
  • MaxBitsPerWorkItem - How many metal bits you can get from a single work item. Defaults to 10.
  • DiminishingReturnFactor - The "factor" of diminishing returns that affects the recycle chance on every successful bit recovery. Defaults to 0.85.
  • RecycleIronBlooms - Whether you get iron bits from splitting iron blooms. Defaults to true.

 

Diminishing returns 

The default factor for the diminishing returns is 0.85. That means that for every bit of metal you successfully recover, the chance to get another metal bit is multiplied by 0.85 (or 85% of 50%). For the default starting chance of 50%, this means:

  • You have a 50% chance of getting the first metal bit
  • Afterwards, you have a 50% * 0.85 = 42.5% chance of getting another metal bit
  • After that, you have a 42.5% * 0.85 = 36.1% chance
  • and so on, and so forth..

To make it easier to get metal bits, increase the value of the diminishing returns factor. To make it harder, lower the value.

Examples:

  • For a factor of 0.9, the chances will go 50% -> 45% -> 40% -> 36%
  • For a factor of 0.5, the changes will halve every time: 50% -> 25% -> 12.5% -> 6.25%

 

Version For Game version Downloads Release date Changelog Download 1-click mod install*
v1.2.0 2337 Jan 26th at 9:26 AM Show metalrecycling_1.2.0.zip 1-click install
v1.1.0 2318 Jun 15th 2024 at 3:42 PM Show metalrecycling_1.1.0.zip 1-click install
v1.0.0 132 Jun 15th 2024 at 8:59 AM Show metalrecycling_1.0.0.zip 1-click install

33 Comments (oldest first | newest first)

💬 prototype464, May 8th at 1:35 AM

Oh, also, I've found another bug. It seems like when the bit pops off, it originates off a certain corner of the anvil (I don't know if it's specifically the back left corner or if a few of my anvils have happened to face the same direction). I like to put my anvils against a wall, and I had a big window behind one of them, every now and then a bit would spawn in the block and phase backwards through the wall.

 

If the position the bit comes from could be changed to be something like near the bottom center of the anvil relative (and towards) the player, that'd be great.

💬 prototype464, May 8th at 1:32 AM

That would fix it, yeah. Thanks! :>

I wouldn't disable the recipe though, rarely there's recipes like Chute Sections which have you split while making it rather than that being the last thing you'd do. Best compromise would be the prior you mentioned.

💬 ilan , Apr 30th at 4:56 AM

prototype464 interesting, I didn't know you could reclaim ALL the bits from an unfinished work item. I'll look into maybe reducing the amount of bits you get from a work item like that if you've already received X bits of metal (or completely disabling the recipe?) 

💬 prototype464, Apr 22nd at 9:19 AM

I'm not sure if anyone's already mentioned but this mod has an exploit: You can split bits off of a work item and then chisel the work item, which leaves you with more bits than what you started with.

 

Not sure how this'd be fixed. Friend found this very early on and didn't use it or tell anyone, I'd found it months later. Might not be too important enough to warrant a fix considering anyone doing it may as well just use creative mode, but could be problematic for servers.

💬 Buggi, Mar 16th at 8:34 PM

I can confirm this does work using the Split feature on an anvil with Knapster installed.
It does not work if you use Knapster option to complete the entire tool, including removing voxels. Which I kind of like.

Manual removal gets you some extra bits

Easy Knapster method costs those extra bits.

 

Love the config options too, 10/10 for this mod. I hope you keep it up!

💬 Buggi, Mar 16th at 7:58 PM

Has this been tested with the Knappster mod? 

💬 RowanSkie, Mar 14th at 1:43 PM

Ever thought about allowing the bits to be added back in case a person accidentally splits too much like Anvil Metal Recovery or Smithing Plus?

💬 BombadeerPain, Mar 4th at 2:18 AM

@WolfKann I had to run the game with the mod loaded once before the config generated

💬 WolfKann, Mar 2nd at 1:13 PM

Yes I'm looking in the right folder

💬 ilan , Feb 28th at 6:41 AM

Ossom There is a problem with AutoConfigLib which causes it to interfere with other mods' configs. Try removing it and trying again.

WolfKann Are you looking in the right folder? On Windows it should be %APPDATA%\VintagestoryData\ModConfig by default. The game is responsible for creating the mod configuration file (the mod just asks the game to create it), so there's not much I can help with..

💬 WolfKann, Feb 23rd at 12:48 AM

I don't have any configuration changing mods.

💬 Ossom, Feb 21st at 12:55 PM

ilan
Yes, both ConfigLib and AutoConfigLib

💬 ilan , Feb 21st at 8:22 AM

Ossom WolfKann

It appears you both have the same issue - the mod configuration is not being generated properly. Do you have any mods that change how mod configurations work (e.g. AutoConfigLib)?

💬 WolfKann, Feb 17th at 7:28 PM

I'm Running it on windows ilan

💬 Ossom, Feb 14th at 4:30 AM

Got DC'd with this in console on my server:

14.2.2025 04:29:11 [Server Notification] Last player disconnected, compacting large object heap...
14.2.2025 04:29:12 [Server Notification] UDP: client disconnected Ossom
14.2.2025 04:29:12 [Server Event] Player Ossom got removed. Reason: Threw an exception at the server
14.2.2025 04:29:12 [Server Error] Exception: Object reference not set to an instance of an object.
   at MetalRecycling.Patches.BEAnvilPatch.GetRecycleChance(ItemStack stack) in D:\Code\VintageStory\VSMods\src\MetalRecycling\Me
talRecycling\Patches\BEAnvilPatch.cs:line 117
   at MetalRecycling.Patches.BEAnvilPatch.Prefix(BlockEntityAnvil __instance, Vec3i voxelPos) in D:\Code\VintageStory\VSMods\src
\MetalRecycling\MetalRecycling\Patches\BEAnvilPatch.cs:line 40
   at Vintagestory.GameContent.BlockEntityAnvil.OnSplit_Patch1(BlockEntityAnvil this, Vec3i voxelPos)
   at Vintagestory.GameContent.BlockEntityAnvil.OnUseOver(IPlayer byPlayer, Vec3i voxelPos, BlockSelection blockSel) in VSSurviv
alMod\BlockEntity\BEAnvil.cs:line 388
   at Vintagestory.GameContent.BlockEntityAnvil.OnReceivedClientPacket(IPlayer player, Int32 packetid, Byte[] data) in VSSurviva
lMod\BlockEntity\BEAnvil.cs:line 1158
   at Vintagestory.Server.ServerSystemBlockSimulation.HandleBlockEntityPacket(Packet_Client packet, ConnectedClient client) in V
intagestoryLib\Server\Systems\World\BlockSimulation.cs:line 342
   at Vintagestory.Server.ServerMain.HandleClientPacket(ConnectedClient client, Byte[] data) in VintagestoryLib\Server\ServerMai
nNetworking.cs:line 154
   at Vintagestory.Server.ServerMain.ProcessNetMessage(NetIncomingMessage msg, NetServer mainSocket) in VintagestoryLib\Server\S
erverMainNetworking.cs:line 147
💬 ilan , Feb 11th at 7:02 AM

WolfKann are you running the game on Linux?

💬 WolfKann, Feb 10th at 12:16 AM

For some reason this mod will not generate a config file in the mods Config no matter what I've tried to do, I'm not sure if it's just my client being dumb or if there's an issue with the config generation

💬 ilan , Feb 4th at 7:42 AM

WaltzingPhantom the mod configuration file is auto-generated in the ModConfig folder, in the game's data folder

💬 WaltzingPhantom, Feb 4th at 4:27 AM

It says the mod configs can be changed using the MetalRecycling.json file, but I don't actually see a file with that name in the .zip folder. I only see a MetalRecycling.dll and Metal Recycling.pdb. Opening either of those in notepad shows mostly random symbols.

💬 Ryumachinae, Jan 30th at 6:09 PM

@dr_jkl so an ingot has 42 workable voxels, and is worth 100 units. which means every voxel if saved would be worth 2.38(roughly) units. That puts your 50% chance at a metal bit, which are worth 5 units each, pretty accurate 👍

For things like copper and bronze, this actually makes smithing more metal efficent than casting, which is actually great!

💬 ilan , Jan 30th at 2:41 PM

dr_jkl

I think it's possible - if you smith something that you can melt back down to 100% of its original cost, like a plate.. but on the other hand, you could also just give yourself creative mode and get as many ingots as you want :) 

💬 Ryumachinae, Jan 29th at 7:20 PM

dr_jkl No, this would essentially reduce the cost of smithed items to LESS than a full Ingot. Though if I recall a "bit" is bigger than the individual voxels of a work item. But from the way the percentage chances work, it should be about right and wont result in a net gain (which would require getting enough bits to make a whole other Ingot, which is statistically not posssible)

💬 dr_jkl, Jan 28th at 10:14 PM

I have a question about this: doesn't this result in an infinite loop of free metal, since you can break down and re-smelt the work pieces back into a full ingot? So you'd end up with 1 ingot plus whatever bits of metal you got from splits? I may be misunderstanding something about this mod (or the game's metalworking system).

💬 ilan , Jan 26th at 9:26 AM

Updated for 1.20.3 (no changes were needed)

💬 prototype464, Jan 22nd at 1:53 AM

Working in 1.20.1

💬 ItsMarmaduke, Jan 20th at 5:12 PM

Working in 1.20.1 so far!

💬 TheRealDiggyChz, Dec 24th 2024 at 4:28 PM

Seems to be working in 1.20rc 6 atleast with vanilla tin bronze items.

💬 SniperGecko, Dec 21st 2024 at 3:14 AM

Anyone know if this still works in 1.20?

💬 prototype464, Dec 11th 2024 at 10:37 PM

Thank you!

💬 ilan , Dec 11th 2024 at 2:52 PM

prototype464

Good question, I'll edit my original post to clarify.

💬 prototype464, Dec 11th 2024 at 8:43 AM

How does the value for DiminishingReturnFactor work? Does lowering the value increase or decrease the rate?

💬 ilan , Jun 15th 2024 at 7:16 PM

😁 Glad you like it!

💬 GermanKursk, Jun 15th 2024 at 5:49 PM

Man, this guy don't miss.

 (edit comment delete)