Posted January 27, 201510 yr If I took a block and set a onBlockActivated method and check the tool that click the block and drop the block could I do that so that block requires a special tool
January 27, 201510 yr Because I have almost no idea what you want to archieve I'll just ask: 1. "If I took a block" Vanilla or custom? 2. "onBlockActivated method" Should it be block activation, break or right-click? 3. "check the tool that click the block" Again - which click? Left, right? Only click or break? 4 "drop the block" Well, dropping need breaking, so are you activating block, breaking it or clicking? 5. "block requires a special tool" How can block "require" special tool? Then again - speacial tool to break it, or to activate it? Last, but not least - are you high? http://i.memeful.com/media/post/1d4BJDM_700wa_0.gif[/img] You are probably looking for BlockBreakEvent or PlayerInteractEvent (or something like it) for Vanilla, and for custom, probably: on BlockDestroyedByPlayer maybe. Anyway - events mentioned 1st can be cancelled to no break block, or you can modify their loot to loot other stuff depending on tool used. 1.7.10 is no longer supported by forge, you are on your own.
January 27, 201510 yr Author 1. take custom block 2. use the onBlockActivated method to check if it was shift+right clicked 3. check what item was used 4. if the item was lets say a "wrench" then replace block with air then spawn the item
January 27, 201510 yr Author Maybe something like public void onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer player) { if(!par1World.isRemote) { if(player.inventory.getCurrentItem().getItem() == Items.wrench && player.isSneaking()){ //stuff } } }
January 27, 201510 yr Idk why you are trying to simulate breaking block by using onBlockActivated, but that's not my concern. Yeah, in theory (even practice) that should work. Remember to always check if slot in not null before you try to get item from it. Also use instanceof instead of "==". (Unless you want a direct to-class comprasion). Finally - to break block you can setBlock to air (depending on which version you use 1.7 or 1.8 methods are different) or simulate BlockBreak by simply telling block to insta-break. In any case - to drop items you should use: BlockFurnace#breakBlock(), code starting with EntityItem entityitem = new EntityItem.... 1.7.10 is no longer supported by forge, you are on your own.
January 27, 201510 yr Idk why you are trying to simulate breaking block by using onBlockActivated, but that's not my concern. It comes from IC2: just "mining" the block out ruins the machine. You have to use a wrench and "disassemble it" (shift-right click, as right-click just rotates it). 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.
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.