158 Commits

Author SHA1 Message Date
Dylan K. Taylor
4c0c2ebd24 CS cleanup 2020-10-26 15:56:30 +00:00
Dylan K. Taylor
3f254bd49c Separated effects' MCPE ID registration from VanillaEffects 2020-10-24 18:52:20 +01:00
Dylan K. Taylor
a01c086481 Introduced VanillaEnchantments registry 2020-10-23 20:48:19 +01:00
Dylan K. Taylor
23e5ade77e Merge branch 'stable' into master
# Conflicts:
#	build/make-release.php
#	composer.lock
#	resources/vanilla
#	src/plugin/PluginDescription.php
#	src/pocketmine/entity/Human.php
2020-10-21 16:55:52 +01:00
Dylan K. Taylor
44e446b621 Merge remote-tracking branch 'origin/stable' into master
# Conflicts:
#	build/php
#	composer.lock
#	phpstan.neon.dist
#	resources/vanilla
#	src/pocketmine/Server.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/lang/locale
#	src/utils/Timezone.php
#	tests/phpstan/bootstrap.php
#	tests/phpstan/configs/custom-leveldb.neon
2020-10-13 17:51:49 +01:00
Dylan K. Taylor
b0b08d45d5 Entity: clean up sendData() handling, remove send-to-self hack 2020-10-08 21:35:36 +01:00
Dylan K. Taylor
cbc6ebebad Entity: make use of MoveActorAbsolutePacket::create() 2020-10-06 18:35:02 +01:00
Dylan K. Taylor
531c6344fe Entity: stop using broadcastPacketToViewers for movement / motion
this is now effectively identical to sending packets to each of hasSpawned, with the exception that it won't send packets to itself if it's a player.
2020-10-06 18:22:46 +01:00
Dylan K. Taylor
7b02cc3efd Implemented #3836: Replace setCancelled() in events with cancel() and uncancel()
The motivation for this is to prevent passing a dynamic argument to cancellation, which in almost all cases is a bug in user code. This same mistake also appears in a few places in the PM core (as seen in this commit), but in those cases the mistakes were mostly harmless since they were taking place before the event was actually called.
closes #3836
2020-09-26 14:31:56 +01:00
Dylan K. Taylor
75e3a0aa0f Merge branch 'stable' into master
# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/command/defaults/StatusCommand.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/level/format/SubChunk.php
2020-09-26 13:27:08 +01:00
Dylan K. Taylor
626680c6c1 Use new Location objects instead of mutating Entity->location directly
I'm actually not a big fan of needing to recreate the whole thing just to modify the coordinates. This seems kind of stupid.
2020-09-25 18:43:49 +01:00
Dylan K. Taylor
db7fb25196 Avoid more Vector3 mutations using withComponents() 2020-09-25 18:40:13 +01:00
Dylan K. Taylor
1d8e7abdd4 Entity: avoid direct mutation of Vector3 in checkObstruction(), use withComponents() instead
this ugly code can be simplified quite a lot further, but that's a job for later.
2020-09-25 18:38:41 +01:00
Dylan K. Taylor
25566c2f1a Entity: avoid direct Vector3 mutations in tryChangeMovement() 2020-09-25 18:37:29 +01:00
Dylan K. Taylor
38b97dd0b7 Entity: remove useless function 2020-09-25 18:11:24 +01:00
Dylan K. Taylor
a5e21bfaa9 Entity: protect getBlocksAroundWithEntityInsideActions() 2020-09-25 16:40:30 +01:00
Dylan K. Taylor
3556f26e00 Entity: Rename getBlocksAround() -> getBlocksAroundWithEntityInsideActions()
this name is more long-winded, but much less misleading.
2020-09-25 16:39:55 +01:00
Dylan K. Taylor
8e12693494 Entity: Invalid blocksAround cache when something happens during onEntityInside()
this fixes TNT spawning multiple entities when lit by flaming arrows.
The problem here is a bit more complex (entities aren't immediately notified when local block updates happen, so they cache stuff that becomes unusable). The simplest option would be to just lose the cache, but that would have some impacts on performance.
Barring a rethink of the block updating mechanism, this solution seems usable for now.
2020-09-25 16:35:59 +01:00
Dylan K. Taylor
5096741b29 World::getChunk() behaviour now matches that of a regular ChunkManager
Various bugs existed for a while with stuff using chunk managers instead of worlds when interacting with terrain due to a behavioural inconsistency between World::getChunk() (return from cache or load from disk), and SimpleChunkManager::getChunk() (return from cache only). This change brings the two in line.
World::getOrLoadChunk() has been added as a replacement, which has the same behaviour as the old getChunk() and also makes it more obvious that there is an issue with code using it during refactoring.
2020-09-20 13:29:09 +01:00
Dylan K. Taylor
5661d0496f RuntimeBlockMapping::toRuntimeId() now accepts a single integer instead of id/meta
the expectation is that eventually this will receive arbitrary internal runtime IDs instead of static id/meta, and RuntimeBlockMapping doesn't really care about this crap anyway.
2020-09-20 12:16:11 +01:00
Dylan K. Taylor
101dc1e1d7 fixed a couple of new phpstan errors 2020-09-04 01:44:21 +01:00
Dylan K. Taylor
0aee39027e Merge branch 'stable' into master
# Conflicts:
#	composer.lock
#	resources/vanilla
#	src/entity/Living.php
#	src/pocketmine/Player.php
#	src/pocketmine/VersionInfo.php
#	src/pocketmine/block/Potato.php
#	src/pocketmine/block/Sugarcane.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/Chunk.php
#	src/pocketmine/level/format/io/leveldb/LevelDB.php
#	src/world/generator/GeneratorRegisterTask.php
#	tests/phpstan/configs/check-explicit-mixed-baseline.neon
#	tests/phpstan/configs/l7-baseline.neon
#	tests/phpstan/configs/l8-baseline.neon
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMainLoggerTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskMemoryLeakTest.php
#	tests/plugins/TesterPlugin/src/pmmp/TesterPlugin/tests/AsyncTaskPublishProgressRaceTest.php
2020-09-04 01:43:52 +01:00
Dylan K. Taylor
40d49b88dd EntityFactory: remove requirement for $className as return type on creation funcs
since the removal of EntityFactory::create() this isn't needed anymore, since these creation functions are only used for creating entities loaded from disk.
2020-08-17 13:20:34 +01:00
Dylan K. Taylor
279abb871d Remove all usages of CompoundTag->hasTag()
in pretty much every case, these usages really wanted to read the tag's contents anyway, which can be combined with a getTag() and instanceof call for more concise and static analysis friendly code.
In the few cases where the tag contents wasn't needed, it still wanted to check the type, which, again, can be done in a more static analysis friendly way by just using getTag() and instanceof.
2020-07-10 21:01:43 +01:00
Dylan K. Taylor
c762ec1319 Entity: removed unused field 2020-07-09 14:10:56 +01:00
Dylan K. Taylor
600ef033ab PlayerSkinPacket: added ::create() 2020-07-09 13:24:31 +01:00
Dylan K. Taylor
31fd427710 Entity: remove usages of Chunk->getX()/getZ() 2020-07-08 20:29:30 +01:00
Dylan K. Taylor
da798817b5 Merge branch 'stable'
# Conflicts:
#	changelogs/3.14.md
#	resources/vanilla
#	src/VersionInfo.php
#	src/entity/Attribute.php
2020-07-08 11:46:02 +01:00
Dylan K. Taylor
909f3f39de Block: get rid of getRuntimeId()
the runtime ID mapping should be non-global in case of multiple protocols.
2020-07-06 11:18:29 +01:00
Dylan K. Taylor
670ad9eb9d Position: rename getWorldNonNull() to getWorld(), remove original getWorld() 2020-06-29 21:19:46 +01:00
Dylan T
d585081c22
Separate consumable item interfaces from general consumable interfaces (#3595)
I wonder if there's a way to generalise item consuming beyond just eating/drinking. Stuff like lava bucket in a furnace needs the same kind of "leftover" logic.
2020-06-28 17:53:03 +01:00
Dylan K. Taylor
2104b2d32b Entity: defer kill() until post-construct
this fixes crashes and various bugs with death logic executing during the creation of entities, as well as an age-old Player crash after quitting the server when dying.
2020-06-27 23:28:03 +01:00
Dylan K. Taylor
87ce92d87e Entity: some cleanup of network position hacks 2020-06-27 23:16:04 +01:00
Dylan K. Taylor
1f0ea0c2c7 Living: stop mutating Vector3 2020-06-27 21:51:42 +01:00
Dylan K. Taylor
f1048aeaa3 Block: rework addVelocityToEntity() to avoid vector3 mutation 2020-06-27 21:38:24 +01:00
Dylan K. Taylor
ff00595a48 Remove some more Vector3 mutations 2020-06-27 20:58:02 +01:00
Dylan K. Taylor
7e331c590d Use static-analysis-friendly method for getting effects from EffectManager
fixes 5 phpstan level 8 errors
2020-06-27 13:09:05 +01:00
Dylan K. Taylor
9e6f1c9a5a Living: check if damager is null before trying to use it 2020-06-27 13:09:05 +01:00
Dylan K. Taylor
b7b5ea6fc9 Painting: use motive directly internally
this is cleaner and also fixes a phpstan level 8 error
2020-06-27 13:09:05 +01:00
Dylan K. Taylor
3c1b8b83f5 HungerManager: use AttributeMap->mustGet()
fixes 2 errors on phpstan level 8
2020-06-27 13:09:05 +01:00
Dylan K. Taylor
80e150c803 Entity: get rid of temporalVector mutation
except for checkBlockCollision, these are all cold paths ... this gets us one step closer to immutable Vector3
2020-06-20 21:41:19 +01:00
Dylan K. Taylor
d38c17835d Properly switch to string entity IDs 2020-06-20 13:43:31 +01:00
Dylan K. Taylor
4e8e10ca45 EntityFactory: remove obsolete indirection (class mappings are redundant here now) 2020-06-19 22:18:42 +01:00
Dylan K. Taylor
0a43fd816c EntityFactory: drop unnecessary @param 2020-06-19 22:10:35 +01:00
Dylan K. Taylor
47baaf4c72 move NBT helper functions from EntityFactory to EntityDataHelper 2020-06-19 22:04:36 +01:00
Dylan K. Taylor
1a3445f4b5 EntityFactory: drop automatic provisioning of short class name as save ID 2020-06-19 22:03:22 +01:00
Dylan K. Taylor
012acdd4cb move runtime entity ID counter from EntityFactory back to Entity
EntityFactory is specialized for the purpose of deserializing data from worlds, and runtime ID assignment isn't related.
2020-06-19 21:55:49 +01:00
Dylan K. Taylor
6d3750994b EntityFactory: remove dead function 2020-06-19 21:54:23 +01:00
Dylan K. Taylor
954e8e6e6f update pocketmine/math dependency 2020-06-19 11:33:10 +01:00
Dylan K. Taylor
9f89f2887a Location: x,y,z parameters are now mandatory 2020-06-19 11:19:05 +01:00