Guest User

Untitled

a guest
Nov 30th, 2013
90
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.ItemStack;
  14. import net.minecraftforge.event.ForgeSubscribe;
  15. import net.minecraftforge.event.entity.living.LivingDropsEvent;
  16.  
  17. import com.google.common.collect.ImmutableMap;
  18.  
  19. public class ButcherEventClass
  20. {
  21.     public static Random rnd = new Random();
  22.     public static Map<Class<? extends EntityLivingBase>, Item> dropMap = ImmutableMap.<Class<? extends EntityLivingBase>, ItemStack>builder()
  23.             .put(EntityPig.class, IntegratedItems.porkChunk)
  24.             .put(EntityChicken.class, IntegratedItems.chickenHead)
  25.             .put(EntityCow.class, IntegratedItems.beefChunk)
  26.             .put(EntitySheep.class, IntegratedItems.rawLamb)
  27.             .put(EntityHorse.class, IntegratedItems.rawHorse)
  28.             .put(EntityPlayer.class, IntegratedItems.rawHuman)
  29.             .build();
  30.  
  31.     //Mobs Drop Flesh
  32.     @ForgeSubscribe
  33.     public void onEntityDrop(LivingDropsEvent event)
  34.     {      
  35.         System.out.println("Event Found???");
  36.  
  37.         double rand = rnd.nextDouble();
  38.        
  39.         try
  40.         {
  41.             System.out.println("Started Trying");
  42.             if( event.source.getEntity() instanceof EntityPlayer )
  43.             {
  44.                 ItemStack currentItem = ((EntityLivingBase)event.source.getEntity()).getHeldItem();
  45.                 System.out.println("Current item or armor: (" + currentItem.itemID + ") " + currentItem.getDisplayName());
  46.    
  47.                 if(currentItem.getItem() == IntegratedItems.meatcleaverstack)
  48.                 {
  49.                     System.out.println("itemstack is a meatcleaver");
  50.                     if(rand < 1D)
  51.                     {
  52.                         ItemStack drop = new ItemStack(dropMap.get(event.entityLiving.getClass()));
  53.                         event.entityLiving.entityDropItem(drop, 0.0f);
  54.                     }
  55.                 }
  56.             }
  57.         }
  58.         catch(NullPointerException e)
  59.         {
  60.             System.out.println("Event Failed");
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment