mojira.dev
MC-308572

Changing the selected hotbar slot is now delayed by one tick

In void() function of Minecraft.java:


	public void tick() {
		this.clientTickCount++;
		if (this.level != null && !this.pause) {
			this.level.tickRateManager().tick();
		}

		if (this.rightClickDelay > 0) {
			this.rightClickDelay--;
		}

		ProfilerFiller profiler = Profiler.get();
		profiler.push("gameMode");
		if (!this.pause && this.level != null) {
			this.gameMode.tick();
		}

		profiler.pop();
		this.pick(1.0F);
		this.tutorial.onLookAt(this.level, this.hitResult);
		profiler.push("gui");
		this.textInputManager.tick();
		this.gui.tick();
		if (this.gui.screen() != null) {
			this.missTime = 10000;
		}

		if (this.gui.overlay() == null && this.gui.screen() == null) {
			profiler.popPush("Keybindings");
			this.handleKeybinds();
			if (this.missTime > 0) {
				this.missTime--;
			}
		}

		if (this.level != null) {
			if (!this.pause) {
				if (this.player != null) {
					this.player.getInventory().applySelectedSlot();
				}

				profiler.popPush("gameRenderer");
				this.gameRenderer.tick();
				profiler.popPush("entities");
				this.level.tickEntities();
				profiler.popPush("blockEntities");
				this.level.tickBlockEntities();
			}
		} else if (this.gameRenderer.currentPostEffect() != null) {
			this.gameRenderer.clearPostEffect();
		}

gameMode.tick() runs before applySelectedSlot(), so if the player changes the selected item in the current tick, the client responds immediately, but the server does not actually receive the slot change packet until the next tick.

P.S.

I noticed that this seems to fix attribute swapping, but it actually does not. You can still trigger attribute swapping by delaying your mouse click by 1 game tick. However, spear lunge swapping does seem to be fixed by this change, although I am not sure why.

Linked issues

Comments 0

No comments.

AzogMine

(Unassigned)

Confirmed

26.2 Pre-Release 2

26.2 Pre-Release 3

Retrieved