From 673a8d7059abe3600cdfad0446580ab46d258000 Mon Sep 17 00:00:00 2001 From: Gabber235 Date: Thu, 19 Dec 2024 15:52:39 +0100 Subject: [PATCH] Tags and Applied Tags changes based on meta --- .../entity/entries/data/minecraft/living/SaddledData.kt | 6 ++++-- .../data/minecraft/living/horse/ChestedHorseChestMeta.kt | 2 +- .../entries/data/minecraft/living/horse/HorseEatingData.kt | 2 +- .../entries/data/minecraft/living/horse/HorseVariantData.kt | 4 ++-- .../entries/data/minecraft/living/tameable/TamedData.kt | 4 +++- .../entity/entries/entity/minecraft/HorseEntity.kt | 6 ++---- .../entity/entries/entity/minecraft/LlamaEntity.kt | 5 ++--- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/SaddledData.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/SaddledData.kt index 928cbce26b..22592ff9f4 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/SaddledData.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/SaddledData.kt @@ -1,6 +1,7 @@ package com.typewritermc.entity.entries.data.minecraft.living import com.typewritermc.core.books.pages.Colors +import com.typewritermc.core.extension.annotations.Default import com.typewritermc.core.extension.annotations.Entry import com.typewritermc.core.extension.annotations.Tags import com.typewritermc.engine.paper.entry.entity.SinglePropertyCollectorSupplier @@ -15,11 +16,12 @@ import java.util.* import kotlin.reflect.KClass @Entry("saddled_data", "If the entity has a saddle.", Colors.RED, "game-icons:saddle") -@Tags("horse_data", "pig_data", "saddled_data") +@Tags("saddled_data", "horse_data", "pig_data") class SaddledData( override val id: String = "", override val name: String = "", - val saddled: Boolean = false, + @Default("true") + val saddled: Boolean = true, override val priorityOverride: Optional = Optional.empty(), ) : EntityData { override fun type(): KClass = SaddledProperty::class diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/ChestedHorseChestMeta.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/ChestedHorseChestMeta.kt index 0ade11797f..fe64bbc5d8 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/ChestedHorseChestMeta.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/ChestedHorseChestMeta.kt @@ -14,7 +14,7 @@ import java.util.* import kotlin.reflect.KClass @Entry("chested_horse_chest_meta", "If the horse has a chest.", Colors.RED, "mdi:horse") -@Tags("chested_horse_data", "chested_horse_chest_meta") +@Tags("chested_horse_chest_meta", "chested_horse_meta") class ChestedHorseChestData( override val id: String = "", override val name: String = "", diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseEatingData.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseEatingData.kt index 827b32bcf5..e63497262a 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseEatingData.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseEatingData.kt @@ -14,7 +14,7 @@ import java.util.* import kotlin.reflect.KClass @Entry("eating_data", "If the entity is eating.", Colors.RED, "mdi:horse") -@Tags("eating_data") +@Tags("eating_data", "horse_data") class HorseEatingData( override val id: String = "", override val name: String = "", diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt index 1f6d3f09ed..c2a4069883 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/horse/HorseVariantData.kt @@ -2,6 +2,7 @@ package com.typewritermc.entity.entries.data.minecraft.living.horse import com.typewritermc.core.books.pages.Colors import com.typewritermc.core.extension.annotations.Entry +import com.typewritermc.core.extension.annotations.Tags import com.typewritermc.engine.paper.entry.entity.SinglePropertyCollectorSupplier import com.typewritermc.engine.paper.entry.entries.EntityData import com.typewritermc.engine.paper.entry.entries.EntityProperty @@ -13,8 +14,7 @@ import java.util.* import kotlin.reflect.KClass @Entry("horse_variant_data", "The variant of the horse.", Colors.RED, "mdi:horse") -@Tags("horse_variant_data") - +@Tags("horse_variant_data", "horse_data") class HorseVariantData( override val id: String = "", override val name: String = "", diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/tameable/TamedData.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/tameable/TamedData.kt index bcf3c877a2..31df45077f 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/tameable/TamedData.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/data/minecraft/living/tameable/TamedData.kt @@ -8,6 +8,7 @@ import com.typewritermc.engine.paper.entry.entity.SinglePropertyCollectorSupplie import com.typewritermc.engine.paper.entry.entries.EntityData import com.typewritermc.engine.paper.entry.entries.EntityProperty import com.typewritermc.engine.paper.extensions.packetevents.metas +import me.tofaa.entitylib.meta.mobs.horse.BaseHorseMeta import me.tofaa.entitylib.meta.types.TameableMeta import me.tofaa.entitylib.wrapper.WrapperEntity import org.bukkit.entity.Player @@ -15,7 +16,7 @@ import java.util.* import kotlin.reflect.KClass @Entry("tamed_data", "When a tamable entity is tamed", Colors.RED, "game-icons:sitting-dog") -@Tags("tamed_data") +@Tags("tamed_data", "horse_data") class TamedData( override val id: String = "", override val name: String = "", @@ -34,6 +35,7 @@ data class TamedProperty(val tamed: Boolean) : EntityProperty { fun applyTamedData(entity: WrapperEntity, property: TamedProperty) { entity.metas { meta { isTamed = property.tamed } + meta { isTamed = property.tamed } error("Could not apply TamedData to ${entity.entityType} entity.") } } \ No newline at end of file diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt index c5e30140ce..ce59f5569d 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/HorseEntity.kt @@ -36,7 +36,7 @@ class HorseDefinition( override val name: String = "", override val displayName: Var = ConstVar(""), override val sound: Sound = Sound.EMPTY, - @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "horse_variant_data", "horse_data", "eating_data", "chested_horse_data") + @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "horse_data") override val data: List>> = emptyList(), ) : SimpleEntityDefinition { override fun create(player: Player): FakeEntity = HorseEntity(player) @@ -55,7 +55,7 @@ class HorseInstance( override val name: String = "", override val definition: Ref = emptyRef(), override val spawnLocation: Position = Position.ORIGIN, - @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "horse_variant_data", "horse_data", "eating_data", "chested_horse_data") + @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "horse_data") override val data: List>> = emptyList(), override val activity: Ref = emptyRef(), ) : SimpleEntityInstance @@ -66,9 +66,7 @@ private class HorseEntity(player: Player) : WrapperFakeEntity( ) { override fun applyProperty(property: EntityProperty) { when (property) { - is AgeableProperty -> applyAgeableData(entity, property) is HorseVariantProperty -> applyHorseVariantData(entity, property) - is ChestedHorseChestProperty -> applyChestedHorseChestData(entity, property) is SaddledProperty -> applySaddledData(entity, property) is EatingProperty -> applyHorseEatingData(entity, property) else -> {} diff --git a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/LlamaEntity.kt b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/LlamaEntity.kt index abbd8dedd7..14a5103259 100644 --- a/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/LlamaEntity.kt +++ b/extensions/EntityExtension/src/main/kotlin/com/typewritermc/entity/entries/entity/minecraft/LlamaEntity.kt @@ -34,7 +34,7 @@ class LlamaDefinition( override val name: String = "", override val displayName: Var = ConstVar(""), override val sound: Sound = Sound.EMPTY, - @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "llama_data", "chested_horse_data") + @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "horse_data", "chested_horse_data", "llama_data") override val data: List>> = emptyList(), ) : SimpleEntityDefinition { override fun create(player: Player): FakeEntity = LlamaEntity(player) @@ -53,7 +53,7 @@ class LlamaInstance( override val name: String = "", override val definition: Ref = emptyRef(), override val spawnLocation: Position = Position.ORIGIN, - @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "ageable_data", "llama_data", "chested_horse_data") + @OnlyTags("generic_entity_data", "living_entity_data", "mob_data", "horse_data", "chested_horse_data", "llama_data") override val data: List>> = emptyList(), override val activity: Ref = emptyRef(), ) : SimpleEntityInstance @@ -64,7 +64,6 @@ private class LlamaEntity(player: Player) : WrapperFakeEntity( ) { override fun applyProperty(property: EntityProperty) { when (property) { - is AgeableProperty -> applyAgeableData(entity, property) is LlamaVariantProperty -> applyLlamaVariantData(entity, property) is LlamaCarpetColorProperty -> applyLlamaCarpetColorData(entity, property) is ChestedHorseChestProperty -> applyChestedHorseChestData(entity, property)