Merge branch '1.21.8' of github.com:CatsSomeCat/CarryOn into CatsSomeCat-1.21.8
# Conflicts: # Common/src/main/java/tschipp/carryon/common/carry/PlacementHandler.java # Fabric/src/main/java/tschipp/carryon/CarryOnFabricMod.java # Fabric/src/main/java/tschipp/carryon/events/CommonEvents.java # gradle.properties
This commit is contained in:
commit
f58829ea21
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user