Posted July 14, 201411 yr Hi, I was wondering how to make blocks be able to be used in beacon bases. I don't know the specs or anything but it might be an @override so just tell me what the code is or whatever. Thanks!
July 14, 201411 yr @Override public boolean isBeaconBase(IBlockAccess world, int x, int y, int z, int beaconX, int beaconX, int beaconY, int beaconZ) { return true; } Next time, search for beacon in vanilla sources.
July 14, 201411 yr @Override public boolean isBeaconBase(IBlockAccess world, int x, int y, int z, int beaconX, int beaconX, int beaconY, int beaconZ) { return true; } Next time, search for beacon in vanilla sources. What he said but if you use a single block file for all non-special blocks like me I would recommend adding a new method in it: First you need to add a variable at the top: private Block beaconBase; after that we simple add a method called setBeaconBase which is going to return a block: public Block setBeaconBase(){ return beaconBase = this; } Now we do pretty much what he said with a twist: @Override public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { return this == beaconBase; } Now we simply add ".setBeaconBase()" to make a block a beacon base block: blockBronze = new SmBlock(Material.iron, "blockBronze", Block.soundTypeMetal, 5.0F, 8.0F).setBeaconBase(); I'm sorry I can't help but make random tutorials in the forums sometimes If I helped please press the Thank You button.
July 14, 201411 yr *She. Additionally, why use a Block and not a boolean as the private flag for whether the block is a beacon base or not? private boolean isBeaconBase; public void setBeaconBase() { isBeaconBase = true; } @Override public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { return isBeaconBase; }
July 14, 201411 yr *She. Additionally, why use a Block and not a boolean as the private flag for whether the block is a beacon base or not? private boolean isBeaconBase; public void setBeaconBase() { isBeaconBase = true; } @Override public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { return isBeaconBase; } If you look at all methods which sets stuff in block all of them returns a block i.e. texture name, block name, hardness, resistance, step sound all methods must return a block to be usable. Ofcourse you can use the boolean as a flag but the method must return a block anyway. If I helped please press the Thank You button.
July 14, 201411 yr You are indeed correct, my mistake. public Block setBeaconBase() { isBeaconBase = true; return this; } The reason they return a Block is not to make them usable, but chainable.
July 14, 201411 yr You are indeed correct, my mistake. public Block setBeaconBase() { isBeaconBase = true; return this; } The reason they return a Block is not to make them usable, but chainable. I know I just made a bad choice of words I just meant usable as in usable when defining your blocks also using a block instead of a boolean is just like 1 line less of code so thats why I used a block. If I helped please press the Thank You button.
July 14, 201411 yr 1 line of code less, maybe - but it is confusing, not indicative of the purpose of the field, as well as taking up 32 or even 64 times more memory.
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.