Commit Graph

34 Commits

Author SHA1 Message Date
033b44df5a CraftingTransaction: Start from pre-computed iteration count for input matching
This will be faster to bail out on failures.
2018-04-04 12:15:46 +01:00
ef2dd1de92 Inventory: Use exceptions to report back why a transaction failed
Returning false all the time could mean any one of a range of things. Throwing exceptions is better in that it allows us to catch them and see what actually broke.
2018-04-04 12:11:24 +01:00
56328f66a7 InventoryAction: remove useless creationTime field 2018-03-29 12:20:13 +01:00
f41a731493 DropItemAction: don't require a source item in constructor 2018-03-29 12:18:19 +01:00
a1090623a2 CraftingRecipe: added methods to allow recipes to derive outputs from inputs
this will be needed for special recipes like shulker-box and banner recipes.
2018-03-29 12:05:22 +01:00
8572e9e560 Crafting: nuke
This commit brings in a much-needed rewrite of crafting transaction handling.

The following classes have been removed:
- CraftingTransferMaterialAction
- CraftingTakeResultAction

The following classes have significant changes:
- CraftingTransaction
	- All API methods have been removed and are now handled in CraftItemEvent
- CraftItemEvent
	- added the following:
		- getInputs()
		- getOutputs()
		- getRepetitions() (tells how many times a recipe was crafted in this event)
- Recipe interface:
	- Removed getResult() (individual recipes may handle this differently)
- CraftingRecipe interface
	- removed the following:
		- matchItems()
		- getExtraResults()
		- getAllResults()
	- added the following
		- getResults()
		- getIngredientList() : Item[], which must return a 1D array of items that should be consumed (wildcards accepted).
		- matchesCraftingGrid(CraftingGrid)
- ShapedRecipe
	- constructor now accepts string[], Item[], Item[]
- ShapelessRecipe
	- constructor now accepts Item[], Item[]
2018-03-29 12:05:22 +01:00
1420cd1fa5 InventoryTransaction: Added a more robust action flattening mechanism
This now handles the case where there are multiple options which could be taken, and opts for the first result which successfully ties all the actions together. Previously it would be entirely down to chance (ordering) whether the actions would get ordered successfully.
2018-03-29 11:23:52 +01:00
0dd8fd2651 CraftingTransaction: fixed ingredient map trimming (again)
closes #2118
2018-03-25 13:46:39 +01:00
b2491a5874 CraftingTransaction: clean up some logic 2018-03-08 20:44:52 +00:00
2e125168c3 CraftingTransaction: Fixed ingredient map trimming
I really don't know why I made this so complicated to start with. This works much better and is much easier to read.

Fixes #2083.
2018-03-08 19:51:06 +00:00
6543d96910 Inventory: Split up armor and player inventory (#1957)
* Inventory: Split up PlayerInventory and armour handling
* Fixed other players don't see armour changes. This bug also exists on master.
2018-01-23 20:01:26 +00:00
4f8e4f0522 Add EOF newlines where missing (bulk) (#1836)
This should solve issues with people making GitHub PRs and having the web editor messing things up. GitHub Web Editor sucks :(
2017-12-20 11:56:36 +00:00
3beccc47cd SlotChangeAction: Remove superfluous >= 0 inventorySlot check
This is done by slotExists() anyway.
2017-12-12 10:36:53 +00:00
8a90d159fe Cleanup unused imports 2017-12-10 12:09:46 +00:00
e94db980d7 Fixed not being able to wear armour 2017-11-29 19:51:38 +00:00
78cf875080 Quick-fix for crafting with big crafting grid after cancelling PlayerInteractEvent on a crafting table
this is not an ideal solution, but it works. Crafting is messy and is going to need more refactoring. Fixes #1480
2017-11-28 19:23:26 +00:00
878f1bffb9 CraftingTransaction: Don't hardcode crafting grid sizes 2017-11-28 17:29:53 +00:00
98ac6fc7be Check inventory slot is in range in SlotChangeAction 2017-11-28 16:56:02 +00:00
74b074753f Bulk addition of constant visibilities
thanks PhpStorm inspections plugin for annoying the shit out of me until
I did this.
2017-11-21 14:44:10 +00:00
97e2d64592 "Fixed" shift-clicking recipe book, close #1401
this is not an optimal solution because you'll still only get 1 crafting
event when the user actually crafted a lot of items, so this isn't very
nice for plugins to work with. However, for gameplay purposes it works,
so it'll do for now.
2017-10-15 18:08:32 +01:00
ca401ec3f5 Force-close the crafting window only when doing crafting transactions
otherwise the client will crash when using right-click on the recipe book
2017-10-03 11:33:09 +01:00
9bbebaa071 Force-close the inventory window when crafting fails to avoid desync issues
mojang, why does this have to be hard work
2017-10-03 11:04:21 +01:00
6b0ac8adb8 Don't overwrite the input map with reindexed stuff
we might need this again?
2017-09-24 19:17:00 +01:00
240cc3043a Rewritten crafting, fixed #45 2017-09-24 14:14:24 +01:00
f01ce8e994 null and void typehints 2017-09-21 12:54:04 +01:00
d89b8cf12e Clean up SlotChangeAction inventory handling 2017-09-21 12:44:03 +01:00
dbed80386a Removed redundant interface 2017-09-21 12:22:47 +01:00
ef6250967f Use Item->isNull() more 2017-09-21 10:29:29 +01:00
55720d9f0a Added InventoryAction->onPreExecute(), fixed PlayerDropItemEvent deleting items 2017-09-20 12:19:42 +01:00
bd64172750 Added API method Item->equalsExact() and removed some boilerplate code 2017-09-15 16:48:46 +01:00
63634d7e7d Added compaction and sorting for repeated slot changes in a single transaction
Now items should be able to move around the crafting grid correctly.
2017-09-15 13:32:17 +01:00
a3d21de559 Cleaned up network inventory action reading and core action creation 2017-08-28 20:04:35 +01:00
83fcec3e94 Don't add actions to the transaction if a crash occurred when getting the source inventory 2017-08-12 14:29:12 +01:00
8958b3c51c Many many changes related to inventory transactions, fixed item dropping, fixed creative menu 2017-08-11 19:57:30 +01:00