Jump to content

call a method from a specific block using the blocks co-ordinates


Recommended Posts

Posted

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?

Posted

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...

Posted

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

Posted

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.

Posted

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

 

 

Posted

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.

Posted

OFFTOPIC (kinda)

Well, what if I want to find coordinates of block player is clicking on when it's not TE?

I mean - best way?

1.7.10 is no longer supported by forge, you are on your own.

Posted

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.

Posted

You can use ray trace, or you can make the method on the client side and call the minecraft objectMouseOver coords. It can grab the x, y, z coords of a block. But ray trace is probably your best bet because it can be done server side.

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • UPDATE: this seems to be an Arch-specific issue. Switching to Ubuntu server fixed EVERYTHING.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

×
×
  • Create New...

Important Information

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