Adjust slot placement and fixed trinket slots not hiding when switching tabs

This commit is contained in:
Sollace 2023-08-28 19:56:38 +01:00
parent ccad91087c
commit d47433a463
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 19 additions and 29 deletions

View file

@ -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<Identifier, Identifier> getBackgroundSprite() {
return Pair.of(PlayerScreenHandler.BLOCK_ATLAS_TEXTURE, PlayerScreenHandler.EMPTY_OFFHAND_ARMOR_SLOT);

View file

@ -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<Identifier, Identifier> 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