Compare commits

...

20 Commits

Author SHA1 Message Date
Auxilor
a27ebb1b5c libreforge-updater 2022-07-24 22:49:45 +01:00
Auxilor
afafd86eaf libreforge-updater 2022-07-24 21:51:44 +01:00
Auxilor
49a2713017 libreforge-updater 2022-07-23 17:43:45 +01:00
Auxilor
a4263e8397 libreforge-updater 2022-07-22 14:21:36 +01:00
Auxilor
17f3aa8862 Updated kotlin 2022-07-22 14:17:51 +01:00
Auxilor
c94024ea19 libreforge-updater 2022-07-21 20:15:00 +01:00
Auxilor
1daa52e1f4 Changed pet display 2022-07-21 16:39:47 +01:00
Auxilor
a06808f802 Updated to 1.11.2 2022-07-21 16:15:23 +01:00
Auxilor
91cf08f0ac Fixed pets obstructing the view when looking up 2022-07-21 16:15:17 +01:00
Auxilor
9a7ff1760c Updated to 1.11.1 2022-07-21 15:50:40 +01:00
Will FP
f2c3f569b7 Merge pull request #10 from Sedri05/master
Fixed Default Pets
2022-07-21 15:25:03 +01:00
Auxilor
508cb3e216 libreforge-updater 2022-07-20 00:11:07 +01:00
Auxilor
5f998f4bad libreforge-updater 2022-07-13 21:23:31 +01:00
Auxilor
e4b468b0da libreforge-updater 2022-07-12 14:59:32 +01:00
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
Sedri05
0bb4aa6d51 Update pets.yml 2022-07-03 01:30:07 +02:00
6 changed files with 58 additions and 49 deletions

View File

@@ -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.72.1'
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) {

View File

@@ -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
)
}

View File

@@ -4,34 +4,18 @@ import com.ticxo.modelengine.api.ModelEngineAPI
import com.willfp.ecopets.pets.Pet
import org.bukkit.Location
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.EntityType
import org.bukkit.inventory.EquipmentSlot
class ModelEnginePetEntity(
pet: Pet,
private val modelID: String
) : PetEntity(pet) {
override fun spawn(location: Location): ArmorStand {
val stand = location.world!!.spawnEntity(location, EntityType.ARMOR_STAND) as ArmorStand
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 stand = emptyArmorStandAt(location, pet)
val model = ModelEngineAPI.createActiveModel(modelID)
val modelled = ModelEngineAPI.createModeledEntity(stand)
modelled.addActiveModel(model)
stand.isCustomNameVisible = true
stand.customName = pet.name
return stand
}
}

View File

@@ -3,6 +3,8 @@ package com.willfp.ecopets.pets.entity
import com.willfp.ecopets.pets.Pet
import org.bukkit.Location
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.EntityType
import org.bukkit.inventory.EquipmentSlot
abstract class PetEntity(
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 org.bukkit.Location
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
class SkullPetEntity(pet: Pet) : PetEntity(pet) {
override fun spawn(location: Location): ArmorStand {
val newStand = location.world!!.spawnEntity(location, EntityType.ARMOR_STAND) as ArmorStand
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 stand = emptyArmorStandAt(location, pet)
val skull: ItemStack = SkullBuilder()
.setSkullTexture(pet.entityTexture)
.build()
newStand.equipment?.helmet = skull
newStand.isCustomNameVisible = true
newStand.customName = pet.name
stand.equipment?.helmet = skull
return newStand
return stand
}
}

View File

@@ -1,4 +1,4 @@
#libreforge-updater
#Tue Jul 05 18:33:01 BST 2022
version=1.8.1
#Sun Jul 24 22:49:45 BST 2022
version=1.13.0
plugin-name=EcoPets