Jump to content

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


Recommended Posts

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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.

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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