Jump to content

Need help with Entity Death Event (forge 1.12.2)


Randomboy

Recommended Posts

What I actually want is spawn some item one second after entity death but I don't know how. Here is my code:

package net.some_more_boss.handler;   

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraft.item.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.some_more_boss.TestBoss;
import net.some_more_boss.TestBoss.EntityCustom;


import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;


import net.minecraftforge.fml.common.gameevent.TickEvent;
public class bossEvent {
    @SubscribeEvent
     public void bossDeath(LivingDeathEvent event){
        if (!(event.getEntityLiving() instanceof TestBoss.EntityCustom))

            return;    
        if (event.getEntityLiving() instanceof TestBoss.EntityCustom){
            EntityCustom boss = (EntityCustom)event.getEntityLiving();
            EntityPlayer player = Minecraft.getMinecraft().player;     
            int X = Minecraft.getMinecraft().player.getPosition().getX();
            int Y = Minecraft.getMinecraft().player.getPosition().getY();
            int Z = Minecraft.getMinecraft().player.getPosition().getZ();
            World world = (World)boss.getEntityWorld();
            if (event.getSource().getTrueSource() instanceof EntityPlayer){
                 //wait some tick here
                world.spawnEntity(new  EntityItem(world, X, Y, Z, new ItemStack(Items.DIAMOND_SWORD, 1)));
                world.spawnEntity(new  EntityItem(world, X, Y, Z, new ItemStack(Items.DIAMOND_HELMET, 1)));
                world.spawnEntity(new  EntityItem(world, X, Y, Z, new ItemStack(Items.WOODEN_AXE, 1)));     
            }
        }
    }
}

Edited by Randomboy
Link to comment
Share on other sites

  • Randomboy changed the title to Need help with Entity Death Event (forge 1.12.2)
Guest
This topic is now closed to further replies.


×
×
  • Create New...

Important Information

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