442 Commits

Author SHA1 Message Date
Dylan K. Taylor
4e91009492 Armor: fixed equipping when right-clicking air instead of a block
this action (which is more accurately referred to as 'activate item' or 'use item' in other areas) always fires on right-click when holding any item, whether aiming at a block or not.
2020-11-09 12:47:36 +00:00
David
b059e0b475
Item: fixed wrong tag being removed during serialization of custom name (#3894) 2020-11-07 01:25:37 +00:00
Dylan K. Taylor
142102a054 ItemFactory: remap bucket:9 and bucket:11 to their appropriate counterparts 2020-11-03 19:44:57 +00:00
Dylan K. Taylor
12e185e3f6 Relocate EntityLegacyIds to pocketmine\data\bedrock package 2020-11-01 17:07:34 +00:00
Dylan K. Taylor
4c0c2ebd24 CS cleanup 2020-10-26 15:56:30 +00:00
Dylan K. Taylor
cf7f50af06 Fixed test failure 2020-10-24 18:25:42 +01:00
Dylan K. Taylor
c5b925a213 Moved EnchantmentIds to pocketmine/data/bedrock package 2020-10-24 18:24:39 +01:00
Dylan K. Taylor
f3f7ff9237 Enchantment internal IDs are now dynamic 2020-10-24 18:21:31 +01:00
Dylan K. Taylor
47976bac34 Moved enchantment ID handling to pocketmine/data/bedrock package
this permits plugins to register their own enchantments mapped to MCPE IDs again.
2020-10-24 17:59:46 +01:00
Dylan K. Taylor
9947e13121 Yank constants out of Enchantment base class 2020-10-23 21:04:27 +01:00
Dylan K. Taylor
a01c086481 Introduced VanillaEnchantments registry 2020-10-23 20:48:19 +01:00
Dylan K. Taylor
7f9c4355f0 Revert back to floor/wall banner variants
this code largely duplicates the same code in FloorSign/WallSign and needs to be de-duplicated.
2020-10-04 19:05:43 +01:00
Dylan K. Taylor
505d4e402f ItemFactory: do not reuse the same itemstack instance for air()
this is mutable, so it's possible for plugins to mess with it and break everything that references it.
2020-10-04 18:36:46 +01:00
Dylan K. Taylor
c42a6d7552 ItemBlock no longer depends on legacy ID/metadata 2020-10-04 18:27:20 +01:00
Dylan K. Taylor
d3a3a41d2b Revert back to separated floor/wall sign
the conditionally useless properties are problematic.
2020-10-04 17:52:23 +01:00
Dylan K. Taylor
e6bf7278fc Sign: remove obsolete clone hook
this is no longer required because SignText is not mutable anymore.
2020-10-04 17:24:40 +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 T
bf401421fa
Implemented bamboo (#3762) 2020-08-16 20:39:51 +01:00
Jack Honour
ff2a3baa8e
Implemented Jukebox & Records (#3742)
Co-authored-by: Dylan K. Taylor <odigiman@gmail.com>
2020-08-07 21:07:58 +01:00
Dylan K. Taylor
2b044195a5 Update for pocketmine/math Axis refactor 2020-08-06 14:38:54 +01:00
Dylan K. Taylor
2e0f7102e8 ItemBlock: remove superfluous doc comments generated by PhpStorm 2020-08-01 16:06:38 +01:00
Dylan K. Taylor
9872bb4cb8 Enchantment: remove dead classes 2020-07-17 14:41:04 +01:00
Dylan K. Taylor
9b52af62b6 Item: skip a step when decoding PC itemstacks 2020-07-10 21:32:39 +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
68c408268c Separate dye colour ID management from DyeColor enum 2020-07-05 19:04:22 +01:00
Govdim
7f81507ea1
Add Releasable interface (#3664)
closes #3301
2020-06-30 21:09:10 +01:00
Dylan K. Taylor
74a919353f Food: remove unused import 2020-06-29 22:52:04 +01:00
Dylan K. Taylor
670ad9eb9d Position: rename getWorldNonNull() to getWorld(), remove original getWorld() 2020-06-29 21:19:46 +01:00
Dylan K. Taylor
0b05fd1987 added missing file 2020-06-29 18:54:47 +01:00
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