Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a27ebb1b5c | ||
|
|
afafd86eaf | ||
|
|
49a2713017 | ||
|
|
a4263e8397 | ||
|
|
17f3aa8862 | ||
|
|
c94024ea19 | ||
|
|
1daa52e1f4 | ||
|
|
a06808f802 | ||
|
|
91cf08f0ac | ||
|
|
9a7ff1760c | ||
|
|
f2c3f569b7 | ||
|
|
508cb3e216 | ||
|
|
0bb4aa6d51 |
@@ -4,7 +4,7 @@ buildscript {
|
||||
}
|
||||
|
||||
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 {
|
||||
compileOnly 'com.willfp:eco:6.37.1'
|
||||
implementation 'com.willfp:libreforge:3.74.2'
|
||||
implementation 'com.willfp:libreforge:3.77.0'
|
||||
implementation 'org.joml:joml:1.10.4'
|
||||
|
||||
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) {
|
||||
|
||||
@@ -19,7 +19,7 @@ class PetDisplay(
|
||||
) : Listener {
|
||||
private var tick = 0
|
||||
|
||||
private val trackedEntities = mutableMapOf<UUID, ArmorStand>()
|
||||
private val trackedEntities = mutableMapOf<UUID, PetArmorStand>()
|
||||
|
||||
fun tickAll() {
|
||||
for (player in Bukkit.getOnlinePlayers()) {
|
||||
@@ -55,15 +55,30 @@ class PetDisplay(
|
||||
private fun getLocation(player: Player): Location {
|
||||
val offset = player.eyeLocation.direction.clone().normalize()
|
||||
.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)
|
||||
|
||||
return player.eyeLocation.clone().add(offset)
|
||||
}
|
||||
|
||||
private fun getOrNew(player: Player): ArmorStand? {
|
||||
val existing = trackedEntities[player.uniqueId]
|
||||
val tracked = trackedEntities[player.uniqueId]
|
||||
val existing = tracked?.stand
|
||||
|
||||
val pet = player.activePet
|
||||
if (pet != tracked?.pet) {
|
||||
tracked?.stand?.remove()
|
||||
}
|
||||
|
||||
if (existing == null || existing.isDead || pet == null) {
|
||||
existing?.remove()
|
||||
@@ -76,15 +91,15 @@ class PetDisplay(
|
||||
val location = getLocation(player)
|
||||
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() {
|
||||
for (stand in trackedEntities.values) {
|
||||
stand.remove()
|
||||
stand.stand.remove()
|
||||
}
|
||||
|
||||
trackedEntities.clear()
|
||||
@@ -92,7 +107,12 @@ class PetDisplay(
|
||||
|
||||
@EventHandler
|
||||
fun onLeave(event: PlayerQuitEvent) {
|
||||
trackedEntities[event.player.uniqueId]?.remove()
|
||||
trackedEntities[event.player.uniqueId]?.stand?.remove()
|
||||
trackedEntities.remove(event.player.uniqueId)
|
||||
}
|
||||
|
||||
private data class PetArmorStand(
|
||||
val stand: ArmorStand,
|
||||
val pet: Pet
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#libreforge-updater
|
||||
#Wed Jul 13 21:23:31 BST 2022
|
||||
version=1.10.2
|
||||
#Sun Jul 24 22:49:45 BST 2022
|
||||
version=1.13.0
|
||||
plugin-name=EcoPets
|
||||
|
||||
Reference in New Issue
Block a user