Posted July 15, 201411 yr How do I find all the packages holding the code for minecraft, I used to be able to read it to figure out. Thank you in advance.[sOLVED] Also, how do I get have a block do something when it is placed and/or broken? what is the method in doing so?
July 15, 201411 yr the minecraft src is in "Referenced Libraries/forgeSrc" Break/placed(from Block.class): /** * Called right before the block is destroyed by a player. Args: world, x, y, z, metaData */ public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_) {} /** * Called whenever the block is added into the world. Args: world, x, y, z */ public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) {} don't forget the thank you button. Here could be your advertisement!
July 15, 201411 yr Author I did those methods doing this. @SubscribeEvent public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_) { p_149726_1_.setBlockToAir(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_ - 1); } But nothing happened when I placed a block.
July 15, 201411 yr If those were events, you would also have to register your class with the correct event handler. But they are not events, so you merely need to @Override the methods in your Block descendant. Enjoy
July 15, 201411 yr Author I think I might know what the problem is. I set up a base block that use a subclass of the original block. and the block where I placed the method was a subclass of that, so I don't know if that really affects anything, but it isn't working. so I don't know
July 15, 201411 yr That will still work. Did you use @Override instead of @SubscribeEvent ? If you're still having issues, showing your code and any errors you get is a good start
July 15, 201411 yr Found them in the Block.class in 10 second: public void onBlockDestroyedByPlayer(World p_149664_1_, int p_149664_2_, int p_149664_3_, int p_149664_4_, int p_149664_5_){} public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_) {}
July 15, 201411 yr Author oh, I was being so stupid... I forgot in my blocks folder to make my block the instance of my new class instead of my base one. im sorry for all the trouble but thank you all!
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.