Jump to content

[1.7.2]Spawning in items with block


starwarsmace

Recommended Posts

Hello guys. So I have a block that spawns in an item everytime you touch it with a fuel item such as coal. Also, since coal has 8 operations in a furnace I have number which I set and I set it to 8. That will spawn 8 of those items. This worked in 1.6.4. But now when Im updating its not working. Heres my code.

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t){
        System.out.println("Activiated");
        System.out.println(player.getHeldItem());
	if(player.getHeldItem() == null){num = 0;}   
        else if(player.getHeldItem() == new ItemStack(Items.coal)){num = 8;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.log)){num = 2;player.getHeldItem().stackSize--;} 
        else if(player.getHeldItem() == new ItemStack(Blocks.log2)){num = 2;player.getHeldItem().stackSize--;} 
        else if(player.getHeldItem() == new ItemStack(Blocks.planks)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.wooden_slab)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.sapling)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.wooden_axe)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.wooden_pickaxe)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.wooden_hoe)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.wooden_shovel)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.wooden_sword)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.wooden_pressure_plate)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.stick)){num = 1;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.fence)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.fence_gate)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.oak_stairs)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.spruce_stairs)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.birch_stairs)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.jungle_stairs)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.jungle_stairs)){ num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.acacia_stairs)){num = 2; player.getHeldItem().stackSize--;}  
        else if(player.getHeldItem() == new ItemStack(Blocks.dark_oak_stairs)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.trapdoor)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.crafting_table)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.bookshelf)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.chest)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.trapped_chest)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.daylight_detector)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.jukebox)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.noteblock)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.brown_mushroom_block)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.red_mushroom_block)){num = 2;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Items.blaze_rod)){num = 8;player.getHeldItem().stackSize--;}
        else if(player.getHeldItem() == new ItemStack(Blocks.coal_block)){num = 80;player.getHeldItem().stackSize--;System.out.println(num);}
        else if(player.getHeldItem() == new ItemStack(Items.lava_bucket)){num = 100;player.getHeldItem().stackSize--;}
        if(world.isRemote && num!=0)
        {
            System.out.println(num);

            EntityItem ei = new EntityItem(world, x, y + 1, z, new ItemStack(RottenFleshMod.cookedZombieFlesh, num));
            world.spawnEntityInWorld(ei);
            System.out.println("DID IT");
            
            num = 0;
            
        }
        return true;

 

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

Is it,

else if(player.getHeldItem().getUnlocalizedName().substring(5).equals(Items.coal.getUnlocalizedName().substring(5))){num = 8;player.getHeldItem().stackSize--;}

It seems to work.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

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.



×
×
  • Create New...

Important Information

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