ToolEvents.java

Created 2017-07-01 08:55:38.305070

back
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
@Mod.EventBusSubscriber
public class ToolEvents {

    @SubscribeEvent
    public void blockBreak(BlockEvent.BreakEvent event) {
        PlayerControllerMP controllerMP = Minecraft.getMinecraft().playerController;
        EntityPlayer player = Minecraft.getMinecraft().player;
        World world = player.getEntityWorld();
        ItemStack tool = player.getHeldItemMainhand();

        if(!tool.isEmpty()) {
            FMLLog.getLogger().info("Tool: " + tool);
            if(tool.getItem() instanceof ItemExcavator) {
                FMLLog.getLogger().info("Excavating!");
            }
        }
    }

    /*
    @SubscribeEvent
    public void renderExtraBlockBreak(RenderWorldLastEvent event) {
        FMLLog.getLogger().info("rendering");
    }
    */
}
back