Class SpawnEggBuilder
java.lang.Object
io.github.lucfr1746.llibrary.itemstack.ItemBuilder
io.github.lucfr1746.llibrary.itemstack.SpawnEggBuilder
The
SpawnEggBuilder
class extends ItemBuilder
to provide
additional functionality for modifying SpawnEggMeta
of an ItemStack
.
This includes setting custom spawned entities and manipulating persistent data.-
Constructor Summary
ConstructorsConstructorDescriptionSpawnEggBuilder
(@NotNull org.bukkit.entity.EntityType entityType, int amount) Constructs aSpawnEggBuilder
with the specifiedEntityType
.SpawnEggBuilder
(@NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aSpawnEggBuilder
using an existingItemStack
. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.entity.EntityType
Gets the entity type associated with the spawn egg.modifyPersistentData
(@NotNull Consumer<org.bukkit.persistence.PersistentDataContainer> action) Modifies the persistent data container of the spawn egg.setSpawnedEntity
(@NotNull org.bukkit.entity.Entity entity) Sets the entity snapshot for the spawn egg.Methods inherited from class io.github.lucfr1746.llibrary.itemstack.ItemBuilder
addAttributeModifier, addEnchant, addEnchant, addEnchant, addItemFlags, addLore, build, getAmount, getAttributeModifiers, getAttributeModifiers, getAttributeModifiers, getCustomModelData, getDamageResistant, getDisplayName, getEnchantable, getEnchantLevel, getEnchantmentGlintOverride, getEnchants, getEquippableComponent, getFoodComponent, getItemFlags, getItemMeta, getItemModel, getJukeboxPlayableComponent, getMaxStackSize, getRarity, getToolComponent, getTooltipStyle, getTranslationKey, getType, getUseCooldownComponent, getUseRemainder, hasAttributeModifiers, hasConflictingEnchant, hasCustomModelData, hasDamageResistant, hasEnchant, hasEnchantable, hasEnchantmentGlintOverride, hasEnchants, hasEquippableComponent, hasFoodComponent, hasItemFlag, hasItemModel, hasJukeboxPlayableComponent, hasMaxStackSize, hasRarity, hasToolComponent, hasTooltipStyle, hasUseCooldownComponent, hasUseRemainder, hideAllItemFlags, insertLore, isGlider, isHideTooltip, isUnbreakable, removeAttributeModifier, removeAttributeModifier, removeAttributeModifier, removeEnchant, removeEnchants, removeItemFlags, replaceLore, setAmount, setAttributeModifiers, setCustomModelData, setDamageResistant, setDisplayName, setEnchantable, setEnchantmentGlintOverride, setEquippableComponent, setEquippableComponent, setFood, setFoodComponent, setGlider, setHideTooltip, setItemModel, setItemModel, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setJukeboxPlayableComponent, setLores, setLores, setMaxStackSize, setRarity, setToolComponent, setToolComponent, setTooltipStyle, setTooltipStyle, setType, setUnbreakable, setUseCooldownComponent, setUseCooldownComponent, setUseCooldownComponent, setUseRemainder
-
Constructor Details
-
SpawnEggBuilder
public SpawnEggBuilder(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack) Constructs aSpawnEggBuilder
using an existingItemStack
.- Parameters:
itemStack
- the item stack to modify- Throws:
IllegalArgumentException
- if the item is not a spawn egg
-
SpawnEggBuilder
public SpawnEggBuilder(@NotNull @NotNull org.bukkit.entity.EntityType entityType, int amount) Constructs aSpawnEggBuilder
with the specifiedEntityType
. Automatically select the appropriate spawn egg material based on the entity type.- Parameters:
entityType
- the type of entity the spawn egg will spawnamount
- the quantity of spawn eggs in the stack- Throws:
IllegalArgumentException
- if no spawn egg material is found for the entity type
-
-
Method Details
-
setSpawnedEntity
Sets the entity snapshot for the spawn egg. The spawned entity will retain the state defined by the provided entity's snapshot.- Parameters:
entity
- the entity to create a snapshot from- Returns:
- this
SpawnEggBuilder
instance for chaining
-
getSpawnedEntityType
@Nullable public @Nullable org.bukkit.entity.EntityType getSpawnedEntityType()Gets the entity type associated with the spawn egg.- Returns:
- the
EntityType
the spawn egg will spawn, or null if not set
-
modifyPersistentData
public SpawnEggBuilder modifyPersistentData(@NotNull @NotNull Consumer<org.bukkit.persistence.PersistentDataContainer> action) Modifies the persistent data container of the spawn egg. This allows adding custom NBT data or modifying existing tags.- Parameters:
action
- aConsumer
that accepts the spawn egg'sPersistentDataContainer
- Returns:
- this
SpawnEggBuilder
instance for chaining
-