Guest User

Untitled

a guest
Nov 30th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Reactioncraft.core;
  2.  
  3. import java.util.Map;
  4. import java.util.Random;
  5.  
  6. import net.minecraft.entity.EntityLivingBase;
  7. import net.minecraft.entity.passive.EntityChicken;
  8. import net.minecraft.entity.passive.EntityCow;
  9. import net.minecraft.entity.passive.EntityHorse;
  10. import net.minecraft.entity.passive.EntityPig;
  11. import net.minecraft.entity.passive.EntitySheep;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.item.Item;
  14. import net.minecraft.item.ItemStack;
  15. import net.minecraftforge.event.ForgeSubscribe;
  16. import net.minecraftforge.event.entity.living.LivingDropsEvent;
  17.  
  18. import com.google.common.collect.ImmutableMap;
  19.  
  20. public class ButcherEventClass
  21. {
  22.     public static Random rnd = new Random();
  23.     public static Map<Class<? extends EntityLivingBase>, Item> dropMap = ImmutableMap.<Class<? extends EntityLivingBase>, Item>builder()
  24.             .put(EntityPig.class, IntegratedItems.porkChunk)
  25.             .put(EntityChicken.class, IntegratedItems.chickenHead)
  26.             .put(EntityCow.class, IntegratedItems.beefChunk)
  27.             .put(EntitySheep.class, IntegratedItems.rawLamb)
  28.             .put(EntityHorse.class, IntegratedItems.rawHorse)
  29.             .put(EntityPlayer.class, IntegratedItems.rawHuman)
  30.             .build();
  31.  
  32.     //Mobs Drop Flesh
  33.     @ForgeSubscribe
  34.     public void onEntityDrop(LivingDropsEvent event)
  35.     {      
  36.         System.out.println("Event Found???");
  37.  
  38.         double rand = rnd.nextDouble();
  39.        
  40.         try
  41.         {
  42.             System.out.println("Started Trying");
  43.             if( event.source.getEntity() instanceof EntityPlayer )
  44.             {
  45.                 ItemStack currentItem = ((EntityLivingBase)event.source.getEntity()).getHeldItem();
  46.                 System.out.println("Current item or armor: (" + currentItem.itemID + ") " + currentItem.getDisplayName());
  47.    
  48.                 if(currentItem.getItem() == IntegratedItems.meatcleaverstack)
  49.                 {
  50.                     System.out.println("itemstack is a meatcleaver");
  51.                     Item drop = dropMap.get(event.entityLiving.getClass());
  52.                     if(rand < 1D && null != drop)
  53.                     {
  54.                         event.entityLiving.entityDropItem(new ItemStack(drop), 0.0f);
  55.                     }
  56.                 }
  57.             }
  58.         }
  59.         catch(NullPointerException e)
  60.         {
  61.             System.out.println("Event Failed");
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment