Package org.bukkit.loot
Class LootContext.Builder
- java.lang.Object
-
- org.bukkit.loot.LootContext.Builder
-
- Enclosing class:
- LootContext
public static class LootContext.Builder extends Object
Utility class to make buildingLootContexteasier. The only required argument isLocationwith a valid (non-null)World.
-
-
Constructor Summary
Constructors Constructor Description Builder(Location location)Creates a new LootContext.Builder instance to facilitate easy creation ofLootContexts.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LootContextbuild()Create a newLootContextinstance using the supplied parameters.LootContext.Builderkiller(HumanEntity killer)Set theHumanEntitythat killedLootContext.getLootedEntity().LootContext.BuilderlootedEntity(Entity lootedEntity)The entity that was killed.LootContext.BuilderlootingModifier(int modifier)Set theEnchantment.LOOT_BONUS_MOBSlevel equivalent to use when generating loot.LootContext.Builderluck(float luck)Set how much luck to have when generating loot.
-
-
-
Constructor Detail
-
Builder
public Builder(@NotNull Location location)Creates a new LootContext.Builder instance to facilitate easy creation ofLootContexts.- Parameters:
location- the location the LootContext should use
-
-
Method Detail
-
luck
@NotNull public LootContext.Builder luck(float luck)
Set how much luck to have when generating loot.- Parameters:
luck- the luck level- Returns:
- the Builder
-
lootingModifier
@NotNull public LootContext.Builder lootingModifier(int modifier)
Set theEnchantment.LOOT_BONUS_MOBSlevel equivalent to use when generating loot. Values less than or equal to 0 will force theLootTableto only return a singleItemStackper pool.- Parameters:
modifier- the looting level modifier- Returns:
- the Builder
-
lootedEntity
@NotNull public LootContext.Builder lootedEntity(@Nullable Entity lootedEntity)
The entity that was killed.- Parameters:
lootedEntity- the looted entity- Returns:
- the Builder
-
killer
@NotNull public LootContext.Builder killer(@Nullable HumanEntity killer)
Set theHumanEntitythat killedLootContext.getLootedEntity(). This entity will be used to get the looting level iflootingModifier(int)is not set.- Parameters:
killer- the killer entity- Returns:
- the Builder
-
build
@NotNull public LootContext build()
Create a newLootContextinstance using the supplied parameters.- Returns:
- a new
LootContextinstance
-
-