Jump to content

Recommended Posts

Posted (edited)

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");
	}

 

Edited by Shadow_tingBRO

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.