Jump to content

Recommended Posts

Posted

use the LivingDeathEvent.

use event.source.getEntity() and check if it's an instance of EntityPlayer.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

I've tried to make it but it doesn't work.

The event class:

 

 

package com.BI.Events;

 

import com.BI.Items.Mod_Items;

 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import net.minecraft.entity.Entity;

import net.minecraft.entity.passive.EntityPig;

import net.minecraft.entity.passive.EntitySquid;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraftforge.event.entity.living.LivingDeathEvent;

public class Drop_Event {

@SubscribeEvent

public void onPlayerKill(LivingDeathEvent event){

if (event.source.getEntity() instanceof EntityPlayer)

{

event.entityLiving.dropItem(Mod_Items.Eye, 1);

}

}

}

 

 

 

Main Class:

 

 

package com.BI.Main_Package;

 

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.item.Item;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.common.util.EnumHelper;

 

import com.BI.Blocks.Mod_Blocks;

import com.BI.Events.Drop_Event;

import com.BI.Items.Mod_Items;

import com.BI.Lib.Reference;

import com.BI.Registers.Game_Registry;

 

import cpw.mods.fml.common.FMLCommonHandler;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.EventHandler;

import cpw.mods.fml.common.event.FMLInitializationEvent;

 

@Mod(modid = Reference.MOD_ID, version = Reference.MOD_VERSION, name = Reference.MOD_NAME)

public class Main_Class

{

public static CreativeTabs CMTab = new CMTab(CreativeTabs.getNextID(), "Chaos Magic");

public static final Item.ToolMaterial DagerM = EnumHelper.addToolMaterial("DagerM", 3, 151, 12.0F, 3.5F, 22);

    @EventHandler

    public void init(FMLInitializationEvent event)

    {

    System.out.println("Chaos Magic " + Reference.MOD_VERSION + ">> is initializating!");

Mod_Blocks.BlocksInit();

Mod_Items.ItemsInit();

Game_Registry.RegistersInitItems();

Game_Registry.RegistersInitBlocks();

FMLCommonHandler.instance().bus().register(new Drop_Event());

System.out.println("Chaos Magic " + Reference.MOD_VERSION + ">> has succesfully initialized all the modules!");

    }

}

 

 

Woking at my first mod, Blocks & Items Revolution : https://github.com/megabitus98/Blocks-Items-Revolution

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.