Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.8] TNT does not prime when I use my own sort of flint and steel. [SOLVED]

Featured Replies

Posted

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.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

  • Author

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

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

  • Author

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.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

  • Author

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.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

  • Author

I now have:

 

http://pastebin.com/7j65ju6W

 

But I do not now what to put in:

 

        	if (state.getBlock() == Blocks.tnt)
        {
       
        }[/Code]

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

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. :P

1.7.10 is no longer supported by forge, you are on your own.

  • Author

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

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

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.

Maker of the Craft++ mod.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.