Posted November 19, 201311 yr 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?
November 19, 201311 yr 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...
November 20, 201311 yr 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
November 20, 201311 yr 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.
November 20, 201311 yr 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
November 20, 201311 yr 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.
November 20, 201311 yr comment_72833 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.
November 20, 201311 yr 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.
November 20, 201311 yr comment_72868 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.
November 20, 201311 yr 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)
November 25, 201311 yr comment_73532 Can't you also use a Block Event? It handles the Block object as well as x, y, and z coords.
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.