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
comment_72731

hi, i need to call a method "isBeingProvided" which belongs to a certain block using the co-ordinates of the block

 

so i need to know if that's even possible,  the method will be called by a few other blocks and they are able to find this specific block which acts like a signal booster for energy, the blocks need to check that every "booster" block within 10 blocks of them are being provided with energy.

 

i have added the "isBeingProvided" method into those booster blocks but don't have a clue how i would be able to call the method... can anybody help me out?

comment_72735

If the block has a TileEntity and the method is a part of that TE then sure.

Just do world.getTileEntityAt(x,y,z) to grab the TE for that block, and call the method on it :)

 

The question is when do you need to call this method, or rather from where do you need to call it?

If you guys dont get it.. then well ya.. try harder...

  • Author
comment_72821

i'm calling the method from another block when the block updates (although i need to reconsider this as the block spreads and ends up 20*20*20 blocks which is very CPU intensive :/)

 

and at the moment the method is actually in the block itself, i will look for a tile entity tutorial now..... a "getBlock(world,x,y,z)" would have been much easier for those occasions where  you only need to call a single method haha..... i wonder if i can implement that by creating an API...... hmmmm

comment_72825

Are you using vectors to define length between blocks? Also, if your wondering if you can get the location when a player hits the block then you could do a EntityPlayer.raytrace(), but seeing as how your dealing with energy it seems you may not be looking for the location only when someone uses the block.

  • Author
comment_72828

vectors to define the length between blocks? could you explain that a bit more please?

 

i'm using a method i was taught in college for searching arrays haha.... treating the map as a very big array

 

for int i /// x

for int j /// y

for int k /// z

 

 

at the moment it doesn't check for energy, it just spreads the block when it finds a provider or booster block.

there's an if statement

 

if the block at  par1 + i, par2 + j, par3 + k is a generator or booster then spread the block

 

 

comment_72829

int id = world.getBlockId(x, y, z);

BlockYourBlock b = (BlockYourBlock)Block.blocksList[id];

b.functionCall();

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.

comment_72843

world.raycast(...)

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.

comment_72870

Hi

 

I'd suggest that it's probably more efficient to make your "booster" blocks into TileEntities.  Unlike normal blocks, TileEntity is stored in a list with [x,y,z] coordinate which makes it relatively easy to find if there aren't too many - just ask WorldServer.getAllTileEntityInBox for a list of all tile entities in a certain [x,y,z] range, then step through them to find all the booster blocks.  NB this needs to be done on the server side.

 

-TGG

 

WorldServer.getAllTileEntityInBox

  /**

    * pars: min x,y,z , max x,y,z

    */

    public List getAllTileEntityInBox(int par1, int par2, int par3, int par4, int par5, int par6)

 

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.