pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.25k stars 1.53k forks source link

4.0.0: Unable to easily identify old item in inventory changes #3323

Closed DaPigGuy closed 4 years ago

DaPigGuy commented 4 years ago

Description

Previously on 3.0.0, the old item in the changed slot could be easily obtained through the EntityInventoryChangeEvent. With 4.0.0, the event has been replaced with inventory change listeners, which lacks the ability to easily get the old item.

Justification

PiggyCE currently has 3 types of custom enchantments: reactive, ticking, & toggling. Toggling enchantments rely on three different events on 3.0.0: PlayerItemHeldEvent for held enchantments, EntityInventoryChangeEvent for inventory enchantments, & EntityArmorChangeEvent for armor enchantments. EntityInventoryChangeEvent, and EntityArmorChangeEvent which extends EntityInventoryChangeEvent, have since been removed, and with them, the ability to easily get the old item. The old items are used to toggle off the enchantments. It's possible to replicate this without having the old item accessible, albeit quite messily. The feature may also benefit other plugin developers when switching to 4.0

Alternative methods

dktapps commented 4 years ago

feel free to pull this if you want it ... shouldn't be too difficult