Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.theishiopian.foragecraft.handler;
- import java.util.List;
- import com.theishiopian.foragecraft.ForageCraftMod;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.world.World;
- import net.minecraft.world.WorldServer;
- import net.minecraft.world.storage.loot.LootContext;
- import net.minecraft.world.storage.loot.LootTable;
- import net.minecraftforge.event.world.BlockEvent.HarvestDropsEvent;
- import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
- public class BlockForageHandler
- {
- static List<ItemStack> list;
- @SubscribeEvent
- public void blockBreak(HarvestDropsEvent event)
- {
- World world = event.getWorld();
- EntityPlayer player = event.getHarvester();
- //LootTable loottable = world.getLootTableManager().getLootTableFromLocation(ForageCraftMod.ForageTable.get(event.getState().getBlock()));
- LootTable loottable = world.getLootTableManager().getLootTableFromLocation(new ResourceLocation("foragecraft:loot_tables/dirt.json"));
- System.out.println(loottable.toString());
- LootContext.Builder context = new LootContext.Builder((WorldServer) world);
- event.getDrops().clear();
- if (player != null) {
- context.withLuck(player.getLuck());
- context.withPlayer(player);
- }
- list = loottable.generateLootForPools(world.rand, context.build());
- System.out.println(list.toString());
- for (ItemStack itemstack : list)
- {
- event.getDrops().add(itemstack);
- System.out.println("adding item "+itemstack.getItem().toString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment