Skip to content

Commit

Permalink
Fix lag when trying to right click items but the interaction fails (#463
Browse files Browse the repository at this point in the history
)

(cherry picked from commit 96b1f83)
  • Loading branch information
kuba6000 authored and Dream-Master committed Dec 31, 2024
1 parent 9f0e08c commit 64a48cc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ public class FixesConfig {
@Config.RequiresMcRestart
public static boolean fixWrongBlockPlacementDistanceCheck;

@Config.Comment("Fix inventory sync lag: prevents client to check recipes on empty slots. Particularly fixes lag when trying to eat food when full.")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean fixInventorySyncLag;

/* ====== Minecraft fixes end ===== */

// bukkit fixes
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ public enum Mixins {
"fml.MixinNetworkDispatcher",
"minecraft.NetworkManagerAccessor")
.setApplyIf(() -> FixesConfig.fixBogusIntegratedServerNPEs).addTargetedMod(TargetedMod.VANILLA)),
FIX_LAG_ON_INVENTORY_SYNC(new Builder("Fix inventory sync lag").setPhase(Phase.EARLY)
.addMixinClasses("minecraft.MixinInventoryCrafting").setSide(Side.BOTH)
.setApplyIf(() -> FixesConfig.fixInventorySyncLag).addTargetedMod(TargetedMod.VANILLA)),

FIX_LOGIN_DIMENSION_ID_OVERFLOW(
new Builder("Fix dimension id overflowing when a player first logins on a server").setPhase(Phase.EARLY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InventoryCrafting.class)
public class MixinInventoryCrafting {

@Shadow
private ItemStack[] stackList;

@Inject(method = "setInventorySlotContents", at = @At("HEAD"), cancellable = true)
public void setInventorySlotContents(int index, ItemStack stack, CallbackInfo ci) {
if (stack == null && this.stackList[index] == null) ci.cancel();
}

}

0 comments on commit 64a48cc

Please sign in to comment.