Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.