endershadow Posted May 20, 2013 Posted May 20, 2013 I've tried my best to trouble shoot this, but I can't. does anyone know what I'm doing wrong with this? The problem is that when i right click it, it only updates itself, not the adjacent blocks. any help appreciated. https://github.com/code-lyoko-modding/CodeLyokoMod/blob/master/matt/lyoko/entities/tileentity/TileEntityCable.java https://github.com/code-lyoko-modding/CodeLyokoMod/blob/master/matt/lyoko/blocks/BlockCable.java
Mew Posted May 20, 2013 Posted May 20, 2013 Have you tried this mehtod? public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {} I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
endershadow Posted May 20, 2013 Author Posted May 20, 2013 No. How would i use it for this situation?
Draco18s Posted May 20, 2013 Posted May 20, 2013 When that function is called its because one of its neighbors changed (think BUD). When that happens, you can look at the neighboring blocks to try and see if the current block needs to change as well. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted May 20, 2013 Posted May 20, 2013 When that function is called its because one of its neighbors changed (think BUD). When that happens, you can look at the neighboring blocks to try and see if the current block needs to change as well. ^^ My words (not quite) exactly I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
endershadow Posted May 20, 2013 Author Posted May 20, 2013 I'm not sure this would work because I'm only given the block ID of the block that changed. it doesn't provide the functionality I need. any other Ideas?
Draco18s Posted May 20, 2013 Posted May 20, 2013 I'm not sure this would work because I'm only given the block ID of the block that changed. it doesn't provide the functionality I need. any other Ideas? if(the ID passed == this.blockID) { look at all six neighbors if one of them has metadata I don't have make my metadata the same } Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
endershadow Posted May 20, 2013 Author Posted May 20, 2013 I guess... I'll try it out and get back to you
Draco18s Posted May 20, 2013 Posted May 20, 2013 I guess... I'll try it out and get back to you The redstone wire code is good code to look at. You can also take a peek at my sourcecode here. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
endershadow Posted May 20, 2013 Author Posted May 20, 2013 I'm not sure if it worked or not, but I can't tell because onNeighborBlockChange isn't being called when it should. any idea on the problem now?
Mew Posted May 20, 2013 Posted May 20, 2013 Put a System.out.println("The onNeighbourChange method just got called!"); in the method. If you see the message (the writing in the speech marks) show up in the console, you know that it has been called. I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
endershadow Posted May 20, 2013 Author Posted May 20, 2013 ok, it calls the method, but only on block place/remove. how do I make it get called on right click.
Mew Posted May 20, 2013 Posted May 20, 2013 Ahh, that is something different. The onNeighbourChange is called ONLY when the block next to it is removed/placed. Try reading through Block.java. It will hold the secret I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
endershadow Posted May 20, 2013 Author Posted May 20, 2013 well, does anyone know how to make my block "transmit" data to adjacent blocks of the same type. I seem to have found a good method of doing it, I just need to figure out how to get it to work. any ideas?
Mew Posted May 21, 2013 Posted May 21, 2013 You could try using a packet though I am not sure if that is a good use for packets... Though I guess you could "transmit" the data to the server, then send the same packet back to the client and take that data into the block you want. This is just an idea of mine... Not sure if it will work. I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted May 21, 2013 Posted May 21, 2013 Ahh, that is something different. The onNeighbourChange is called ONLY when the block next to it is removed/placed. Try reading through Block.java. It will hold the secret That's not true. world.setBlockMetadataWithNotify(...); takes an integer flag as its last parameter. Pass a 3. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Mew Posted May 21, 2013 Posted May 21, 2013 see? I told you I am Mew. The Legendary Psychic. I behave oddly and am always playing practical jokes. I have also found that I really love making extremely long and extremely but sometimes not so descriptive variables. Sort of like what I just did there
Draco18s Posted May 21, 2013 Posted May 21, 2013 Seriously, look at the source code for my phase stone. It updates its neighbors just fine. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
endershadow Posted May 21, 2013 Author Posted May 21, 2013 I got it work. I just had to use world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
Recommended Posts