Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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. 

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.

  • 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

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.

  • 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? 

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.

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 by theDataSmith

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.