Jump to content




Adding Peripherals to existing Blocks


  • You cannot reply to this topic
3 replies to this topic

#1 tattyseal

  • Members
  • 15 posts

Posted 13 July 2014 - 04: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! :)

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 14 July 2014 - 12: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!

#3 tattyseal

  • Members
  • 15 posts

Posted 14 July 2014 - 06:46 AM

I ended up just checking in the provider if it was that block and return the peripheral and that works fine! :)

Edited by tattyseal, 14 July 2014 - 06:46 AM.


#4 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 14 July 2014 - 10:47 AM

View Posttattyseal, on 14 July 2014 - 06:46 AM, said:

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





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users