Compare commits

...

5 Commits

Author SHA1 Message Date
Auxilor
675d2b8508 libreforge-updater 2022-07-11 16:17:10 +01:00
Auxilor
edddd67f58 Updated to 1.9.1 2022-07-09 14:51:48 +01:00
Auxilor
ed676e50c7 Fixed armor stand persistence 2022-07-09 14:51:41 +01:00
Auxilor
b36551a179 Improved pet entities 2022-07-09 14:50:03 +01:00
Auxilor
053f22258a libreforge-updater 2022-07-09 12:11:28 +01:00
5 changed files with 29 additions and 40 deletions

View File

@@ -48,7 +48,7 @@ allprojects {
dependencies { dependencies {
compileOnly 'com.willfp:eco:6.37.1' compileOnly 'com.willfp:eco:6.37.1'
implementation 'com.willfp:libreforge:3.72.1' implementation 'com.willfp:libreforge:3.74.0'
implementation 'org.joml:joml:1.10.4' implementation 'org.joml:joml:1.10.4'
compileOnly 'org.jetbrains:annotations:23.0.0' compileOnly 'org.jetbrains:annotations:23.0.0'

View File

@@ -4,34 +4,18 @@ import com.ticxo.modelengine.api.ModelEngineAPI
import com.willfp.ecopets.pets.Pet import com.willfp.ecopets.pets.Pet
import org.bukkit.Location import org.bukkit.Location
import org.bukkit.entity.ArmorStand import org.bukkit.entity.ArmorStand
import org.bukkit.entity.EntityType
import org.bukkit.inventory.EquipmentSlot
class ModelEnginePetEntity( class ModelEnginePetEntity(
pet: Pet, pet: Pet,
private val modelID: String private val modelID: String
) : PetEntity(pet) { ) : PetEntity(pet) {
override fun spawn(location: Location): ArmorStand { override fun spawn(location: Location): ArmorStand {
val stand = location.world!!.spawnEntity(location, EntityType.ARMOR_STAND) as ArmorStand val stand = emptyArmorStandAt(location, pet)
stand.isVisible = false
stand.isInvulnerable = true
stand.isPersistent = true
stand.removeWhenFarAway = false
stand.isSmall = true
stand.setGravity(false)
stand.isCollidable = false
for (slot in EquipmentSlot.values()) {
stand.addEquipmentLock(slot, ArmorStand.LockType.ADDING_OR_CHANGING)
}
val model = ModelEngineAPI.createActiveModel(modelID) val model = ModelEngineAPI.createActiveModel(modelID)
val modelled = ModelEngineAPI.createModeledEntity(stand) val modelled = ModelEngineAPI.createModeledEntity(stand)
modelled.addActiveModel(model) modelled.addActiveModel(model)
stand.isCustomNameVisible = true
stand.customName = pet.name
return stand return stand
} }
} }

View File

@@ -3,6 +3,8 @@ package com.willfp.ecopets.pets.entity
import com.willfp.ecopets.pets.Pet import com.willfp.ecopets.pets.Pet
import org.bukkit.Location import org.bukkit.Location
import org.bukkit.entity.ArmorStand import org.bukkit.entity.ArmorStand
import org.bukkit.entity.EntityType
import org.bukkit.inventory.EquipmentSlot
abstract class PetEntity( abstract class PetEntity(
val pet: Pet val pet: Pet
@@ -31,3 +33,23 @@ abstract class PetEntity(
} }
} }
} }
internal fun emptyArmorStandAt(location: Location, pet: Pet): ArmorStand {
val stand = location.world!!.spawnEntity(location, EntityType.ARMOR_STAND) as ArmorStand
stand.isVisible = false
stand.isInvulnerable = true
stand.isSmall = true
stand.setGravity(false)
stand.isCollidable = false
stand.isPersistent = false
for (slot in EquipmentSlot.values()) {
stand.addEquipmentLock(slot, ArmorStand.LockType.ADDING_OR_CHANGING)
}
stand.isCustomNameVisible = true
stand.customName = pet.name
return stand
}

View File

@@ -4,35 +4,18 @@ import com.willfp.eco.core.items.builder.SkullBuilder
import com.willfp.ecopets.pets.Pet import com.willfp.ecopets.pets.Pet
import org.bukkit.Location import org.bukkit.Location
import org.bukkit.entity.ArmorStand import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Entity
import org.bukkit.entity.EntityType
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.inventory.ItemStack import org.bukkit.inventory.ItemStack
class SkullPetEntity(pet: Pet) : PetEntity(pet) { class SkullPetEntity(pet: Pet) : PetEntity(pet) {
override fun spawn(location: Location): ArmorStand { override fun spawn(location: Location): ArmorStand {
val newStand = location.world!!.spawnEntity(location, EntityType.ARMOR_STAND) as ArmorStand val stand = emptyArmorStandAt(location, pet)
newStand.isVisible = false
newStand.isInvulnerable = true
newStand.isPersistent = true
newStand.removeWhenFarAway = false
newStand.isSmall = true
newStand.setGravity(false)
newStand.isCollidable = false
for (slot in EquipmentSlot.values()) {
newStand.addEquipmentLock(slot, ArmorStand.LockType.ADDING_OR_CHANGING)
}
val skull: ItemStack = SkullBuilder() val skull: ItemStack = SkullBuilder()
.setSkullTexture(pet.entityTexture) .setSkullTexture(pet.entityTexture)
.build() .build()
newStand.equipment?.helmet = skull stand.equipment?.helmet = skull
newStand.isCustomNameVisible = true
newStand.customName = pet.name
return newStand return stand
} }
} }

View File

@@ -1,4 +1,4 @@
#libreforge-updater #libreforge-updater
#Tue Jul 05 18:33:01 BST 2022 #Mon Jul 11 16:17:10 BST 2022
version=1.8.1 version=1.10.0
plugin-name=EcoPets plugin-name=EcoPets