pmmp / PocketMine-MP

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

Pick-block can be used to obtain items that are not normally obtainable (e.g. portal blocks) #2706

Open Johnmacrocraft opened 5 years ago

Johnmacrocraft commented 5 years ago

Issue description

In vanilla, when you pick-block an item frame with any item in it, you get a copy of the item. PocketMine, on the other hand, gives an item frame, not an item in it. PocketMine also allows obtaining items that are not supposed to be obtainable in normal means (e.g. Portal). It also doesn't check whether players already have the item in their inventory.

Steps to reproduce the issue

Issue 1:

  1. Place an item frame
  2. Put an item on it
  3. Pick-block it

Issue 2:

  1. Place a block that is not supposed to be obtainable
  2. Once again, pick-block it

Issue 3:

  1. Have a block in your inventory that you're trying to pick-block
  2. Pick-block the same block
  3. Notice that you have two same items in your hotbar (in vanilla the selected slot is changed to a slot with the same item)

OS and versions

Plugins

Crashdump, backtrace or other files

dktapps commented 5 years ago

Small note: block-picking an empty item frame should indeed give you an item frame.

dktapps commented 5 years ago

Additional side note: The condition is not whether or not it's available to creative. For example, it's possible to block-pick command blocks.

Johnmacrocraft commented 5 years ago

I'm actually not sure what's the condition... After that, I thought it is the items that I can obtain from /give, but blocks like Nether Reactor cannot be obtained from it but still pick-blockable. In other news, I found another inconsistency and added it.

dktapps commented 3 years ago

Inconsistencies with vanilla behaviour have been resolved by 60225a378f76196b5e598db3f7b880efd49a4ea0. The issue of being able to get normally unobtainable blocks in creative (e.g. portals) still remains, but I don't think anyone will really mind that much.

ShockedPlot7560 commented 1 year ago

(for issue posterity) This problem can now be fixed by overloading getPickedItem. However, this is a rather hacky way of doing it.
It might be interesting to add a function in the blocks to specify this logic, in the sense that the contents of the creative inventory cannot be used (command blocks are recoverable).

dktapps commented 1 year ago

My line of thought on this issue was to make getPickedItem() able to return NULL, but that requires a BC break.