Skip to content

Mutating the list returned by getDrops() in PlayerShearBlockEvent has no effect #10955

@TothAdam0012

Description

@TothAdam0012

Expected behavior

Since clearing the drop list results in no item drops, mutating the list should also change the items dropped by the event.

Observed/Actual behavior

Changing the contents of the list has no effect (the list is probably a copy?) the same items are dropped that would drop otherwise.

Steps/models to reproduce

register the following event handler

	public void onPlayerShearBlock(PlayerShearBlockEvent e) {
		e.getDrops().clear();
		e.getDrops().add(new ItemStack(Material.DIAMOND));
	}

This should make it so for example carving a pumpkin drops a diamond but it still only drops the pumpkin seeds.
If I change the code to just:

	public void onPlayerShearBlock(PlayerShearBlockEvent e) {
		e.getDrops().clear();
	}

then no item is dropped, as expected.

Plugin and Datapack List

Empty/only test plugin

Paper version

[14:39:26 INFO]: Checking version, please wait...
[14:39:26 INFO]: This server is running Paper version 1.21-25-master@19105a9 (2024-06-21T19:03:48Z) (Implementing API version 1.21-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21-9-4ea696f (MC: 1.21)

Other

We either should be able to mutate the drop list, or there should be a setDrops method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething doesn't work as it was intended to.version: 1.21Game version 1.21

    Type

    No fields configured for Bug.

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions