generated from TerminalMC/Framework
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
common/src/main/java/dev/terminalmc/clientsort/compat/ItemLocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dev.terminalmc.clientsort.compat; | ||
|
||
import com.kirdow.itemlocks.client.LockManager; | ||
import dev.terminalmc.clientsort.util.inject.ISlot; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.inventory.Slot; | ||
|
||
import static com.kirdow.itemlocks.client.input.KeyBindings.isBypass; | ||
import static com.kirdow.itemlocks.proxy.Components.getComponent; | ||
|
||
public class ItemLocks { | ||
static boolean isLocked(Slot slot) { | ||
if (!(slot.container instanceof Inventory)) return false; | ||
int index = adjustForInventory(((ISlot) slot).mouseWheelie_getIndexInInv()); | ||
return getComponent(LockManager.class).isLockedSlotRaw(index) && !isBypass(); | ||
} | ||
|
||
/** | ||
* Moves the hotbar from 0-8 to 27-35. | ||
*/ | ||
private static int adjustForInventory(int slot) { | ||
// | ||
if (0 <= slot && slot <= 8) { | ||
return slot + 27; | ||
} else if (9 <= slot && slot <= 35) { | ||
return slot - 9; | ||
} else { | ||
return slot; | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
common/src/main/java/dev/terminalmc/clientsort/compat/ItemLocksWrapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.terminalmc.clientsort.compat; | ||
|
||
import net.minecraft.world.inventory.Slot; | ||
|
||
public class ItemLocksWrapper { | ||
private static boolean hasFailed = false; | ||
|
||
public static boolean isLocked(Slot slot) { | ||
if (hasFailed) return false; | ||
try { | ||
return ItemLocks.isLocked(slot); | ||
} catch (NoClassDefFoundError | NoSuchMethodError ignored) { | ||
hasFailed = true; | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters