Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ff6d68a5b | ||
|
|
a27ebb1b5c | ||
|
|
afafd86eaf | ||
|
|
49a2713017 | ||
|
|
a4263e8397 | ||
|
|
17f3aa8862 | ||
|
|
c94024ea19 | ||
|
|
1daa52e1f4 | ||
|
|
a06808f802 | ||
|
|
91cf08f0ac | ||
|
|
9a7ff1760c | ||
|
|
f2c3f569b7 | ||
|
|
508cb3e216 | ||
|
|
5f998f4bad | ||
|
|
e4b468b0da | ||
|
|
675d2b8508 | ||
|
|
edddd67f58 | ||
|
|
ed676e50c7 | ||
|
|
b36551a179 | ||
|
|
053f22258a | ||
|
|
0bb4aa6d51 |
@@ -4,7 +4,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,12 +48,12 @@ 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.78.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'
|
||||||
|
|
||||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.6.21'
|
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class PetDisplay(
|
|||||||
) : Listener {
|
) : Listener {
|
||||||
private var tick = 0
|
private var tick = 0
|
||||||
|
|
||||||
private val trackedEntities = mutableMapOf<UUID, ArmorStand>()
|
private val trackedEntities = mutableMapOf<UUID, PetArmorStand>()
|
||||||
|
|
||||||
fun tickAll() {
|
fun tickAll() {
|
||||||
for (player in Bukkit.getOnlinePlayers()) {
|
for (player in Bukkit.getOnlinePlayers()) {
|
||||||
@@ -55,15 +55,30 @@ class PetDisplay(
|
|||||||
private fun getLocation(player: Player): Location {
|
private fun getLocation(player: Player): Location {
|
||||||
val offset = player.eyeLocation.direction.clone().normalize()
|
val offset = player.eyeLocation.direction.clone().normalize()
|
||||||
.multiply(-1)
|
.multiply(-1)
|
||||||
.apply { y = abs(y) }
|
.apply {
|
||||||
|
y = abs(y)
|
||||||
|
|
||||||
|
if (abs(x) < 0.5) {
|
||||||
|
x = 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abs(z) < 0.5) {
|
||||||
|
z = 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
.rotateAroundY(PI / 6)
|
.rotateAroundY(PI / 6)
|
||||||
|
|
||||||
return player.eyeLocation.clone().add(offset)
|
return player.eyeLocation.clone().add(offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getOrNew(player: Player): ArmorStand? {
|
private fun getOrNew(player: Player): ArmorStand? {
|
||||||
val existing = trackedEntities[player.uniqueId]
|
val tracked = trackedEntities[player.uniqueId]
|
||||||
|
val existing = tracked?.stand
|
||||||
|
|
||||||
val pet = player.activePet
|
val pet = player.activePet
|
||||||
|
if (pet != tracked?.pet) {
|
||||||
|
tracked?.stand?.remove()
|
||||||
|
}
|
||||||
|
|
||||||
if (existing == null || existing.isDead || pet == null) {
|
if (existing == null || existing.isDead || pet == null) {
|
||||||
existing?.remove()
|
existing?.remove()
|
||||||
@@ -76,15 +91,15 @@ class PetDisplay(
|
|||||||
val location = getLocation(player)
|
val location = getLocation(player)
|
||||||
val stand = pet.makePetEntity().spawn(location)
|
val stand = pet.makePetEntity().spawn(location)
|
||||||
|
|
||||||
trackedEntities[player.uniqueId] = stand
|
trackedEntities[player.uniqueId] = PetArmorStand(stand, pet)
|
||||||
}
|
}
|
||||||
|
|
||||||
return trackedEntities[player.uniqueId]
|
return trackedEntities[player.uniqueId]?.stand
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shutdown() {
|
fun shutdown() {
|
||||||
for (stand in trackedEntities.values) {
|
for (stand in trackedEntities.values) {
|
||||||
stand.remove()
|
stand.stand.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
trackedEntities.clear()
|
trackedEntities.clear()
|
||||||
@@ -92,7 +107,12 @@ class PetDisplay(
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onLeave(event: PlayerQuitEvent) {
|
fun onLeave(event: PlayerQuitEvent) {
|
||||||
trackedEntities[event.player.uniqueId]?.remove()
|
trackedEntities[event.player.uniqueId]?.stand?.remove()
|
||||||
trackedEntities.remove(event.player.uniqueId)
|
trackedEntities.remove(event.player.uniqueId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private data class PetArmorStand(
|
||||||
|
val stand: ArmorStand,
|
||||||
|
val pet: Pet
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#libreforge-updater
|
#libreforge-updater
|
||||||
#Tue Jul 05 18:33:01 BST 2022
|
#Mon Jul 25 17:03:22 BST 2022
|
||||||
version=1.8.1
|
version=1.14.0
|
||||||
plugin-name=EcoPets
|
plugin-name=EcoPets
|
||||||
|
|||||||
Reference in New Issue
Block a user