Guest User

EntityJoinWorldEvent

a guest
Jan 12th, 2016
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package com.knifesurge.ToolExpansion.eventhandlers;
  2.  
  3. import com.knifesurge.ToolExpansion.entityItem.SpecialEntityItem;
  4.  
  5. import net.minecraft.entity.item.EntityItem;
  6. import net.minecraft.init.Items;
  7. import net.minecraftforge.event.entity.EntityJoinWorldEvent;
  8. import net.minecraftforge.fml.common.eventhandler.EventPriority;
  9. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  10.  
  11. public class EntityJoinWorldEventHandler {
  12.  
  13.     @SubscribeEvent(priority=EventPriority.HIGHEST)
  14.     public void onEntityJoinWorld(EntityJoinWorldEvent event)
  15.     {
  16.         if(event.entity instanceof EntityItem)
  17.         {
  18.             if(((EntityItem)event.entity).getEntityItem().getItem() == Items.blaze_rod)
  19.             {
  20.                 event.setCanceled(true);
  21.                 SpecialEntityItem entityItem = new SpecialEntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, ((EntityItem)event.entity).getEntityItem());
  22.                 event.entity.worldObj.spawnEntityInWorld(entityItem);
  23.                
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment