Skip to content

Commit 42909a7

Browse files
committed
Change hotbarSlotToUpdate to isDesynced
1 parent 9815784 commit 42909a7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/main/java/net/earthcomputer/clientcommands/TempRulesImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import java.util.ArrayList;
44
import java.util.List;
5-
import java.util.concurrent.atomic.AtomicInteger;
5+
import java.util.concurrent.atomic.AtomicBoolean;
66

77
import net.earthcomputer.clientcommands.network.NetUtils;
88
import net.minecraft.block.material.Material;
@@ -35,12 +35,11 @@ private static void initBlockReachDistance() {
3535
});
3636
}
3737

38-
private static AtomicInteger hotbarSlotToUpdate = new AtomicInteger(-1);
38+
private static AtomicBoolean isDesynced = new AtomicBoolean(false);
3939

4040
private static void initToolBreakProtection() {
4141
EventManager.addPlayerTickListener(e -> {
42-
int hotbarSlot = hotbarSlotToUpdate.getAndSet(-1);
43-
if (hotbarSlot != -1) {
42+
if (isDesynced.getAndSet(false)) {
4443
NetUtils.resyncInventory(slot -> slot.inventory == Minecraft.getMinecraft().player.inventory);
4544
}
4645
});
@@ -58,7 +57,7 @@ private static void initToolBreakProtection() {
5857
// fix client-server desync
5958
e.getItemStack().setItemDamage(e.getItemStack().getItemDamage() + e.getDamageAmount());
6059
if (EnchantmentHelper.getEnchantmentLevel(Enchantments.UNBREAKING, e.getItemStack()) > 0) {
61-
hotbarSlotToUpdate.set(e.getEntityPlayer().inventory.currentItem);
60+
isDesynced.set(true);
6261
}
6362
}
6463
});

0 commit comments

Comments
 (0)