Allow Creating Blank Tags
ScriptCraft/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-04-25 21:25:57 -04:00
parent d2ba0b6cf2
commit b9235876b2
2 changed files with 30 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import net.minecraft.nbt.AbstractNumberTag;
import net.minecraft.nbt.ByteTag;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.DoubleTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
@ -71,5 +72,8 @@ class TagBridges {
AbstractListTag<?> tag = (AbstractListTag<?>) args[0];
return tag.size();
});
Bridges.addBridge("CompoundTag.create", args -> new CompoundTag());
Bridges.addBridge("ListTag.create", args -> new ListTag());
}
}

View File

@ -59,6 +59,19 @@ export class CompoundTag {
keys(): string[] {
return useBridge('CompoundTag.keys', this.javaObject) as string[];
}
/**
* Create Empty Tag
* @returns Empty Tag
*/
static create(): CompoundTag {
const obj = useBridge('CompoundTag.create') as JavaObject;
if (obj) {
return new CompoundTag(obj);
} else {
return null;
}
}
}
/**
@ -103,4 +116,17 @@ export class ListTag {
size(): number {
return useBridge('ListTag.size', this.javaObject) as number;
}
/**
* Create Empty Tag
* @returns Empty Tag
*/
static create(): ListTag {
const obj = useBridge('ListTag.create') as JavaObject;
if (obj) {
return new ListTag(obj);
} else {
return null;
}
}
}