Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Add remove command #1
Adding a command to remove items from inventory.
How to test:
Test the steps 1 to 4 for blocks and shapes too.
jellysnake left a comment
So you mentioned wanting to reduce redundancies in the code, and I can see why. There are definitely parts of the code that look tantalisingly similar.
Firstly you can split the similar bits of code up into multiple smaller functions and then reuse those in each of the logic flows. For instance, lines 373-383 and 359-369 and 165-175 all look like they could be extracted as does the return at the end of the private
The second method is to take the whole monolithic section and extract it, and then to pass in the things that make it different. For instance a
removeMatching(prefab, itemAmount, (prefab, currentPrefab) -> currentPrefab != null && currentPrefab.matches(prefab))
(Although it would depend on how you structured the extracted function)
The unmentioned third method is an extension of the second one. Go even further with "generifiying" the function and then move it to a
Either method, I agree that reducing duplicate code would definitely be a good idea, and you have the capabilities to do so.
On a more general note about the code, as it's essentially a duplicate of the PR to Movingblocks/Terasology the overall structure is alright. It's just small things I would like fixed or clarified.
Just tested it out in-game.