Posted June 11, 20178 yr Ok. I am making a mod about lasers. I need a block to know when it gets hit by a laser. Obviously, I can't just check if a line is rendering through a block, so I was thinking that I could use tile entities and send data between them. Is this the right way of going about this? And how could I do it? The system would be something like this: Block A ———gl line——— Block B Block A sends data to Block B Block B realizes it has a lazer on it Yay we're done here.
June 11, 20178 yr Why do you need a TE? I could do this with blocks, nothing but blocks, and a custom Interface. 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.
June 12, 20178 yr Author Ok, can you give me an idea of how I could do that? I was thinking that I needed a te because the lasers were going to act as a power transfer system
June 12, 20178 yr If you're transferring power then yes, you'd need a TE to store the power in. 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.
June 12, 20178 yr Author Ok, thanks! Any idea on what to use to actually send data between the tile entities? Storing the power and creating the power is fine. I'm just confused on transporting the power. Any clarification?
June 12, 20178 yr You need to do a raytrace along the line of your laser and find the block that it hits.
June 12, 20178 yr Author I already know how to get the block that I am aiming for. I just don't know how to tell the tile entity that it is being hit
June 12, 20178 yr world.getTileEntity(pos)? 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.
June 13, 20178 yr Author Any ideas on how to send a peice of data to the tile entity from another tile entity? It would probably be a couple variables.
June 13, 20178 yr Give your TileEntity a method. public class MyTileEntity extends TileEntity { public void sendData(int data) { // Do something with data. } } Assuming you have the world and position of your TileEntity, you can cast it to your custom class and call the method. TileEntity te = world.getTileEntity(pos); if(te instanceof MyTileEntity) { MyTileEntity myTE = (MyTileEntity) te; myTE.sendData(12); } If you're going to have multiple TileEntity classes that need to receive data in a similar way, I recommend making an interface. Edited June 13, 20178 yr by theDataSmith
June 13, 20178 yr Author Thanks. I will have multiple tile entities, how could I use an interface to accomplish this?
June 13, 20178 yr Multiple instances or multiple types? Am interface is just an object which says "this method exists" and then every class that inherits that interface MUST provide an implementation. 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.
June 13, 20178 yr This is a basic java question. There are plenty of resources online that can help you. I recommend starting by learning inheritance if you haven't already, then specifically interfaces.
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.