Skip to content

Commit

Permalink
Implement the start of TexturedItem class
Browse files Browse the repository at this point in the history
  • Loading branch information
EsotericEnderman committed Nov 1, 2024
1 parent bf8f56a commit 433ddfa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class CustomItem(protected val plugin: CustomItemPlugin, private val it
* @param item The existing item. The material of this item must match the material of the custom item.
* @return The transformed `ItemStack`.
*/
fun toItem(item: ItemStack): ItemStack {
open fun toItem(item: ItemStack): ItemStack {
require(item.type == material) { "Cannot transform item of material " + item.type + " to item of material " + material.name + "." }

item.editMeta { meta: ItemMeta ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package foundation.esoteric.minecraft.plugins.library.item

import org.bukkit.Material
import org.bukkit.inventory.ItemStack
import java.nio.file.Path

class TexturedItem : CustomItem {

companion object {
val startingModelData = 7919
var texturedItems: Int = 0
}

constructor(plugin: CustomItemPlugin, itemId: String, material: Material, resourcePath: Path) : super(plugin, itemId, material) {
texturedItems++
}

constructor(plugin: CustomItemPlugin, itemId: String, material: Material, resourcePath: String) : this(plugin, itemId, material, Path.of(resourcePath))

override fun toItem(item: ItemStack): ItemStack {
super.toItem(item)

item.editMeta {
meta ->
meta.setCustomModelData(startingModelData + texturedItems)
}

return item
}
}

0 comments on commit 433ddfa

Please sign in to comment.