Jump to content

somewhatOfACoder

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by somewhatOfACoder

  1. You used to be able to do DimensionManager#getWorld to get a world but DimensionManager disappeared in 1.16 How do I go about getting a world?
  2. If I can't make custom commands from scratch, then is there a method in a class somewhere to execute a command, so I can just have my custom command run a vanilla command? For example, /pm would just run /msg with the targets and the message.
  3. I decided to make a custom command for fun, similar to the /msg command. The code for the command is below: public class PrivateMessageCommand { public static void register(CommandDispatcher<CommandSource> dispatcher) { dispatcher.register(Commands.literal("pm").requires((context) -> { return context.hasPermissionLevel(0); }).then(Commands.argument("targets", EntityArgument.players()) .then(Commands.argument("message", MessageArgument.message()).executes((context) -> { ITextComponent itextcomponent = MessageArgument.getMessage(context, "message"); int i = 0; for (ServerPlayerEntity serverplayerentity : EntityArgument.getPlayers(context, "targets")) { serverplayerentity.sendMessage(TextComponentUtils.func_240645_a_(context.getSource(), itextcomponent, serverplayerentity, 0), Util.DUMMY_UUID); ++i; } return i; })))); } } It is supposed to work like the /msg command where the syntax of the command is the following: /pm <targets> <message> This works in single player but not on a realm/server, and I don't know why. The message command can be used without permissions, which I tried to replicate here but returning a permission level of 0, however my command doesn't show up in the prompt when I type it while in a realm. How do I go about getting my command to work on a server?
  4. Unforntunately I haven't got it to work. I tried sending two presses as you said, one down then one up, but it didn't work. Do I need to have some sort of delay inbetween? And if so how do I do that
  5. Ok I am now stumped. I read the input guide and made a callback method for the keyboard which allowed me to get the keycode, scancode, action and modifier of whatever key I typed. However after using these values as parameters for KeyboardListener#onKeyEvent, nothing happened. For example, the space bar has a keycode of 32, a scancode of 57, an action of 1 when pressed and no modifiers. When I put these values directly into KeyboardListener#onKeyEvent nothing happened. Help?
  6. Ok so I changed the method I made to be the following: public static void jump() { Minecraft mc = Minecraft.getInstance(); int jumpKeyCode = mc.gameSettings.keyBindJump.getKey().getKeyCode(); int scanCode = jumpKeyCode; int action = 1; int modifiers = 0; mc.keyboardListener.onKeyEvent(mc.getMainWindow().getHandle(), jumpKeyCode, scanCode, action, modifiers); } However it still doesn't work. The keyCode is fine, but I am not sure about how to get the scanCode. I had a look at KeyboardListener#onKeyEvent and it seems that if the action is 1 then the key will be pressed. I am also not sure about the modifiers because I can't find where it is used.
  7. Looking at both KeyboardListener#setupCallbacks and MouseHelper#registerCallbacks, I can see that I need to use the following: // for the keyboard this.onKeyEvent(windowPointer, key, scanCode, action, modifiers); // for the mouse this.mouseButtonCallback(handle1, button, action, modifiers); However I am unsure as to how to get the windowPointer and the handle1. From what I understand, InputMappings#setKeyCallbacks gives the necessary parameters, but calling this again would mean that I would need my own onKeyEvent and mouseButtonCallback methods to handle the input. Do I need to call InputMappings#setKeyCallbacks again or is there a nice way to get the windowPointer and the other parameters?
  8. I am trying to simulate keyboard and mouse input for a neural network but I can't figure out how to actually get the keys to be pressed. I put the following code into a separate class but when I call the jump method nothing happens. public static void jump() { Minecraft mc = Minecraft.getInstance(); KeyBinding.setKeyBindState(mc.gameSettings.keyBindJump.getKey(), true); KeyBinding.onTick(mc.gameSettings.keyBindJump.getKey()); } The method is indeed being called but the jump keybind isn't changing whatsoever. How do I go about simulating these inputs?
  9. uhhhh about that. there isn't an error anymore, so I can't show u a screenshot. However, I remember clearly that the error said something along the lines of the following: Error: typetools-0.8.1.jar specified in the classpath does not exist C:\\blahblahblah\.gradle\caches\modules-2\files-2.1\net.jodah\type-tools\0.8.1\d12de898d333cb7eb0e39a35db03c1e09d92d595\typetools-0.8.1.jar it wasn't an error that was spit out by the game, but by eclipse itself when trying to run the runClient thing
  10. So I was playing around with my mod, and something magical happened. I got an error saying that typetools-0.8.1 didn't exist. After reading the error more thoroughly, I navigated my way to the jar file for typetools, and surprise surprise, typetools-0.8.1 didn't exist. typetools-0.8.3 had taken its place. I tried running the setup commands again, doing gradlew genEclipseRuns first, then gradlew eclipse The commands executed successfully, but there was no overall change. I still couldn't run my mod in the testing environment. So I searched for the error on google, and I wasn't surprised to see that there weren't any results. I then google for forge typetools. And BAM. There was the answer. typetools-0.8.3 had just been released. So I downloaded the jar file for 0.8.1, put it into the expected directory, and now everything is fine. However, I am unsure as to how to change the classpath so that I can use typetools-0.8.3 instead of the older 0.8.1 Could I get some help on this?
×
×
  • Create New...

Important Information

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