From 8f2ec05641bcde15282efbf36156249c3fbc2369 Mon Sep 17 00:00:00 2001 From: Jonas Metzger Date: Wed, 12 Aug 2026 12:32:31 +0200 Subject: [PATCH 1/3] Allow to change pool/target and name for jigsaw block entity data. --- .../main/java/org/bukkit/block/Jigsaw.java | 52 ++++++++++++++++++- .../bukkit/craftbukkit/block/CraftJigsaw.java | 47 +++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/block/Jigsaw.java b/paper-api/src/main/java/org/bukkit/block/Jigsaw.java index 02c7fa58ec4a..f94dbbd175b4 100644 --- a/paper-api/src/main/java/org/bukkit/block/Jigsaw.java +++ b/paper-api/src/main/java/org/bukkit/block/Jigsaw.java @@ -1,6 +1,56 @@ package org.bukkit.block; +import org.bukkit.NamespacedKey; +import org.jetbrains.annotations.NotNull; + /** * Represents a captured state of a jigsaw. */ -public interface Jigsaw extends TileState { } +public interface Jigsaw extends TileState { + + /** + * Gets the Target Pool Structure key + * + * @return The NamespacedKey of the Jigsaw's Target Pool + */ + @NotNull + NamespacedKey getTargetPool(); + + /** + * Sets the Target Pool Structure key + * + * @param targetPool the key of target Pool + */ + void setTargetPool(@NotNull NamespacedKey targetPool); + + /** + * Gets the Name of the Jigsaw Block + * + * @return The NamespacedKey of the Jigsaw Block + */ + @NotNull + NamespacedKey getName(); + + /** + * Sets the Name of the Jigsaw Block + * + * @param name the name of the Jigsaw Block + */ + void setName(@NotNull NamespacedKey name); + + /** + * Gets the Target Name of the Jigsaw Block + * + * @return The NamespacedKey of the Jigsaw's Target Name + */ + @NotNull + NamespacedKey getTargetName(); + + /** + * Sets the Target Name of the Jigsaw Block + * + * @param targetName the target name of the Jigsaw Block + */ + void setTargetName(@NotNull NamespacedKey targetName); + +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java index 1c9d54fc516f..fdf5e58c40f5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java @@ -1,9 +1,17 @@ package org.bukkit.craftbukkit.block; +import com.google.common.base.Preconditions; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.entity.JigsawBlockEntity; import org.bukkit.Location; +import org.bukkit.NamespacedKey; import org.bukkit.World; import org.bukkit.block.Jigsaw; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.jetbrains.annotations.NotNull; +import java.util.Objects; + +import static net.minecraft.core.registries.Registries.TEMPLATE_POOL; public class CraftJigsaw extends CraftBlockEntityState implements Jigsaw { @@ -15,6 +23,45 @@ protected CraftJigsaw(CraftJigsaw state, Location location) { super(state, location); } + @Override + @NotNull + public NamespacedKey getTargetPool() { + final Identifier targetPoolKey = getSnapshot().getPool().identifier(); + return CraftNamespacedKey.fromMinecraft(targetPoolKey); + } + + @Override + public void setTargetPool(final @NotNull NamespacedKey targetPool) { + Preconditions.checkArgument(Objects.nonNull(targetPool), "targetPool cannot be null"); + getSnapshot().setPool(CraftNamespacedKey.toResourceKey(TEMPLATE_POOL, targetPool)); + } + + @Override + @NotNull + public NamespacedKey getName() { + final Identifier targetPoolKey = this.getSnapshot().getName(); + return CraftNamespacedKey.fromMinecraft(targetPoolKey); + } + + @Override + public void setName(final @NotNull NamespacedKey name) { + Preconditions.checkArgument(Objects.nonNull(name), "name cannot be null"); + getSnapshot().setName(CraftNamespacedKey.toMinecraft(name)); + } + + @Override + @NotNull + public NamespacedKey getTargetName() { + final Identifier targetPoolKey = this.getSnapshot().getTarget(); + return CraftNamespacedKey.fromMinecraft(targetPoolKey); + } + + @Override + public void setTargetName(final @NotNull NamespacedKey targetName) { + Preconditions.checkArgument(Objects.nonNull(targetName), "targetName cannot be null"); + getSnapshot().setTarget(CraftNamespacedKey.toMinecraft(targetName)); + } + @Override public CraftJigsaw copy() { return new CraftJigsaw(this, null); From a0021dde5d74283ca3dcaedd85f87581e58b1600 Mon Sep 17 00:00:00 2001 From: Jonas Metzger Date: Wed, 12 Aug 2026 13:19:06 +0200 Subject: [PATCH 2/3] Fix copilot reviews - prefer != null instead of Objects.nonNull - inconsistent variable naming - typos inside of javadoc --- .../main/java/org/bukkit/block/Jigsaw.java | 24 +++++++++---------- .../bukkit/craftbukkit/block/CraftJigsaw.java | 14 +++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/block/Jigsaw.java b/paper-api/src/main/java/org/bukkit/block/Jigsaw.java index f94dbbd175b4..e5b7672d8eec 100644 --- a/paper-api/src/main/java/org/bukkit/block/Jigsaw.java +++ b/paper-api/src/main/java/org/bukkit/block/Jigsaw.java @@ -9,47 +9,47 @@ public interface Jigsaw extends TileState { /** - * Gets the Target Pool Structure key + * Gets the target pool structure key. * - * @return The NamespacedKey of the Jigsaw's Target Pool + * @return the {@link NamespacedKey} of the jigsaw's target pool. */ @NotNull NamespacedKey getTargetPool(); /** - * Sets the Target Pool Structure key + * Sets the target pool structure key. * - * @param targetPool the key of target Pool + * @param targetPool the key of target pool */ void setTargetPool(@NotNull NamespacedKey targetPool); /** - * Gets the Name of the Jigsaw Block + * Gets the name of the jigsaw block. * - * @return The NamespacedKey of the Jigsaw Block + * @return The NamespacedKey of the jigsaw block */ @NotNull NamespacedKey getName(); /** - * Sets the Name of the Jigsaw Block + * Sets the name of the jigsaw block. * - * @param name the name of the Jigsaw Block + * @param name the name of the jigsaw block */ void setName(@NotNull NamespacedKey name); /** - * Gets the Target Name of the Jigsaw Block + * Gets the target name of the jigsaw block. * - * @return The NamespacedKey of the Jigsaw's Target Name + * @return The NamespacedKey of the jigsaw's target name */ @NotNull NamespacedKey getTargetName(); /** - * Sets the Target Name of the Jigsaw Block + * Sets the target name of the jigsaw block. * - * @param targetName the target name of the Jigsaw Block + * @param targetName the target name of the jigsaw block */ void setTargetName(@NotNull NamespacedKey targetName); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java index fdf5e58c40f5..a7eee545f7d2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java @@ -32,33 +32,33 @@ public NamespacedKey getTargetPool() { @Override public void setTargetPool(final @NotNull NamespacedKey targetPool) { - Preconditions.checkArgument(Objects.nonNull(targetPool), "targetPool cannot be null"); + Preconditions.checkArgument(targetPool != null, "targetPool cannot be null"); getSnapshot().setPool(CraftNamespacedKey.toResourceKey(TEMPLATE_POOL, targetPool)); } @Override @NotNull public NamespacedKey getName() { - final Identifier targetPoolKey = this.getSnapshot().getName(); - return CraftNamespacedKey.fromMinecraft(targetPoolKey); + final Identifier nameKey = this.getSnapshot().getName(); + return CraftNamespacedKey.fromMinecraft(nameKey); } @Override public void setName(final @NotNull NamespacedKey name) { - Preconditions.checkArgument(Objects.nonNull(name), "name cannot be null"); + Preconditions.checkArgument(name != null, "name cannot be null"); getSnapshot().setName(CraftNamespacedKey.toMinecraft(name)); } @Override @NotNull public NamespacedKey getTargetName() { - final Identifier targetPoolKey = this.getSnapshot().getTarget(); - return CraftNamespacedKey.fromMinecraft(targetPoolKey); + final Identifier targetNameKey = this.getSnapshot().getTarget(); + return CraftNamespacedKey.fromMinecraft(targetNameKey); } @Override public void setTargetName(final @NotNull NamespacedKey targetName) { - Preconditions.checkArgument(Objects.nonNull(targetName), "targetName cannot be null"); + Preconditions.checkArgument(targetName != null, "targetName cannot be null"); getSnapshot().setTarget(CraftNamespacedKey.toMinecraft(targetName)); } From ae0a6b51a21ca15f0cc70ec57ec59b6c777aa24b Mon Sep 17 00:00:00 2001 From: Jonas Metzger Date: Wed, 12 Aug 2026 15:16:02 +0200 Subject: [PATCH 3/3] remove unused import. --- .../src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java | 1 - 1 file changed, 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java index a7eee545f7d2..a79239045bc6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJigsaw.java @@ -9,7 +9,6 @@ import org.bukkit.block.Jigsaw; import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.jetbrains.annotations.NotNull; -import java.util.Objects; import static net.minecraft.core.registries.Registries.TEMPLATE_POOL;