Merge branch 'CatsSomeCat-1.21.8' into 1.21.9
This commit is contained in:
commit
3352c497e2
|
|
@ -47,14 +47,15 @@ public class CarryOnCommonClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void onCarryClientTick()
|
public static void onCarryClientTick() {
|
||||||
{
|
|
||||||
Player player = Minecraft.getInstance().player;
|
Player player = Minecraft.getInstance().player;
|
||||||
if(player != null) {
|
if (player != null) {
|
||||||
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
CarryOnData carry = CarryOnDataManager.getCarryData(player);
|
||||||
if(carry.isCarrying())
|
if (carry.isCarrying()) {
|
||||||
{
|
int wantedSlot = carry.getSelected();
|
||||||
player.getInventory().setSelectedSlot(carry.getSelected());
|
if (player.getInventory().getSelectedSlot() != wantedSlot) {
|
||||||
|
player.getInventory().setSelectedSlot(wantedSlot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,4 +64,4 @@ public class CarryOnCommonClient
|
||||||
{
|
{
|
||||||
return Minecraft.getInstance().player;
|
return Minecraft.getInstance().player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -28,11 +28,24 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||||
import tschipp.carryon.common.carry.CarryOnDataManager;
|
import tschipp.carryon.common.carry.CarryOnDataManager;
|
||||||
|
|
||||||
@Mixin(Minecraft.class)
|
@Mixin(Minecraft.class)
|
||||||
public class MinecraftMixin
|
public class MinecraftMixin {
|
||||||
{
|
|
||||||
@WrapWithCondition(method = "handleKeybinds()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Inventory;setSelectedSlot(I)V", ordinal = 0))
|
@WrapWithCondition(
|
||||||
private boolean allowSlotSelection(Inventory inv,int slot)
|
method = "handleKeybinds()V",
|
||||||
{
|
at = @At(
|
||||||
return !CarryOnDataManager.getCarryData(inv.player).isCarrying();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user