Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Reactioncraft.core;
- import java.util.Map;
- import java.util.Random;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.passive.EntityChicken;
- import net.minecraft.entity.passive.EntityCow;
- import net.minecraft.entity.passive.EntityHorse;
- import net.minecraft.entity.passive.EntityPig;
- import net.minecraft.entity.passive.EntitySheep;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraftforge.event.ForgeSubscribe;
- import net.minecraftforge.event.entity.living.LivingDropsEvent;
- import com.google.common.collect.ImmutableMap;
- public class ButcherEventClass
- {
- public static Random rnd = new Random();
- public static Map<Class<? extends EntityLivingBase>, Item> dropMap = ImmutableMap.<Class<? extends EntityLivingBase>, Item>builder()
- .put(EntityPig.class, IntegratedItems.porkChunk)
- .put(EntityChicken.class, IntegratedItems.chickenHead)
- .put(EntityCow.class, IntegratedItems.beefChunk)
- .put(EntitySheep.class, IntegratedItems.rawLamb)
- .put(EntityHorse.class, IntegratedItems.rawHorse)
- .put(EntityPlayer.class, IntegratedItems.rawHuman)
- .build();
- //Mobs Drop Flesh
- @ForgeSubscribe
- public void onEntityDrop(LivingDropsEvent event)
- {
- System.out.println("Event Found???");
- double rand = rnd.nextDouble();
- try
- {
- System.out.println("Started Trying");
- if( event.source.getEntity() instanceof EntityPlayer )
- {
- ItemStack currentItem = ((EntityLivingBase)event.source.getEntity()).getHeldItem();
- System.out.println("Current item or armor: (" + currentItem.itemID + ") " + currentItem.getDisplayName());
- if(currentItem.getItem() == IntegratedItems.meatcleaverstack)
- {
- System.out.println("itemstack is a meatcleaver");
- Item drop = dropMap.get(event.entityLiving.getClass());
- if(rand < 1D && null != drop)
- {
- event.entityLiving.entityDropItem(new ItemStack(drop), 0.0f);
- }
- }
- }
- }
- catch(NullPointerException e)
- {
- System.out.println("Event Failed");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment