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

Long story short, I'm writing some mod which allows you to increase your arrow speed and bow draw speed.

Currently I'm handling this though events.

    @SubscribeEvent
    public void onArrowSpeed(@NotNull EntityJoinLevelEvent event) {
        if (event.getEntity() instanceof Arrow arrow) {
            if (arrow.getOwner() instanceof ServerPlayer serverPlayer) {
                serverPlayer.getCapability(PlayerCapabilityProvider.PLAYER_CAP).ifPresent(capability -> {
                    if (capability.isUnlocked(serverPlayer, ARROW_SPEED)) {
                        int level = capability.getLevel(serverPlayer, ARROW_SPEED);
                        //Level is value between 0 and 20;
                        if (level > 0) {
                            float modifier = 1.0F + level * 0.05F;
                            arrow.setDeltaMovement(arrow.getDeltaMovement().scale(modifier));
                        }
                    }
                });
            }
        }
    }

    @SubscribeEvent
    public void onBowDraw(@NotNull ArrowNockEvent event) {
        if (event.getEntity() instanceof ServerPlayer serverPlayer) {
            if (event.getBow().getItem() instanceof BowItem) {
                serverPlayer.getCapability(PlayerCapabilityProvider.PLAYER_CAP).ifPresent(capability -> {
                    if (capability.isUnlocked(serverPlayer, BOW_DRAW)) {
                        int level = capability.getLevel(serverPlayer, BOW_DRAW);
                        //Level is value between 0 and 10;
                        if (level > 0) {
                        //I have used AT to make this field public from protected;
                            serverPlayer.useItemRemaining -= level;
                        }
                    }
                });
            }
        }
    }
}

Problem I have is this delta movement data is not syncronized with the client, because when I shoot the arrow, at first the arrow goes in another direction and later actually syncs to it's real position.

In other words client-side animation is bugged/not properly synced.

To better visualize the problem I'm including a video:

https://streamable.com/x741gp

Any ideas how can I fix this?

Try setting

arrow.hasImpulse = true

after you change the velocity.

If you look at ServerEntity.sendChanges() that should cause it to send an update packet instead of waiting 20 ticks (the arrow's updateInterval).

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

Already tried that, unfortunately it doesn't work. Also tried setting field arrow.hurtMarked = true; , but that also doesn't work.

I think your problem is caused by the ClientBoundSetEntityMotionPacket which clamps the maximum delta at +/- 3.9d

Obviously, the same clamp doesn't happen to the real data on the server so there is an inconsistency.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.