847 Commits

Author SHA1 Message Date
Dylan K. Taylor
e61a08a56b Make SignText immutable 2020-06-29 20:18:10 +01:00
Dylan K. Taylor
42f543b405 SignText: fixed crash when fetching lines of text if not all lines were provided to the constructor 2020-06-29 19:35:38 +01:00
Dylan K. Taylor
0b05fd1987 added missing file 2020-06-29 18:54:47 +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
01d221b794 imports cleanup 2020-06-28 17:50:49 +01:00
Dylan K. Taylor
f1048aeaa3 Block: rework addVelocityToEntity() to avoid vector3 mutation 2020-06-27 21:38:24 +01:00
Dylan K. Taylor
7e391a8123 Tile: use phpstan-friendly way to pass block NBT
fixes 1 level 8 error
2020-06-27 13:09:05 +01:00
Dylan K. Taylor
9484220bd5 ContainerTrait: use a static-analysis-friendly way to read NBT, fixes 4 phpstan level 8 errors 2020-06-27 13:09:05 +01:00
Dylan K. Taylor
f039a077cd ItemFrame: fixed a phpstan level 8 error 2020-06-27 13:09:05 +01:00
Dylan K. Taylor
7e6adc41f0 Merge 1.16 support into PM4 (with changes) 2020-06-26 22:21:09 +01:00
Dylan K. Taylor
1ef6e5e17b TileFactory now only manages loading tiles from NBT, not direct creation
my objective is to make this use proper constructors like entities, but there's a couple of obstacles to get around first.
2020-06-21 00:47:02 +01:00
Dylan K. Taylor
42637f97c6 Liquid: eliminate some unnecessary Vector3 field mutations 2020-06-20 21:32:24 +01:00
Dylan K. Taylor
4b528aa637 NBT is no longer needed to create an entity
it's still able to be provided, but shouldn't be needed in the majority of cases (constructor args and/or API methods should be sufficient).
2020-06-19 10:51:27 +01: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
921aa091e0 Merge commit '04191ec44a00dd058f5d7e9e315d451e44285494'
# Conflicts:
#	resources/vanilla
#	tests/phpstan/configs/l7-baseline.neon
2020-06-17 20:40:12 +01:00
Dylan K. Taylor
017afead3b extract FurnaceRecipeManager unit from CraftingManager
I'd like to have this directly provided to Furnace, but I don't know how to short of making into a singleton. Since I want to have per-furnace recipe managers (e.g. for stuff like blast furnace vs regular furnace etc), a singleton isn't really an option.
2020-06-03 18:59:59 +01:00
Dylan K. Taylor
e250553670 Merge commit '3f2455f09'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/block/SnowLayer.php
2020-06-03 12:43:36 +01:00
Dylan K. Taylor
d7ae86b30c Merge commit '9d26a224a'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/block/DoublePlant.php
2020-06-03 12:35:59 +01:00
Dylan K. Taylor
0a730db030 Merge commit '4199c3796f4c6d8da0eccba64fe4cd9812acadeb'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/block/Water.php
2020-05-31 14:46:51 +01:00
Dylan K. Taylor
ec8ee29291 moving sneak & sprint properties to Living 2020-05-21 19:55:58 +01:00
Dylan K. Taylor
f93bc0739c Force types of RegistryTrait usages to shut PHPStan up
we need generic traits to solve this problem properly.
2020-05-21 19:12:48 +01:00
Dylan K. Taylor
8e2b9b686b Block: Invert default behaviour of silk touch (more logical)
Now, blocks do not respond to silk touch unless specifically opted into. Since this always involves custom drops in one way or another, it's easy enough to figure out which blocks need to be marked for silk touch - anything that overrides getDrops, getDropsForCompatibleTool or getSilkTouchDrops is a block which _might_ need to be flagged. Using these criteria to reduce the number of blocks needing to be checked, I was able to manually invert the behaviour as needed.

This fixes reoccurring bugs with blocks erroneously dropping themselves whenever new blocks are added and someone forgot to set that flag, granting players access to internal blocks with strange behaviour.
2020-05-21 13:02:36 +01:00
Dylan K. Taylor
72f59eca3c Slab: ignore silk touch on breaking tools, closes #2794 2020-05-21 11:46:43 +01:00
Dylan K. Taylor
8ec2ba79de Unhackify Registry member cloning, fixes #3519 2020-05-21 11:38:02 +01:00
Dylan K. Taylor
3f1f135a59 remove a couple more Position->getWorld() usages 2020-05-19 21:38:51 +01:00
Dylan K. Taylor
337addf1de Eradicate remaining usages of public Position->world field
and as an added bonus, ditch a bunch of extra phpstan errors
2020-05-19 19:14:56 +01:00
Dylan K. Taylor
8a8b1b0b97 Remove Position->setWorld() 2020-05-19 18:33:16 +01:00
Dylan K. Taylor
86db3af896 remove utils\Color, use new pocketmine/color class
we're so close to separating protocol from core !!!
2020-05-14 20:38:08 +01:00
Dylan K. Taylor
4437756987 Inventory: reduce API duplication by using a Set for viewers 2020-05-14 14:13:28 +01:00
Dylan K. Taylor
6b037d6a4c RuntimeBlockMapping: these IDs are not static any more 2020-05-11 12:40:55 +01:00
Dylan K. Taylor
81f982a8d9 remove hardcoded legacy entity type ID mapping, load from resources instead 2020-05-04 13:47:39 +01:00
Dylan K. Taylor
0eec536f97 Spawnable: remove unused field 2020-05-04 13:10:23 +01:00
Dylan K. Taylor
a73c54bdd0 making tile spawn compound cache use CacheableNbt instead of strings 2020-05-04 12:35:13 +01:00
Dylan K. Taylor
6f38031121 Liquid: do not schedule delayed blockupdate when hardening occurs on nearby blockupdate
fix #3390
fix #3392
2020-04-30 09:35:55 +01:00
Dylan K. Taylor
a97cafd4f6 moving serializers into protocol namespace 2020-04-27 13:54:39 +01:00
Dylan K. Taylor
ac5cf2443e convert TileFactory to singleton 2020-04-26 01:11:30 +01:00
Dylan K. Taylor
6dd31cc3f5 break cycle between block and inventory packages 2020-04-24 23:53:49 +01:00
Dylan K. Taylor
4fbf4dcdc6 Rename InventoryChangeListener -> InventoryListener 2020-04-24 23:44:38 +01:00
Dylan K. Taylor
7d9df6af6f Convert EntityFactory to singleton 2020-04-24 22:43:02 +01:00
Dylan K. Taylor
287bf4274f move RuntimeBlockMapping to convert package 2020-04-24 12:42:43 +01:00
Dylan K. Taylor
5cc03775d3 added a SingletonTrait to reduce code duplication 2020-04-24 00:31:55 +01:00
Dylan K. Taylor
5a94af40e2 Convert ItemFactory to singleton 2020-04-24 00:18:31 +01:00
Dylan K. Taylor
13d784cd0c Convert BlockFactory to singleton 2020-04-23 23:45:13 +01:00
Dylan K. Taylor
aa1828aa98 RuntimeBlockMapping is now a singleton instead of static class
this prepares for a fully dynamic block mapper, as well as allowing a small performance improvement to chunk encoding by eliding the constant lazy-init checks.
2020-04-23 21:09:58 +01:00
Dylan K. Taylor
86e051b7bf Merge commit 'a2543ff80d2906bccda1a4e2fdbd9d8e7d147fb3' 2020-04-18 17:33:05 +01:00
Dylan K. Taylor
995309424e updated pocketmine/nbt dependency
this is going to need work on exception handling, but right now it's so inconsistent that it doesn't matter anyway.
2020-03-04 17:53:37 +00:00
Dylan K. Taylor
7c2741e4f5 Inventory: eliminate remaining $send parameters 2020-02-23 21:59:51 +00:00
Dylan K. Taylor
fd675449e9 BlockFactory: fill blastResistance with float(0)
technically there wasn't anything wrong with this code, but it caused the type inference to report incompatibility, and I can't be bothered to report a PHPStan bug.
2020-02-07 22:06:34 +00:00
Dylan K. Taylor
d2aca6023b add native return types to closures (for phpstan) 2020-02-07 22:05:15 +00:00