Skip to content

Commit

Permalink
Tags and Applied Tags changes based on meta
Browse files Browse the repository at this point in the history
  • Loading branch information
gabber235 committed Dec 19, 2024
1 parent a99d2e4 commit 673a8d7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<Int> = Optional.empty(),
) : EntityData<SaddledProperty> {
override fun type(): KClass<SaddledProperty> = SaddledProperty::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ 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
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 = "",
Expand All @@ -34,6 +35,7 @@ data class TamedProperty(val tamed: Boolean) : EntityProperty {
fun applyTamedData(entity: WrapperEntity, property: TamedProperty) {
entity.metas {
meta<TameableMeta> { isTamed = property.tamed }
meta<BaseHorseMeta> { isTamed = property.tamed }
error("Could not apply TamedData to ${entity.entityType} entity.")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class HorseDefinition(
override val name: String = "",
override val displayName: Var<String> = 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<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = HorseEntity(player)
Expand All @@ -55,7 +55,7 @@ class HorseInstance(
override val name: String = "",
override val definition: Ref<HorseDefinition> = 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<Ref<EntityData<*>>> = emptyList(),
override val activity: Ref<out SharedEntityActivityEntry> = emptyRef(),
) : SimpleEntityInstance
Expand All @@ -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 -> {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LlamaDefinition(
override val name: String = "",
override val displayName: Var<String> = 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<Ref<EntityData<*>>> = emptyList(),
) : SimpleEntityDefinition {
override fun create(player: Player): FakeEntity = LlamaEntity(player)
Expand All @@ -53,7 +53,7 @@ class LlamaInstance(
override val name: String = "",
override val definition: Ref<LlamaDefinition> = 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<Ref<EntityData<*>>> = emptyList(),
override val activity: Ref<out SharedEntityActivityEntry> = emptyRef(),
) : SimpleEntityInstance
Expand All @@ -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)
Expand Down

0 comments on commit 673a8d7

Please sign in to comment.