use of net.minecraft.world.level.storage.loot.LootTables in project Denizen-For-Bukkit by DenizenScript.
the class FishingHelperImpl method getRandomReward.
public ItemStack getRandomReward(FishingHook hook, ResourceLocation key) {
ServerLevel worldServer = (ServerLevel) hook.level;
LootContext.Builder playerFishEvent2 = new LootContext.Builder(worldServer);
LootTables registry = ((ServerLevel) hook.level).getServer().getLootTables();
// registry.getLootTable(key).getLootContextParameterSet()
LootContext info = playerFishEvent2.withOptionalParameter(LootContextParams.ORIGIN, new Vec3(hook.getX(), hook.getY(), hook.getZ())).withOptionalParameter(LootContextParams.TOOL, new ItemStack(Items.FISHING_ROD)).create(LootContextParamSets.FISHING);
List<ItemStack> itemStacks = registry.get(key).getRandomItems(info);
return itemStacks.get(worldServer.random.nextInt(itemStacks.size()));
}
use of net.minecraft.world.level.storage.loot.LootTables in project Denizen-For-Bukkit by DenizenScript.
the class FishingHelperImpl method getRandomReward.
public ItemStack getRandomReward(FishingHook hook, ResourceLocation key) {
ServerLevel worldServer = (ServerLevel) hook.level;
LootContext.Builder playerFishEvent2 = new LootContext.Builder(worldServer);
LootTables registry = ((ServerLevel) hook.level).getServer().getLootTables();
// registry.getLootTable(key).getLootContextParameterSet()
LootContext info = playerFishEvent2.withOptionalParameter(LootContextParams.ORIGIN, new Vec3(hook.getX(), hook.getY(), hook.getZ())).withOptionalParameter(LootContextParams.TOOL, new ItemStack(Items.FISHING_ROD)).create(LootContextParamSets.FISHING);
List<ItemStack> itemStacks = registry.get(key).getRandomItems(info);
return itemStacks.get(worldServer.random.nextInt(itemStacks.size()));
}
Aggregations