Jump to content

Zen3515

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Zen3515's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. It's only normal for the main thread to block. I mean you join the main thread, it will be blocked until the other thread finish.
  2. You can take a look at my github, I implement almost every button possible there. But some will only work in single player. https://github.com/Zen3515/Minecraft-Http-Controller/blob/master/src/main/java/com/zen3515/mcrestful/ClientSocket.java#L148
  3. Yes, I do aware of that, however, it is a single player mod, and it just work for this case Thanks, that's really helpful
  4. Thanks, so I just enqueue it to the server, if only I knew it was this simple ? if(mcInstance.objectMouseOver.getType() == RayTraceResult.Type.ENTITY) { final int mountingEntityId = ((EntityRayTraceResult)mcInstance.objectMouseOver).getEntity().getEntityId(); this.player.getServer().enqueue(new TickDelayedTask(this.player.getServer().getTickCounter(), () -> { this.player.startRiding(this.player.world.getEntityByID(mountingEntityId), true); // server side })); }
  5. Could you provide some code snippet? I intended to use this mod on a single player world. If I only use context.getSource().asPlayer().startRiding(((EntityRayTraceResult)Minecraft.getInstace().objectMouseOver).getEntity(), true); I'll need to re-login to the world to see the effect, Or you're saying that I can't use Minecraft.getInstace().objectMouseOver and I must ray trace them myself?
  6. My goal: • A player entity shall be mounted on any Entity My step: • ray trace entity player is looking at • I'm stuck here, mount player on the entity. For testing purpose, the player will always be looking at a Minecart. if (Minecraft.getInstace().objectMouseOver.getType() == RayTraceResult.Type.ENTITY) { Minecraft.getInstace().enqueue(() -> { // execute on the same thread context.getSource().asPlayer().startRiding(((EntityRayTraceResult)Minecraft.getInstace().objectMouseOver).getEntity(), true); // server side Minecraft.getInstace().player.startRiding(((EntityRayTraceResult)Minecraft.getInstace().objectMouseOver).getEntity(), true); // client side context.getSource().asPlayer().connection.sendPacket(new SSetPassengersPacket(((EntityRayTraceResult)mcInstance.objectMouseOver).getEntity())); // update client? } } I try swap ordering of the three lines that execute on main thread, have no success. By no success, I mean that, either I need to re-login the game to see myself on the cart, or when I re-log in I'm not in the cart anymore. (If server success, need to re-login to see myself on the cart) (If client success, can't press shift to get out of the cart) (not once that both side are success) Is there anything that I'm missing? SOLVED by change from Minecraft.getInstace().enqueue(...) to context.getSource().asPlayer().getServer().enqueue(...)
  7. How could I accomplish that? I could not find replacement for addScheduledTask minecraft.addScheduledTask(() -> minecraft.displayGuiScreen((Screen)null)); Edited, so the name become more generic, now it is solved. Thanks. mcInstance.enqueue(() -> mcInstance.displayGuiScreen((Screen)null));
  8. Sorry for late respond, I cannot use Robot, I tried that, and it says java.awt.AWTException: headless environment during Initialization of the Robot. I'm trying to play Minecraft with voice, here are my codes Link to Github To do that I have to have a way to control Minecraft from another process (Likely by python program) And for this question specifically, I'm trying to close the pause menu. I forgot to mention that this code run in a new thread, I don't know if that's the cause.
  9. Hi, after I pause the game, I want to close the pause menu too. I use the code below to pause. Minecraft.getInstance().displayInGameMenu(false); The game did pause, but I want to close it too, so I tried mcInstance.displayGuiScreen((Screen)null); mcInstance.mouseHelper.grabMouse(); And this mcInstance.currentScreen.keyPressed(256, 0, 0); // press esc I did manage to close the pause menu, but it has some unexpected behavior. The problem is that after the GUI was closed, I can't use mouse to pan around, it is acting like it was still in the menu with invisible pointer. I can click I can walk. I've looked at source code how it was done, and I just repeat it, but it doesn't work ?. Edited: solved Turns out I should not interact with Minecraft from different thread. For 1.15.2 to execute task on the main thread, use enqueue instead Minecraft.getInstance().enqueue(() -> Minecraft.getInstance().displayGuiScreen((Screen)null));
×
×
  • Create New...

Important Information

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