@@ -13,9 +13,9 @@ import com.typewritermc.engine.paper.entry.entity.PositionProperty
1313import com.typewritermc.engine.paper.entry.entity.SkinProperty
1414import com.typewritermc.engine.paper.entry.entries.EntityProperty
1515import com.typewritermc.engine.paper.entry.entries.Var
16+ import com.typewritermc.engine.paper.plugin
1617import com.typewritermc.engine.paper.utils.toBukkitLocation
1718import com.typewritermc.entity.entries.data.minecraft.GlowingEffectProperty
18- import com.typewritermc.entity.entries.data.minecraft.SpeedData
1919import com.typewritermc.entity.entries.data.minecraft.SpeedProperty
2020import com.typewritermc.entity.entries.data.minecraft.living.EquipmentProperty
2121import com.typewritermc.entity.entries.data.minecraft.living.ScaleProperty
@@ -125,28 +125,31 @@ class ModelEngineEntity(
125125
126126 override fun spawn (location : PositionProperty ) {
127127 if (modelId.isEmpty() || ModelEngineAPI .getBlueprint(modelId) == null ) return
128- entity.pollLocation(location.toBukkitLocation())
129128
130- modeledEntity = ModelEngineAPI .createModeledEntity(entity).apply {
131- isModelRotationLocked = false
132- }
133- activeModel = ModelEngineAPI .createActiveModel(modelId)
134- modeledEntity.addModel(activeModel, true )
135- entity.setForceViewing(player, true )
136-
137- // This only exists in the newer developer builds, so there's a little fallback
138- val callbackField = entity.data::class .members
139- .find { it.name == " syncUpdateCallback" }
140-
141- if (callbackField != null ) {
142- subscribeId = entity.data.syncUpdateCallback.subscribe {
143- this .location.poll()?.let {
144- if (defaultAnimationSettings.walkAnimation) entity.isWalking =
145- isMoving(previousLocation.get(), it)
146- entity.pollLocation(it)
147- }
129+ bukkitRun {
130+ entity.pollLocation(location.toBukkitLocation())
131+
132+ modeledEntity = ModelEngineAPI .createModeledEntity(entity).apply {
133+ isModelRotationLocked = false
148134 }
149- } else tickInThread = true
135+ activeModel = ModelEngineAPI .createActiveModel(modelId)
136+ modeledEntity.addModel(activeModel, true )
137+ entity.setForceViewing(player, true )
138+
139+ // This only exists in the newer developer builds, so there's a little fallback
140+ val callbackField = entity.data::class .members
141+ .find { it.name == " syncUpdateCallback" }
142+
143+ if (callbackField != null ) {
144+ subscribeId = entity.data.syncUpdateCallback.subscribe {
145+ this .location.poll()?.let {
146+ if (defaultAnimationSettings.walkAnimation) entity.isWalking =
147+ isMoving(previousLocation.get(), it)
148+ entity.pollLocation(it)
149+ }
150+ }
151+ } else tickInThread = true
152+ }
150153
151154 super .spawn(location)
152155 }
@@ -174,6 +177,10 @@ class ModelEngineEntity(
174177 return this .entityId == entityId
175178 }
176179
180+ fun bukkitRun (runnable : Runnable ) {
181+ Bukkit .getScheduler().runTask(plugin, runnable)
182+ }
183+
177184 fun height (): Double {
178185 val blueprint = ModelEngineAPI .getBlueprint(modelId) ? : return 0.0
179186 val scale = property(ScaleProperty ::class )?.scale ? : 1.0
@@ -182,7 +189,7 @@ class ModelEngineEntity(
182189 }
183190
184191 fun speed (): Float {
185- return property(SpeedProperty ::class )?.speed ? : 0.2085f ;
192+ return property(SpeedProperty ::class )?.speed ? : 0.2085f
186193 }
187194
188195 fun isMoving (prev : Location , current : Location , threshold : Double = 0.01): Boolean {
0 commit comments