Commit Graph

31 Commits

Author SHA1 Message Date
4b9a142a5d Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called.

When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace.
This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified.

However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement.
But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations.
We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
2019-01-04 20:43:15 +00:00
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
ec332e3e60 Fill null UUIDs in CraftingDataPacket, remove all UUID things from CraftingRecipe
This allows deleting lots of code, and additionally provides a huge reduction in the compressed size of CraftingDataPacket. Since we don't care about these UUIDs (they are only used in CraftingEventPacket, which is broken and unused in PM) we fill them with zeros instead.
2018-03-29 12:05:23 +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
08c48d8145 CraftingRecipe: removed requiresCraftingTable()
the requirement for a crafting table is determined by the number of ingredients can fit on the grid (shapeless) or the max height and width (shaped). It's impossible to craft a big recipe with a small crafting table simply because you're not able to put the required resources into the grid.
2018-03-29 11:43:31 +01:00
81ecb56095 ShapedRecipe: fixed bug in constructor 2018-03-29 11:32:39 +01:00
c448f4a3b5 Added handling for reflected ShapedRecipe crafting, close #1415 2017-09-28 18:45:22 +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
6aa9b081e9 Cleanup unused imports 2017-09-21 12:26:41 +01:00
ee052f91d4 Fixed some air items with count 1 instead of 0 2017-09-21 10:30:14 +01:00
7996a7b08c Testing handling multiple result items for ShapedRecipes
this doesn't work yet, I wanted to see how glitchy it is with cakes. The answer is: very glitchy.
2017-09-20 11:14:09 +01:00
f0755d1659 Fixed handling of recipes that require a crafting table 2017-09-20 09:43:49 +01:00
fd33a65e3b Small cleanup of recipe UUID handling (furnace recipes don't need UUIDs) 2017-09-20 09:34:00 +01:00
8728547a11 Remove unused imports 2017-09-19 19:58:53 +01:00
642c7733cd Cleaned up ShapedRecipe handling, ShapedRecipe API changes
use shapes from json instead of just generating maps
fix a ton of bugs
2017-09-17 11:45:16 +01:00
876659cc73 Item factory refactor and added capability to register custom items 2017-08-21 17:49:26 +01:00
c3b8be3f60 and more typehints 2017-07-14 10:56:51 +01:00
b9355387da fix some inspections related to crafting recipes 2017-07-14 08:53:37 +01:00
2a7b736f18 Heap of bugfixes, cleanup and PHP 7 upgrades 2017-07-13 19:18:56 +01:00
51b0673b4b Bite the bullet and enable strict types on everything 2017-06-07 12:53:16 +01:00
1082e32fd7 Fixed ShapedRecipe constructor 2016-02-07 01:02:40 +08:00
c7c78b1159 Read recipes from json 2016-01-25 20:40:26 +01:00
1fa467eb58 Proper recipe ingredient matching, fixed crafting type resetting 2015-08-07 22:00:35 +02:00
09720a2d90 Properly implemented Shaped recipes on Network and manager, no crafting! 2015-08-04 21:59:54 +02:00
5621ab0c49 Updated some packets for 0.12, UUIDs, other stuff! 2015-08-02 01:22:36 +02:00
8c4faa8622 Added extra Exceptions 2014-10-28 21:07:12 +01:00
8d40f843cf MainLogger can now have debug level disabled 2014-05-29 00:08:02 +02:00
6746987ce5 Added CraftItemEvent, Crafting system now uses Transactions 2014-05-27 17:49:22 +02:00
6fcd5322d0 Implemented Transactions 2014-05-27 01:20:18 +02:00