changelog: rewrite a whole lot of confusing bullshit

EntityFactory doesn't exist at all on PM3, so mentioning changes in its
behaviour here is only going to confuse people.
This commit is contained in:
Dylan K. Taylor 2021-06-19 19:53:51 +01:00
parent c07f3f5e12
commit 908fa5f901
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -395,18 +395,30 @@ However, if we add `src-namespace-prefix: pmmp\TesterPlugin` to the `plugin.yml`
- `Entity->initEntity()` now accepts a `CompoundTag` parameter.
#### Entity creation
- Runtime entity creation no longer requires `EntityFactory` - just use `new YourEntity` instead.
- Entity constructors no longer require `CompoundTag`. You can now make your entity constructors have any signature you want.
- `EntityFactory` now requires a creation callback (usually a closure) with the signature `function(World, CompoundTag) : Entity` to construct entities loaded from disk. This is required to allow entity classes to have custom constructor signatures. This callback should do any necessary actions to transform NBT into constructor parameters.
- Example: `ItemEntity` now requires an `Item` in its constructor, so its creation callback decodes the `Item` from the NBT to be passed to the constructor.
- Example: `Painting` now requires a `PaintingMotive` in its constructor, so its creation callback decides which `PaintingMotive` to provide based on the NBT it receives.
- See `EntityFactory` for more examples.
- `EntityFactory`'s responsibility as runtime entity creator has been removed. It's now solely responsible for restoring entities saved on disk.
- Registering entities will now throw exceptions on error cases instead of returning `false`.
- `Entity::createEntity()` has been removed. It's no longer needed for creating new entities at runtime - just use `new YourEntity` instead.
- `Entity` subclass constructors can now have any signature, just like a normal class.
- Loading entities from NBT is now handled by `EntityFactory`. It works quite a bit differently than `Entity::createEntity()` did. Instead of registering `YourEntity::class` to a set of Minecraft save IDs, you now need to provide a callback which will construct an entity when given some NBT and a `World`.
- The creation callback is registered using `EntityFactory::register()`.
- The creation callback must have the signature `function(World, CompoundTag) : Entity`.
- This enables `Entity` subclasses to have any constructor parameters they like.
- It also allows requiring that certain data is always provided (for example, it doesn't make much sense to create a `FallingBlock` without specifying what type of block).
- Examples:
- `ItemEntity` now requires an `Item` in its constructor, so its creation callback decodes the `Item` from the NBT to be passed to the constructor.
- `Painting` now requires a `PaintingMotive` in its constructor, so its creation callback decides which `PaintingMotive` to provide based on the NBT it receives.
- See `EntityFactory` for more examples.
- `EntityFactory::register()` (previously `Entity::registerEntity()`) will now throw exceptions on error cases instead of returning `false`.
- The following API methods have been moved:
- `Entity::registerEntity()` -> `EntityFactory::register()`
- `Entity::createBaseNBT()` -> `EntityDataHelper::createBaseNBT()`
- The following classes have changed constructors:
- All projectile subclasses now require a `?Entity $thrower` parameter.
- `Arrow->__construct()` now requires a `bool $critical` parameter (in addition to the `$thrower` parameter).
- `ExperienceOrb->__construct()` now requires a `int $xpValue` parameter.
- `FallingBlock->__construct()` now requires a `Block $block` parameter.
- `ItemEntity->__construct()` now requires an `Item $item` parameter.
- `Painting->__construct()` now requires a `PaintingMotive $motive` parameter.
- `SplashPotion->__construct()` now requires a `int $potionId` parameter.
- The following API methods have been removed:
- `Entity::createBaseNBT()`: `new YourEntity` and appropriate API methods should be used instead
- `Entity->getSaveId()`
- `Entity::getKnownEntityTypes()`
- `Entity::createEntity()`: use `new YourEntity` instead (to be reviewed)