1
0
Fork 0

fix inventory

This commit is contained in:
Sen 2025-08-18 17:43:46 +02:00
parent 030268bfc3
commit 593e10c3cc
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
19 changed files with 52 additions and 121 deletions

View file

@ -11,14 +11,13 @@ public class GuiChest extends GuiContainer {
public GuiChest(EntityNPC player, IInventory chest, Block block) {
super(new ContainerChest(player, chest));
this.block = block;
int i = 222;
int j = i - 108;
this.xSize += (((ContainerChest)this.inventorySlots).getWidth() - 9) * 18;
this.ySize = j + ((ContainerChest)this.inventorySlots).getHeight() * 18;
if(((ContainerChest)this.inventorySlots).getWidth() > 12)
this.xSize += (((ContainerChest)this.inventorySlots).getWidth() - 12) * 18;
this.ySize = 37 + 18 * ((player.getInventoryCapacity() + 11) / 12) + ((ContainerChest)this.inventorySlots).getHeight() * 18;
}
public void addElements() {
this.label(this.block.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 37 - 8 + ((ContainerChest)this.inventorySlots).getHeight() * 18);
}
}

View file

@ -33,6 +33,7 @@ import common.collect.Lists;
import common.collect.Sets;
import common.enchantment.Enchantment;
import common.entity.npc.Attribute;
import common.entity.npc.EntityNPC;
import common.init.ItemRegistry;
import common.inventory.Container;
import common.inventory.Slot;
@ -66,7 +67,7 @@ public abstract class GuiContainer extends Gui
private static CheatTab selectedTab = CheatTab.ALL;
protected RenderItem itemRender;
protected int xSize = 176;
protected int xSize = 14 + 18 * 12;
protected int ySize = 166;
public Container inventorySlots;
private Slot theSlot;
@ -257,6 +258,12 @@ public abstract class GuiContainer extends Gui
this.inventorySlots = container;
this.ignoreMouseUp = true;
}
public GuiContainer(Container container, EntityNPC player)
{
this(container);
this.ySize = 90 + 18 * ((player.getInventoryCapacity() + 11) / 12);
}
public void init(int width, int height) {
this.itemRender = this.gm.getRenderItem();

View file

@ -12,11 +12,11 @@ public class GuiCrafting extends GuiContainer {
public GuiCrafting(EntityNPC inv, World world, BlockWorkbench type) {
super(new ContainerWorkbench(inv, world, BlockPos.ORIGIN, type));
this.type = type;
this.ySize = 112 + 18 * this.type.getSize();
this.ySize = 36 + 18 * ((inv.getInventoryCapacity() + 11) / 12) + 18 * this.type.getSize();
}
public void addElements() {
this.label(this.type.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 36 - 8 + 18 * this.type.getSize());
}
}

View file

@ -24,7 +24,7 @@ public class GuiDevice extends GuiContainer {
super(new ContainerTile(player, tile, inv));
this.playerInv = player;
this.tileInv = tile;
this.ySize = 194;
this.ySize = 118 + 18 * ((player.getInventoryCapacity() + 11) / 12);
this.tile = tile;
}
@ -49,7 +49,7 @@ public class GuiDevice extends GuiContainer {
public void addElements() {
this.header = this.label("", 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 118 - 8);
this.desc = this.display("", 8, 18, 160, 4);
this.progress = this.tile.hasProgress() ? this.bar(7, 70, 162, 9) : null;
this.temperature = this.tile.hasTemperature() ? this.bar(7, this.progress == null ? 70 : 60, 162, 9) : null;

View file

@ -26,7 +26,7 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
private final Label[] mana = new Label[3];
public GuiEnchant(EntityNPC inv, World world) {
super(new ContainerEnchantment(inv, world));
super(new ContainerEnchantment(inv, world), inv);
this.enchantment = (ContainerEnchantment)this.inventorySlots;
}
@ -60,7 +60,7 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
public void addElements() {
this.label(Blocks.enchanting_table.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 90 - 8);
for(int l = 0; l < 3; ++l) {
int i1 = 60;
int j1 = i1 + 2;

View file

@ -9,12 +9,12 @@ public class GuiEntity extends GuiContainer {
private final String title;
public GuiEntity(EntityNPC player, IInventory entityInv, Entity entity) {
super(new ContainerEntityInventory(player, entityInv, entity));
super(new ContainerEntityInventory(player, entityInv, entity), player);
this.title = entity.getName();
}
public void addElements() {
this.label(this.title, 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 90 - 8);
}
}

View file

@ -4,7 +4,7 @@ import common.entity.npc.EntityNPC;
public class GuiInventory extends GuiContainer {
public GuiInventory(EntityNPC player) {
super(player.inventoryContainer);
super(player.inventoryContainer, player);
}
public void addElements() {

View file

@ -24,7 +24,7 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
private ActButton nextBtn;
public GuiMerchant(EntityNPC inv, Entity entity, World world) {
super(new ContainerMerchant(inv, null, world));
super(new ContainerMerchant(inv, null, world), inv);
this.title = entity.getName();
}
@ -41,7 +41,7 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
public void addElements() {
this.label(this.title, 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 90 - 8);
}
public void drawOverlays() {

View file

@ -12,7 +12,7 @@ public class GuiRepair extends GuiContainer {
private EntityNPC playerInv;
public GuiRepair(EntityNPC inv, World world) {
super(new ContainerRepair(inv, world));
super(new ContainerRepair(inv, world), inv);
this.playerInv = inv;
this.anvil = (ContainerRepair)this.inventorySlots;
}
@ -32,6 +32,6 @@ public class GuiRepair extends GuiContainer {
public void addElements() {
this.label("Amboss", 8, 16);
this.info = this.label("", 60, 77);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.label("Inventar", 8, 90 - 8);
}
}

View file

@ -1130,7 +1130,7 @@ public class ClientPlayer implements IClientPlayer
// flag = true; // guicontainercreative.getSelectedTabIndex() != CheatTab.tabInventory.getIndex();
// }
if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 5 + Equipment.ARMOR_SLOTS + 27 && packetIn.getSlot() < 5 + Equipment.ARMOR_SLOTS + 27 + 9)
if (packetIn.getWindowId() == 0 && packetIn.getSlot() >= 5 + Equipment.ARMOR_SLOTS && packetIn.getSlot() < 5 + Equipment.ARMOR_SLOTS + entityplayer.getInventoryCapacity())
{
ItemStack itemstack = entityplayer.inventoryContainer.getSlot(packetIn.getSlot()).getStack();