From e3394a89072138691c1fe36fdd0675114eaa7060 Mon Sep 17 00:00:00 2001 From: Snownee Date: Tue, 16 Mar 2021 21:56:04 +0800 Subject: [PATCH] Allow attribute filter screen to have space to show JEI bookmarks --- .../simibubi/create/compat/jei/CreateJEI.java | 4 ++++ .../item/filter/AbstractFilterContainer.java | 2 +- .../item/filter/AbstractFilterScreen.java | 22 ++++++++++++++----- .../item/filter/AttributeFilterContainer.java | 4 ++-- .../item/filter/AttributeFilterScreen.java | 4 ++-- .../item/filter/FilterContainer.java | 2 +- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java index 33606b4da..b66b93999 100644 --- a/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java +++ b/src/main/java/com/simibubi/create/compat/jei/CreateJEI.java @@ -40,6 +40,8 @@ import com.simibubi.create.content.contraptions.fluids.recipe.PotionMixingRecipe import com.simibubi.create.content.contraptions.processing.BasinRecipe; import com.simibubi.create.content.logistics.block.inventories.AdjustableCrateScreen; import com.simibubi.create.content.logistics.item.filter.AbstractFilterScreen; +import com.simibubi.create.content.logistics.item.filter.AttributeFilterScreen; +import com.simibubi.create.content.logistics.item.filter.FilterScreen; import com.simibubi.create.content.schematics.block.SchematicTableScreen; import com.simibubi.create.content.schematics.block.SchematicannonScreen; import com.simibubi.create.foundation.config.AllConfigs; @@ -231,6 +233,8 @@ public class CreateJEI implements IModPlugin { registration.addGuiContainerHandler(AdjustableCrateScreen.class, slotMover); registration.addGuiContainerHandler(SchematicannonScreen.class, slotMover); registration.addGuiContainerHandler(SchematicTableScreen.class, slotMover); + registration.addGuiContainerHandler(FilterScreen.class, slotMover); + registration.addGuiContainerHandler(AttributeFilterScreen.class, slotMover); registration.addGhostIngredientHandler(AbstractFilterScreen.class, new FilterGhostIngredientHandler()); } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java index 611401b98..1bd54d34d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterContainer.java @@ -54,7 +54,7 @@ public abstract class AbstractFilterContainer extends Container { protected abstract void saveData(ItemStack filterItem); protected void addPlayerSlots() { - int x = 58; + int x = 8; int y = 28 + getInventoryOffset(); for (int hotbarSlot = 0; hotbarSlot < 9; ++hotbarSlot) diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java index ae138ce3d..21ba7976d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AbstractFilterScreen.java @@ -6,6 +6,7 @@ import static net.minecraft.util.text.TextFormatting.GRAY; import java.util.Collections; import java.util.List; +import com.google.common.collect.ImmutableList; import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option; import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen; import com.simibubi.create.foundation.gui.AllGuiTextures; @@ -19,6 +20,7 @@ import com.simibubi.create.foundation.item.TooltipHelper; import com.simibubi.create.foundation.networking.AllPackets; import net.minecraft.client.gui.widget.Widget; +import net.minecraft.client.renderer.Rectangle2d; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.util.text.ITextComponent; @@ -26,6 +28,7 @@ import net.minecraft.util.text.ITextComponent; public abstract class AbstractFilterScreen extends AbstractSimiContainerScreen { protected AllGuiTextures background; + private List extraAreas = Collections.EMPTY_LIST; private IconButton resetButton; private IconButton confirmButton; @@ -37,12 +40,15 @@ public abstract class AbstractFilterScreen ex @Override protected void init() { - setWindowSize(background.width + 80, background.height + PLAYER_INVENTORY.height + 20); + setWindowSize(PLAYER_INVENTORY.width, background.height + PLAYER_INVENTORY.height + 20); super.init(); widgets.clear(); + int x = guiLeft - 50; + int offset = guiTop < 30 ? 30 - guiTop : 0; + extraAreas = ImmutableList.of(new Rectangle2d(x, guiTop + offset, background.width + 70, background.height - offset)); - resetButton = new IconButton(guiLeft + background.width - 62, guiTop + background.height - 24, AllIcons.I_TRASH); - confirmButton = new IconButton(guiLeft + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); + resetButton = new IconButton(x + background.width - 62, guiTop + background.height - 24, AllIcons.I_TRASH); + confirmButton = new IconButton(x + background.width - 33, guiTop + background.height - 24, AllIcons.I_CONFIRM); widgets.add(resetButton); widgets.add(confirmButton); @@ -50,11 +56,11 @@ public abstract class AbstractFilterScreen ex @Override protected void renderWindow(int mouseX, int mouseY, float partialTicks) { - int x = guiLeft; + int x = guiLeft - 50; int y = guiTop; background.draw(this, x, y); - int invX = x + 50; + int invX = guiLeft; int invY = y + background.height + 10; PLAYER_INVENTORY.draw(this, invX, invY); @@ -62,7 +68,7 @@ public abstract class AbstractFilterScreen ex font.drawStringWithShadow(I18n.format(container.filterItem.getTranslationKey()), x + 15, y + 3, 0xdedede); GuiGameElement.of(container.filterItem) - .at(guiLeft + background.width, guiTop +background.height -60) + .at(x + background.width, guiTop +background.height -60) .scale(5) .render(); @@ -150,4 +156,8 @@ public abstract class AbstractFilterScreen ex AllPackets.channel.sendToServer(new FilterScreenPacket(option)); } + @Override + public List getExtraAreas() { + return extraAreas; + } } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java index 54e945ca9..3f768d574 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterContainer.java @@ -62,8 +62,8 @@ public class AttributeFilterContainer extends AbstractFilterContainer { } protected void addFilterSlots() { - this.addSlot(new SlotItemHandler(filterInventory, 0, 16, 22)); - this.addSlot(new SlotItemHandler(filterInventory, 1, 22, 57) { + this.addSlot(new SlotItemHandler(filterInventory, 0, -34, 22)); + this.addSlot(new SlotItemHandler(filterInventory, 1, -28, 57) { @Override public boolean canTakeStack(PlayerEntity playerIn) { return false; diff --git a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java index d23c2fa57..ddf6fe7c3 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/filter/AttributeFilterScreen.java @@ -60,7 +60,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen