diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt index f1d21d0..ba39dc0 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsPlugin.kt @@ -20,6 +20,7 @@ import com.willfp.ecopets.pets.Pets import com.willfp.ecopets.pets.SpawnEggHandler import com.willfp.ecopets.pets.activePet import com.willfp.ecopets.pets.activePetLevel +import com.willfp.ecopets.pets.entity.ItemStackPetEntity import com.willfp.ecopets.pets.hasPet import com.willfp.ecopets.pets.entity.ModelEnginePetEntity import com.willfp.ecopets.pets.entity.PetEntity @@ -85,6 +86,10 @@ class EcoPetsPlugin : LibreforgePlugin() { } pets.toString() }.register() + + PetEntity.registerPetEntity("itemstack") { pet, itemStack -> + ItemStackPetEntity(pet, itemStack) + } } override fun handleReload() { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt index db1d5b8..f1be2b2 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/Pet.kt @@ -115,6 +115,10 @@ class Pet( val entityTexture = config.getString("entity-texture") + val offset = config.getDouble("offset") + + val rotatable = config.getBool("rotatable") + private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements") val maxLevel = levelXpRequirements.size diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt index 310d10a..dd2d925 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetDisplay.kt @@ -50,13 +50,14 @@ class PetDisplay( val location = getLocation(player) + location.y += pet.offset location.y += NumberUtils.fastSin(tick / (2 * PI) * 0.5) * 0.15 if (location.world != null) { stand.teleport(location) } - if (!pet.entityTexture.contains(":")) { + if (!pet.entityTexture.contains(":") && pet.rotatable) { stand.setRotation((20 * tick / (2 * PI)).toFloat(), 0f) } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetLevelGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetLevelGUI.kt index 8ce413f..5453804 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetLevelGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/PetLevelGUI.kt @@ -67,7 +67,7 @@ class PetLevelGUI( } menu = menu(plugin.configYml.getInt("level-gui.rows")) { - title = pet.name + title = plugin.langYml.getString("menu.level-title").replace("%pet%", pet.name) maxPages(component.pages) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ItemStackPetEntity.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ItemStackPetEntity.kt new file mode 100644 index 0000000..b83d3f9 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/ItemStackPetEntity.kt @@ -0,0 +1,23 @@ +package com.willfp.ecopets.pets.entity + +import com.willfp.eco.core.items.Items +import com.willfp.ecopets.pets.Pet +import org.bukkit.Location +import org.bukkit.entity.ArmorStand +import org.bukkit.inventory.ItemStack + +class ItemStackPetEntity( + pet: Pet, + private val itemStack: String +) : PetEntity(pet) { + override fun spawn(location: Location): ArmorStand { + val stand = emptyArmorStandAt(location, pet) + + val itemStack: ItemStack = Items.lookup(itemStack).item + + @Suppress("UNNECESSARY_SAFE_CALL") // Can be null. + stand.equipment?.helmet = itemStack + + return stand + } +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/PetEntity.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/PetEntity.kt index 919da59..f8189d8 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/PetEntity.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/pets/entity/PetEntity.kt @@ -44,7 +44,7 @@ internal fun emptyArmorStandAt(location: Location, pet: Pet): ArmorStand { stand.isCollidable = false stand.isPersistent = false - for (slot in EquipmentSlot.values()) { + for (slot in EquipmentSlot.entries) { stand.addEquipmentLock(slot, ArmorStand.LockType.ADDING_OR_CHANGING) } diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index fa9b328..c58d048 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -27,5 +27,6 @@ messages: menu: title: "Pets" + level-title: "%pet%" infinity: "∞" diff --git a/eco-core/core-plugin/src/main/resources/pets/_example.yml b/eco-core/core-plugin/src/main/resources/pets/_example.yml index e95bd1f..43a83a9 100644 --- a/eco-core/core-plugin/src/main/resources/pets/_example.yml +++ b/eco-core/core-plugin/src/main/resources/pets/_example.yml @@ -7,6 +7,12 @@ # The display name of the pet name: "&6Tiger" +# Offset of pet display position on the y-axis (default is 0.0) +offset: 0.0 + +# Whether the pet will rotate on its own (default is false) +rotatable: true + # The description of the pet description: "&8&oLevel up by dealing melee damage" @@ -115,6 +121,8 @@ conditions: [ ] # The texture of the pet entity in game # If you're using modelengine, use modelengine:id as the texture +# If you want to use custom item, use itemstack: as the texture (For example: itemstack:itemsadder:namespace__key) +# https://plugins.auxilor.io/all-plugins/the-item-lookup-system entity-texture: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0=" # The icon in GUIs