413 Commits

Author SHA1 Message Date
Dylan K. Taylor
4fc134bd04 Separate item ID/meta to ItemIdentifier structure 2020-06-29 12:16:34 +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
c040248dbd Item: use static-analysis-friendly method for retrieving custom block data
fixes 2 phpstan level 8 errors
2020-06-27 13:46:04 +01:00
Dylan K. Taylor
0000783926 Item: make nbt field non-nullable 2020-06-27 13:34:08 +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
d2089afbc3 ItemBlock: get rid of -1 meta check (meta is never -1 in this code path now) 2020-06-20 09:52:02 +01:00
Dylan K. Taylor
62e7b0e2b1 (Splash)Potion: do not assume that META == potion ID
it probably will be, but meta might not be accessible anymore soon.
2020-06-20 09:31:06 +01:00
Dylan K. Taylor
d62d0762ff item: remove some unnecessary CompoundTag usages 2020-06-19 22:59:19 +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
3f135da704 Simplify motion handling in ProjectileItem 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
0ae357cf8f ProjectileItem: get NBT as far away as possible 2020-06-18 20:25:19 +01:00
Dylan K. Taylor
d0c8d64b40 Merge commit '097c260db'
# Conflicts:
#	resources/vanilla
#	src/item/enchantment/Enchantment.php
#	src/plugin/PluginDescription.php
#	src/pocketmine/entity/Effect.php
#	src/pocketmine/item/ItemFactory.php
#	src/pocketmine/plugin/PluginManager.php
2020-06-14 19:28:05 +01:00
Dylan K. Taylor
899da1b7f7 Merge commit '42e14f749'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/Player.php
#	src/pocketmine/item/Bow.php
#	src/world/World.php
2020-06-03 12:31:17 +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
8ec2ba79de Unhackify Registry member cloning, fixes #3519 2020-05-21 11:38:02 +01:00
Dylan K. Taylor
81dff6d4c5 Merge branch 'next-minor' 2020-05-19 21:32:44 +01:00
Dylan K. Taylor
5b82bd4fad Merge commit 'a67d2ae978ecae234c3e46b5ac0f8f0dc99e85a7'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/item/Bow.php
2020-05-19 21:15:56 +01:00
Dylan K. Taylor
148228e360 update pocketmine/math, adapt to add() changes 2020-05-19 12:26:18 +01:00
Dylan K. Taylor
c30dd9f1b6 Entity: add abstract getNetworkTypeId(), remove NETWORK_ID constant
this now requires that subclasses supply a proper NETWORK_ID.
2020-05-16 16:08:12 +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
11ef9fb0c0 Item-from-string parsing no longer depends on ItemIds
after this is done I'm banning the constant() function.
2020-05-13 00:18:49 +01:00
Dylan K. Taylor
ec13aa659a ItemFactory: do not explode on invalid damage values for durables
just treat them as unknown items instead
this might break some use cases, but at least this way they won't crash the server when read from disk and they won't get lost either.
2020-05-12 23:28:17 +01:00
Dylan K. Taylor
f9a587d40e imports cleanup 2020-04-28 17:27:38 +01:00
Dylan K. Taylor
45bed454f2 Merge commit '3d2ca45' 2020-04-25 12:14:45 +01:00
Dylan K. Taylor
7d9df6af6f Convert EntityFactory to singleton 2020-04-24 22:43:02 +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
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
78394a336c Merge branch 'stable' 2020-02-25 20:45:39 +00:00
Dylan K. Taylor
8a770d837e Merge branch 'stable' 2020-02-24 20:32:43 +00:00
Dylan K. Taylor
bc60bb9462 remove useless type asserts on Entity->getWorld() 2020-02-07 22:08:38 +00:00
Dylan K. Taylor
aac7da6c96 eliminate remaining empty() usages 2020-02-07 21:51:50 +00:00
Dylan K. Taylor
fb1126797a Merge branch 'stable' 2020-02-07 18:13:55 +00:00
Dylan K. Taylor
9c33ea8dd1 EnumTrait: use a better method to initialize enums
this method is simpler, and is also safe at the native type level.
Coincidentally, it also eliminates 30 PHPStan false-positives.
2020-02-01 20:33:30 +00:00
Dylan K. Taylor
89c6da13ac phpstan: use more class-string 2020-01-31 22:05:33 +00:00
Dylan K. Taylor
cb16f5c142 Merge commit '260ac47588c76a2e6814cfba46773a990fb8c5da'
# Conflicts:
#	resources/vanilla
#	src/Server.php
#	src/lang/Language.php
#	src/network/mcpe/protocol/AddItemActorPacket.php
#	src/network/mcpe/protocol/AddPlayerPacket.php
#	src/network/mcpe/protocol/SetActorDataPacket.php
#	src/network/mcpe/serializer/NetworkBinaryStream.php
#	src/permission/Permission.php
#	src/pocketmine/block/Leaves.php
#	src/pocketmine/entity/DataPropertyManager.php
#	src/pocketmine/entity/Entity.php
#	src/pocketmine/item/Banner.php
#	src/pocketmine/item/Item.php
#	src/pocketmine/level/format/io/LevelProvider.php
#	src/pocketmine/level/format/io/LevelProviderManager.php
#	src/pocketmine/network/mcpe/protocol/AddActorPacket.php
#	src/pocketmine/network/mcpe/protocol/LoginPacket.php
#	src/pocketmine/tile/Banner.php
#	src/scheduler/BulkCurlTask.php
#	src/updater/AutoUpdater.php
#	src/utils/Config.php
#	src/utils/Utils.php
#	src/world/generator/Flat.php
#	src/world/generator/Generator.php
2020-01-31 21:07:34 +00:00
Dylan K. Taylor
96ac95798b Merge commit '4ff4434a220813e446efde4a38e48a0416476dba'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/item/Banner.php
#	src/pocketmine/item/Item.php
2020-01-31 20:11:29 +00:00
Dylan K. Taylor
8262633820 Merge commit '3b9a5c5ccc22170499b686f59ea55e8be231407a'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/item/Item.php
2020-01-31 19:21:03 +00:00
Dylan K. Taylor
055b13a6cf strip extra blank lines (php-cs-fixer) 2020-01-22 15:14:10 +00:00
Dylan K. Taylor
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
Dylan K. Taylor
b4e6608e9f Merge branch 'stable' 2020-01-18 20:13:54 +00:00
Dylan K. Taylor
0e1cea043a added some phpstan-specific generic type annotations 2020-01-13 15:05:02 +00:00
Dylan K. Taylor
0f718ea28b Merge commit '8726604899d1a371567141e0831ed570d3233356' 2019-12-25 14:19:35 +00:00
Dylan K. Taylor
0a4a1f634f Item: fixed possible type violation in jsonDeserialize() 2019-12-12 20:26:26 +00:00
Dylan K. Taylor
137245ed7b ItemFactory: fix var type doc in get() 2019-12-12 13:54:44 +00:00
Dylan K. Taylor
66aa940ed1 Item: fixed foreach doc comment in deserializeCompoundTag()
detected by PHPStan 0.12.0
2019-12-04 11:28:59 +00:00