Sorry this is the wrong forum, but the other ones link does not work
Whenever I try to execute the command in single player It just sends me 'An unexpected error occured trying to execute that command'
Here is the command code:
public static void register(CommandDispatcher<CommandSource> d) {
d.register(Commands.literal("import").requires(s->s.hasPermissionLevel(2))
.then(Commands.argument("modelFile", StringArgument.string())
.then(Commands.argument("xOrigin", IntegerArgumentType.integer())
.then(Commands.argument("yOrigin", IntegerArgumentType.integer())
.then(Commands.argument("zOrigin", IntegerArgumentType.integer())
.then(Commands.argument("blockID", ResourceLocationArgument.resourceLocation())
.suggests(blockSuggestions)//show the suggestions for all blocks
.executes(context -> {
String modelFile = context.getArgument("modelFile", String.class);
int x = context.getArgument("xOrigin", int.class);
int y = context.getArgument("yOrigin", int.class);
int z = context.getArgument("zOrigin", int.class);
Block block = ForgeRegistries.BLOCKS.getValue(
context.getArgument("blockID", ResourceLocation.class));
//handle stuff
return 0;
}).then(Commands.argument("scale", IntegerArgumentType.integer()))
.executes(context->{
String modelFile = context.getArgument("modelFile", String.class);
int x = context.getArgument("xOrigin", int.class);
int y = context.getArgument("yOrigin", int.class);
int z = context.getArgument("zOrigin", int.class);
int scale = context.getArgument("scale", int.class);
Block block = ForgeRegistries.BLOCKS.getValue(
context.getArgument("blockID", ResourceLocation.class));
//handle stuff, with scale argument
return 0;
})
))))));
}
The command gets registered as I can use it in game and It shows suggestions and tells me I have the correct number of args but whenever I enter, it just says there was an error. I debugged and the code does not even execute the execute lambas so It cant be the code (it doesnt event enter the execute methods)
What am I doing wrong?
Registering in main:
public ...() {
instance=this;
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(this::setup);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void setup(FMLServerStartingEvent event) {
ImportCommand.register(event.getCommandDispatcher());
System.out.println("\n\n\nLoaded the Import command\n\n\n");
}