RS485 / LogisticsPipes

The RS485 take on LogisticsPipes -- ESTḌ 2012
https://rs485.network
Other
239 stars 123 forks source link

CC: Tweaked 1.12.2-1.89.2 & Logistics 1.12.2-0.10.4.18 - makeRequest #1676

Open JordanTemrite opened 1 year ago

JordanTemrite commented 1 year ago

Hey there!

I've seen a few duplicate posts about the API and getItem / makeRequest. The API works just fine for me but I am unable to get it to actually process makeRequest.

Heres my code -------------->

local pipe = peripheral.wrap('LogisticsPipes:Request_0') local item_dat = pipe.getAvailableItems()

local function getItem() local r = pipe.getLP().getItemIdentifierBuilder() r.setItemID( item_dat[1].getValue1().getIdName() || tostring(..) || textutils.serialise(..)) r.setItemData( item_dat[1].getValue1().getData()) req = r.build() pipe.makeRequest( req, 1) end


When running with item_dat[1].getValue1().getIdName() || tostring(..) I get these errors -------------->

Java Exception Thrown: java.lang.UnsupportedOperationException: No such method.makeRequest(logisticspipes.utils.item.ItemIdentifier, java.lang.Double, java.lang.Boolean) makeRequest(logisticspipes.utils.item.ItemIdentifierStack) makeRequest(logisticspipes.utils.item.ItemIdentifierStack, java.lang.Boolean) makeRequest(logisticspipes.utils.item.ItemIdentifier, java.lang.Double)


If I run it with textutils.serialise(..) I get this -------------->

Java Exception Thrown: java.lang.RuntimeException: Java.lang.UnsupportedOperationException: Not a valid ItemIdentifier. I've also tried using the integer item ID's as well as raw item names etc.

Any help would be greatly appreciated!!

tranquillity-codes commented 1 year ago

I can replicate this bug as well, and have made a private fork of the mod, where I tracked down the bug & added a workaround. The issue comes from PipeItemsRequestLogistics#makeRequest expecting an ItemIdentifier, however instead receiving a Map<String, Object>. I have been unable to find a way to pass in an ItemIdentifier; using getItemIdentifierBuilder (as result of build() in Lua code) results in an empty Map. I might've missed something in the codebase, it is quite complex. So far the workaround replaces the API such that peripheral.wrap(side).makeRequest({item="minecraft:wool",damage=12},4) or peripheral.wrap(side).makeRequest({item="minecraft:grass"},32). It is only a workaround, however, as I have not been able to figure out how an ItemIdentifier could make it into the method call at all, or find definitive proof it cannot. I will publish the hack I wrote after cleaning it up a bit on my fork over at tranquillity-codes/LogisticsPipes If any more action would be necessary, do tell me. I have done this as I hit this issue in my personal modpack & decided to fix it.

KorewaLidesu commented 1 year ago

using getItemIdentifierBuilder (as result of build() in Lua code) results in an empty Map. image

logisticspipes.proxy.computers.objects.CCItemIdentifierBuilder image

could you send me sample world?

tranquillity-codes commented 1 year ago

I think that passing around the ItemIdentifier is not working. Any world with latest CC:Tweaked and LP on 1.12.2, attach to a request pipe, try to use makeRequest. I admit I am not well versed in the CC API enough to know how to pass arbitrary objects around in the Lua code, and the way used by LP does not seem to work rn, as seen in this bug. I personally don't understand the need to pass around a custom object rather than just reading from a table.