Jump to content

[SOLVED] Explosive Sword not working


ThaxxelGaming

Recommended Posts

Hey guys,

 

  I am stepping up into a more intermediate level of modding after a long break.

Made a sword, wanting to have myself click on a block (dirt, cobblestone, etc) and make the surrounding area explode on touch or disappear. One of the two.

(Without totally killing me in the process) Started off with the code below:

 

Code:

 

public class ItemTNTSword extends ItemSword{

 

public ItemTNTSword(int par1, EnumToolMaterial i) {

super(par1, i);

this.maxStackSize = 1;

this.setCreativeTab(CreativeTabs.tabCombat);

}

 

public void updateIcons(IconRegister iconRegister){

iconIndex = iconRegister.registerIcon("Explosive:TnTSword");

}

 

public boolean onBlockActivated(ItemStack itemstack, EntityPlayer entityplayer, World world, int blockx, int blocky, int blockz, int par7, float x, float y, float z) { if (par7 == 0) blocky--;

if (par7 == 1) blocky++;

    if (par7 == 2) blockz--;

    if (par7 == 3) blockz++;

    if (par7 == 4) blockx--;

    if (par7 == 5) blockx++;

    world.createExplosion(entityplayer, blockx, blocky, blockz, 10.0f, true);

    return true;

}

 

However, this doesn't seem to work. I realize I have something wrong here, just not sure what. I am also pretty sure "onBlockActivated" is the wrong use for what I am going for. Would appreciate the help and input!!  :D

 

Thanks!

Link to comment
Share on other sites

I believe onBlockActivated only triggers when you right click it. But you never specified what button you are clicking with.

 

Also, I advise using a switch system instead of your bunch of if(...) code. Not that efficiency here would matter too much, but any little bit always helps.

 

edit:

Or at least use an if else system.

Link to comment
Share on other sites

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.