Skip to content

Commit db3d663

Browse files
committed
feat: updated to beta-171, special thanks to aaron
1 parent 48095c0 commit db3d663

File tree

2 files changed

+31
-24
lines changed

2 files changed

+31
-24
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repositories {
1414

1515
dependencies {
1616
compileOnly("com.typewritermc:EntityExtension:0.9.0")
17-
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.9")
17+
compileOnly("com.ticxo.modelengine:ModelEngine:R4.1.0")
1818
}
1919

2020
typewriter {
@@ -25,7 +25,7 @@ typewriter {
2525
shortDescription = "Simple usage of ModelEngine for NPCs"
2626
description =
2727
"Adding the capability to use ModelEngine for non player characters in your quests. I need atleast 100 characters blablablalbal"
28-
engineVersion = "0.9.0-beta-170"
28+
engineVersion = "0.9.0-beta-171"
2929
channel = com.typewritermc.moduleplugin.ReleaseChannel.BETA
3030

3131
paper {

src/main/kotlin/entries/entity/ModelEngineEntity.kt

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import com.typewritermc.engine.paper.entry.entity.PositionProperty
1313
import com.typewritermc.engine.paper.entry.entity.SkinProperty
1414
import com.typewritermc.engine.paper.entry.entries.EntityProperty
1515
import com.typewritermc.engine.paper.entry.entries.Var
16+
import com.typewritermc.engine.paper.plugin
1617
import com.typewritermc.engine.paper.utils.toBukkitLocation
1718
import com.typewritermc.entity.entries.data.minecraft.GlowingEffectProperty
18-
import com.typewritermc.entity.entries.data.minecraft.SpeedData
1919
import com.typewritermc.entity.entries.data.minecraft.SpeedProperty
2020
import com.typewritermc.entity.entries.data.minecraft.living.EquipmentProperty
2121
import 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

Comments
 (0)