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

Hi,

 

Can someone help me fix a problem I am having with my tile entity, I can't seem to find the neighbouring tile entitys from my block, so that I can render some pipes. Here is my code https://github.com/Shamboozle/FluidTransport if some one could look at it and point me i the right direction it would be greatly appreciated.

 

~Sham

(I'm sufficient in Java and Minecraft modding BTW)

Example code to locate all direct neighbors of a tile-entity.  Lots of ways to do this, including just manually checking each x/y/z +/- set.  But I like loops, so this is a simple loop :)

 

After calling the method, cachedNeighbors will contain references to any nearby tile entities, or null if none.  Each index corresponds to a forge-direction (north, south, east, west, up, down..though not necessarily in that order).

 

TileEntity[] cachedNeighbors = new TileEntity[6];

public void updateNeighbors()
  {
  ForgeDirection d;
  int x, y, z;
  TileEntity te;
  for(int i = 0; i <6 ;i++)
    {
    d = ForgeDirection.values()[i];
    x = xCoord + d.offsetX;
    y = yCoord + d.offsetY;
    z = zCoord + d.offsetZ;
    te = worldObj.getTileEntity(x, y, z);
    cachedNeighbors[d.ordinal()]=te;
    }
  }

 

You can use the above without the caching as well...just put your operational code in instead of putting the te in the array.

 

To check a specific side, after the cache has been updated, you could query such as

 

if(cachedNeighbors[ForgeDirection.NORTH.ordinal]!=null)

{

//do something with the north-neighbor

}

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.