Jump to content

Recommended Posts

Posted

I'm looking to update a command tree I made for 1.12 to 1.15.2.

Obviously Commands have changed to the CommandDispatcher now, so does anybody know of any good/simple source code I could look at for a basic command tree?

 

Thanks for your help!

Posted (edited)

Update:

I'm definitely misunderstanding this. Here's my code:

public class Command {

	public static void register(CommandDispatcher<CommandSource> dispatcher) {

		final LiteralArgumentBuilder<CommandSource> root = Commands.literal("commandtree");
		root.then(Commands.literal("edit_a_float").then(Commands.argument("float", FloatArgumentType.floatArg()))).executes(source -> {
			return editPower(source.getSource(), source.getSource().asPlayer(), FloatArgumentType.getFloat(source, "float"));
			}).then(Commands.argument("player", EntityArgument.player())).executes(source -> {
			return editPower(source.getSource(), EntityArgument.getPlayer(source, "player"), FloatArgumentType.getFloat(source, "float"));
			});	
		root.then(Commands.literal("edit_a_cooldown").then(Commands.argument("ticks", IntegerArgumentType.integer()))).executes(source -> {
			return editCooldown(source.getSource(), source.getSource().asPlayer(), IntegerArgumentType.getInteger(source, "ticks"));
			}).then(Commands.argument("player", EntityArgument.player())).executes(source -> {
			return editCooldown(source.getSource(), EntityArgument.getPlayer(source, "player"), IntegerArgumentType.getInteger(source, "ticks"));
			});
		dispatcher.register(root);
	}

	private static int editPower(CommandSource source, PlayerEntity player, float amount) {
		System.out.println("Adjusted power by " + amount + "!");
		return 1;
	}
	
	private static int editCooldown(CommandSource source, PlayerEntity player, int ticks) {
		System.out.println("Adjusted cooldown by " + ticks + "!");
		return 1;
	}
}

 

When entering my command, edit_a_float and edit_a_cooldown are recommended, but it also recommends usernames and all the @s.

 

When typing in a command I get the message 'Unknown Command' or 'Incorrect argument for command'.

Please could someone explain to me where I'm going wrong?

Edited by squidlex
Posted

Because that's how commands work. @p and not supplying a target means that it affects the player typing the command. But what if you wanted to affect a different player?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
  On 7/9/2020 at 5:18 PM, Draco18s said:

Because that's how commands work. @p and not supplying a target means that it affects the player typing the command. But what if you wanted to affect a different player?

Expand  

Thanks for your reply, but I'm now seeing either I worded my question poorly or I don't quite understand your reply.

It doesn't sugget @p or anything like that at all when I type /commandtree edit_a_float but it does when I type /commandtree.

 

When I type /commandtree edit_a_float and then type anything after that it returns Unknown Command.

Posted

I misunderstood the problem.  I am not sure, then.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

If my understanding is correct, .executes() needs to put inside the bracket of the .then (all "connected" action needs to do that)which should look like this

		root.then(Commands.literal("edit_a_float")
                  .then(Commands.argument("float", FloatArgumentType.floatArg()) -> removed two brackets here
          .executes(source -> {
			return editPower(source.getSource(), source.getSource().asPlayer(), FloatArgumentType.getFloat(source, "float"));
			}))); -> added two brackets here

 

Edited by poopoodice
  • Thanks 1
Posted
  On 7/9/2020 at 9:00 PM, poopoodice said:

If my understanding is correct, .executes() needs to put inside the bracket of the .then (all "connected" action needs to do that)which should looks like this

		root.then(Commands.literal("edit_a_float")
                  .then(Commands.argument("float", FloatArgumentType.floatArg()) -> removed two brackets here
          .executes(source -> {
			return editPower(source.getSource(), source.getSource().asPlayer(), FloatArgumentType.getFloat(source, "float"));
			}))); -> added two brackets here

 

Expand  

That was the problem!

Thanks for spotting that, I'm really bad at spotting little errors like this.

 

Thank you so much I can finally finish porting my mod! :)

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So, i'm hosting (or attempting to host) a port-forwarded modded server for 1.12.2. There's quite a few mods in this pack, but they all run and have no compatibility issues (besides something causing the game to crash if you go fullscreen, a problem ive given up trying to identify or fix). It can run on 6gb of ram or less, and works fine in singleplayer. All of my friends that want to join have the exact same mod/config/game setup as I do (I personally helped them set everything up). Just to be safe, we've all allocated 12 gigabytes of RAM to the installation, and I've also allocated 12GB to the server itself. I am able to join with no issue and it runs fine. However, when they try to join, it gets stuck in the 'logging in' screen before their game becomes unresponsive. When they close it, it gives them the exit code 805306369, which usually means not enough RAM, but this cant be the case. On my screen, in the server, it shows them joining, and then disconnecting, so I dont think its a port-forwarding issue. They can all run it just fine in singleplayer as well. The annoying bit about this particular issue is that it generates no crash log. Does anyone have any suggestions? Thanks! Here is my debug log, and his, starting from the same place. MINE: [132647] [Netty Client IO #5INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132653.817 [132653] [Client threadINFO] [minecraftGuiConnecting] Connecting to 0, 25565 132654.682 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.common.core.transformer.ClassNodeTransformertransform29] Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 132654.684 [132654] [Netty Client IO #9INFO] [STDOUT] [xaero.map.core.transformer.ClassNodeTransformertransform29] Transforming class net.minecraft.client.network.NetHandlerPlayClient 132654.764 [132654] [Netty Client IO #9INFO] [FML] Server protocol version 2 132654.777 [132654] [Netty Client IO #9INFO] [FML] Attempting connection with missing mods [ctm, fusion] at SERVER 132656.193 [132656] [Client threadINFO] [FML] Injecting existing registry data into this client instance 132659.081 [132659] [Client threadINFO] [FML] Applying holder lookups 132659.082 [132659] [Client threadINFO] [FML] Holder lookups applied 132659.092 [132659] [Netty Client IO #9INFO] [FML] [Netty Client IO #9] Client side modded connection established HIS: [13:12:16] [Netty Client IO #0/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:25.597 [13:12:25] [Client thread/INFO] [minecraft/GuiConnecting]: Connecting to (my IP address and the server port 25565) 13:12:26.805 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.common.core.transformer.ClassNodeTransformer:transform:29]: Transforming class brz net.minecraft.client.network.NetHandlerPlayClient 13:12:26.808 [13:12:26] [Netty Client IO #1/INFO] [STDOUT]: [xaero.map.core.transformer.ClassNodeTransformer:transform:29]: Transforming class net.minecraft.client.network.NetHandlerPlayClient 13:12:26.936 [13:12:26] [Netty Client IO #1/INFO] [FML]: Server protocol version 2 13:12:27.114 [13:12:27] [Netty Client IO #1/INFO] [FML]: Attempting connection with missing mods [ctm, fusion] at SERVER 13:12:27.480 [13:12:27] [Client thread/INFO] [FML]: Injecting existing registry data into this client instance 13:12:30.669 [13:12:30] [Client thread/INFO] [FML]: Applying holder lookups 13:12:30.671 [13:12:30] [Client thread/INFO] [FML]: Holder lookups applied 13:13:04.700 Process crashed with exit code -805306369 P.S - Both mods "CTM" and "FUSION" are present in both our folders so idk what that's about.
    • Please read the FAQ (link is orange banner at top of page), and post logs as described there, to an external site such as https://mclo.gs  
    • Hi! I've got a modpack with about 56 mods that has, up until now, been running pretty well. Starting today, any world i try to open causes minecraft to crash. It isn't the game itself- the main menu opens up fine.  I tried changing the ram allocated with both the minecraft launcher, and the forge launcher. No success with either. I tried deleting the JEI folder and letting it remake itself. No success. I tried turning off multiple mods. No success. I tried turning off JEI incase that was the issue. No dice. If you need to know specifically which mods I have installed, let me know, and I'll send them all to you. I've included the very first crash log. Please let me know if there's anything I can do! https://pastebin.com/Zfv6gWN7 -- Crash log on Pastebin (if this doesnt work, let me know)
    • I had this issue on ftb-stoneblock-3-1.11.5 (most recent version right now, installed through CurseForge), but my friend didn't get it when installing the same pack in the same way. I tried reinstalling the modpack several times, didn't help. I later finally solved it by updating REI Plugin Compatibilities (REIPC) in my StoneBlock client from version 8.0.69 to 8.0.89 (the most recent one as of now).
    • Delete the personality-client.toml file in your config folder and add this mod: https://www.curseforge.com/minecraft/mc-mods/night-config-fixes  
  • Topics

×
×
  • Create New...

Important Information

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