Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 31be4f2

Browse files
committed
Fixes #229
1 parent 3f45321 commit 31be4f2

16 files changed

Lines changed: 489 additions & 242 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ bin/
2525
run/
2626
run
2727

28+
run-server
29+
2830
# kotlin
2931
*.ws.kts
3032

@@ -37,4 +39,4 @@ repo
3739
/common/src/main/gen/
3840

3941
# macOS
40-
.DS_Store
42+
.DS_Store

platforms/fabric-1.14/src/main/java/org/anti_ad/mc/ipnext/mixin/MixinPlayerInventory.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.spongepowered.asm.mixin.Shadow;
3535
import org.spongepowered.asm.mixin.injection.At;
3636
import org.spongepowered.asm.mixin.injection.Inject;
37+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3738
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3839

3940
@Mixin(PlayerInventory.class)
@@ -44,30 +45,34 @@ public abstract class MixinPlayerInventory {
4445

4546
private ItemStack addedStack = null;
4647

48+
private boolean skipChecks = false;
49+
4750
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;getEmptySlot()I"),
4851
method = "getEmptySlot",
4952
cancellable = true)
5053
public void getEmptySlot(CallbackInfoReturnable<Integer> info) {
51-
if (MinecraftClient.getInstance().player != null) {
52-
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
53-
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
54-
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
55-
for (int i = 0; i < this.main.size(); ++i) {
56-
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
57-
&& PlayerInventory.isValidHotbarIndex(i)
58-
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
59-
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
60-
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
61-
continue;
62-
}
63-
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
64-
if ((this.main.get(i)).isEmpty()) {
65-
info.setReturnValue(i);
66-
return;
54+
if (!skipChecks) {
55+
if (MinecraftClient.getInstance().player != null) {
56+
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
57+
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
58+
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
59+
for (int i = 0; i < this.main.size(); ++i) {
60+
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
61+
&& PlayerInventory.isValidHotbarIndex(i)
62+
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
63+
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
64+
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
65+
continue;
66+
}
67+
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
68+
if ((this.main.get(i)).isEmpty()) {
69+
info.setReturnValue(i);
70+
return;
71+
}
6772
}
6873
}
74+
info.setReturnValue(-1);
6975
}
70-
info.setReturnValue(-1);
7176
}
7277
}
7378
}
@@ -85,4 +90,16 @@ public void addStackPost(ItemStack stack, CallbackInfoReturnable<Integer> cir) {
8590
}
8691

8792

93+
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
94+
method = "addPickBlock")
95+
public void setPickedItemPre(ItemStack stack, CallbackInfo ci) {
96+
skipChecks = true;
97+
}
98+
99+
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
100+
method = "addPickBlock")
101+
public void setPickedItemPost(ItemStack stack, CallbackInfo ci) {
102+
skipChecks = false;
103+
}
104+
88105
}

platforms/fabric-1.15/src/main/java/org/anti_ad/mc/ipnext/mixin/MixinPlayerInventory.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.spongepowered.asm.mixin.Shadow;
3535
import org.spongepowered.asm.mixin.injection.At;
3636
import org.spongepowered.asm.mixin.injection.Inject;
37+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3738
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3839

3940
@Mixin(PlayerInventory.class)
@@ -44,30 +45,34 @@ public abstract class MixinPlayerInventory {
4445

4546
private ItemStack addedStack = null;
4647

48+
private boolean skipChecks = false;
49+
4750
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;getEmptySlot()I"),
4851
method = "getEmptySlot",
4952
cancellable = true)
5053
public void getEmptySlot(CallbackInfoReturnable<Integer> info) {
51-
if (MinecraftClient.getInstance().player != null) {
52-
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
53-
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
54-
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
55-
for (int i = 0; i < this.main.size(); ++i) {
56-
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
57-
&& PlayerInventory.isValidHotbarIndex(i)
58-
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
59-
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
60-
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
61-
continue;
62-
}
63-
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
64-
if ((this.main.get(i)).isEmpty()) {
65-
info.setReturnValue(i);
66-
return;
54+
if (!skipChecks) {
55+
if (MinecraftClient.getInstance().player != null) {
56+
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
57+
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
58+
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
59+
for (int i = 0; i < this.main.size(); ++i) {
60+
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
61+
&& PlayerInventory.isValidHotbarIndex(i)
62+
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
63+
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
64+
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
65+
continue;
66+
}
67+
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
68+
if ((this.main.get(i)).isEmpty()) {
69+
info.setReturnValue(i);
70+
return;
71+
}
6772
}
6873
}
74+
info.setReturnValue(-1);
6975
}
70-
info.setReturnValue(-1);
7176
}
7277
}
7378
}
@@ -85,4 +90,16 @@ public void addStackPost(ItemStack stack, CallbackInfoReturnable<Integer> cir) {
8590
}
8691

8792

93+
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
94+
method = "addPickBlock")
95+
public void setPickedItemPre(ItemStack stack, CallbackInfo ci) {
96+
skipChecks = true;
97+
}
98+
99+
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
100+
method = "addPickBlock")
101+
public void setPickedItemPost(ItemStack stack, CallbackInfo ci) {
102+
skipChecks = false;
103+
}
104+
88105
}

platforms/fabric-1.16/src/main/java/org/anti_ad/mc/ipnext/mixin/MixinPlayerInventory.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.spongepowered.asm.mixin.Shadow;
3535
import org.spongepowered.asm.mixin.injection.At;
3636
import org.spongepowered.asm.mixin.injection.Inject;
37+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3738
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3839

3940
@Mixin(PlayerInventory.class)
@@ -44,30 +45,34 @@ public abstract class MixinPlayerInventory {
4445

4546
private ItemStack addedStack = null;
4647

48+
private boolean skipChecks = false;
49+
4750
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;getEmptySlot()I"),
4851
method = "getEmptySlot",
4952
cancellable = true)
5053
public void getEmptySlot(CallbackInfoReturnable<Integer> info) {
51-
if (MinecraftClient.getInstance().player != null) {
52-
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
53-
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
54-
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
55-
for (int i = 0; i < this.main.size(); ++i) {
56-
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
57-
&& PlayerInventory.isValidHotbarIndex(i)
58-
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
59-
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
60-
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
61-
continue;
62-
}
63-
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
64-
if ((this.main.get(i)).isEmpty()) {
65-
info.setReturnValue(i);
66-
return;
54+
if (!skipChecks) {
55+
if (MinecraftClient.getInstance().player != null) {
56+
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
57+
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
58+
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
59+
for (int i = 0; i < this.main.size(); ++i) {
60+
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
61+
&& PlayerInventory.isValidHotbarIndex(i)
62+
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
63+
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
64+
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
65+
continue;
66+
}
67+
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
68+
if ((this.main.get(i)).isEmpty()) {
69+
info.setReturnValue(i);
70+
return;
71+
}
6772
}
6873
}
74+
info.setReturnValue(-1);
6975
}
70-
info.setReturnValue(-1);
7176
}
7277
}
7378
}
@@ -85,4 +90,16 @@ public void addStackPost(ItemStack stack, CallbackInfoReturnable<Integer> cir) {
8590
}
8691

8792

93+
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
94+
method = "addPickBlock")
95+
public void setPickedItemPre(ItemStack stack, CallbackInfo ci) {
96+
skipChecks = true;
97+
}
98+
99+
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
100+
method = "addPickBlock")
101+
public void setPickedItemPost(ItemStack stack, CallbackInfo ci) {
102+
skipChecks = false;
103+
}
104+
88105
}

platforms/fabric-1.17/src/main/java/org/anti_ad/mc/ipnext/mixin/MixinPlayerInventory.java

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.spongepowered.asm.mixin.Shadow;
3535
import org.spongepowered.asm.mixin.injection.At;
3636
import org.spongepowered.asm.mixin.injection.Inject;
37+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
3738
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
3839

3940
@Mixin(PlayerInventory.class)
@@ -44,30 +45,34 @@ public abstract class MixinPlayerInventory {
4445

4546
private ItemStack addedStack = null;
4647

48+
private boolean skipChecks = false;
49+
4750
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;getEmptySlot()I"),
4851
method = "getEmptySlot",
4952
cancellable = true)
5053
public void getEmptySlot(CallbackInfoReturnable<Integer> info) {
51-
if (MinecraftClient.getInstance().player != null) {
52-
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
53-
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
54-
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
55-
for (int i = 0; i < this.main.size(); ++i) {
56-
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
57-
&& PlayerInventory.isValidHotbarIndex(i)
58-
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
59-
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
60-
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
61-
continue;
62-
}
63-
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
64-
if ((this.main.get(i)).isEmpty()) {
65-
info.setReturnValue(i);
66-
return;
54+
if (!skipChecks) {
55+
if (MinecraftClient.getInstance().player != null) {
56+
if (ModSettings.INSTANCE.getENABLE_LOCK_SLOTS().getValue() &&
57+
!LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_ALLOW_PICKUP_INTO_EMPTY().getValue()
58+
&& !Debugs.INSTANCE.getFORCE_SERVER_METHOD_FOR_LOCKED_SLOTS().getValue()) {
59+
for (int i = 0; i < this.main.size(); ++i) {
60+
if (LockedSlotsSettings.INSTANCE.getLOCKED_SLOTS_EMPTY_HOTBAR_AS_SEMI_LOCKED().getValue()
61+
&& PlayerInventory.isValidHotbarIndex(i)
62+
&& !LockedSlotKeeper.INSTANCE.isOnlyHotbarFree()
63+
&& !LockedSlotKeeper.INSTANCE.isIgnored(addedStack)
64+
&& LockedSlotKeeper.INSTANCE.isHotBarSlotEmpty(i)) {
65+
continue;
66+
}
67+
if (!LockSlotsHandler.INSTANCE.isSlotLocked(i)) {
68+
if ((this.main.get(i)).isEmpty()) {
69+
info.setReturnValue(i);
70+
return;
71+
}
6772
}
6873
}
74+
info.setReturnValue(-1);
6975
}
70-
info.setReturnValue(-1);
7176
}
7277
}
7378
}
@@ -85,4 +90,16 @@ public void addStackPost(ItemStack stack, CallbackInfoReturnable<Integer> cir) {
8590
}
8691

8792

93+
@Inject(at = @At(value = "HEAD", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
94+
method = "addPickBlock")
95+
public void setPickedItemPre(ItemStack stack, CallbackInfo ci) {
96+
skipChecks = true;
97+
}
98+
99+
@Inject(at = @At(value = "TAIL", target = "Lnet/minecraft/entity/player/PlayerInventory;addPickBlock(Lnet/minecraft/item/ItemStack;)V"),
100+
method = "addPickBlock")
101+
public void setPickedItemPost(ItemStack stack, CallbackInfo ci) {
102+
skipChecks = false;
103+
}
104+
88105
}

0 commit comments

Comments
 (0)