Skip to content

Extend Jigsaw TileState - #14182

Open
pappel-ig wants to merge 3 commits into
PaperMC:mainfrom
pappel-ig:extend-jigsaw-tilestate
Open

Extend Jigsaw TileState#14182
pappel-ig wants to merge 3 commits into
PaperMC:mainfrom
pappel-ig:extend-jigsaw-tilestate

Conversation

@pappel-ig

Copy link
Copy Markdown

Currently there is no way to fetch information from the tilestate from jigsaw blocks. This PR extends the functionality of the Jigsaw tile state to allow fetching and changing of the target pool, target name and name. This allows Developers to use the jigsaw block to place own structures in a more profound way.

Arguably one could make the methods (setTargetPool(final @NotNull NamespacedKey targetPool), setName(final @NotNull NamespacedKey name) and void setTargetName(final @NotNull NamespacedKey targetName)) @nullable, and change the default Identifier in case of null to minecraft:empty (default value when placing a jigsaw). However this might be counterintuitive as developers default namespace is not minecraft, so I dont see any reason to change this. Also I haven't implemented the remaining options from the tilestate (joint, finalState, ...), this can be done using a different PR.

I've verified the changes using a small sample plugin. The Plugin intercepts the BlockPlacesEvent of an Jigsaw Block and prints the target pool, target name and name. Then it changes the target pool, target name and name using the setters and updates the tilestates. Afterwards it prints out the target pool, target name and name again. The output is plausible.

@pappel-ig
pappel-ig requested a review from a team as a code owner August 12, 2026 11:03
Copilot AI lite review requested due to automatic review settings August 12, 2026 11:03
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Aug 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Extends the Bukkit Jigsaw TileState API to expose and mutate key jigsaw configuration (target pool, name, target name) so plugins can inspect/adjust jigsaw block behavior more directly.

Changes:

  • Adds new NamespacedKey-based getters/setters to org.bukkit.block.Jigsaw.
  • Implements the new API in CraftJigsaw by bridging between Bukkit NamespacedKey and NMS identifiers/resource keys.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java Implements the new Jigsaw API by reading/writing NMS jigsaw fields and converting to/from NamespacedKey.
paper-api/src/main/java/org/bukkit/block/Jigsaw.java Expands the public API surface for jigsaw tile states with getters/setters for pool/name/target.
Suppressed comments (3)

paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java:49

  • Avoid using Objects.nonNull(...) here; prefer a direct null check (or Preconditions.checkNotNull) for readability and to match existing CraftBukkit validation patterns.
    public void setName(final @NotNull NamespacedKey name) {
        Preconditions.checkArgument(Objects.nonNull(name), "name cannot be null");
        getSnapshot().setName(CraftNamespacedKey.toMinecraft(name));

paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java:62

  • Avoid using Objects.nonNull(...) here; prefer a direct null check (or Preconditions.checkNotNull) for readability and to match existing CraftBukkit validation patterns.
    public void setTargetName(final @NotNull NamespacedKey targetName) {
        Preconditions.checkArgument(Objects.nonNull(targetName), "targetName cannot be null");
        getSnapshot().setTarget(CraftNamespacedKey.toMinecraft(targetName));

paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java:57

  • Local variable name targetPoolKey is misleading here (this method reads the jigsaw's target name). Renaming improves clarity and reduces copy/paste confusion.
    public NamespacedKey getTargetName() {
        final Identifier targetPoolKey = this.getSnapshot().getTarget();
        return CraftNamespacedKey.fromMinecraft(targetPoolKey);
    }

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread paper-api/src/main/java/org/bukkit/block/Jigsaw.java Outdated
Comment thread paper-api/src/main/java/org/bukkit/block/Jigsaw.java Outdated
- prefer != null instead of Objects.nonNull
- inconsistent variable naming
- typos inside of javadoc

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java:13

  • Unused import java.util.Objects is present but not referenced in this class. This is likely to fail formatting/checkstyle steps and should be removed.
import org.jetbrains.annotations.NotNull;
import java.util.Objects;

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (2)

paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java:17

  • Avoid static-importing NMS registry keys here; the surrounding codebase consistently references them via Registries.* (e.g. CraftHumanEntity uses Registries.RECIPE). Using a normal import keeps this file aligned with existing style and makes the registry origin clearer.
import static net.minecraft.core.registries.Registries.TEMPLATE_POOL;

public class CraftJigsaw extends CraftBlockEntityState<JigsawBlockEntity> implements Jigsaw {

    public CraftJigsaw(World world, JigsawBlockEntity blockEntity) {

paper-api/src/main/java/org/bukkit/block/Jigsaw.java:15

  • The javadocs refer to a "structure key", but this is actually the jigsaw's target pool (template pool) key. Tightening the wording helps avoid confusion about what registry this refers to.
    /**
     * Gets the target pool structure key.
     *
     * @return the {@link NamespacedKey} of the jigsaw's target pool.
     */

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