2024-03-14 05:09:55 +00:00
|
|
|
package pm.c7.scout.mixin.client;
|
|
|
|
|
|
|
|
import net.fabricmc.api.EnvType;
|
|
|
|
import net.fabricmc.api.Environment;
|
|
|
|
import net.minecraft.client.gui.screen.ingame.CraftingScreen;
|
|
|
|
import net.minecraft.client.gui.screen.ingame.HandledScreen;
|
2024-03-16 02:01:13 +00:00
|
|
|
import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
|
2024-03-14 05:09:55 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.screen.CraftingScreenHandler;
|
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
|
|
import pm.c7.scout.ScoutUtil;
|
|
|
|
import pm.c7.scout.item.BaseBagItem;
|
|
|
|
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
|
|
@Mixin(CraftingScreen.class)
|
|
|
|
public abstract class CraftingScreenMixin extends HandledScreen<CraftingScreenHandler> implements RecipeBookProvider {
|
|
|
|
public CraftingScreenMixin() {
|
|
|
|
super(null, null, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "isClickOutsideBounds", at = @At("TAIL"), cancellable = true)
|
|
|
|
private void scout$adjustOutsideBounds(double mouseX, double mouseY, int left, int top, int button, CallbackInfoReturnable<Boolean> callbackInfo) {
|
|
|
|
if (this.client != null && this.client.player != null) {
|
|
|
|
ItemStack backStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.SATCHEL, false);
|
|
|
|
if (!backStack.isEmpty()) {
|
|
|
|
BaseBagItem bagItem = (BaseBagItem) backStack.getItem();
|
|
|
|
int slots = bagItem.getSlotCount();
|
|
|
|
int rows = (int) Math.ceil(slots / 9);
|
|
|
|
|
|
|
|
if (mouseY < (top + this.backgroundHeight) + 8 + (18 * rows) && mouseY >= (top + this.backgroundHeight) && mouseX >= left && mouseY < (left + this.backgroundWidth)) {
|
|
|
|
callbackInfo.setReturnValue(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemStack leftPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, false);
|
|
|
|
if (!leftPouchStack.isEmpty()) {
|
|
|
|
BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
|
|
|
|
int slots = bagItem.getSlotCount();
|
|
|
|
int columns = (int) Math.ceil(slots / 3);
|
|
|
|
|
|
|
|
if (mouseX >= left - (columns * 18) && mouseX < left && mouseY >= (top + this.backgroundHeight) - 90 && mouseY < (top + this.backgroundHeight) - 22) {
|
|
|
|
callbackInfo.setReturnValue(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ItemStack rightPouchStack = ScoutUtil.findBagItem(this.client.player, BaseBagItem.BagType.POUCH, true);
|
|
|
|
if (!rightPouchStack.isEmpty()) {
|
|
|
|
BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem();
|
|
|
|
int slots = bagItem.getSlotCount();
|
|
|
|
int columns = (int) Math.ceil(slots / 3);
|
|
|
|
|
|
|
|
if (mouseX >= (left + this.backgroundWidth) && mouseX < (left + this.backgroundWidth) + (columns * 18) && mouseY >= (top + this.backgroundHeight) - 90 && mouseY < (top + this.backgroundHeight) - 22) {
|
|
|
|
callbackInfo.setReturnValue(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|