Skip to content

Commit 0b8f5ae

Browse files
committed
修复了数据模板类型变量nbt路径错误的问题
1 parent 3dac093 commit 0b8f5ae

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

src/main/kotlin/top/mcfpp/lang/DataTemplateObject.kt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ open class DataTemplateObject : Var<DataTemplateObject> {
3838
* @param template 模板的类型
3939
* @param identifier 标识符
4040
*/
41-
constructor(template: DataTemplate, identifier: String = UUID.randomUUID().toString()) {
41+
constructor(template: DataTemplate, identifier: String = UUID.randomUUID().toString()): super(identifier) {
4242
this.templateType = template
4343
this.name = identifier
4444
this.identifier = identifier
@@ -286,20 +286,7 @@ class DataTemplateObjectConcrete: DataTemplateObject, MCFPPValue<CompoundTag>{
286286
val parent = this.parent
287287

288288
if(parent != null){
289-
val cmd = when(parent){
290-
is ClassPointer -> {
291-
Commands.selectRun(parent)
292-
}
293-
is ObjectClass -> {
294-
arrayOf(Command.build("execute as ${parent.uuid} run "))
295-
}
296-
else -> TODO()
297-
298-
}
299-
if(cmd.size == 2){
300-
Function.addCommand(cmd[0])
301-
}
302-
Function.addCommand(cmd.last().build(Commands.dataSetValue(nbtPath, value)))
289+
Function.addCommands(Commands.selectRun(parent, Commands.dataSetValue(nbtPath, value)))
303290
}else {
304291
Function.addCommand(Commands.dataSetValue(nbtPath, value))
305292
}

src/main/kotlin/top/mcfpp/model/function/Function.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,12 @@ open class Function : Member, FieldContainer, Serializable {
453453
* @param returnType
454454
*/
455455
fun buildReturnVar(returnType: MCFPPType): Var<*>{
456-
return if(returnType == MCFPPBaseType.Void) Void()
457-
else Var.buildUnConcrete("return",returnType,this)
456+
return if(returnType == MCFPPBaseType.Void) {
457+
Void()
458+
}
459+
else {
460+
Var.buildUnConcrete("return", returnType, this)
461+
}
458462
}
459463

460464
/**
@@ -654,12 +658,7 @@ open class Function : Member, FieldContainer, Serializable {
654658
LogProcessor.error("Function $identifier has no return value but tried to return a ${v.type}")
655659
return
656660
}
657-
try {
658-
returnVar.assign(v)
659-
} catch (e: VariableConverseException) {
660-
LogProcessor.error("Cannot convert " + v.javaClass + " to " + currBaseFunction.returnVar.javaClass)
661-
throw VariableConverseException()
662-
}
661+
returnVar.assign(v)
663662
}
664663

665664
/**

0 commit comments

Comments
 (0)