Skip to content
Snippets Groups Projects
Commit 59cced5b authored by lion's avatar lion Committed by Hiroku
Browse files

Fix animations not playing on Pokédex

parent b828fe2b
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import net.minecraft.world.entity.Entity
import java.lang.reflect.Type
/**
......@@ -43,36 +44,21 @@ class PoseAdapter(
val pose = JsonPose(model, obj)
val conditionsList = mutableListOf<(PosableState) -> Boolean>()
val mustBeTouchingWater = json.get("isTouchingWater")?.asBoolean
if (mustBeTouchingWater != null) {
conditionsList.add { mustBeTouchingWater == it.getEntity()?.isInWater }
}
val mustBeTouchingWaterOrRain = json.get("isInWaterOrRain")?.asBoolean
if (mustBeTouchingWaterOrRain != null) {
conditionsList.add { mustBeTouchingWaterOrRain == it.getEntity()?.isInWaterOrRain }
}
val mustBeSubmergedInWater = json.get("isUnderWater")?.asBoolean
if (mustBeSubmergedInWater != null) {
conditionsList.add { mustBeSubmergedInWater == it.getEntity()?.isUnderWater }
}
val mustBeStandingOnRedSand = json.get("isStandingOnRedSand")?.asBoolean
if (mustBeStandingOnRedSand != null) {
conditionsList.add { mustBeStandingOnRedSand == it.getEntity()?.isStandingOnRedSand() }
}
val mustBeStandingOnSand = json.get("isStandingOnSand")?.asBoolean
if (mustBeStandingOnSand != null) {
conditionsList.add { mustBeStandingOnSand == it.getEntity()?.isStandingOnSand() }
}
val mustBeStandingOnSandOrRedSand = json.get("isStandingOnSandOrRedSand")?.asBoolean
if (mustBeStandingOnSandOrRedSand != null) {
conditionsList.add { mustBeStandingOnSandOrRedSand == it.getEntity()?.isStandingOnSandOrRedSand() }
}
val mustBeDusk = json.get("isDusk")?.asBoolean
if (mustBeDusk != null) {
conditionsList.add { mustBeDusk == it.getEntity()?.isDusk() }
fun addCondition(jsonKey: String, condition: (Entity, Boolean) -> Boolean) {
json.get(jsonKey)?.asBoolean?.let { expectedValue ->
conditionsList.add { it.getEntity()?.let { entity -> condition(entity, expectedValue) } ?: true }
}
}
addCondition("isTouchingWater") { entity, expectedValue -> entity.isInWater == expectedValue }
addCondition("isInWaterOrRain") { entity, expectedValue -> entity.isInWaterOrRain == expectedValue }
addCondition("isUnderWater") { entity, expectedValue -> entity.isUnderWater == expectedValue }
addCondition("isStandingOnRedSand") { entity, expectedValue -> entity.isStandingOnRedSand() == expectedValue }
addCondition("isStandingOnSand") { entity, expectedValue -> entity.isStandingOnSand() == expectedValue }
addCondition("isStandingOnSandOrRedSand") { entity, expectedValue -> entity.isStandingOnSandOrRedSand() == expectedValue }
addCondition("isDusk") { entity, expectedValue -> entity.isDusk() == expectedValue }
conditionsList.addAll(poseConditionReader(json))
if (json.has("conditions")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment