Class CustomBlock
java.lang.Object
dev.lone.itemsadder.api.CustomStack
dev.lone.itemsadder.api.CustomBlock
Wrapper for a custom block item and, when available, its placed block.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAdvanced helpers for editing ItemsAdder custom block region data directly. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable CustomBlockbyAlreadyPlaced(Block block) Gets the custom block wrapper for an already placed block.static @Nullable CustomBlockbyItemStack(ItemStack itemStack) Gets a custom block wrapper from an item stack.@Nullable BlockDataDeprecated.@Nullable BlockDataGets the base block data used by this custom block.static @Nullable BlockDatagetBaseBlockData(String namespacedID) Gets the base block data used by a registered custom block.@Nullable BlockgetBlock()Gets the placed Bukkit block associated with this wrapper.static @Nullable CustomBlockgetInstance(String namespacedID) Gets a clone of the custom block item declared in the ItemsAdder registry.getLoot()Gets the loot generated by this custom block using the default options.getLoot(boolean includeSelfBlock) Gets the loot generated by this custom block.Gets the loot generated by a placed custom block.Gets the loot generated by this custom block.Gets all custom block namespaced ids currently registered.intGets the light level configured for this custom block.static booleanisInRegistry(String namespacedId) Checks if a custom block is registered.booleanisPlaced()Checks if this wrapper is associated with a placed block.static @Nullable CustomBlockPlaces a custom block in the world.Places this custom block in the world.booleanPlays the configured break particles and sound for this block.static booleanplayBreakEffect(Block bukkitBlock) Plays the configured break particles and sound for a placed custom block.booleanPlays the configured break particles for this block.static booleanplayBreakParticles(Block bukkitBlock) Plays the configured break particles for a placed custom block.booleanPlays the configured break sound for this block.static booleanplayBreakSound(Block bukkitBlock) Plays the configured break sound for a placed custom block.booleanPlays the configured place sound for this block.static booleanplayPlaceSound(Block bukkitBlock) Plays the configured place sound for a placed custom block.booleanremove()Removes this custom block from the world.static booleanRemoves a custom block from the world and from ItemsAdder region data.voidsetCurrentLightLevel(int level) Sets the current light level emitted by this custom block.Methods inherited from class CustomStack
drop, getConfig, getConfigPath, getConfigSectionCopy, getConfigSectionCopy, getConfigSectionCopy, getConfigSectionCopy, getCooldownMs, getDamageMainhand, getDisplayName, getDurability, getId, getItemStack, getMaxDurability, getModelPath, getNamespace, getNamespacedID, getPermission, getRequiredStats, getTextures, getUsages, hasAutoGeneratedModel, hasCooldown, hasCustomDurability, hasPermission, hasUsagesAttribute, isBlock, isBlock, isBlockAllEnchants, isComplexFurniture, isFurniture, isFurnitureConsumable, isFurnitureSittable, isFurnitureTradeMachine, isVehicle, itemName, matchNamespacedID, openTradeMenu, reduceUsages, requiresStats, setAttributeModifier, setDisplayName, setDurability, setMaxDurability, setUsages, updateAttackDamageLore, updateAttackSpeedLore
-
Method Details
-
getNamespacedIdsInRegistry
-
isInRegistry
Checks if a custom block is registered.- Parameters:
namespacedId- the custom block namespaced id.- Returns:
- true if the custom block exists in the registry.
-
getInstance
Gets a clone of the custom block item declared in the ItemsAdder registry.- Parameters:
namespacedID- the custom block namespaced id.- Returns:
- the custom block wrapper, or null if it does not exist.
-
byItemStack
Gets a custom block wrapper from an item stack.- Parameters:
itemStack- the item stack to read.- Returns:
- the custom block wrapper, or null if the item is not a custom block.
-
place
Places a custom block in the world.- Parameters:
namespacedId- the custom block namespaced id.location- the location where the block will be placed.- Returns:
- the placed custom block wrapper, or null if the block does not exist.
-
byAlreadyPlaced
Gets the custom block wrapper for an already placed block.- Parameters:
block- the block to check.- Returns:
- the custom block wrapper, or null if the block is not a custom block.
-
remove
Removes a custom block from the world and from ItemsAdder region data.- Parameters:
location- the custom block location.- Returns:
- true if a custom block was removed.
-
generateBlockData
Deprecated.usegetBaseBlockData()instead.Generates the base block data used by this custom block.- Returns:
- the base block data, or null if not available.
-
getBaseBlockData
Gets the base block data used by this custom block.- Returns:
- the base block data, or null if not available.
-
getBaseBlockData
-
getBlock
Gets the placed Bukkit block associated with this wrapper.- Returns:
- the Bukkit block, or null if this wrapper is not placed.
-
isPlaced
public boolean isPlaced()Checks if this wrapper is associated with a placed block.- Returns:
- true if this custom block is placed.
-
place
Places this custom block in the world.- Parameters:
location- the location where the block will be placed.- Returns:
- this wrapper.
-
remove
public boolean remove()Removes this custom block from the world.- Returns:
- true if the custom block was removed.
-
playBreakEffect
public boolean playBreakEffect()Plays the configured break particles and sound for this block.- Returns:
- true if the effect was played.
-
playBreakEffect
Plays the configured break particles and sound for a placed custom block.- Parameters:
bukkitBlock- the placed custom block.- Returns:
- true if the effect was played.
-
playBreakSound
public boolean playBreakSound()Plays the configured break sound for this block.- Returns:
- true if the sound was played.
-
playBreakSound
Plays the configured break sound for a placed custom block.- Parameters:
bukkitBlock- the placed custom block.- Returns:
- true if the sound was played.
-
playBreakParticles
public boolean playBreakParticles()Plays the configured break particles for this block.- Returns:
- true if the particles were played.
-
playBreakParticles
Plays the configured break particles for a placed custom block.- Parameters:
bukkitBlock- the placed custom block.- Returns:
- true if the particles were played.
-
playPlaceSound
public boolean playPlaceSound()Plays the configured place sound for this block.- Returns:
- true if the sound was played.
-
playPlaceSound
Plays the configured place sound for a placed custom block.- Parameters:
bukkitBlock- the placed custom block.- Returns:
- true if the sound was played.
-
getLoot
-
getLoot
-
getLoot
Gets the loot generated by this custom block.- Parameters:
tool- the tool used to break the block, or null.includeSelfBlock- true to include the block item itself when configured.- Returns:
- the generated loot.
-
getLoot
public static List<ItemStack> getLoot(Block bukkitBlock, @Nullable @Nullable ItemStack tool, boolean includeSelfBlock) Gets the loot generated by a placed custom block.- Parameters:
bukkitBlock- the placed custom block.tool- the tool used to break the block, or null.includeSelfBlock- true to include the block item itself when configured.- Returns:
- the generated loot, or an empty list if the block is not custom.
-
getOriginalLightLevel
public int getOriginalLightLevel()Gets the light level configured for this custom block.- Returns:
- the configured light level.
-
setCurrentLightLevel
public void setCurrentLightLevel(int level) Sets the current light level emitted by this custom block.- Parameters:
level- the new light level.
-
getBaseBlockData()instead.