Add isstackvalid check to furnace types#1322
Add isstackvalid check to furnace types#1322me4502 merged 3 commits intoEngineHub:masterfrom RasmusKD:master
Conversation
Removes unnessesary lag caused by empty furnaces checking the pipe system
add 5 seconds of delay on pipes if they fail to move a stack, returns to normal behaviour when stack pipe is able to transfer items
| import java.util.Iterator; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.*; |
There was a problem hiding this comment.
Please revert these formatting changes
| private void searchNearbyPipes(Block block, Set<Vector> visitedPipes, List<ItemStack> items) { | ||
| Deque<Block> searchQueue = new ArrayDeque<>(); | ||
| searchQueue.addFirst(block); | ||
|
|
|
|
||
| if(!EventUtil.passesFilter(event)) return; | ||
|
|
||
| //System.out.println("Pipe triggered"); |
|
|
||
| if(!EventUtil.passesFilter(event)) return; | ||
|
|
||
| //System.out.println("Pipe triggered 2"); |
| import java.util.*; | ||
|
|
||
| public class Pipes extends AbstractCraftBookMechanic { | ||
| private Map<String, Long> lastFailedAttempt = new HashMap<>(); |
There was a problem hiding this comment.
Is this guaranteed to be cleared of all added entries? This could easily cause a pretty major runaway memory problem
|
|
||
| String pipeKey = getPipeKey(block); | ||
| long currentTime = System.currentTimeMillis(); | ||
| if(lastFailedAttempt.containsKey(pipeKey) && (currentTime - lastFailedAttempt.get(pipeKey) < 5000)) { |
There was a problem hiding this comment.
Overall I don't feel this is something that can actually be added as is, without a configuration option.
If this does actually make sense (which is probably questionable), it'd have to be behind a configuration option as this will break most currently built systems that rely on any form of timing
There was a problem hiding this comment.
sorry didnt mean to add that part
There was a problem hiding this comment.
I'm happy for the original change of checking if the stack is valid before performing other logic, as that's a simple fast return optimisation - but the rest of it needs more thought and couldn't be merged as-is
This reverts commit c783d2b.
Removes unnessesary lag caused by empty furnaces checking the pipe system