From d47433a4633835102c4dd58f818d5552e012b31f Mon Sep 17 00:00:00 2001 From: Sollace Date: Mon, 28 Aug 2023 19:56:38 +0100 Subject: [PATCH] Adjust slot placement and fixed trinket slots not hiding when switching tabs --- .../container/SpellbookScreenHandler.java | 12 +++---- .../trinkets/SpellbookTrinketSlot.java | 36 +++++++------------ 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java index 3d261daf..f4bc0241 100644 --- a/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java +++ b/src/main/java/com/minelittlepony/unicopia/container/SpellbookScreenHandler.java @@ -100,7 +100,7 @@ public class SpellbookScreenHandler extends ScreenHandler { for (int i = 0; i < 4; i++) { final EquipmentSlot eq = EquipmentSlot.values()[5 - i]; - addSlot(new InventorySlot(this, inventory, PlayerInventory.OFF_HAND_SLOT - i - 1, 340, 50 + (i * 20)) { + addSlot(new InventorySlot(this, inventory, PlayerInventory.OFF_HAND_SLOT - i - 1, 335, 50 + (i * 20)) { @Override public int getMaxItemCount() { return 1; @@ -127,12 +127,12 @@ public class SpellbookScreenHandler extends ScreenHandler { }); } - TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.FACE, 0, 340 + 20, 60).ifPresent(this::addSlot); - TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.NECKLACE, 0, 340 + 20, 60 + 20).ifPresent(this::addSlot); - TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.MAINHAND, 0, 350 - 20, 170).ifPresent(this::addSlot); - TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.OFFHAND, 0, 330 + 20, 170).ifPresent(this::addSlot); + TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.FACE, 0, 336 + 20, 60).ifPresent(this::addSlot); + TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.NECKLACE, 0, 336 + 20, 60 + 20).ifPresent(this::addSlot); + TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.MAINHAND, 0, 336 - 10, 155).ifPresent(this::addSlot); + TrinketsDelegate.getInstance().createSlot(this, inv.player, TrinketsDelegate.OFFHAND, 0, 336 + 20, 155).ifPresent(this::addSlot); - addSlot(new InventorySlot(this, inventory, PlayerInventory.OFF_HAND_SLOT, 340, 150) { + addSlot(new InventorySlot(this, inventory, PlayerInventory.OFF_HAND_SLOT, 342, 140) { @Override public Pair getBackgroundSprite() { return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT); diff --git a/src/main/java/com/minelittlepony/unicopia/trinkets/SpellbookTrinketSlot.java b/src/main/java/com/minelittlepony/unicopia/trinkets/SpellbookTrinketSlot.java index c870dbdb..9805d496 100644 --- a/src/main/java/com/minelittlepony/unicopia/trinkets/SpellbookTrinketSlot.java +++ b/src/main/java/com/minelittlepony/unicopia/trinkets/SpellbookTrinketSlot.java @@ -1,11 +1,7 @@ package com.minelittlepony.unicopia.trinkets; -import org.jetbrains.annotations.Nullable; - import com.minelittlepony.unicopia.container.SpellbookScreenHandler; import com.minelittlepony.unicopia.container.inventory.InventorySlot; -import com.mojang.datafixers.util.Pair; - import dev.emi.trinkets.SurvivalTrinketSlot; import dev.emi.trinkets.api.SlotGroup; import dev.emi.trinkets.api.TrinketInventory; @@ -18,73 +14,67 @@ class SpellbookTrinketSlot extends InventorySlot implements TrinketsDelegate.Slo public SpellbookTrinketSlot(SpellbookScreenHandler handler, TrinketInventory inventory, int index, int x, int y, SlotGroup group) { super(handler, inventory, index, x, y); - this.slot = new SurvivalTrinketSlot(inventory, index, x, y, group, inventory.getSlotType(), 0, true); + slot = new SurvivalTrinketSlot(inventory, index, x, y, group, inventory.getSlotType(), 0, true); } @Override public void onTakeItem(PlayerEntity player, ItemStack stack) { - this.slot.onTakeItem(player, stack); + slot.onTakeItem(player, stack); } @Override public boolean canInsert(ItemStack stack) { - return this.slot.canInsert(stack); + return slot.canInsert(stack); } @Override public ItemStack getStack() { - return this.slot.getStack(); + return slot.getStack(); } @Override public boolean hasStack() { - return this.slot.hasStack(); + return slot.hasStack(); } @Override public void setStack(ItemStack stack) { - this.slot.setStack(stack); + slot.setStack(stack); } @Override public void setStackNoCallbacks(ItemStack stack) { - this.slot.setStackNoCallbacks(stack); + slot.setStackNoCallbacks(stack); } @Override public void markDirty() { - this.slot.markDirty(); + slot.markDirty(); } @Override public int getMaxItemCount() { - return this.slot.getMaxItemCount(); + return slot.getMaxItemCount(); } @Override public int getMaxItemCount(ItemStack stack) { - return this.slot.getMaxItemCount(stack); - } - - @Override - @Nullable - public Pair getBackgroundSprite() { - return null; + return slot.getMaxItemCount(stack); } @Override public ItemStack takeStack(int amount) { - return this.slot.takeStack(amount); + return slot.takeStack(amount); } @Override public boolean isEnabled() { - return this.slot.isEnabled(); + return super.isEnabled() && slot.isEnabled(); } @Override public boolean canTakeItems(PlayerEntity playerEntity) { - return this.slot.canTakeItems(playerEntity); + return slot.canTakeItems(playerEntity); } @Override