Slab Wand

Started by ClassifiedSecret on Sat, 03/12/2016 - 22:38
Last seen on 21:06, 10. Feb 2017
Joined Mar 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Slab Wand
Sat, 03/12/2016 - 22:38

Hello all!

I'm very new to coding and would like some help if anyone is willing to offer.

Utilizing MCreator I was able to create a tool that when you right-click on a block it deletes it. easy enough but i want to take it further. I want a tool that turns a block or an area of blocks into a slab(s) upon right clicking. It might take some custom coding that is why I'm looking for help here. I am limited with the types of events that I can add. The following is the thinking process that im going through and want this tool to do.

  1. Craft tool
  2. Equip tool
  3. Shift+Right-click to change working size from 1x1 to 3x3
  4. Right click on any building block(s) and transform it to a slab(s)

If anyone can help with the coding aspects of this it would be greatly appreciated!

~ClassifiedSecret

 

 

Last seen on 21:06, 10. Feb 2017
Joined Mar 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
This is what I have so far...
Sun, 03/13/2016 - 02:25

This is what I have so far...

[spoiler]

import net.minecraftforge.common.util.*;public class mcreator_slabWand{

public mcreator_slabWand(){}

public static Item block;
public static Object instance;public void load(){
ItemStack stack = new ItemStack(block, 1);
GameRegistry.addRecipe(stack, new Object[]{
    "X12", "X45", "6XX", Character.valueOf('1'), new ItemStack(Blocks.stone_slab, 1, 5), Character.valueOf('2'), new ItemStack(Blocks.stone_slab, 1, 5), Character.valueOf('4'), new ItemStack(Items.stick, 1), Character.valueOf('5'), new ItemStack(Blocks.stone_slab, 1, 5), Character.valueOf('6'), new ItemStack(Items.stick, 1), 
});}
public void generateNether(World world, Random random, int chunkX, int chunkZ){}
public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
public int addFuel(ItemStack fuel){return 0;}
public void serverLoad(FMLServerStartingEvent event){}
public void preInit(FMLPreInitializationEvent event){}
public void registerRenderers(){}


static{
Item.ToolMaterial enumt = EnumHelper.addToolMaterial("SLABWAND", 1, 1000, 1F, 2, 5);block = (new ItemSlabWand(){

public boolean onItemUse(ItemStack itemstack, EntityPlayer entity, World world, int i, int j, int k, int l, float a, float b, float c){
super.onItemUse(itemstack, entity, world, i, j, k, l, a, b, c);float var4 = 1.0F;


if(true){
world.setBlockToAir(i, j, k);
}

if(true){
world.spawnParticle("largesmoke", (double)i, (double)j, (double)k, 1.0D, 1.0D, 1.0D);
}

if(true){
world.setBlock(i, j, k, Blocks.wooden_slab, 0, 2);
}

if(true){
world.playRecord("fire.ignite", i, j, k);
}


return true;
}
}).setUnlocalizedName("SlabWand").setTextureName("SlabWand");
Item.itemRegistry.addObject(423, "SlabWand", block);

}

static class ItemSlabWand extends Item
{
    private Block[] blocksEffectiveAgainst = new Block[]
                    {
                    };

                int harvest = 1;

    protected float efficiencyOnProperMaterial;

    protected ItemSlabWand()
    {
        efficiencyOnProperMaterial = 1;
        setMaxDamage(1000);
        setMaxStackSize(1);
        this.setCreativeTab(CreativeTabs.tabTools);
    }

    public float func_150893_a(ItemStack par1ItemStack, Block par2Block)
    {
        for (int i = 0; i < blocksEffectiveAgainst.length; i++)
        {
            if (blocksEffectiveAgainst[i] == par2Block)
            {
                return efficiencyOnProperMaterial;
            }
        }

        return 0.0F;
    }

    public boolean hitEntity(ItemStack par1ItemStack, EntityLivingBase par2EntityLiving, EntityLivingBase par3EntityLiving)
    {
        par1ItemStack.damageItem(2, par3EntityLiving);
        return true;
    }

    public boolean onBlockDestroyed(ItemStack par1ItemStack, World par2World, Block par3, int par4, int par5, int par6, EntityLivingBase par7EntityLiving){
            par1ItemStack.damageItem(1, par7EntityLiving);
            return true;
        }

    public boolean isFull3D()
    {
        return true;
    }

    public int getItemEnchantability()
    {
        return 5;
    }

    
}
}

[/spoiler]