19 Commits

Author SHA1 Message Date
Dylan K. Taylor
2c8a065b94 Standardise SNAKE_CASE for surrogate enums 2019-02-20 11:14:07 +00:00
Dylan K. Taylor
dce08b4e88 Introduce Item use results - can be success, fail or none
closes #2693, closes #2705, closes #2734
2019-02-14 19:21:29 +00:00
Dylan K. Taylor
7d827a1c65 Introduce EntityFactory
This contains all of the static stuff that was previously embedded in the Entity static root. This solves a bunch of problems like circular dependencies between parent and child classes, encapsulating logic and reducing the size of the enormous Entity.php.
2019-01-06 23:54:29 +00:00
Dylan K. Taylor
b1cef8509a Revamp Entity construction
This is a similar refactor to the one I recently did for tiles.

- Entity::createEntity() is removed. In its place are Entity::create() (runtime creation, use where you'd use a constructor, accepts a ::class parameter, throws exceptions on unknown entities) and Entity::createFromData() (internal, used to restore entities from chunks, swallows unknown entities and returns null).
- Entity::registerEntity() is renamed to Entity::register().
- Added Entity::override() to allow overriding factory classes without touching save IDs. This allows more cleanly extending & overriding entities. This method only allows overriding registered Entity classes with children of that class, which makes code using the factory much more sane and allows to provide safety guarantees which make the code less nasty.
- Entity::getKnownEntityTypes() is renamed to Entity::getKnownTypes().
- ProjectileItem::getProjectileEntityType() now returns a ::class constant instead of a stringy ID.
- Cleaned up a bunch of nasty code, particularly in Bow.
2019-01-06 23:33:36 +00:00
Dylan K. Taylor
ffa733fe0c Merge branch 'release/3.5' 2018-12-12 19:51:41 +00:00
Dylan K. Taylor
30f5a8fac6 Protocol changes for 1.8.0 release 2018-12-11 21:05:03 +00:00
Dylan K. Taylor
90482e79bc Merge branch 'release/3.4' 2018-10-21 18:23:54 +01:00
Dylan K. Taylor
6dd2597934 Merge branch 'release/3.3' into release/3.4 2018-10-21 18:17:07 +01:00
Dylan K. Taylor
45c9caa38c Fixup some formatting issues 2018-10-21 18:15:25 +01:00
Dylan K. Taylor
139aaa5577 Protect Item->count 2018-10-07 14:34:04 +01:00
Dylan K. Taylor
1dd6591ac1 Migrate a bunch of PluginManager->callEvent() usages to Event->call
This has the triple bonus effect of a) making a lot of code easier to read, b) reducing Server::getInstance() usages, and c) removing a whole bunch of Server dependencies.

The network and block namespaces are untouched by this commit due to potential for merge conflicts. These should be dealt with separately on master.
2018-10-05 17:30:06 +01:00
Dylan K. Taylor
606407933e ProjectileItem: fixed error when projectile entity is null 2018-03-10 10:59:22 +00:00
Dylan K. Taylor
2e9bf7e93b Implemented Splash Potions 2018-03-09 12:25:02 +00:00
Dylan K. Taylor
5059a92b91 Fixed bow and throwable sounds 2018-03-08 13:20:26 +00:00
Dylan K. Taylor
eab7b93483
Fixed misuse of kill() and close() when deleting entities (#1490) 2017-11-04 19:30:48 +00:00
Dylan K. Taylor
50be26958a Added a helper function Entity->createBaseNBT() to cut down on boilerplate code 2017-10-19 17:36:51 +01:00
Dylan K. Taylor
584810780a Moved projectile-related classes to their own namespace 2017-10-19 12:27:44 +01:00
Matt
9cd7f39c03 Fixed typo on ProjectileItem class (#1431) 2017-09-30 16:17:22 +01:00
Dylan K. Taylor
b071ce9c5a Refactored projectile handling, added Item->onClickAir() 2017-09-02 11:57:26 +01:00