11 Commits

Author SHA1 Message Date
Dylan K. Taylor
d0ff6d2e36
Enable various types of interaction to return items to the player, without needing to have a bunch of boilerplate creative mode and held item checks
it became glaringly obvious that this was needed because of #4827 and #4868.

this is further needed with the addition of cauldrons.
2022-07-16 19:50:33 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
SalmonDE
7fd712c1ff
Refactor Block & Tile: getPos() to getPosition() (#4395)
this also changes the name of the class property 'pos' to 'position' as well as Block->getPosOffset() to Block->getPositionOffset()
2021-08-23 14:01:32 +01:00
Dylan K. Taylor
6cf875ca3a Item: rename onActivate() to onInteractBlock() 2020-11-09 19:33:13 +00:00
Dylan K. Taylor
1205432c34 Extract mandatory parameters into constructor parameters
the goal is obviously to ditch NBT entirely here, but there's more work to be done before that becomes possible.
2020-06-19 10:51:27 +01:00
Dylan K. Taylor
6a26c0bebf EntityFactory now exclusively handles loading data from disk
this commit removes the ability to replace centrally registered entity classes in favour of using constructors directly.
In future commits I may introduce a dedicated factory interface which allows an _actual_ factory pattern (e.g. factory->createArrow(world, pos, shooter, isCritical) with proper static analysability) but for now it's peripheral to my intended objective.
The purpose of this change is to facilitate untangling of NBT from entity constructors so that they can be properly created without using NBT at all, and instead use nice APIs.

Spawn eggs now support arbitrary entity creation functions like EntityFactory does, allowing much more flexibility in what can be passed to an entity's constructor (e.g. a Plugin reference can be injected by use()ing it in a closure or via traditional DI.
2020-06-19 10:51:27 +01:00
Dylan K. Taylor
7d9df6af6f Convert EntityFactory to singleton 2020-04-24 22:43:02 +01:00
Dylan K. Taylor
89c6da13ac phpstan: use more class-string 2020-01-31 22:05:33 +00:00
Dylan K. Taylor
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
Dylan K. Taylor
53ab860db5 first shot making Block not extend Position
this makes some stuff a lot less pretty, but this seems to be the bare minimum necessary to do this task. It can be enhanced later.
2019-08-05 16:44:09 +01:00
Dylan K. Taylor
5499ac620c Removed pocketmine subdirectory, map PSR-4 style 2019-07-30 19:14:57 +01:00