Namespace support in old schematic command
Changes to be committed: modified: src/main/java/org/dimdev/dimdoors/command/SchematicCommand.java
This commit is contained in:
parent
88210b1965
commit
b204259fe1
1 changed files with 23 additions and 20 deletions
|
@ -5,6 +5,7 @@ import java.io.InputStream;
|
||||||
|
|
||||||
import org.dimdev.dimcore.schematic.Schematic;
|
import org.dimdev.dimcore.schematic.Schematic;
|
||||||
import org.dimdev.dimcore.schematic.SchematicConverter;
|
import org.dimdev.dimcore.schematic.SchematicConverter;
|
||||||
|
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
|
@ -19,28 +20,30 @@ public class SchematicCommand {
|
||||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
dispatcher.register(literal("schematicold")
|
dispatcher.register(literal("schematicold")
|
||||||
.then(literal("place")
|
.then(literal("place")
|
||||||
.then(argument("schematic_name", StringArgumentType.string())
|
.then(argument("namespace", new SchematicNamespaceArgumentType())
|
||||||
.executes(ctx -> {
|
.then(argument("schematic_name", StringArgumentType.string())
|
||||||
SchematicConverter.reloadConversions();
|
.executes(ctx -> {
|
||||||
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
SchematicConverter.reloadConversions();
|
||||||
String id = StringArgumentType.getString(ctx, "schematic_name");
|
ServerPlayerEntity player = ctx.getSource().getPlayer();
|
||||||
|
String id = StringArgumentType.getString(ctx, "schematic_name");
|
||||||
|
String ns = SchematicNamespaceArgumentType.getValue(ctx, "namespace");
|
||||||
|
try (InputStream in = SchematicCommand.class.getResourceAsStream("/data/dimdoors/pockets/schematic/" + ns + "/" + id + ".schem")) {
|
||||||
|
Schematic.fromTag(NbtIo.readCompressed(in))
|
||||||
|
.place(
|
||||||
|
player.world,
|
||||||
|
(int) player.getPos().x,
|
||||||
|
(int) player.getPos().y,
|
||||||
|
(int) player.getPos().z
|
||||||
|
);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
try (InputStream in = SchematicCommand.class.getResourceAsStream("/data/dimdoors/pockets/schematic/ruins/" + id + ".schem")) {
|
System.out.println(id + " placed");
|
||||||
Schematic.fromTag(NbtIo.readCompressed(in))
|
|
||||||
.place(
|
|
||||||
player.world,
|
|
||||||
(int) player.getPos().x,
|
|
||||||
(int) player.getPos().y,
|
|
||||||
(int) player.getPos().z
|
|
||||||
);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(id + " placed");
|
return 1;
|
||||||
|
}
|
||||||
return 1;
|
)
|
||||||
}
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue