15 posts
Posted 13 July 2014 - 05:53 PM
Hello! :D/>
I was wondering how I can add peripherals to blocks like Chests, Furnaces etc.
I looked at mods like OpenPeripheral but could not find anything
Thanks! :)/>
7508 posts
Location
Australia
Posted 14 July 2014 - 01:43 AM
Well in OpenPeripherals case they tell ComputerCraft through the PeripheralProvider that all TileEntities (TE) are a peripheral, and then when ComputerCraft passes them a peripheral they check if they want it or not. However I do suggest against this method; just register the blocks you're interested in.
Once they have the TE they're interested in, it and another class, which they call an Adapter, gets wrapped together into another class, this Adapter is where all the methods are defined, and it had access to the TE to get information from it, a lot of the time this information is having to be taken from the TE through use of reflection, or the API of the mod which adds the block.
I do suggest having a read through of an
older OpenPeripheral, back when times were simpler, and the cohesion, coherence, and functional complexity of OpenPeripheral was
far lower!
15 posts
Posted 14 July 2014 - 07:46 AM
I ended up just checking in the provider if it was that block and return the peripheral and that works fine! :)/>
Edited on 14 July 2014 - 05:46 AM
1522 posts
Location
The Netherlands
Posted 14 July 2014 - 11:47 AM
I ended up just checking in the provider if it was that block and return the peripheral and that works fine! :)/>/>
That was what you were supposed to do :P/>