Posted October 23, 201213 yr Hi im trying to change this method to true/false every time the player clicks on the block. This is what I've got so far, just can't seem to get the block to change the boolean method to false, wondering if anyone had an idea how I could do this. public boolean setOpen() { return true; } public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { if(this.setOpen() == true) { this.setBlockBoundsBasedOnState(par1World, par2, par3, par4); return super.getCollisionBoundingBoxFromPool(par1World, par2, par3, par4); } else return null; } public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } if(this.setOpen() == true) { return this.setOpen() == false; } else return this.setOpen() == true; }
October 23, 201213 yr Hello Sir. I made an account (was gonna anyway) to help you. Your code is as far as I care to understand, Well... However, in onBlockActivated, in the if else statement, return true if setOpen is false else return true if setOpen is ture. Thus you make a loop of true. Solution, if you don't know already: //Instead of return this.setOpen() == false; //return return this.setOpen(); Actually you made a big derp. SetOpen() is ALWAYS true... Have you even learned Java? Im a partial newb and you fail. There should be a variable in the class which would be called private boolean open; I think. set open would SET open and another method would GET open called getOpen Example: public void onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } if(this.getOpen() == true) { this.setOpen(false); } else{ this.setOpen(true); } private boolean open; hope you get the idea. If you are trying this without java experience, go NOW AND LEARN IT. You definitly don't get objects or you don't know how to apply. Hope this post is good enough and you aren't offended, I can be a little mean sometimes, Green0Yoshi Edit: I don't think there is a point of isRemote, it might mess it up. I didn't have time to mess around yet cause of Homework. You will need to mess around and do some reseach, any other question might apply. Thanks for your time... Hopefully I can reply soon after you reply, but I'm busy, anyways. I can't wait to start working on my mod. I haven't worked on it in a while but it is on Github. It needs much more organization and work, I have lots of plans.
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.