Bregor Posted June 23, 2015 Posted June 23, 2015 Hi, I am looking for best practices for discovery of specific blocks in the neighborhood of another specific block. To be more specific the scenario I have in mind is a kind of wireless master-slave block relationship. For example if the master block is placed it searches for all slave blocks in a given radius (e.g. 32 blocks radius). Scanning the blocks in range seems to be a bad idea performance wise, as 32 blocks radius would require scanning 262k blocks in worst case. Is it a good idea to keep a global storage of all master blocks and slave blocks without a master block? Or is there a better way to achieve such a thing? Neither the master nor the slave blocks will be generated naturally, but there may be a lot of slave blocks. Thanks Quote
Pancake Posted June 23, 2015 Posted June 23, 2015 You could try making an item that, when rightclicked on the master, binds to it (stores it's location or something) When you then click on a slave block, it links the 2 together. It's manual work, but I'm pretty sure that should work. Oh wait. I made it. Ofcourse it works. It also solves some problems that could arise by your method. What if a slaveblock is surrounded by 10 masters? pick a random one? Good luck! Quote
delpi Posted June 23, 2015 Posted June 23, 2015 I was going to ask you the same question as pancake about how to pick which master. One other way to do it is to create a GUI on the slave where you have to pick the master that was found. Another way to do this is to create a tick item for each block. Assuming you will have Tile Entities based upon what you have said. Could on each tick update a master list that they exist. Purge from list if not receiving a tick so often. Your slaves could look at that list and calculate the master block that is closest and use it. That would save you from random searches. Could speed that up as well as to say if the master is still in the list, don't bother to iterate for closest again. Just some options to think about. Quote Long time Bukkit & Forge Programmer Happy to try and help
Bregor Posted June 23, 2015 Author Posted June 23, 2015 Well I thought about something like the attuning to the master block too, but as there will be many slave nodes for each master I didn't want to force the user to update all nodes after the master node is placed somewhere else or is destroyed by something. And about the tile entity idea, may be worth investigating. Non ticking tile entities are not available before 1.8? Quote
delpi Posted June 23, 2015 Posted June 23, 2015 That is my understanding. I'm still operating on 1.7.2. Going to make the plunge to 1.8 soon. Quote Long time Bukkit & Forge Programmer Happy to try and help
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.