From 647fd5b4192fa7dc71b0babe77e7bbed85c2eb35 Mon Sep 17 00:00:00 2001 From: Srendi Date: Sun, 6 Oct 2024 15:26:57 +0200 Subject: [PATCH] [#660] Fixed blank nbt when using some inventory manager functions --- .../computercraft/peripheral/InventoryManagerPeripheral.java | 4 ++-- .../addons/computercraft/peripheral/MeBridgePeripheral.java | 4 ++-- .../addons/computercraft/peripheral/RsBridgePeripheral.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java index 66abb49fb..1a8002bd0 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/InventoryManagerPeripheral.java @@ -189,12 +189,12 @@ public final int getFreeSlot() throws LuaException { @LuaFunction(mainThread = true) public final Map getItemInHand() throws LuaException { - return LuaConverter.stackToObject(getOwnerPlayer().getMainHandItem()); + return LuaConverter.stackToObject(getOwnerPlayer().getMainHandItem().copy()); } @LuaFunction(mainThread = true) public final Map getItemInOffHand() throws LuaException { - return LuaConverter.stackToObject(getOwnerPlayer().getOffhandItem()); + return LuaConverter.stackToObject(getOwnerPlayer().getOffhandItem().copy()); } private Player getOwnerPlayer() throws LuaException { diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java index 2696ed9ed..216e27702 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/MeBridgePeripheral.java @@ -420,8 +420,8 @@ public final MethodResult getItem(IArguments arguments) throws LuaException { if (parsedFilter.isEmpty()) return MethodResult.of(null, "EMPTY_FILTER"); - Pair item = AppEngApi.findAEStackFromFilter(monitor, getCraftingService(), parsedFilter) - if (item.getRight().isEmpty()) + Pair item = AppEngApi.findAEStackFromFilter(monitor, getCraftingService(), parsedFilter); + if (item.getRight() == null && item.getLeft() == 0) return MethodResult.of(null, "NOT_FOUND"); return MethodResult.of(AppEngApi.getObjectFromStack(item, getCraftingService())); } diff --git a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java index ee71949cb..87fd927b7 100644 --- a/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java +++ b/src/main/java/de/srendi/advancedperipherals/common/addons/computercraft/peripheral/RsBridgePeripheral.java @@ -299,7 +299,7 @@ public final MethodResult getItem(IArguments arguments) throws LuaException { if (filter.rightPresent()) return MethodResult.of(null, filter.getRight()); - ItemStack item = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()) + ItemStack item = RefinedStorage.findStackFromFilter(getNetwork(), getNetwork().getCraftingManager(), filter.getLeft()); if (item.isEmpty()) return MethodResult.of(null, "NOT_FOUND"); return MethodResult.of(RefinedStorage.getObjectFromStack(item, getNetwork()));