Class LootTable
java.lang.Object
com.ryandw11.structure.loottables.LootTable
- Direct Known Subclasses:
ConfigLootTable
,MinecraftLootTable
Represents a LootTable.
You can extend this class to implement custom LootTables.
This class comes with a RandomCollection
of LootItem
by default. You can opt to not use this
collection with your implementation by overriding getRandomWeightedItem()
and getItems()
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RandomCollection<LootItem>
The default RandomCollection provided.protected List<LootTableType>
The list of LootTable types. -
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor for the LootTable which initializes the RandomCollection and list of LootTableTypes. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addLootItem(double weight, @NotNull LootItem lootItem)
Add an item to the LootTable's random collection.void
addType(LootTableType type)
Add a LootTable type.void
fillBrewerInventory(org.bukkit.inventory.BrewerInventory brewerInventory, Random random, org.bukkit.Location location)
Fills a brewer with items.void
fillContainerInventory(org.bukkit.inventory.Inventory inventory, Random random, org.bukkit.Location location)
Fills a container's inventory with items.void
fillFurnaceInventory(org.bukkit.inventory.FurnaceInventory furnaceInventory, Random random, org.bukkit.Location location)
Fills a furnace inventory with items.getItems()
Get the list of items from the loot table.abstract String
getName()
Get the name of the LootTable.org.bukkit.inventory.ItemStack
Get a random item from the loot table.abstract int
getRolls()
Get the number of rolls for the loot table.getTypes()
Get the list of LootTable types.abstract void
setRolls(int rolls)
Set the number of rolls for the loot table.void
setTypes(List<LootTableType> types)
Set the list of LootTable types.
-
Field Details
-
randomCollection
The default RandomCollection provided. -
types
The list of LootTable types.Avoid changing the default behavior of LootTableTypes.
-
-
Constructor Details
-
LootTable
public LootTable()The default constructor for the LootTable which initializes the RandomCollection and list of LootTableTypes.
-
-
Method Details
-
getName
Get the name of the LootTable.- Returns:
- The name of the LootTable.
-
getRolls
public abstract int getRolls()Get the number of rolls for the loot table. (The number of items to be chosen).- Returns:
- The number of rolls for the loot table.
-
setRolls
public abstract void setRolls(int rolls)Set the number of rolls for the loot table.An implementation of this method is not strictly necessary.
- Parameters:
rolls
- The number of rolls for the loot tables.
-
fillContainerInventory
public void fillContainerInventory(org.bukkit.inventory.Inventory inventory, Random random, org.bukkit.Location location)Fills a container's inventory with items.Override this method to replace the default functionality.
- Parameters:
inventory
- The inventory to fill.random
- The randomizer.location
- The location of the container.
-
fillFurnaceInventory
public void fillFurnaceInventory(org.bukkit.inventory.FurnaceInventory furnaceInventory, Random random, org.bukkit.Location location)Fills a furnace inventory with items.Override this method to replace the default functionality.
- Parameters:
furnaceInventory
- The furnace inventory to fill.random
- The randomizer.location
- The location of the furnace.
-
fillBrewerInventory
public void fillBrewerInventory(org.bukkit.inventory.BrewerInventory brewerInventory, Random random, org.bukkit.Location location)Fills a brewer with items.Override this method to replace the default functionality.
- Parameters:
brewerInventory
- The brewer invetory to fill.random
- The randomizer.location
- The location of the furnace.
-
getRandomWeightedItem
public org.bukkit.inventory.ItemStack getRandomWeightedItem()Get a random item from the loot table.Override this method if you don't use the default RandomCollection.
- Returns:
- A random item from the loot table.
-
getItems
Get the list of items from the loot table.Override this method if you don't use the default RandomCollection.
- Returns:
- This list of possible items in the LootTable.
-
addLootItem
Add an item to the LootTable's random collection.- Parameters:
weight
- The weight of the item to add.lootItem
- The LootItem to add.
-
getTypes
Get the list of LootTable types.- Returns:
- The list of LootTable types.
-
setTypes
Set the list of LootTable types.- Parameters:
types
- The list of types to be set.
-
addType
Add a LootTable type.- Parameters:
type
- The LootTable type to be added.
-