gnembon / carpet-autoCraftingTable

autoCraftingTable extension for carpet-mod
GNU Lesser General Public License v3.0
80 stars 27 forks source link

Hopper sorter causes item to craft even though it doesn't pull the item #8

Open Yuurg opened 3 years ago

Yuurg commented 3 years ago

Here's the setup: a hopper pointing into the auto crafting table and a hopper underneath the crafting table. The hopper underneath has all its slots filled with 1 gold block so it cannot accept anything but a gold block. The hopper on the side is filled with 9 gold ingots. When the ingots start flowing into the table, the first ingot is immediately crafted into 9 gold nuggets, even though the hopper underneath hasn't actually pulled it. (Nothing has removed the 9 nuggets from the output slot, therefore the ingot should not have been crafted.) This means that the 9 nuggets stay in the output slot of the crafting table, and nothing else can be crafted until these nuggets are manually removed.

This means that it is impossible to use hopper sorters with recipes whose top left slot is an item with a solo crafting recipe. This affects a lot of recipes: iron blocks, gold blocks, lapis blocks, melon blocks, chests, signs, bookshelves, note blocks, golden apples, anvils, barrels, blast furnaces, beehives, and cauldrons.

This also causes a minor visual glitch where if you are looking at the crafting table's gui while the item is crafted, the item disappears as you would expect it to if a hopper did pull it, but when you click the output or close and reopen the gui the item is there.

craftingtableglitch

DragonEggBedrockBreaking commented 3 years ago

Confirmed in 1.16.3.

kneasle commented 3 years ago

Also found this in 1.16.3:

edited-screenshot

Here's my setup - crafting paper is tedious if this is impossible

evermoreobsolete commented 3 years ago

There is a larger problem than just the use case here. Currently if there is no space for the crafted item in the bottom hopper it tries to pull the output slot, consumes the input items and then leaves the crafted item on the table. I raised a separate issue (#13) but reading this ticket again I see it is the same core problem.

Amongst other things observed:

My take on this is a check is needed to ensure there is space in the bottom hopper for the output item prior to the item being crafted. My understanding of container code is not fantastic but I'm guessing the crafting table is queried for what slots are available for extraction, then the item is pulled, which triggers the crafting of the item, but then the extraction is aborted when there is no space available?

kneasle commented 3 years ago

Your theory matches my observations too. I also have no real idea how the game code works (otherwise I'd attempt to fix this in a PR), but your solution also seems like it will work.

evermoreobsolete commented 3 years ago

I've been kicking this around a bit and I think a design decision is needed here. There are 2 possible options:

1) Items are crafted whenever the bottom hopper is enabled. This would mean controlling the crafting table using item filters would be impossible and instead everything would have to be done by carefully locking the bottom hopper (to craft gold blocks the bottom hopper would have to be locked until the table was full). No code changes would need to be made in this case and this ticket can be closed.

2) Items are crafted when an item is successfully moved from the crafting table to the hopper. This would allow for item filters to be used. This would require alterations to hopper behaviour to prevent items being crafted prematurely.

Neither is necessarily wrong but a decision does need to be made. In my opinion (1) seems more confusing but plenty of things are counter-intuitive in this game and the correct behaviour just needs to be made clear.

kneasle commented 3 years ago

I would prefer option 2., in that I (and it seems the 3 other people who added examples to this issue) found it intuitive that item filters should behave the way they do with other block entities.

I think that generally the non-function of item filters is OK, but in some cases (like the sugar cane -> paper machine I demonstrated), doing this without an item filter is both massively less efficient and extremely annoying.

However, I think that the point of this mod over the old autocrafting mod is that it is more compatible with vanilla clients, and rewriting some of the hopper code could potentially break that compatibility.

Cypphi commented 3 years ago

I'm also experiencing this issue, hopefully it will be fixed in the future so we can simplify autocrafters quite a lot!

fooeyround commented 3 years ago

This is a Hopper thing and a way for you to fix is to lock the hopper for set time or for gnembon to add a system (if possible probably) that gets if the crafted item is in the hopper and if not the hopper is kept locked and / or where items end back get somehow uncrafted and get overwritten with new recipe, this should only be if the locking system does not work, and It could have been implemented before conversion if able, so I don't know if it will work.

fooeyround commented 3 years ago

I would prefer option 2., in that I (and it seems the 3 other people who added examples to this issue) found it intuitive that item filters should behave the way they do with other block entities.

I think that generally the non-function of item filters is OK, but in some cases (like the sugar cane -> paper machine I demonstrated), doing this without an item filter is both massively less efficient and extremely annoying.

However, I think that the point of this mod over the old autocrafting mod is that it is more compatible with vanilla clients, and rewriting some of the hopper code could potentially break that compatibility.

sadly the reason it can't be the same is cause the item is different from the starter item and for a furnace there is only one way something can smelt so it does not have this issue but similarly you can use a system that tries it and if it comes back and does not go back it will not do it

fooeyround commented 3 years ago

I've been kicking this around a bit and I think a design decision is needed here. There are 2 possible options:

  1. Items are crafted whenever the bottom hopper is enabled. This would mean controlling the crafting table using item filters would be impossible and instead everything would have to be done by carefully locking the bottom hopper (to craft gold blocks the bottom hopper would have to be locked until the table was full). No code changes would need to be made in this case and this ticket can be closed.
  2. Items are crafted when an item is successfully moved from the crafting table to the hopper. This would allow for item filters to be used. This would require alterations to hopper behavior to prevent items being crafted prematurely.

Neither is necessarily wrong but a decision does need to be made. In my opinion (1) seems more confusing but plenty of things are counter-intuitive in this game and the correct behavior just needs to be made clear.

this is a good idea but if 2 was an option it could be good as a rule