PneumaticCraft: Repressurized

PneumaticCraft: Repressurized

50M Downloads

Generic computercraft peripherals being overwritten

Quezler opened this issue ยท 3 comments

commented

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
  1. notice it listing only pressure related methods

  2. 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

commented

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?

commented

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:
cc-tweaked/CC-Tweaked@737b3cb

commented

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