Update EMI exclusion zones

This commit is contained in:
Cynthia Foxwell 2024-03-18 12:01:19 -06:00
parent a70df52234
commit 806ee14060
1 changed files with 55 additions and 8 deletions

View File

@ -4,9 +4,12 @@ import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry;
import dev.emi.emi.api.widget.Bounds;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen;
import net.minecraft.item.ItemStack;
import pm.c7.scout.ScoutUtil;
import pm.c7.scout.client.ScoutUtilClient;
import pm.c7.scout.item.BaseBagItem;
import pm.c7.scout.item.BaseBagItem.BagType;
import pm.c7.scout.mixin.client.HandledScreenAccessor;
@ -14,18 +17,55 @@ import pm.c7.scout.mixin.client.HandledScreenAccessor;
public class ScoutEmiPlugin implements EmiPlugin {
@Override
public void register(EmiRegistry registry) {
registry.addExclusionArea(InventoryScreen.class, (screen, consumer) -> {
registry.addGenericExclusionArea((screen, consumer) -> {
if (!(screen instanceof HandledScreen<?> handledScreen)) return;
if (ScoutUtilClient.isScreenBlacklisted(screen)) return;
MinecraftClient client = MinecraftClient.getInstance();
var handledScreenAccessor = (HandledScreenAccessor) handledScreen;
var sx = handledScreenAccessor.getX();
var sy = handledScreenAccessor.getY();
var sw = handledScreenAccessor.getBackgroundWidth();
var sh = handledScreenAccessor.getBackgroundHeight();
ItemStack satchelStack = ScoutUtil.findBagItem(client.player, BagType.SATCHEL, false);
if (!satchelStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) satchelStack.getItem();
int slots = bagItem.getSlotCount();
int rows = (int) Math.ceil(slots / 9);
int x = sx;
int y = sy + sh;
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
y -= 1;
}
int w = sw;
int h = (rows * 18) + 8;
consumer.accept(new Bounds(x, y, w, h));
}
ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
if (!leftPouchStack.isEmpty()) {
BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
int slots = bagItem.getSlotCount();
int columns = (int) Math.ceil(slots / 3);
int x = ((HandledScreenAccessor) screen).getX() - (columns * 18);
int y = ((HandledScreenAccessor) screen).getY() + 76;
int x = sx - (columns * 18);
int y = (sy + sh) - 100;
consumer.accept(new Bounds(x, y, columns * 18, 68));
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
y -= 1;
}
int w = (columns * 18);
int h = 68;
consumer.accept(new Bounds(x, y, w, h));
}
ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
@ -34,10 +74,17 @@ public class ScoutEmiPlugin implements EmiPlugin {
int slots = bagItem.getSlotCount();
int columns = (int) Math.ceil(slots / 3);
int x = ((HandledScreenAccessor) screen).getX() + 176;
int y = ((HandledScreenAccessor) screen).getY() + 76;
int x = sx + sw;
int y = (sy + sh) - 100;
consumer.accept(new Bounds(x, y, columns * 18, 68));
if (screen instanceof GenericContainerScreen || screen instanceof ShulkerBoxScreen) {
y -= 1;
}
int w = (columns * 18);
int h = 68;
consumer.accept(new Bounds(x, y, w, h));
}
});
}