Skip to content

Add SulfurCubeSwallowEvent#14061

Open
kacimiamine wants to merge 2 commits into
PaperMC:mainfrom
kacimiamine:feat/sulfurcube-swallow-event
Open

Add SulfurCubeSwallowEvent#14061
kacimiamine wants to merge 2 commits into
PaperMC:mainfrom
kacimiamine:feat/sulfurcube-swallow-event

Conversation

@kacimiamine

Copy link
Copy Markdown

Add a new event to the sulfur cube swallowing an item after the player interaction.

@kacimiamine kacimiamine requested a review from a team as a code owner July 13, 2026 15:52
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Jul 13, 2026

@Strokkur424 Strokkur424 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally like the QoL this event provides. For anyone following along, with PlayerInteractAtEntityEvent, replacing the cube's contained item on interact can be done like so:

@EventHandler
void onInteractWithSulfurCube(PlayerInteractAtEntityEvent event) {
    if (!(event.getRightClicked() instanceof SulfurCube cube)) {
        return;
    }

    ItemStack is = event.getPlayer().getInventory().getItemInMainHand();
    if (is.getType().asItemType() == ItemType.SHEARS) {
        return;
    }

    if (!cube.getEquipment().getItem(EquipmentSlot.BODY).isEmpty()) {
        return;
    }

    event.setCancelled(true);
    cube.getEquipment().setItem(EquipmentSlot.BODY, ItemType.BIRCH_LOG.createItemStack());
    event.getPlayer().swingMainHand();
}

With this new event, that is simplified to just this:

@EventHandler
void onSulfurCubeSwallowItem(SulfurCubeSwallowItemEvent event) {
    event.setNewItem(ItemType.BIRCH_LOG.createItemStack());
}

Generally, a lot of entity interaction stuff is left just as a generic PlayerInteractAtEntityEvent. But in this case I'd argue there are enough lines saved and logical edge-cases (like that top version does not handle the small sulfur cubes not being allowed to swallow items normally) for this event to make sense.

The way it is integrated with NMS code also makes complete sense, for this reason I approve.

@kacimiamine

Copy link
Copy Markdown
Author

The punctuation and comments should be all resolved now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

2 participants