Skip to content

Incorrect Crafting Matrix Result in Bukkit#craftItemResult #12300

Closed
@huzvanec

Description

@huzvanec

Expected behavior

Calling craftItemResult with a crafting matrix that forms a valid recipe should return an ItemCraftResult where getResultingMatrix() reflects the correct state of the crafting grid after the operation.

For example, given the following input:

H H A
H H A
A A A

(H = Honey Bottle, A = Air, G = Glass Bottle)

The expected getResultingMatrix() should be:

G G A
G G A
A A A

Where honey bottles have been replaced by glass bottles as expected.

Similarly, attempting to uncraft a gold block into 9 gold ingots with the input:

A A A
B A A
A A A

(B = Gold Block, A = Air)

Should result in:

A A A
A A A
A A A

Where the gold block has been removed as expected.

Observed/Actual behavior

Instead of returning the expected matrices, getResultingMatrix() returns:

For honey bottles:

G G G
G H A
A A A

Where a honey bottle remains in the matrix incorrectly and one glass bottle is incorrectly placed.

For gold block uncrafting:

A A A
B A A
A A A

Where the gold block is not removed.

Steps/models to reproduce

  1. Call craftItemResult with the following crafting matrix for honey bottles:
ItemStack bottle = ItemStack.of(Material.HONEY_BOTTLE);
ItemStack air = ItemStack.empty();

ItemStack[] craftingGrid = {
    bottle.clone(), bottle.clone(), air.clone(),
	bottle.clone(), bottle.clone(), air.clone(),
	air.clone(),    air.clone(),    air.clone()
};

ItemCraftResult result = Bukkit.craftItemResult(
    craftingGrid,
    player.getWorld(),
    player
);
ItemStack[] resultingMatrix = result.getResultingMatrix();
player.sendMessage(Component.text(Arrays.toString(resultingMatrix)));
  1. Notice, that resultingMatrix does not correctly replace honey bottles with glass bottles.
  2. Call craftItemResult with a crafting matrix for gold block uncrafting:
ItemStack air = ItemStack.empty();

ItemStack[] craftingGrid = {
    air.clone(),                       air.clone(), air.clone(),
	ItemStack.of(Material.GOLD_BLOCK), air.clone(), air.clone(),
	air.clone(),                       air.clone(), air.clone()
};

ItemCraftResult result = Bukkit.craftItemResult(
    craftingGrid,
    player.getWorld(),
    player
);
ItemStack[] resultingMatrix = result.getResultingMatrix();
player.sendMessage(Component.text(Arrays.toString(resultingMatrix)));
  1. Notice, that gold block still remains in the resultingMatrix after the operation.

Plugin and Datapack List

Datapacks: none
Plugins: One plugin (used to reproduce this issue), only contains the above written code inside a PlayerJoinEvent handler.

Paper version

> version
[18:59:06 INFO]: This server is running Paper version 1.21.4-211-main@6ea4202 (2025-03-13T11:49:31Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
You are running the latest version
Previous version: 1.21.4-209-f0388e2 (MC: 1.21.4)
> 

Other

  1. The issue occurs consistently across many different recipes.
  2. I discovered that placing the gold block in the first slot instead of the fourth one actually works as expected, and the block is removed correctly. This suggests that the issue may be position-dependent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope: apistatus: acceptedDisputed bug is accepted as valid or Feature accepted as desired to be added.version: 1.21.4Game version 1.21.4

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions