Jump to content

Recommended Posts

Posted

Hello. I want to make jump boost boots. But I'm not going to use jumpboost effect. I want to give player extra force.
I tried to make it like this:

Quote
@Override
    public void inventoryTick(ItemStack pStack, Level pLevel, Entity pEntity, int pSlotId, boolean pIsSelected) {
        super.inventoryTick(pStack, pLevel, pEntity, pSlotId, pIsSelected);
        if(!pLevel.isClientSide) {
            if (pEntity instanceof Player player) {
                if (player.getItemBySlot(EquipmentSlot.FEET) == pStack) {

                    if (Minecraft.getInstance().options.keyJump.consumeClick() && player.onGround()) {
                        player.push(0.0,1.0,0.0);
                        player.sendSystemMessage(Component.literal("test" + count));
                        count++;


                    }


                }
            }
        }

    }

 

But when I jump "player.push" method doesn't always work but "sendSystemMessage" works absolutly fine.

What i did wrong?

Posted

From what I've found, you can only manipulate the player's motion on the client side. It's extremely annoying. If you know how to use packets, you can use packets to transfer the information from the server. Take a look at my implementation on GitHub here if you want. You'd want something similar to the way I've done the PlayerAddVelocityPacket. Unfortunately, packets are rather complex; I'd recommend you watch a few tutorials on them before even trying to work with them. Feel free to use my code as a reference, but please give attribution if you plan to directly copy it.

Posted

Thanks a lot. But I found an information that "Minecraft.getInstance().options.keyJump.consumeClick()" and other keybinding methods don't work on the server. But how when all my method works? I placed "if(!pLevel.isClientSide)" statement in the top of all but it somehow do the "sendSystemMessage" method.

 

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.