Normalize indentation
This commit is contained in:
		
							parent
							
								
									8712c28b0e
								
							
						
					
					
						commit
						b803b794f8
					
				
					 14 changed files with 370 additions and 378 deletions
				
			
		| 
						 | 
				
			
			@ -3,5 +3,5 @@ package pm.c7.scout;
 | 
			
		|||
import net.minecraft.util.Identifier;
 | 
			
		||||
 | 
			
		||||
public class ScoutNetworking {
 | 
			
		||||
    public static final Identifier ENABLE_SLOTS = new Identifier(ScoutUtil.MOD_ID, "enable_slots");
 | 
			
		||||
	public static final Identifier ENABLE_SLOTS = new Identifier(ScoutUtil.MOD_ID, "enable_slots");
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ import net.minecraft.util.collection.DefaultedList;
 | 
			
		|||
import pm.c7.scout.screen.BagSlot;
 | 
			
		||||
 | 
			
		||||
public interface ScoutScreenHandler {
 | 
			
		||||
    DefaultedList<BagSlot> scout$getSatchelSlots();
 | 
			
		||||
    DefaultedList<BagSlot> scout$getLeftPouchSlots();
 | 
			
		||||
    DefaultedList<BagSlot> scout$getRightPouchSlots();
 | 
			
		||||
	DefaultedList<BagSlot> scout$getSatchelSlots();
 | 
			
		||||
	DefaultedList<BagSlot> scout$getLeftPouchSlots();
 | 
			
		||||
	DefaultedList<BagSlot> scout$getRightPouchSlots();
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ import net.minecraft.nbt.NbtCompound;
 | 
			
		|||
import net.minecraft.nbt.NbtList;
 | 
			
		||||
import net.minecraft.screen.PlayerScreenHandler;
 | 
			
		||||
import net.minecraft.screen.slot.Slot;
 | 
			
		||||
import net.minecraft.screen.slot.SlotActionType;
 | 
			
		||||
import net.minecraft.util.Identifier;
 | 
			
		||||
import net.minecraft.util.Pair;
 | 
			
		||||
import net.minecraft.util.collection.DefaultedList;
 | 
			
		||||
| 
						 | 
				
			
			@ -44,59 +45,59 @@ public class ScoutUtil {
 | 
			
		|||
	public static final int BAG_SLOTS_END = RIGHT_POUCH_SLOT_START - MAX_POUCH_SLOTS;
 | 
			
		||||
 | 
			
		||||
	public static ItemStack findBagItem(PlayerEntity player, BaseBagItem.BagType type, boolean right) {
 | 
			
		||||
        ItemStack targetStack = ItemStack.EMPTY;
 | 
			
		||||
		ItemStack targetStack = ItemStack.EMPTY;
 | 
			
		||||
 | 
			
		||||
        boolean hasFirstPouch = false;
 | 
			
		||||
        Optional<TrinketComponent> _component = TrinketsApi.getTrinketComponent(player);
 | 
			
		||||
        if (_component.isPresent()) {
 | 
			
		||||
            TrinketComponent component = _component.get();
 | 
			
		||||
            for (Pair<SlotReference, ItemStack> pair : component.getAllEquipped()) {
 | 
			
		||||
                ItemStack slotStack = pair.getRight();
 | 
			
		||||
		boolean hasFirstPouch = false;
 | 
			
		||||
		Optional<TrinketComponent> _component = TrinketsApi.getTrinketComponent(player);
 | 
			
		||||
		if (_component.isPresent()) {
 | 
			
		||||
			TrinketComponent component = _component.get();
 | 
			
		||||
			for (Pair<SlotReference, ItemStack> pair : component.getAllEquipped()) {
 | 
			
		||||
				ItemStack slotStack = pair.getRight();
 | 
			
		||||
 | 
			
		||||
                if (slotStack.getItem() instanceof BaseBagItem bagItem) {
 | 
			
		||||
				if (slotStack.getItem() instanceof BaseBagItem bagItem) {
 | 
			
		||||
					if (bagItem.getType() == type) {
 | 
			
		||||
                        if (type == BagType.POUCH) {
 | 
			
		||||
                            if (right && !hasFirstPouch) {
 | 
			
		||||
                                hasFirstPouch = true;
 | 
			
		||||
						if (type == BagType.POUCH) {
 | 
			
		||||
							if (right && !hasFirstPouch) {
 | 
			
		||||
								hasFirstPouch = true;
 | 
			
		||||
							} else {
 | 
			
		||||
                                targetStack = slotStack;
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                        } else {
 | 
			
		||||
                            targetStack = slotStack;
 | 
			
		||||
                            break;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
								targetStack = slotStack;
 | 
			
		||||
								break;
 | 
			
		||||
							}
 | 
			
		||||
						} else {
 | 
			
		||||
							targetStack = slotStack;
 | 
			
		||||
							break;
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        return targetStack;
 | 
			
		||||
    }
 | 
			
		||||
		return targetStack;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public static NbtList inventoryToTag(Inventory inventory) {
 | 
			
		||||
        NbtList tag = new NbtList();
 | 
			
		||||
	public static NbtList inventoryToTag(Inventory inventory) {
 | 
			
		||||
		NbtList tag = new NbtList();
 | 
			
		||||
 | 
			
		||||
        for(int i = 0; i < inventory.size(); i++) {
 | 
			
		||||
            NbtCompound stackTag = new NbtCompound();
 | 
			
		||||
            stackTag.putInt("Slot", i);
 | 
			
		||||
            stackTag.put("Stack", inventory.getStack(i).writeNbt(new NbtCompound()));
 | 
			
		||||
            tag.add(stackTag);
 | 
			
		||||
        }
 | 
			
		||||
		for(int i = 0; i < inventory.size(); i++) {
 | 
			
		||||
			NbtCompound stackTag = new NbtCompound();
 | 
			
		||||
			stackTag.putInt("Slot", i);
 | 
			
		||||
			stackTag.put("Stack", inventory.getStack(i).writeNbt(new NbtCompound()));
 | 
			
		||||
			tag.add(stackTag);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        return tag;
 | 
			
		||||
    }
 | 
			
		||||
		return tag;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public static void inventoryFromTag(NbtList tag, Inventory inventory) {
 | 
			
		||||
        inventory.clear();
 | 
			
		||||
	public static void inventoryFromTag(NbtList tag, Inventory inventory) {
 | 
			
		||||
		inventory.clear();
 | 
			
		||||
 | 
			
		||||
        tag.forEach(element -> {
 | 
			
		||||
            NbtCompound stackTag = (NbtCompound) element;
 | 
			
		||||
            int slot = stackTag.getInt("Slot");
 | 
			
		||||
            ItemStack stack = ItemStack.fromNbt(stackTag.getCompound("Stack"));
 | 
			
		||||
            inventory.setStack(slot, stack);
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
		tag.forEach(element -> {
 | 
			
		||||
			NbtCompound stackTag = (NbtCompound) element;
 | 
			
		||||
			int slot = stackTag.getInt("Slot");
 | 
			
		||||
			ItemStack stack = ItemStack.fromNbt(stackTag.getCompound("Stack"));
 | 
			
		||||
			inventory.setStack(slot, stack);
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public static boolean isBagSlot(int slot) {
 | 
			
		||||
		return slot <= SATCHEL_SLOT_START && slot > BAG_SLOTS_END;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,79 +27,79 @@ import pm.c7.scout.mixin.client.HandledScreenAccessor;
 | 
			
		|||
import pm.c7.scout.screen.BagSlot;
 | 
			
		||||
 | 
			
		||||
public class ScoutClient implements ClientModInitializer {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onInitializeClient(ModContainer mod) {
 | 
			
		||||
        ClientPlayNetworking.registerGlobalReceiver(ScoutNetworking.ENABLE_SLOTS, (client, handler, packet, sender) -> {
 | 
			
		||||
            client.execute(() -> {
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onInitializeClient(ModContainer mod) {
 | 
			
		||||
		ClientPlayNetworking.registerGlobalReceiver(ScoutNetworking.ENABLE_SLOTS, (client, handler, packet, sender) -> {
 | 
			
		||||
			client.execute(() -> {
 | 
			
		||||
				assert client.player != null;
 | 
			
		||||
				ScoutScreenHandler screenHandler = (ScoutScreenHandler) client.player.playerScreenHandler;
 | 
			
		||||
 | 
			
		||||
                ItemStack satchelStack = ScoutUtil.findBagItem(client.player, BagType.SATCHEL, false);
 | 
			
		||||
                DefaultedList<BagSlot> satchelSlots = screenHandler.scout$getSatchelSlots();
 | 
			
		||||
				ItemStack satchelStack = ScoutUtil.findBagItem(client.player, BagType.SATCHEL, false);
 | 
			
		||||
				DefaultedList<BagSlot> satchelSlots = screenHandler.scout$getSatchelSlots();
 | 
			
		||||
 | 
			
		||||
                for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
 | 
			
		||||
                    BagSlot slot = satchelSlots.get(i);
 | 
			
		||||
                    slot.setInventory(null);
 | 
			
		||||
                    slot.setEnabled(false);
 | 
			
		||||
                }
 | 
			
		||||
                if (!satchelStack.isEmpty()) {
 | 
			
		||||
                    BaseBagItem satchelItem = (BaseBagItem) satchelStack.getItem();
 | 
			
		||||
                    Inventory satchelInv = satchelItem.getInventory(satchelStack);
 | 
			
		||||
				for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
 | 
			
		||||
					BagSlot slot = satchelSlots.get(i);
 | 
			
		||||
					slot.setInventory(null);
 | 
			
		||||
					slot.setEnabled(false);
 | 
			
		||||
				}
 | 
			
		||||
				if (!satchelStack.isEmpty()) {
 | 
			
		||||
					BaseBagItem satchelItem = (BaseBagItem) satchelStack.getItem();
 | 
			
		||||
					Inventory satchelInv = satchelItem.getInventory(satchelStack);
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < satchelItem.getSlotCount(); i++) {
 | 
			
		||||
                        BagSlot slot = satchelSlots.get(i);
 | 
			
		||||
                        slot.setInventory(satchelInv);
 | 
			
		||||
                        slot.setEnabled(true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
					for (int i = 0; i < satchelItem.getSlotCount(); i++) {
 | 
			
		||||
						BagSlot slot = satchelSlots.get(i);
 | 
			
		||||
						slot.setInventory(satchelInv);
 | 
			
		||||
						slot.setEnabled(true);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
                ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
 | 
			
		||||
                DefaultedList<BagSlot> leftPouchSlots = screenHandler.scout$getLeftPouchSlots();
 | 
			
		||||
				ItemStack leftPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, false);
 | 
			
		||||
				DefaultedList<BagSlot> leftPouchSlots = screenHandler.scout$getLeftPouchSlots();
 | 
			
		||||
 | 
			
		||||
                for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
                    BagSlot slot = leftPouchSlots.get(i);
 | 
			
		||||
                    slot.setInventory(null);
 | 
			
		||||
                    slot.setEnabled(false);
 | 
			
		||||
                }
 | 
			
		||||
                if (!leftPouchStack.isEmpty()) {
 | 
			
		||||
                    BaseBagItem leftPouchItem = (BaseBagItem) leftPouchStack.getItem();
 | 
			
		||||
                    Inventory leftPouchInv = leftPouchItem.getInventory(leftPouchStack);
 | 
			
		||||
				for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
					BagSlot slot = leftPouchSlots.get(i);
 | 
			
		||||
					slot.setInventory(null);
 | 
			
		||||
					slot.setEnabled(false);
 | 
			
		||||
				}
 | 
			
		||||
				if (!leftPouchStack.isEmpty()) {
 | 
			
		||||
					BaseBagItem leftPouchItem = (BaseBagItem) leftPouchStack.getItem();
 | 
			
		||||
					Inventory leftPouchInv = leftPouchItem.getInventory(leftPouchStack);
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < leftPouchItem.getSlotCount(); i++) {
 | 
			
		||||
                        BagSlot slot = leftPouchSlots.get(i);
 | 
			
		||||
                        slot.setInventory(leftPouchInv);
 | 
			
		||||
                        slot.setEnabled(true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
					for (int i = 0; i < leftPouchItem.getSlotCount(); i++) {
 | 
			
		||||
						BagSlot slot = leftPouchSlots.get(i);
 | 
			
		||||
						slot.setInventory(leftPouchInv);
 | 
			
		||||
						slot.setEnabled(true);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
                ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
 | 
			
		||||
                DefaultedList<BagSlot> rightPouchSlots = screenHandler.scout$getRightPouchSlots();
 | 
			
		||||
				ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
 | 
			
		||||
				DefaultedList<BagSlot> rightPouchSlots = screenHandler.scout$getRightPouchSlots();
 | 
			
		||||
 | 
			
		||||
                for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
                    BagSlot slot = rightPouchSlots.get(i);
 | 
			
		||||
                    slot.setInventory(null);
 | 
			
		||||
                    slot.setEnabled(false);
 | 
			
		||||
                }
 | 
			
		||||
                if (!rightPouchStack.isEmpty()) {
 | 
			
		||||
                    BaseBagItem rightPouchItem = (BaseBagItem) rightPouchStack.getItem();
 | 
			
		||||
                    Inventory rightPouchInv = rightPouchItem.getInventory(rightPouchStack);
 | 
			
		||||
				for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
					BagSlot slot = rightPouchSlots.get(i);
 | 
			
		||||
					slot.setInventory(null);
 | 
			
		||||
					slot.setEnabled(false);
 | 
			
		||||
				}
 | 
			
		||||
				if (!rightPouchStack.isEmpty()) {
 | 
			
		||||
					BaseBagItem rightPouchItem = (BaseBagItem) rightPouchStack.getItem();
 | 
			
		||||
					Inventory rightPouchInv = rightPouchItem.getInventory(rightPouchStack);
 | 
			
		||||
 | 
			
		||||
                    for (int i = 0; i < rightPouchItem.getSlotCount(); i++) {
 | 
			
		||||
                        BagSlot slot = rightPouchSlots.get(i);
 | 
			
		||||
                        slot.setInventory(rightPouchInv);
 | 
			
		||||
                        slot.setEnabled(true);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
					for (int i = 0; i < rightPouchItem.getSlotCount(); i++) {
 | 
			
		||||
						BagSlot slot = rightPouchSlots.get(i);
 | 
			
		||||
						slot.setInventory(rightPouchInv);
 | 
			
		||||
						slot.setEnabled(true);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			});
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
        TooltipComponentCallback.EVENT.register(data -> {
 | 
			
		||||
            if (data instanceof BagTooltipData d) {
 | 
			
		||||
                return new BagTooltipComponent(d);
 | 
			
		||||
            }
 | 
			
		||||
		TooltipComponentCallback.EVENT.register(data -> {
 | 
			
		||||
			if (data instanceof BagTooltipData d) {
 | 
			
		||||
				return new BagTooltipComponent(d);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
            return null;
 | 
			
		||||
        });
 | 
			
		||||
			return null;
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entityType, entityRenderer, registrationHelper, context) -> {
 | 
			
		||||
			if (entityType == EntityType.PLAYER) {
 | 
			
		||||
| 
						 | 
				
			
			@ -200,5 +200,5 @@ public class ScoutClient implements ClientModInitializer {
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
    }
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,34 +12,34 @@ import pm.c7.scout.item.BaseBagItem.BagType;
 | 
			
		|||
import pm.c7.scout.mixin.client.HandledScreenAccessor;
 | 
			
		||||
 | 
			
		||||
public class ScoutEmiPlugin implements EmiPlugin {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void register(EmiRegistry registry) {
 | 
			
		||||
        registry.addExclusionArea(InventoryScreen.class, (screen, consumer) -> {
 | 
			
		||||
            MinecraftClient client = MinecraftClient.getInstance();
 | 
			
		||||
            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);
 | 
			
		||||
	@Override
 | 
			
		||||
	public void register(EmiRegistry registry) {
 | 
			
		||||
		registry.addExclusionArea(InventoryScreen.class, (screen, consumer) -> {
 | 
			
		||||
			MinecraftClient client = MinecraftClient.getInstance();
 | 
			
		||||
			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 = ((HandledScreenAccessor) screen).getX() - (columns * 18);
 | 
			
		||||
				int y = ((HandledScreenAccessor) screen).getY() + 76;
 | 
			
		||||
 | 
			
		||||
                consumer.accept(new Bounds(x, y, columns * 18, 68));
 | 
			
		||||
            }
 | 
			
		||||
				consumer.accept(new Bounds(x, y, columns * 18, 68));
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
            ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
 | 
			
		||||
            if (!rightPouchStack.isEmpty()) {
 | 
			
		||||
                BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem();
 | 
			
		||||
                int slots = bagItem.getSlotCount();
 | 
			
		||||
                int columns = (int) Math.ceil(slots / 3);
 | 
			
		||||
			ItemStack rightPouchStack = ScoutUtil.findBagItem(client.player, BagType.POUCH, true);
 | 
			
		||||
			if (!rightPouchStack.isEmpty()) {
 | 
			
		||||
				BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem();
 | 
			
		||||
				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 = ((HandledScreenAccessor) screen).getX() + 176;
 | 
			
		||||
				int y = ((HandledScreenAccessor) screen).getY() + 76;
 | 
			
		||||
 | 
			
		||||
                consumer.accept(new Bounds(x, y, columns * 18, 68));
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
				consumer.accept(new Bounds(x, y, columns * 18, 68));
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,19 +5,19 @@ import net.minecraft.item.ItemStack;
 | 
			
		|||
import net.minecraft.util.collection.DefaultedList;
 | 
			
		||||
 | 
			
		||||
public class BagTooltipData implements TooltipData {
 | 
			
		||||
    private final DefaultedList<ItemStack> inventory;
 | 
			
		||||
    private final int slotCount;
 | 
			
		||||
	private final DefaultedList<ItemStack> inventory;
 | 
			
		||||
	private final int slotCount;
 | 
			
		||||
 | 
			
		||||
    public BagTooltipData(DefaultedList<ItemStack> inventory, int slots) {
 | 
			
		||||
        this.inventory = inventory;
 | 
			
		||||
        this.slotCount = slots;
 | 
			
		||||
    }
 | 
			
		||||
	public BagTooltipData(DefaultedList<ItemStack> inventory, int slots) {
 | 
			
		||||
		this.inventory = inventory;
 | 
			
		||||
		this.slotCount = slots;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public DefaultedList<ItemStack> getInventory() {
 | 
			
		||||
        return this.inventory;
 | 
			
		||||
    }
 | 
			
		||||
	public DefaultedList<ItemStack> getInventory() {
 | 
			
		||||
		return this.inventory;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public int getSlotCount() {
 | 
			
		||||
        return this.slotCount;
 | 
			
		||||
    }
 | 
			
		||||
	public int getSlotCount() {
 | 
			
		||||
		return this.slotCount;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,85 +31,85 @@ import java.util.List;
 | 
			
		|||
import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
public class BaseBagItem extends TrinketItem {
 | 
			
		||||
    private static final String ITEMS_KEY = "Items";
 | 
			
		||||
	private static final String ITEMS_KEY = "Items";
 | 
			
		||||
 | 
			
		||||
    private final int slots;
 | 
			
		||||
    private final BagType type;
 | 
			
		||||
	private final int slots;
 | 
			
		||||
	private final BagType type;
 | 
			
		||||
 | 
			
		||||
    public BaseBagItem(Settings settings, int slots, BagType type) {
 | 
			
		||||
        super(settings);
 | 
			
		||||
	public BaseBagItem(Settings settings, int slots, BagType type) {
 | 
			
		||||
		super(settings);
 | 
			
		||||
 | 
			
		||||
        if (type == BagType.SATCHEL && slots > ScoutUtil.MAX_SATCHEL_SLOTS) {
 | 
			
		||||
            throw new IllegalArgumentException("Satchel has too many slots.");
 | 
			
		||||
        }
 | 
			
		||||
        if (type == BagType.POUCH && slots > ScoutUtil.MAX_POUCH_SLOTS) {
 | 
			
		||||
            throw new IllegalArgumentException("Pouch has too many slots.");
 | 
			
		||||
        }
 | 
			
		||||
		if (type == BagType.SATCHEL && slots > ScoutUtil.MAX_SATCHEL_SLOTS) {
 | 
			
		||||
			throw new IllegalArgumentException("Satchel has too many slots.");
 | 
			
		||||
		}
 | 
			
		||||
		if (type == BagType.POUCH && slots > ScoutUtil.MAX_POUCH_SLOTS) {
 | 
			
		||||
			throw new IllegalArgumentException("Pouch has too many slots.");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        this.slots = slots;
 | 
			
		||||
        this.type = type;
 | 
			
		||||
    }
 | 
			
		||||
		this.slots = slots;
 | 
			
		||||
		this.type = type;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public int getSlotCount() {
 | 
			
		||||
        return this.slots;
 | 
			
		||||
    }
 | 
			
		||||
	public int getSlotCount() {
 | 
			
		||||
		return this.slots;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public BagType getType() {
 | 
			
		||||
        return this.type;
 | 
			
		||||
    }
 | 
			
		||||
	public BagType getType() {
 | 
			
		||||
		return this.type;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
 | 
			
		||||
        super.appendTooltip(stack, world, tooltip, context);
 | 
			
		||||
        tooltip.add(Text.translatable("tooltip.scout.slots", Text.literal(String.valueOf(this.slots)).formatted(Formatting.BLUE)).formatted(Formatting.GRAY));
 | 
			
		||||
    }
 | 
			
		||||
	@Override
 | 
			
		||||
	public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip, TooltipContext context) {
 | 
			
		||||
		super.appendTooltip(stack, world, tooltip, context);
 | 
			
		||||
		tooltip.add(Text.translatable("tooltip.scout.slots", Text.literal(String.valueOf(this.slots)).formatted(Formatting.BLUE)).formatted(Formatting.GRAY));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public Inventory getInventory(ItemStack stack) {
 | 
			
		||||
        SimpleInventory inventory = new SimpleInventory(this.slots) {
 | 
			
		||||
            @Override
 | 
			
		||||
            public void markDirty() {
 | 
			
		||||
                stack.getOrCreateNbt().put(ITEMS_KEY, ScoutUtil.inventoryToTag(this));
 | 
			
		||||
                super.markDirty();
 | 
			
		||||
            }
 | 
			
		||||
        };
 | 
			
		||||
	public Inventory getInventory(ItemStack stack) {
 | 
			
		||||
		SimpleInventory inventory = new SimpleInventory(this.slots) {
 | 
			
		||||
			@Override
 | 
			
		||||
			public void markDirty() {
 | 
			
		||||
				stack.getOrCreateNbt().put(ITEMS_KEY, ScoutUtil.inventoryToTag(this));
 | 
			
		||||
				super.markDirty();
 | 
			
		||||
			}
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
        NbtCompound compound = stack.getOrCreateNbt();
 | 
			
		||||
        if (!compound.contains(ITEMS_KEY)) {
 | 
			
		||||
            compound.put(ITEMS_KEY, new NbtList());
 | 
			
		||||
        }
 | 
			
		||||
		NbtCompound compound = stack.getOrCreateNbt();
 | 
			
		||||
		if (!compound.contains(ITEMS_KEY)) {
 | 
			
		||||
			compound.put(ITEMS_KEY, new NbtList());
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        NbtList items = compound.getList(ITEMS_KEY, 10);
 | 
			
		||||
		NbtList items = compound.getList(ITEMS_KEY, 10);
 | 
			
		||||
 | 
			
		||||
        ScoutUtil.inventoryFromTag(items, inventory);
 | 
			
		||||
		ScoutUtil.inventoryFromTag(items, inventory);
 | 
			
		||||
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
		return inventory;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Optional<TooltipData> getTooltipData(ItemStack stack) {
 | 
			
		||||
        DefaultedList<ItemStack> stacks = DefaultedList.of();
 | 
			
		||||
        Inventory inventory = getInventory(stack);
 | 
			
		||||
	@Override
 | 
			
		||||
	public Optional<TooltipData> getTooltipData(ItemStack stack) {
 | 
			
		||||
		DefaultedList<ItemStack> stacks = DefaultedList.of();
 | 
			
		||||
		Inventory inventory = getInventory(stack);
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < slots; i++) {
 | 
			
		||||
            stacks.add(inventory.getStack(i));
 | 
			
		||||
        }
 | 
			
		||||
		for (int i = 0; i < slots; i++) {
 | 
			
		||||
			stacks.add(inventory.getStack(i));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        if (stacks.stream().allMatch(ItemStack::isEmpty)) return Optional.empty();
 | 
			
		||||
		if (stacks.stream().allMatch(ItemStack::isEmpty)) return Optional.empty();
 | 
			
		||||
 | 
			
		||||
        return Optional.of(new BagTooltipData(stacks, slots));
 | 
			
		||||
    }
 | 
			
		||||
		return Optional.of(new BagTooltipData(stacks, slots));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onEquip(ItemStack stack, SlotReference slotRef, LivingEntity entity) {
 | 
			
		||||
        if (entity instanceof PlayerEntity player)
 | 
			
		||||
			updateSlots(player);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onUnequip(ItemStack stack, SlotReference slotRef, LivingEntity entity) {
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onEquip(ItemStack stack, SlotReference slotRef, LivingEntity entity) {
 | 
			
		||||
		if (entity instanceof PlayerEntity player)
 | 
			
		||||
			updateSlots(player);
 | 
			
		||||
    }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onUnequip(ItemStack stack, SlotReference slotRef, LivingEntity entity) {
 | 
			
		||||
		if (entity instanceof PlayerEntity player)
 | 
			
		||||
			updateSlots(player);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void updateSlots(PlayerEntity player) {
 | 
			
		||||
		ScoutScreenHandler handler = (ScoutScreenHandler) player.playerScreenHandler;
 | 
			
		||||
| 
						 | 
				
			
			@ -177,37 +177,37 @@ public class BaseBagItem extends TrinketItem {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean canEquip(ItemStack stack, SlotReference slot, LivingEntity entity) {
 | 
			
		||||
        Item item = stack.getItem();
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean canEquip(ItemStack stack, SlotReference slot, LivingEntity entity) {
 | 
			
		||||
		Item item = stack.getItem();
 | 
			
		||||
 | 
			
		||||
        ItemStack slotStack = slot.inventory().getStack(slot.index());
 | 
			
		||||
        Item slotItem = slotStack.getItem();
 | 
			
		||||
		ItemStack slotStack = slot.inventory().getStack(slot.index());
 | 
			
		||||
		Item slotItem = slotStack.getItem();
 | 
			
		||||
 | 
			
		||||
        if (slotItem instanceof BaseBagItem) {
 | 
			
		||||
            if (((BaseBagItem) item).getType() == BagType.SATCHEL) {
 | 
			
		||||
                if (((BaseBagItem) slotItem).getType() == BagType.SATCHEL) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.SATCHEL, false).isEmpty();
 | 
			
		||||
                }
 | 
			
		||||
            } else if (((BaseBagItem) item).getType() == BagType.POUCH) {
 | 
			
		||||
                if (((BaseBagItem) slotItem).getType() == BagType.POUCH) {
 | 
			
		||||
                    return true;
 | 
			
		||||
                } else {
 | 
			
		||||
                    return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.POUCH, true).isEmpty();
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            if (((BaseBagItem) item).getType() == BagType.SATCHEL) {
 | 
			
		||||
                return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.SATCHEL, false).isEmpty();
 | 
			
		||||
            } else if (((BaseBagItem) item).getType() == BagType.POUCH) {
 | 
			
		||||
                return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.POUCH, true).isEmpty();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
		if (slotItem instanceof BaseBagItem) {
 | 
			
		||||
			if (((BaseBagItem) item).getType() == BagType.SATCHEL) {
 | 
			
		||||
				if (((BaseBagItem) slotItem).getType() == BagType.SATCHEL) {
 | 
			
		||||
					return true;
 | 
			
		||||
				} else {
 | 
			
		||||
					return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.SATCHEL, false).isEmpty();
 | 
			
		||||
				}
 | 
			
		||||
			} else if (((BaseBagItem) item).getType() == BagType.POUCH) {
 | 
			
		||||
				if (((BaseBagItem) slotItem).getType() == BagType.POUCH) {
 | 
			
		||||
					return true;
 | 
			
		||||
				} else {
 | 
			
		||||
					return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.POUCH, true).isEmpty();
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if (((BaseBagItem) item).getType() == BagType.SATCHEL) {
 | 
			
		||||
				return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.SATCHEL, false).isEmpty();
 | 
			
		||||
			} else if (((BaseBagItem) item).getType() == BagType.POUCH) {
 | 
			
		||||
				return ScoutUtil.findBagItem((PlayerEntity) entity, BagType.POUCH, true).isEmpty();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
 | 
			
		||||
| 
						 | 
				
			
			@ -219,8 +219,8 @@ public class BaseBagItem extends TrinketItem {
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    public enum BagType {
 | 
			
		||||
        SATCHEL,
 | 
			
		||||
        POUCH
 | 
			
		||||
    }
 | 
			
		||||
	public enum BagType {
 | 
			
		||||
		SATCHEL,
 | 
			
		||||
		POUCH
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,14 +9,13 @@ import pm.c7.scout.item.BaseBagItem;
 | 
			
		|||
 | 
			
		||||
@Mixin(ItemStack.class)
 | 
			
		||||
public class ItemStackMixin {
 | 
			
		||||
 | 
			
		||||
    // Trinkets calls areEqual to check whether it should unequip old and equip new (https://github.com/emilyploszaj/trinkets/blob/7cb63ce0/src/main/java/dev/emi/trinkets/mixin/LivingEntityMixin.java#L155-L158)
 | 
			
		||||
    // Excluding ourselves from this check to force unequip/equip when switching bag items fixes a duplication bug
 | 
			
		||||
    // Gross and hacky but oh well, can't mixin mixins.
 | 
			
		||||
    @Inject(method = "areEqual", at = @At("HEAD"), cancellable = true)
 | 
			
		||||
    private static void scout$grossTrinketsEquipFix(ItemStack stack, ItemStack otherStack, CallbackInfoReturnable<Boolean> callbackInfo) {
 | 
			
		||||
        if (stack.getItem() instanceof BaseBagItem && otherStack.getItem() instanceof BaseBagItem) {
 | 
			
		||||
            callbackInfo.setReturnValue(false);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
	// Trinkets calls areEqual to check whether it should unequip old and equip new (https://github.com/emilyploszaj/trinkets/blob/7cb63ce0/src/main/java/dev/emi/trinkets/mixin/LivingEntityMixin.java#L155-L158)
 | 
			
		||||
	// Excluding ourselves from this check to force unequip/equip when switching bag items fixes a duplication bug
 | 
			
		||||
	// Gross and hacky but oh well, can't mixin mixins.
 | 
			
		||||
	@Inject(method = "areEqual", at = @At("HEAD"), cancellable = true)
 | 
			
		||||
	private static void scout$grossTrinketsEquipFix(ItemStack stack, ItemStack otherStack, CallbackInfoReturnable<Boolean> callbackInfo) {
 | 
			
		||||
		if (stack.getItem() instanceof BaseBagItem && otherStack.getItem() instanceof BaseBagItem) {
 | 
			
		||||
			callbackInfo.setReturnValue(false);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,84 +18,84 @@ import pm.c7.scout.screen.BagSlot;
 | 
			
		|||
@Mixin(value = PlayerScreenHandler.class, priority = 950)
 | 
			
		||||
@Transformer(PlayerScreenHandlerTransformer.class)
 | 
			
		||||
public abstract class PlayerScreenHandlerMixin extends ScreenHandler implements ScoutScreenHandler {
 | 
			
		||||
    protected PlayerScreenHandlerMixin() {
 | 
			
		||||
        super(null, 0);
 | 
			
		||||
    }
 | 
			
		||||
	protected PlayerScreenHandlerMixin() {
 | 
			
		||||
		super(null, 0);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Unique
 | 
			
		||||
    public final DefaultedList<BagSlot> scout$satchelSlots = DefaultedList.ofSize(ScoutUtil.MAX_SATCHEL_SLOTS);
 | 
			
		||||
    @Unique
 | 
			
		||||
    public final DefaultedList<BagSlot> scout$leftPouchSlots = DefaultedList.ofSize(ScoutUtil.MAX_POUCH_SLOTS);
 | 
			
		||||
    @Unique
 | 
			
		||||
    public final DefaultedList<BagSlot> scout$rightPouchSlots = DefaultedList.ofSize(ScoutUtil.MAX_POUCH_SLOTS);
 | 
			
		||||
	@Unique
 | 
			
		||||
	public final DefaultedList<BagSlot> scout$satchelSlots = DefaultedList.ofSize(ScoutUtil.MAX_SATCHEL_SLOTS);
 | 
			
		||||
	@Unique
 | 
			
		||||
	public final DefaultedList<BagSlot> scout$leftPouchSlots = DefaultedList.ofSize(ScoutUtil.MAX_POUCH_SLOTS);
 | 
			
		||||
	@Unique
 | 
			
		||||
	public final DefaultedList<BagSlot> scout$rightPouchSlots = DefaultedList.ofSize(ScoutUtil.MAX_POUCH_SLOTS);
 | 
			
		||||
 | 
			
		||||
    @Inject(method = "<init>", at = @At("RETURN"))
 | 
			
		||||
    private void scout$addSlots(PlayerInventory inventory, boolean onServer, PlayerEntity owner, CallbackInfo callbackInfo) {
 | 
			
		||||
        // satchel
 | 
			
		||||
        int x = 8;
 | 
			
		||||
        int y = 168;
 | 
			
		||||
	@Inject(method = "<init>", at = @At("RETURN"))
 | 
			
		||||
	private void scout$addSlots(PlayerInventory inventory, boolean onServer, PlayerEntity owner, CallbackInfo callbackInfo) {
 | 
			
		||||
		// satchel
 | 
			
		||||
		int x = 8;
 | 
			
		||||
		int y = 168;
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
 | 
			
		||||
            if (i % 9 == 0) {
 | 
			
		||||
                x = 8;
 | 
			
		||||
            }
 | 
			
		||||
		for (int i = 0; i < ScoutUtil.MAX_SATCHEL_SLOTS; i++) {
 | 
			
		||||
			if (i % 9 == 0) {
 | 
			
		||||
				x = 8;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
            BagSlot slot = new BagSlot(i, x, y);
 | 
			
		||||
			BagSlot slot = new BagSlot(i, x, y);
 | 
			
		||||
			slot.id = ScoutUtil.SATCHEL_SLOT_START - i;
 | 
			
		||||
			scout$satchelSlots.add(slot);
 | 
			
		||||
 | 
			
		||||
            x += 18;
 | 
			
		||||
			x += 18;
 | 
			
		||||
 | 
			
		||||
            if ((i + 1) % 9 == 0) {
 | 
			
		||||
                y += 18;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
			if ((i + 1) % 9 == 0) {
 | 
			
		||||
				y += 18;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        // left pouch
 | 
			
		||||
        x = 8;
 | 
			
		||||
        y = 66;
 | 
			
		||||
		// left pouch
 | 
			
		||||
		x = 8;
 | 
			
		||||
		y = 66;
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
            if (i % 3 == 0) {
 | 
			
		||||
                x -= 18;
 | 
			
		||||
                y += 54;
 | 
			
		||||
            }
 | 
			
		||||
		for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
			if (i % 3 == 0) {
 | 
			
		||||
				x -= 18;
 | 
			
		||||
				y += 54;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
            BagSlot slot = new BagSlot(i, x, y);
 | 
			
		||||
			BagSlot slot = new BagSlot(i, x, y);
 | 
			
		||||
			slot.id = ScoutUtil.LEFT_POUCH_SLOT_START - i;
 | 
			
		||||
			scout$leftPouchSlots.add(slot);
 | 
			
		||||
 | 
			
		||||
            y -= 18;
 | 
			
		||||
        }
 | 
			
		||||
			y -= 18;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
        // right pouch
 | 
			
		||||
        x = 152;
 | 
			
		||||
        y = 66;
 | 
			
		||||
		// right pouch
 | 
			
		||||
		x = 152;
 | 
			
		||||
		y = 66;
 | 
			
		||||
 | 
			
		||||
        for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
            if (i % 3 == 0) {
 | 
			
		||||
                x += 18;
 | 
			
		||||
                y += 54;
 | 
			
		||||
            }
 | 
			
		||||
		for (int i = 0; i < ScoutUtil.MAX_POUCH_SLOTS; i++) {
 | 
			
		||||
			if (i % 3 == 0) {
 | 
			
		||||
				x += 18;
 | 
			
		||||
				y += 54;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
            BagSlot slot = new BagSlot(i, x, y);
 | 
			
		||||
			BagSlot slot = new BagSlot(i, x, y);
 | 
			
		||||
			slot.id = ScoutUtil.RIGHT_POUCH_SLOT_START - i;
 | 
			
		||||
			scout$rightPouchSlots.add(slot);
 | 
			
		||||
 | 
			
		||||
            y -= 18;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
			y -= 18;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public final DefaultedList<BagSlot> scout$getSatchelSlots() {
 | 
			
		||||
        return scout$satchelSlots;
 | 
			
		||||
    }
 | 
			
		||||
    @Override
 | 
			
		||||
    public final DefaultedList<BagSlot> scout$getLeftPouchSlots() {
 | 
			
		||||
        return scout$leftPouchSlots;
 | 
			
		||||
    }
 | 
			
		||||
    @Override
 | 
			
		||||
    public final DefaultedList<BagSlot> scout$getRightPouchSlots() {
 | 
			
		||||
        return scout$rightPouchSlots;
 | 
			
		||||
    }
 | 
			
		||||
	@Override
 | 
			
		||||
	public final DefaultedList<BagSlot> scout$getSatchelSlots() {
 | 
			
		||||
		return scout$satchelSlots;
 | 
			
		||||
	}
 | 
			
		||||
	@Override
 | 
			
		||||
	public final DefaultedList<BagSlot> scout$getLeftPouchSlots() {
 | 
			
		||||
		return scout$leftPouchSlots;
 | 
			
		||||
	}
 | 
			
		||||
	@Override
 | 
			
		||||
	public final DefaultedList<BagSlot> scout$getRightPouchSlots() {
 | 
			
		||||
		return scout$rightPouchSlots;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,10 +5,8 @@ import net.fabricmc.api.Environment;
 | 
			
		|||
import net.minecraft.client.gui.screen.ingame.AbstractFurnaceScreen;
 | 
			
		||||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
 | 
			
		||||
import net.minecraft.client.gui.screen.recipe.book.RecipeBookProvider;
 | 
			
		||||
import net.minecraft.entity.player.PlayerInventory;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.screen.AbstractFurnaceScreenHandler;
 | 
			
		||||
import net.minecraft.text.Text;
 | 
			
		||||
import org.spongepowered.asm.mixin.Mixin;
 | 
			
		||||
import org.spongepowered.asm.mixin.injection.At;
 | 
			
		||||
import org.spongepowered.asm.mixin.injection.Inject;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,10 +9,10 @@ import org.spongepowered.asm.mixin.gen.Accessor;
 | 
			
		|||
@Environment(EnvType.CLIENT)
 | 
			
		||||
@Mixin(HandledScreen.class)
 | 
			
		||||
public interface HandledScreenAccessor {
 | 
			
		||||
    @Accessor("x")
 | 
			
		||||
    int getX();
 | 
			
		||||
    @Accessor("y")
 | 
			
		||||
    int getY();
 | 
			
		||||
	@Accessor("x")
 | 
			
		||||
	int getX();
 | 
			
		||||
	@Accessor("y")
 | 
			
		||||
	int getY();
 | 
			
		||||
	@Accessor("backgroundWidth")
 | 
			
		||||
	int getBackgroundWidth();
 | 
			
		||||
	@Accessor("backgroundHeight")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,6 @@ import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
 | 
			
		|||
import net.minecraft.client.gui.screen.ingame.HandledScreen;
 | 
			
		||||
import net.minecraft.client.gui.screen.ingame.ScreenHandlerProvider;
 | 
			
		||||
import net.minecraft.client.gui.screen.ingame.ShulkerBoxScreen;
 | 
			
		||||
import net.minecraft.client.render.GameRenderer;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.screen.ScreenHandler;
 | 
			
		||||
import net.minecraft.screen.slot.Slot;
 | 
			
		||||
| 
						 | 
				
			
			@ -277,7 +276,6 @@ public abstract class HandledScreenMixin<T extends ScreenHandler> extends Screen
 | 
			
		|||
			for (int i = ScoutUtil.SATCHEL_SLOT_START; i > ScoutUtil.BAG_SLOTS_END; i--) {
 | 
			
		||||
				BagSlot slot = (BagSlot) ScoutUtil.getBagSlot(i, this.client.player.playerScreenHandler);
 | 
			
		||||
				if (slot != null && slot.isEnabled()) {
 | 
			
		||||
					RenderSystem.setShader(GameRenderer::getPositionTexShader);
 | 
			
		||||
					this.drawSlot(graphics, slot);
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,19 +1,15 @@
 | 
			
		|||
package pm.c7.scout.mixin.client;
 | 
			
		||||
 | 
			
		||||
import com.mojang.blaze3d.systems.RenderSystem;
 | 
			
		||||
import net.fabricmc.api.EnvType;
 | 
			
		||||
import net.fabricmc.api.Environment;
 | 
			
		||||
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
 | 
			
		||||
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
 | 
			
		||||
import net.minecraft.client.gui.screen.recipe.book.RecipeBookProvider;
 | 
			
		||||
import net.minecraft.client.render.GameRenderer;
 | 
			
		||||
import net.minecraft.client.util.math.MatrixStack;
 | 
			
		||||
import net.minecraft.item.ItemStack;
 | 
			
		||||
import net.minecraft.screen.PlayerScreenHandler;
 | 
			
		||||
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.CallbackInfo;
 | 
			
		||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
 | 
			
		||||
import pm.c7.scout.ScoutUtil;
 | 
			
		||||
import pm.c7.scout.item.BaseBagItem;
 | 
			
		||||
| 
						 | 
				
			
			@ -22,45 +18,45 @@ import pm.c7.scout.item.BaseBagItem.BagType;
 | 
			
		|||
@Environment(EnvType.CLIENT)
 | 
			
		||||
@Mixin(InventoryScreen.class)
 | 
			
		||||
public abstract class InventoryScreenMixin extends AbstractInventoryScreen<PlayerScreenHandler> implements RecipeBookProvider {
 | 
			
		||||
    private InventoryScreenMixin() {
 | 
			
		||||
        super(null, null, null);
 | 
			
		||||
    }
 | 
			
		||||
	private InventoryScreenMixin() {
 | 
			
		||||
		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, BagType.SATCHEL, false);
 | 
			
		||||
            if (!backStack.isEmpty()) {
 | 
			
		||||
                BaseBagItem bagItem = (BaseBagItem) backStack.getItem();
 | 
			
		||||
                int slots = bagItem.getSlotCount();
 | 
			
		||||
                int rows = (int) Math.ceil(slots / 9);
 | 
			
		||||
	@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, 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);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
				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, BagType.POUCH, false);
 | 
			
		||||
            if (!leftPouchStack.isEmpty()) {
 | 
			
		||||
                BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
 | 
			
		||||
                int slots = bagItem.getSlotCount();
 | 
			
		||||
                int columns = (int) Math.ceil(slots / 3);
 | 
			
		||||
			ItemStack leftPouchStack = ScoutUtil.findBagItem(this.client.player, 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);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
				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, BagType.POUCH, true);
 | 
			
		||||
            if (!rightPouchStack.isEmpty()) {
 | 
			
		||||
                BaseBagItem bagItem = (BaseBagItem) rightPouchStack.getItem();
 | 
			
		||||
                int slots = bagItem.getSlotCount();
 | 
			
		||||
                int columns = (int) Math.ceil(slots / 3);
 | 
			
		||||
			ItemStack rightPouchStack = ScoutUtil.findBagItem(this.client.player, 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);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
				if (mouseX >= (left + this.backgroundWidth) && mouseX < (left + this.backgroundWidth) + (columns * 18) && mouseY >= (top + this.backgroundHeight) - 90 && mouseY < (top + this.backgroundHeight) - 22) {
 | 
			
		||||
					callbackInfo.setReturnValue(false);
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,36 +19,36 @@ import pm.c7.scout.item.BaseBagItem.BagType;
 | 
			
		|||
@Environment(EnvType.CLIENT)
 | 
			
		||||
@Mixin(value = RecipeBookWidget.class, priority = 950)
 | 
			
		||||
public class RecipeBookWidgetMixin {
 | 
			
		||||
    @Shadow
 | 
			
		||||
    protected MinecraftClient client;
 | 
			
		||||
    @Shadow
 | 
			
		||||
    private int leftOffset;
 | 
			
		||||
	@Shadow
 | 
			
		||||
	protected MinecraftClient client;
 | 
			
		||||
	@Shadow
 | 
			
		||||
	private int leftOffset;
 | 
			
		||||
 | 
			
		||||
    @Inject(method = "findLeftEdge", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
 | 
			
		||||
    private void scout$modifyRecipeBookPosition(int width, int backgroundWidth, CallbackInfoReturnable<Integer> callbackInfo, int x) {
 | 
			
		||||
        if (this.client != null && this.client.player != null && this.isOpen()) {
 | 
			
		||||
            ItemStack leftPouchStack = ScoutUtil.findBagItem(this.client.player, BagType.POUCH, false);
 | 
			
		||||
            if (!leftPouchStack.isEmpty()) {
 | 
			
		||||
                BaseBagItem bagItem = (BaseBagItem) leftPouchStack.getItem();
 | 
			
		||||
                int slots = bagItem.getSlotCount();
 | 
			
		||||
	@Inject(method = "findLeftEdge", at = @At("RETURN"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
 | 
			
		||||
	private void scout$modifyRecipeBookPosition(int width, int backgroundWidth, CallbackInfoReturnable<Integer> callbackInfo, int x) {
 | 
			
		||||
		if (this.client != null && this.client.player != null && this.isOpen()) {
 | 
			
		||||
			ItemStack leftPouchStack = ScoutUtil.findBagItem(this.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 columns = (int) Math.ceil(slots / 3);
 | 
			
		||||
 | 
			
		||||
                // Realign as best we can when "Keep crafting screens centered" is enabled in Better Recipe Book
 | 
			
		||||
                if (this.leftOffset != 86) {
 | 
			
		||||
                    int diff = this.leftOffset - 86;
 | 
			
		||||
                    x -= diff;
 | 
			
		||||
                }
 | 
			
		||||
				// Realign as best we can when "Keep crafting screens centered" is enabled in Better Recipe Book
 | 
			
		||||
				if (this.leftOffset != 86) {
 | 
			
		||||
					int diff = this.leftOffset - 86;
 | 
			
		||||
					x -= diff;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
                x += 18 * columns;
 | 
			
		||||
				x += 18 * columns;
 | 
			
		||||
 | 
			
		||||
                callbackInfo.setReturnValue(x);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
				callbackInfo.setReturnValue(x);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
    @Shadow
 | 
			
		||||
    public boolean isOpen() {
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
	@Shadow
 | 
			
		||||
	public boolean isOpen() {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue