Slimefun

Slimefun

3M Downloads

Usage Of Inadequate Automated Crafting Chamber Recipe Identification Key

mohkamfer opened this issue ยท 4 comments

commented

Description

The Map automatedCraftingChamberRecipes that lives in SlimefunPlugin#Utilities#automatedCraftingChamberRecipes identifies possible recipes by each ItemStack's material, display name and lore. The problem in this unique key combination is that it could be replicated using vanilla items renamed in an anvil, and still gets normally identified by the tick method's logic living inside AutomatedCraftingChamber.java

Steps to reproduce the Issue

I'm taking the electromagnet here as an example.
1- Get 4 player_head items and 4 iron_ingot items.
2- Rename two iron_ingot items in an anvil into &bNickel Ingot
3- Rename two player_head items into &cMagnet
4- Rename two iron_ingot items into &9Cobalt Ingot
5- Rename two player_head items into &6Battery
6- Put the two shaped recipes in an automated crafting chamber and enable it.
7- You get an electromagnet from non-Slimefun items.

Expected behavior

This type of recipes should be ignored, since this shouldn't be an identifiable recipe!

Server Log / Error Report

No logs produced, save for the auto block save logs each x mins.

Environment

  • Minecraft Version: 1.14.4
  • Server Software: CraftBukkit v1_14_R1
  • Slimefun Version: DEV 385
  • CS-CoreLib Version: DEV 80
  • Installed Addons: 0
commented

This shouldn't be a problem though since you cannot create colored items in an Anvil in Vanilla, so they'd never match.

commented

I did not mention anything about colors. Who said the Anvil will color them? The produced item has a display name with &code then whatever you typed, all still in plain white. However, they get serialized like normally colored items without any differentiation.

commented

Oh, you are right.
Well that is pretty stupid...

But it would be a mistake in CS-CoreLib then.
And to be fair, this custom serializer is total bullshit, very old and already deprecated.
It should have been replaced by something better years ago...

https://github.com/TheBusyBiscuit/CS-CoreLib/blob/master/src/me/mrCookieSlime/CSCoreLibPlugin/general/Inventory/Item/CustomItemSerializer.java#L76

commented

The recipe system for the crafting chamber is a mess... We discussed this on Discord a few days ago. We should replace this with the MinecraftRecipe class in CS-CoreLib2.

Look here for context: https://canary.discordapp.com/channels/565557184348422174/569249847258120222/659929284336549888

I haven't had the time yet as Christmas and all that came up. If you wish to do this before me go ahead. Please make sure to add vanilla recipes as well though :p