@@ -2,117 +2,56 @@ package dev.helight.kotale.ext
22
33import com.hypixel.hytale.component.ComponentAccessor
44import com.hypixel.hytale.component.Ref
5- import com.hypixel.hytale.server.core.entity.Frozen
6- import com.hypixel.hytale.server.core.entity.UUIDComponent
7- import com.hypixel.hytale.server.core.entity.damage.DamageDataComponent
5+ import com.hypixel.hytale.component.Store
6+ import com.hypixel.hytale.math.vector.Transform
87import com.hypixel.hytale.server.core.entity.entities.Player
9- import com.hypixel.hytale.server.core.entity.nameplate.Nameplate
10- import com.hypixel.hytale.server.core.modules.entity.component.*
11- import com.hypixel.hytale.server.core.modules.entity.damage.DeathComponent
12- import com.hypixel.hytale.server.core.modules.entity.item.ItemComponent
13- import com.hypixel.hytale.server.core.modules.entity.repulsion.Repulsion
14- import com.hypixel.hytale.server.core.modules.physics.component.Velocity
15- import com.hypixel.hytale.server.core.modules.projectile.config.StandardPhysicsProvider
8+ import com.hypixel.hytale.server.core.modules.entity.teleport.Teleport
9+ import com.hypixel.hytale.server.core.modules.entitystats.EntityStatMap
10+ import com.hypixel.hytale.server.core.modules.entitystats.asset.DefaultEntityStatTypes
1611import com.hypixel.hytale.server.core.universe.PlayerRef
12+ import com.hypixel.hytale.server.core.universe.world.World
1713import com.hypixel.hytale.server.core.universe.world.storage.EntityStore
18- import java.util.*
1914
2015val Ref <EntityStore >.player: Player get() = this .store.player(this )
2116val Ref <EntityStore >.playerRef: PlayerRef get() = this .store.playerRef(this )
22- val Ref <EntityStore >.playerRefOrNull: PlayerRef ? get() = this .store.maybePlayerRef(this )
17+ val Ref <EntityStore >.playerRefOrNull: PlayerRef ? get() = this .store.playerRefOrNull(this )
18+ val PlayerRef .playerOrNull: Player ? get() = this .reference?.player
19+
20+ fun Store<EntityStore>.heal (ref : Ref <EntityStore >) {
21+ val comp = getComponent(ref, EntityStatMap .getComponentType())
22+ comp?.resetStatValue(DefaultEntityStatTypes .getHealth())
23+ }
24+
25+ fun Store<EntityStore>.teleport (ref : Ref <EntityStore >, world : World , transform : Transform ) {
26+ this .addComponent(
27+ ref,
28+ Teleport .getComponentType(),
29+ Teleport (world, transform.position.clone(), transform.rotation.clone())
30+ )
31+ }
2332
2433fun ComponentAccessor<EntityStore>.playerRef (ref : Ref <EntityStore >): PlayerRef {
2534 return this .getComponent(ref, PlayerRef .getComponentType()) as PlayerRef
2635}
2736
37+ @Deprecated(" Name change for consistency" , replaceWith = ReplaceWith (" playerRefOrNull" ))
2838fun ComponentAccessor<EntityStore>.maybePlayerRef (ref : Ref <EntityStore >): PlayerRef ? {
2939 return this .getComponent(ref, PlayerRef .getComponentType())
3040}
3141
42+ fun ComponentAccessor<EntityStore>.playerRefOrNull (ref : Ref <EntityStore >): PlayerRef ? {
43+ return this .getComponent(ref, PlayerRef .getComponentType())
44+ }
45+
3246fun ComponentAccessor<EntityStore>.player (ref : Ref <EntityStore >): Player {
3347 return this .getComponent(ref, Player .getComponentType()) as Player
3448}
3549
50+ @Deprecated(" Name change for consistency" , replaceWith = ReplaceWith (" playerOrNull" ))
3651fun ComponentAccessor<EntityStore>.maybePlayer (ref : Ref <EntityStore >): Player ? {
3752 return this .getComponent(ref, Player .getComponentType())
3853}
3954
40- fun ComponentAccessor<EntityStore>.transform (ref : Ref <EntityStore >): TransformComponent {
41- return this .getComponent(ref, TransformComponent .getComponentType()) as TransformComponent
42- }
43-
44- fun ComponentAccessor<EntityStore>.uuid (ref : Ref <EntityStore >): UUID {
45- return (this .getComponent(ref, UUIDComponent .getComponentType()) as UUIDComponent ).uuid
46- }
47-
48- fun ComponentAccessor<EntityStore>.scale (ref : Ref <EntityStore >): Float {
49- return (this .getComponent(ref, EntityScaleComponent .getComponentType()) as EntityScaleComponent ).scale
50- }
51-
52- fun ComponentAccessor<EntityStore>.velocity (ref : Ref <EntityStore >): Velocity {
53- return this .getComponent(ref, Velocity .getComponentType()) as Velocity
54- }
55-
56- fun ComponentAccessor<EntityStore>.standardPhysics (ref : Ref <EntityStore >): StandardPhysicsProvider {
57- return this .getComponent(ref, StandardPhysicsProvider .getComponentType()) as StandardPhysicsProvider
58- }
59-
60- fun ComponentAccessor<EntityStore>.boundingBox (ref : Ref <EntityStore >): BoundingBox {
61- return this .getComponent(ref, BoundingBox .getComponentType()) as BoundingBox
62- }
63-
64- fun ComponentAccessor<EntityStore>.headRotation (ref : Ref <EntityStore >): HeadRotation {
65- return this .getComponent(ref, HeadRotation .getComponentType()) as HeadRotation
66- }
67-
68- fun ComponentAccessor<EntityStore>.audio (ref : Ref <EntityStore >): AudioComponent {
69- return this .getComponent(ref, AudioComponent .getComponentType()) as AudioComponent
70- }
71-
72- fun ComponentAccessor<EntityStore>.model (ref : Ref <EntityStore >): ModelComponent {
73- return this .getComponent(ref, ModelComponent .getComponentType()) as ModelComponent
74- }
75-
76- fun ComponentAccessor<EntityStore>.persistentModel (ref : Ref <EntityStore >): PersistentModel {
77- return this .getComponent(ref, PersistentModel .getComponentType()) as PersistentModel
78- }
79-
80- fun ComponentAccessor<EntityStore>.item (ref : Ref <EntityStore >): ItemComponent {
81- return this .getComponent(ref, ItemComponent .getComponentType()) as ItemComponent
82- }
83-
84- fun ComponentAccessor<EntityStore>.nameplate (ref : Ref <EntityStore >): Nameplate {
85- return this .getComponent(ref, Nameplate .getComponentType()) as Nameplate
86- }
87-
88- fun ComponentAccessor<EntityStore>.repulsion (ref : Ref <EntityStore >): Repulsion {
89- return this .getComponent(ref, Repulsion .getComponentType()) as Repulsion
90- }
91-
92- fun ComponentAccessor<EntityStore>.damageData (ref : Ref <EntityStore >): DamageDataComponent {
93- return this .getComponent(ref, DamageDataComponent .getComponentType()) as DamageDataComponent
94- }
95-
96- fun ComponentAccessor<EntityStore>.maybeDeath (ref : Ref <EntityStore >): DeathComponent ? {
97- return this .getComponent(ref, DeathComponent .getComponentType())
98- }
99-
100- fun ComponentAccessor<EntityStore>.intangible (ref : Ref <EntityStore >): Boolean {
101- return this .getComponent(ref, Intangible .getComponentType()) != null
102- }
103-
104- fun ComponentAccessor<EntityStore>.invulnerable (ref : Ref <EntityStore >): Boolean {
105- return this .getComponent(ref, Invulnerable .getComponentType()) != null
106- }
107-
108- fun ComponentAccessor<EntityStore>.interactable (ref : Ref <EntityStore >): Boolean {
109- return this .getComponent(ref, Interactable .getComponentType()) != null
110- }
111-
112- fun ComponentAccessor<EntityStore>.frozen (ref : Ref <EntityStore >): Boolean {
113- return this .getComponent(ref, Frozen .getComponentType()) != null
114- }
115-
116- fun ComponentAccessor<EntityStore>.prop (ref : Ref <EntityStore >): Boolean {
117- return this .getComponent(ref, PropComponent .getComponentType()) != null
55+ fun ComponentAccessor<EntityStore>.playerOrNull (ref : Ref <EntityStore >): Player ? {
56+ return this .getComponent(ref, Player .getComponentType())
11857}
0 commit comments