Jump to content

  • Curse Sites
Become a Premium Member! Help
Latest News Article

Block change on right-click


  • Please log in to reply
4 replies to this topic

#1

tandeelaptop
  • Location: Coventry, UK
  • Minecraft: Tandeelaptop

Posted 30 March 2012 - 05:54 PM

I'm using the most simplest code for my block to change.
I have it set that when it is right-clicked, it changes into stone.

package net.minecraft.src;
import java.util.Random;
public class BlockSpiritstone extends Block
{
    public BlockSpiritstone(int i, int j)
    {
   super(i, j, Material.iron);
    }
  
   public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer)
   {
   world.setBlockWithNotify(i, j, k, Block.stone.blockID);
   return true;
   }
}

What do i have to add to this if i want it to turn to stone by using a sword on it? (eg. right click with a stone sword turns a bluestone into stone and removes the sword from inventory)

Help please? Credit will be given in the mod for good advice!!

Posted Image


Register or log in to remove.

#2

lemonszz
    lemonszz

    Void Walker

  • Members
  • 1844 posts
  • Location: New Zealand :D
  • Minecraft: Lemonszz
  • Xbox:Lemonsszz

Posted 30 March 2012 - 06:12 PM

You should check if the player is holding the correct item.

Posted Image

Come check out my mod! You might just like it!


#3

tandeelaptop
  • Location: Coventry, UK
  • Minecraft: Tandeelaptop

Posted 30 March 2012 - 06:27 PM

View Postlemonszz, on 30 March 2012 - 06:12 PM, said:

You should check if the player is holding the correct item.

and how do i do that?

Posted Image


#4

tandeelaptop
  • Location: Coventry, UK
  • Minecraft: Tandeelaptop

Posted 30 March 2012 - 07:04 PM

Never mind, ive done it

Posted Image


#5

Eliander9802
  • Location: Germany
  • Minecraft: Eliander9802

Posted 21 January 2013 - 02:49 PM

can somebody give me the right code that not work with 1.4.7 i think.