Skip to content

Commit 60fef54

Browse files
committed
现在栈模拟用的nbt路径不再包含命名空间
1 parent 305b3ab commit 60fef54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+630
-1486
lines changed

ResourceIDGenerator.jar

-159 Bytes
Binary file not shown.

src/main/java/top/mcfpp/mni/NBTListConcreteData.java

Lines changed: 12 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -27,158 +27,39 @@ public class NBTListConcreteData {
2727

2828
@InsertCommand
2929
@MNIFunction(normalParams = {"E e"}, caller = "list", genericType = "E")
30-
public static void add(Var<?> e, NBTListConcrete caller){
30+
public static void add(Var<?> e, NBTListConcrete caller) throws IOException {
3131
if(e instanceof MCFPPValue<?>){
32-
//都是确定的
33-
//直接添加值
3432
caller.getValue().add(e);
3533
}else {
36-
//e不是确定的,但是list可能是确定的可能不是确定的
37-
caller.toDynamic(true);
38-
Command[] command;
39-
if(e.parentClass() != null) e = e.getTempVar();
40-
if(e.isTemp()) e.storeToStack();
41-
if(caller.getParent() != null){
42-
command = Commands.INSTANCE.selectRun(caller.getParent(),
43-
new Command("data modify " +
44-
"entity @s " +
45-
"data." + caller.getIdentifier() + " " +
46-
"append from " +
47-
"storage mcfpp:system " +
48-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier() + " "), true);
49-
}else {
50-
command = new Command[]{ new Command("data modify " +
51-
"storage mcfpp:system " +
52-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
53-
"append from " +
54-
"storage mcfpp:system " +
55-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier() + " ")};
56-
}
57-
Function.Companion.addCommands(command);
34+
NBTListData.add(e, (NBTList) caller.toDynamic(true));
5835
}
5936
}
6037

6138
@InsertCommand
6239
@MNIFunction(normalParams = {"list<E> list"}, caller = "list", genericType = "E")
6340
public static void addAll(NBTList list, NBTListConcrete caller){
6441
if(list instanceof MCFPPValue<?> ec){
65-
//都是确定的
66-
//直接添加值
6742
caller.getValue().addAll((Collection) ec.getValue());
6843
}else {
69-
caller.toDynamic(true);
70-
Command[] command;
71-
NBTBasedData l;
72-
if(list.parentClass() != null) {
73-
l = list.getTempVar();
74-
}else{
75-
l = list;
76-
}
77-
if(caller.getParent() != null){
78-
command = Commands.INSTANCE.selectRun(caller.getParent(),"data modify " +
79-
"entity @s " +
80-
"data." + caller.getIdentifier() + " " +
81-
"append from " +
82-
"storage mcfpp:system " +
83-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + l.getIdentifier() + "[]", true);
84-
}else {
85-
command = new Command[]{ new Command("data modify " +
86-
"storage mcfpp:system " +
87-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
88-
"append from " +
89-
"storage mcfpp:system " +
90-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + l.getIdentifier() + "[]")};
91-
}
92-
Function.Companion.addCommands(command);
44+
NBTListData.addAll(list, (NBTList) caller.toDynamic(true));
9345
}
9446
}
9547

9648
@InsertCommand
9749
@MNIFunction(normalParams = {"int index", "E e"}, caller = "list", genericType = "E")
98-
public static void insert(MCInt index, Var<?> e, NBTListConcrete caller){
50+
public static void insert(MCInt index, Var<?> e, NBTListConcrete caller) throws IOException {
9951
if(e instanceof MCFPPValue<?> && index instanceof MCIntConcrete indexC){
100-
//都是确定的
101-
//直接添加值
10252
caller.getValue().add(indexC.getValue(), e);
103-
}else if(index instanceof MCIntConcrete indexC){
104-
//e不是确定的,index是确定的,所以可以直接调用命令而不需要宏
105-
int i = indexC.getValue();
106-
caller.toDynamic(true);
107-
Command[] command;
108-
if(e.parentClass() != null) e = e.getTempVar();
109-
if(caller.getParent() != null){
110-
command = Commands.INSTANCE.selectRun(caller.getParent(), "data modify " +
111-
"entity @s " +
112-
"data." + caller.getIdentifier() + " " +
113-
"insert " + i + " from " +
114-
"storage mcfpp:system " +
115-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true);
116-
}else {
117-
command = new Command[] {new Command("data modify " +
118-
"storage mcfpp:system " +
119-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
120-
"insert " + i + " from " +
121-
"storage mcfpp:system " +
122-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier())};
123-
}
124-
Function.Companion.addCommands(command);
125-
}else if(e instanceof MCFPPValue<?>){
126-
//e是确定的,index不是确定的,需要使用宏
127-
caller.toDynamic(true);
128-
Tag<?> tag = NBTUtil.INSTANCE.varToNBT(e);
129-
try {
130-
if(caller.getParent() != null){
131-
var command = Commands.INSTANCE.selectRun(caller.getParent(),
132-
new Command("data modify " +
133-
"entity @s " +
134-
"data." + caller.getIdentifier() + " " +
135-
"insert").build("", "$" + index.getIdentifier(), true).build ("value " + SNBTUtil.toSNBT(tag), true), true
136-
);
137-
Function.Companion.addCommand(command[0]);
138-
var f = command[1].buildMacroFunction();
139-
Function.Companion.addCommands(f);
140-
} else {
141-
var command = new Command("data modify " +
142-
"storage mcfpp:system " +
143-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
144-
"insert").build("", "$" + index.getIdentifier(), true).build("value " + SNBTUtil.toSNBT(tag), true);
145-
var f = command.buildMacroFunction();
146-
Function.Companion.addCommands(f);
147-
}
148-
} catch (IOException ex) {
149-
throw new RuntimeException(ex);
150-
}
151-
} else{
152-
//e是不确定的,index也不是确定的
153-
caller.toDynamic(true);
154-
if(e.parentClass() != null) e = e.getTempVar();
155-
Command[] command;
156-
if(caller.getParent() != null){
157-
command = Commands.INSTANCE.selectRun(caller.getParent(), new Command("data modify " +
158-
"entity @s " +
159-
"data." + caller.getIdentifier() + " " +
160-
"insert").build("", "$" + index.getIdentifier(), true).build ("from " +
161-
"storage mcfpp:system " +
162-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true), true);
163-
} else {
164-
command = new Command[] {new Command("data modify " +
165-
"storage mcfpp:system " +
166-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + caller.getIdentifier() + " " +
167-
"insert").build("", "$" + index.getIdentifier(), true).build("from " +
168-
"storage mcfpp:system " +
169-
Project.INSTANCE.getCurrNamespace() + ".stack_frame[" + caller.getStackIndex() + "]." + e.getIdentifier(), true)};
170-
}
171-
if(command.length == 2) Function.Companion.addCommand(command[0]);
172-
var f = command[command.length - 1].buildMacroFunction();
173-
Function.Companion.addCommands(f);
53+
}else if(index instanceof MCIntConcrete indexC) {
54+
NBTListData.insert(index, e, (NBTList) caller.toDynamic(true));
17455
}
17556
}
17657

177-
@InsertCommand
178-
@MNIFunction(normalParams = {"E e"}, caller = "list", genericType = "E")
179-
public static void remove(Var<?> e, NBTListConcrete caller){
180-
//TODO NBT的api本来就没有remove(E e)这个方法,只有remove(int index)
181-
}
58+
//@InsertCommand
59+
//@MNIFunction(normalParams = {"E e"}, caller = "list", genericType = "E")
60+
//public static void remove(Var<?> e, NBTListConcrete caller){
61+
// //TODO NBT的api本来就没有remove(E e)这个方法,只有remove(int index)
62+
//}
18263

18364
@InsertCommand
18465
@MNIFunction(normalParams = {"int index"}, caller = "list", genericType = "E")
@@ -221,6 +102,7 @@ public static void lastIndexOf(Var<?> e, NBTListConcrete caller, ValueWrapper<MC
221102
}
222103
}
223104

105+
@SuppressWarnings("SuspiciousMethodCalls")
224106
@MNIFunction(normalParams = {"E e"}, caller = "list", genericType = "E", returnType = "bool")
225107
public static void contains(Var<?> e, NBTListConcrete caller, ValueWrapper<ScoreBool> returnVar){
226108
if(e instanceof MCFPPValue eC){

0 commit comments

Comments
 (0)