mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 01:01:58 +01:00
SPIGOT-6901: Add Support for Random in methods for LootTable
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
ce2ac2868b
commit
4c024e72f9
@ -41,7 +41,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
|
||||
LootTableInfo nmsContext = convertContext(context);
|
||||
LootTableInfo nmsContext = convertContext(context, random);
|
||||
List<net.minecraft.world.item.ItemStack> nmsItems = handle.getRandomItems(nmsContext);
|
||||
Collection<ItemStack> bukkit = new ArrayList<>(nmsItems.size());
|
||||
|
||||
@ -57,7 +57,7 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
|
||||
@Override
|
||||
public void fillInventory(Inventory inventory, Random random, LootContext context) {
|
||||
LootTableInfo nmsContext = convertContext(context);
|
||||
LootTableInfo nmsContext = convertContext(context, random);
|
||||
CraftInventory craftInventory = (CraftInventory) inventory;
|
||||
IInventory handle = craftInventory.getInventory();
|
||||
|
||||
@ -70,11 +70,14 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
return key;
|
||||
}
|
||||
|
||||
private LootTableInfo convertContext(LootContext context) {
|
||||
private LootTableInfo convertContext(LootContext context, Random random) {
|
||||
Location loc = context.getLocation();
|
||||
WorldServer handle = ((CraftWorld) loc.getWorld()).getHandle();
|
||||
|
||||
LootTableInfo.Builder builder = new LootTableInfo.Builder(handle);
|
||||
if (random != null) {
|
||||
builder = builder.withRandom(random);
|
||||
}
|
||||
setMaybe(builder, LootContextParameters.ORIGIN, new Vec3D(loc.getX(), loc.getY(), loc.getZ()));
|
||||
if (getHandle() != LootTable.EMPTY) {
|
||||
// builder.luck(context.getLuck());
|
||||
|
Loading…
Reference in New Issue
Block a user