mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
fix preprocessors not applying reliably
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -166,6 +166,8 @@ public class BukkitChunkGenerator extends ChunkGenerator implements PlatformChun
|
||||
|
||||
return targetCache.aquire(() -> {
|
||||
IrisData data = IrisData.get(dataLocation);
|
||||
data.dump();
|
||||
data.clearLists();
|
||||
IrisDimension dimension = data.getDimensionLoader().load(dimensionKey);
|
||||
|
||||
if (dimension == null) {
|
||||
|
||||
@@ -14,9 +14,9 @@ abstract class EngineScript
|
||||
object EngineScriptDefinition : ScriptCompilationConfiguration(listOf(DataScriptDefinition), {
|
||||
providedProperties(
|
||||
"engine" to Engine::class,
|
||||
"complex" to IrisComplex::class,
|
||||
"seed" to Long::class,
|
||||
"dimension" to IrisDimension::class,
|
||||
"complex" to IrisComplex::class,
|
||||
"biome" to BiomeLookup::class,
|
||||
)
|
||||
}) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.volmit.iris.core.scripting.kotlin.base
|
||||
|
||||
import com.volmit.iris.core.loader.IrisRegistrant
|
||||
import com.volmit.iris.engine.framework.Engine
|
||||
import com.volmit.iris.engine.`object`.IrisDimension
|
||||
import kotlin.script.experimental.annotations.KotlinScript
|
||||
import kotlin.script.experimental.api.ScriptCompilationConfiguration
|
||||
import kotlin.script.experimental.api.providedProperties
|
||||
@@ -8,8 +10,13 @@ import kotlin.script.experimental.api.providedProperties
|
||||
@KotlinScript(fileExtension = "proc.kts", compilationConfiguration = PreprocessorScriptDefinition::class)
|
||||
abstract class PreprocessorScript
|
||||
|
||||
object PreprocessorScriptDefinition : ScriptCompilationConfiguration(listOf(EngineScriptDefinition), {
|
||||
providedProperties("object" to IrisRegistrant::class)
|
||||
object PreprocessorScriptDefinition : ScriptCompilationConfiguration(listOf(DataScriptDefinition), {
|
||||
providedProperties(
|
||||
"engine" to Engine::class,
|
||||
"seed" to Long::class,
|
||||
"dimension" to IrisDimension::class,
|
||||
"object" to IrisRegistrant::class
|
||||
)
|
||||
}) {
|
||||
private fun readResolve(): Any = PreprocessorScriptDefinition
|
||||
}
|
||||
@@ -33,18 +33,24 @@ data class IrisExecutionEnvironment(
|
||||
execute(script, PostMobSpawningScript::class.java, engine.parameters("location" to location, "entity" to mob))
|
||||
|
||||
override fun preprocessObject(script: String, `object`: IrisRegistrant) =
|
||||
execute(script, PreprocessorScript::class.java, engine.parameters("object" to `object`))
|
||||
execute(script, PreprocessorScript::class.java, engine.limitedParameters("object" to `object`))
|
||||
|
||||
override fun updateChunk(script: String, mantleChunk: MantleChunk, chunk: Chunk, executor: UpdateExecutor) =
|
||||
execute(script, ChunkUpdateScript::class.java, engine.parameters("mantleChunk" to mantleChunk, "chunk" to chunk, "executor" to executor))
|
||||
|
||||
private fun Engine.parameters(vararg values: Pair<String, Any?>): Map<String, Any?> {
|
||||
private fun Engine.limitedParameters(vararg values: Pair<String, Any?>): Map<String, Any?> {
|
||||
return mapOf(
|
||||
"data" to data,
|
||||
"engine" to this,
|
||||
"complex" to complex,
|
||||
"seed" to seedManager.seed,
|
||||
"dimension" to dimension,
|
||||
*values,
|
||||
)
|
||||
}
|
||||
|
||||
private fun Engine.parameters(vararg values: Pair<String, Any?>): Map<String, Any?> {
|
||||
return limitedParameters(
|
||||
"complex" to complex,
|
||||
"biome" to BiomeLookup(::getSurfaceBiome),
|
||||
*values,
|
||||
)
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.volmit.iris.core.scripting.kotlin.base.*
|
||||
import com.volmit.iris.core.scripting.kotlin.runner.Script
|
||||
import com.volmit.iris.core.scripting.kotlin.runner.ScriptRunner
|
||||
import com.volmit.iris.core.scripting.kotlin.runner.classpath
|
||||
import com.volmit.iris.core.scripting.kotlin.runner.valueOrNull
|
||||
import com.volmit.iris.core.scripting.kotlin.runner.value
|
||||
import com.volmit.iris.core.scripting.kotlin.runner.valueOrThrow
|
||||
import com.volmit.iris.util.collection.KMap
|
||||
import com.volmit.iris.util.data.KCache
|
||||
@@ -68,7 +68,7 @@ open class IrisSimpleExecutionEnvironment(
|
||||
return compile(name, type)
|
||||
.evaluate(properties)
|
||||
.valueOrThrow("Failed to evaluate script")
|
||||
.valueOrNull()
|
||||
.value()
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
@@ -21,10 +21,11 @@ internal fun <T, R> ResultWithDiagnostics<T>.map(transformer: (T) -> R): ResultW
|
||||
is ResultWithDiagnostics.Failure -> this
|
||||
}
|
||||
|
||||
internal fun EvaluationResult.valueOrNull() = returnValue.valueOrNull()
|
||||
internal fun ResultValue.valueOrNull(): Any? =
|
||||
internal fun EvaluationResult.value() = returnValue.value()
|
||||
internal fun ResultValue.value(): Any? =
|
||||
when (this) {
|
||||
is ResultValue.Value -> value
|
||||
is ResultValue.Error -> throw error
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user