Jump to content

Recommended Posts

Posted
package com.examplemod.item;

import com.idtech.BaseMod;
import net.minecraft.block.Block;
import net.minecraft.block.BlockOre;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemHoe;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import java.util.Random;

public class ItemFirePickaxe extends ItemPickaxe {
    public static final String name = "fire_pickaxe";

    protected ItemFirePickaxe(){
        super(ItemMod.FIRE); //material

        this.setUnlocalizedName(BaseMod.MODID + "_" + name);
        this.setCreativeTab(CreativeTabs.TOOLS);

    }

    protected PlayerInteractEvent.LeftClickBlock leftClickBlock;
    protected World world;
    protected EntityPlayer player;

   @SubscriveEvent
    public void onBlockDestroyed(BlockEvent.HarvestDropsEvent event, PlayerInteractEvent interactEvent, World world)
    {
        if(event.getHarvester().getHeldItem(EnumHand.MAIN_HAND)!=null&&event.getHarvester().getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemFirePickaxe){
            BlockPos pos = leftClickBlock.getPos();
            Block block = world.getBlockState(pos).getBlock();
            ItemStack stack = FurnaceRecipes.instance().getSmeltingResult(new ItemStack(block));
            if(stack!=null)
            {
                ItemStack x=new ItemStack(stack.getItem());

                event.getDrops().clear();
                event.getDrops().add(x);
            }
        }
    }
}

 

Posted (edited)

If you guys lock my thread and say its no longer supported. I am sorry and I didn't know until after I posted it. But can you guys be helpful and at least tell me where I can go to get help. That will be greatly appreciated. Thanks and I hope you guys can help me fix my mistake.

Edited by LordKingBob
Posted (edited)

Read the docs on events. @SubscribeEvent is only part of what you need in order to get events (you should also use a dedicated event handler class).

But yes, 1.12 is no longer supported.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

1.12 is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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