use of net.minecraft.client.gui.screen.ingame.ContainerScreen in project tweakermore by Fallen-Breath.
the class ContainerProcessor method process.
public static void process(Container container) {
if (hasTweakEnabled()) {
Screen screen = MinecraftClient.getInstance().currentScreen;
ClientPlayerEntity player = MinecraftClient.getInstance().player;
// not inventory and not crafting table
if (player != null && screen instanceof ContainerScreen<?> && !(screen instanceof AbstractInventoryScreen) && !(screen instanceof CraftingTableScreen)) {
ContainerScreen<?> containerScreen = (ContainerScreen<?>) screen;
if (containerScreen.getContainer() != container || !((AutoProcessableScreen) screen).shouldProcess()) {
return;
}
((AutoProcessableScreen) screen).setShouldProcess(false);
List<Slot> allSlots = container.slots;
List<Slot> playerInvSlots = allSlots.stream().filter(slot -> slot.inventory instanceof PlayerInventory).collect(Collectors.toList());
if (allSlots.isEmpty() || playerInvSlots.isEmpty()) {
return;
}
List<Slot> containerInvSlots = allSlots.stream().filter(slot -> ItemScrollerInventoryUtilsAccessor.areSlotsInSameInventory(slot, allSlots.get(0))).collect(Collectors.toList());
if (containerInvSlots.isEmpty()) {
return;
}
for (Processor processor : CONTAINER_PROCESSORS) {
if (processor.isEnabled()) {
boolean success = processor.process(player, containerScreen, allSlots, playerInvSlots, containerInvSlots);
if (success) {
break;
}
}
}
player.closeContainer();
}
}
}
Aggregations