Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lag when trying to right click items but the interaction fails #463

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,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 @@ -206,6 +206,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();
}

}