SHARE
TWEET

Untitled

a guest Apr 7th, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.theishiopian.foragecraft.handler;
  2.  
  3. import java.util.List;
  4. import java.util.Random;
  5.  
  6. import com.theishiopian.foragecraft.ForageCraftMod;
  7.  
  8. import net.minecraft.item.ItemStack;
  9. import net.minecraft.util.ResourceLocation;
  10. import net.minecraft.world.World;
  11. import net.minecraft.world.WorldServer;
  12. import net.minecraft.world.storage.loot.LootContext;
  13. import net.minecraft.world.storage.loot.LootTable;
  14. import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
  15. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  16.  
  17. public class BlockForageHandler
  18. {
  19.     static List<ItemStack> list;
  20.  
  21.     @SubscribeEvent
  22.     public void blockBreak(HarvestDropsEvent event)
  23.     {
  24.         ResourceLocation table = ForageCraftMod.ForageTable.get(event.getState().getBlock());
  25.  
  26.         if(table != null)
  27.         {
  28.             System.out.println(table.toString());
  29.            
  30.             World world = event.getWorld();
  31.             LootTable loottable = world.getLootTableManager().getLootTableFromLocation(table);
  32.             LootContext.Builder lootcontext$builder = (new LootContext.Builder((WorldServer)world));
  33.  
  34.             event.getDrops().clear();
  35.            
  36.             list = loottable.generateLootForPools(new Random(), lootcontext$builder.build());
  37.            
  38.             System.out.println(list.toString());
  39.            
  40.             for (ItemStack itemstack : list)
  41.             {
  42.                 event.getDrops().add(itemstack);
  43.                
  44.                 System.out.println("adding item "+itemstack.getItem().toString());
  45.             }
  46.         }
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top