Skip to content

Commit

Permalink
fix: item dupe on tool interact occasion (closes #994)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarWishsama committed Jan 13, 2025
1 parent 5fcccb8 commit f712b5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static String itemStack2String(ItemStack itemStack) {
var itemStr = Base64Coder.encodeLines(stream.toByteArray());

if (Slimefun.getDatabaseManager().getBlockDataStorageType() != StorageType.SQLITE
&& itemStr.length() > 65535) {
&& itemStr.length() > 65533) {
throw new IllegalArgumentException("检测到过大物品, 请联系物品对应插件开发者解决: " + StringUtil.itemStackToString(itemStack)
+ ", size = " + itemStr.length());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ public void onBlockPlace(BlockPlaceEvent e) {
}

if (sfItem != null && !(sfItem instanceof NotPlaceable)) {
/*
如果这个物品是工具类物品,我们需要检查它是否修改了一个方块 (铲子右键、打火石点火)
并不要为替换的方块创建一个对应工具 ID 的数据
这应该适用于大部分情况,但建议附属开发者们还是显式声明对应物品是不可放置的最好
*/
if (!e.getBlockReplacedState().getType().isAir()) {
return;
}

if (!sfItem.canUse(e.getPlayer(), true)) {
e.setCancelled(true);
} else {
Expand Down

0 comments on commit f712b5d

Please sign in to comment.