Merge branch 'CatsSomeCat-1.21.8' into 1.21.9

This commit is contained in:
Tschipp 2025-12-25 16:30:41 +01:00
commit 3352c497e2
2 changed files with 28 additions and 14 deletions

View File

@ -47,14 +47,15 @@ public class CarryOnCommonClient
}
public static void onCarryClientTick()
{
public static void onCarryClientTick() {
Player player = Minecraft.getInstance().player;
if(player != null) {
if (player != null) {
CarryOnData carry = CarryOnDataManager.getCarryData(player);
if(carry.isCarrying())
{
player.getInventory().setSelectedSlot(carry.getSelected());
if (carry.isCarrying()) {
int wantedSlot = carry.getSelected();
if (player.getInventory().getSelectedSlot() != wantedSlot) {
player.getInventory().setSelectedSlot(wantedSlot);
}
}
}
}
@ -63,4 +64,4 @@ public class CarryOnCommonClient
{
return Minecraft.getInstance().player;
}
}
}

View File

@ -28,11 +28,24 @@ import org.spongepowered.asm.mixin.injection.At;
import tschipp.carryon.common.carry.CarryOnDataManager;
@Mixin(Minecraft.class)
public class MinecraftMixin
{
@WrapWithCondition(method = "handleKeybinds()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;setSelectedSlot(I)V", ordinal = 0))
private boolean allowSlotSelection(Inventory inv,int slot)
{
return !CarryOnDataManager.getCarryData(inv.player).isCarrying();
}
public class MinecraftMixin {
@WrapWithCondition(
method = "handleKeybinds()V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/player/Inventory;setSelectedSlot(I)V",
ordinal = 0
)
)
private boolean allowSlotSelection(Inventory inv, int slot) {
boolean carrying = CarryOnDataManager.getCarryData(inv.player).isCarrying();
// Allow if not carrying
if (!carrying) return true;
// Block only if trying to switch away
return inv.getSelectedSlot() == slot;
}
}