TeamPneumatic / pnc-repressurized

A port of PneumaticCraft to MC1.12+
Other
119 stars 47 forks source link

Generic computercraft peripherals being overwritten #1034

Open Quezler opened 2 years ago

Quezler commented 2 years ago

Describe the bug

computercraft only binds generic peripherals (e.g. item inventories & fluid tanks) when there is no peripheral defined, unfortunately registering the custom ones via event.addCapability(RL(ModIds.COMPUTERCRAFT) gets rid of the generics.

i have tried digging deep into the code of both pnc & cc-tweaked to try and find a way to easily do both, one attempt for instance was on the BaseItemStackHandler in order to make it proxy inventory methods, e.g. size:

        registry.registerLuaMethod(new LuaMethod("size") {
            @Override
            public Integer call(Object[] args){
                return InventoryMethods.size(BaseItemStackHandler.this);
            }
        });

but then it would need that bit of code for each method, and the return types seriously get ugly and confusing: Screen Shot 2022-06-21 at 11 41 45

attempt 2 involved trying to get all the generic methods in order to be able to pass those into registerLuaMethod as key value pairs, but its well hidden away and not even remotely fruitful: Screen Shot 2022-06-21 at 11 39 53

i had also hoped that maybe there was an easy way to convert the pnc integration into a generic peripheral (triggered by the existence of the air capability), but the integration is very specific so i lack the skills to even begin to attempt this.

How to reproduce the bug

1) run this snippet on a computer with unmodified builds: (with a charging station placed behind it)

local charging_station = peripheral.wrap('back')

for k, v in pairs(charging_station) do
  print(k)
end

2) notice it listing only pressure related methods

3) now comment out the capability register quoted above, compile & do this again, notice it now lists inventory methods.

Expected behavior

For both pressure & inventory/tanks to show up, instead of only custom pnc lua methods.

Currently it is not possible to interact with pnc blocks properly using computercraft alone, it would be awesome if i could just io items in the charging station & wrap refineries and fluid tanks, the only workaround atm is using one piece of integrated dynamics cable with an interface for the thing i need on either end, but ideally pnc would support those methods by itself.

Additional details

2022-06-21_11 47 52

Which Minecraft version are you using?

1.18

Crash log

No response

desht commented 2 years ago

This honestly sounds like more of a ComputerCraft problem than a PNC problem. I just register an IPeripheral capability object with all my block entities which support Lua methods, that's all. Standard Forge capability registration, happening here: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.18.2/src/main/java/me/desht/pneumaticcraft/common/thirdparty/computercraft/ComputerCraft.java#L51-L56, and capability provider here: https://github.com/TeamPneumatic/pnc-repressurized/blob/1.18.2/src/main/java/me/desht/pneumaticcraft/common/thirdparty/computercraft/PneumaticPeripheralProvider.java

Have you spoken to the CC:Tweaked author?

Quezler commented 2 years ago

i made two attempts on the computercraft discord: https://discord.com/channels/477910221872824320/477911902152949771/988706228949643294 https://discord.com/channels/477910221872824320/477911902152949771/988895159972429854

i also recently found this, hinting at that it might be fairly impossible to reuse the generic peripherals: https://github.com/cc-tweaked/CC-Tweaked/commit/737b3cb57696fb5517252e7db38bc88ce960b4d8

Quezler commented 2 years ago

giving this thread a bump in order to notify desht about the mention ^