Kander16 Posted March 14, 2015 Posted March 14, 2015 Hi, I have a custom sort of flint and steel, (magnesium and steel) which has the same purpose. Whenever I right click on the TNT, it does not directly get primed. I see that in the method of the BlockTNT.class OnBlockActivated, items.flint_and_steel in is. Now, my question is: How do I get TNT primed whenever I right click it with my magnesium and steel. Quote Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
Elix_x Posted March 14, 2015 Posted March 14, 2015 If you can't do this in rightclick method for block, use one for item. And vise versa. (I mean that if you can't change method in block, you can do this in method of same functionality in item. In this case it's onItemUse()) Quote Check out my mods: BTAM Armor sets Avoid Exploding Creepers Tools compressor Anti Id Conflict Key bindings overhaul Colourfull blocks Invisi Zones
Kander16 Posted March 14, 2015 Author Posted March 14, 2015 I tried this, but it does not work. public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { pos = pos.offset(side); if (!playerIn.canPlayerEdit(pos, side, stack)) { return false; } else { if (worldIn.isAirBlock(pos)) { worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); worldIn.setBlockState(pos, Blocks.fire.getDefaultState()); } if (worldIn.getBlockState(pos) instanceof BlockTNT) { tnt.explode(worldIn, pos, state, playerIn); worldIn.setBlockToAir(pos); } stack.damageItem(1, playerIn); return true; } } }[/Code] full code: http://pastebin.com/9Yw6PJCu Quote Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
Kander16 Posted March 14, 2015 Author Posted March 14, 2015 I don't really know how to do this then. I want to have the code checks that if you right click on tnt, it will explode. Quote Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
Kander16 Posted March 14, 2015 Author Posted March 14, 2015 I just am not very good at modding itself, I am confused with forge 1.8 & I am still learing. Do you want to give me an example of how it should work with the tnt? Then I'll pointer out how it works. Thanks. Quote Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
Kander16 Posted March 14, 2015 Author Posted March 14, 2015 I now have: http://pastebin.com/7j65ju6W But I do not now what to put in: if (state.getBlock() == Blocks.tnt) { }[/Code] Quote Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
Ernio Posted March 14, 2015 Posted March 14, 2015 I just hate giving working code. Learn java. pos = pos.offset(side); This moves clicked position to block next to block you clicked, facing the face you clicked. So basically when you click on wall you will not check if wall is air and set it to fire, but do it (check and ignite) block before it. Logically you can't do tnt-ignite on block NEXT to tnt, it's not logical. You need to do it 1st (on block you clicked). Now look at BlockTNT class. if (block instanceof BlockTNT) { ((BlockTNT) block).explode(worldIn, pos, state, igniter); } And now go learn java. Quote 1.7.10 is no longer supported by forge, you are on your own.
Kander16 Posted March 15, 2015 Author Posted March 15, 2015 O no, I think a was a little bit tired yesterday :-P. The moment I waked up, looked 10 seconds at the code... and I was feeling stupid because I could not solve a simple thing! Thanks for helping. New code: http://pastebin.com/iRu2248k Quote Creator of the Master Chef Mod and many more to come. If I helped you, please click the 'thank you' button.
Anon10W1z Posted March 15, 2015 Posted March 15, 2015 O no, I think a was a little bit tired yesterday :-P. The moment I waked up, looked 10 seconds at the code... and I was feeling stupid because I could not solve a simple thing! Thanks for helping. New code: http://pastebin.com/iRu2248k You need to use posSide when getting the block state from the world. Quote Maker of the Craft++ mod.
Recommended Posts
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.