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();

View file

@ -19,8 +19,8 @@ public class ContainerChest extends Container
BlockChest block = BlockChest.getChest(this.chestSize);
this.width = block.getInventoryWidth();
this.height = block.getInventoryHeight();
int xOffset = (this.width - 9) * 18 / 2;
int yoffset = (this.height - 4) * 18;
int xOffset = this.width < 12 ? 0 : (this.width - 12) * 18 / 2;
int yOffset = (this.height - 3) * 18;
for (int j = 0; j < this.height; ++j)
{
@ -30,17 +30,9 @@ public class ContainerChest extends Container
}
}
for (int l = 0; l < 3; ++l)
for (int l = 0; l < player.getInventoryCapacity(); ++l)
{
for (int j1 = 0; j1 < 9; ++j1)
{
this.addSlotToContainer(new Slot(player, j1 + l * 9 + 9, 8 + j1 * 18 + xOffset, 103 + l * 18 + yoffset));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(player, i1, 8 + i1 * 18 + xOffset, 161 + yoffset));
this.addSlotToContainer(new Slot(player, l, 8 + (l % 12) * 18 + xOffset, 85 + (l / 12) * 18 + yOffset));
}
}

View file

@ -63,17 +63,9 @@ public class ContainerEnchantment extends Container
}
});
for (int i = 0; i < 3; ++i)
for (int l = 0; l < playerInv.getInventoryCapacity(); ++l)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInv, k, 8 + k * 18, 142));
this.addSlotToContainer(new Slot(playerInv, l, 8 + (l % 12) * 18, 84 + (l / 12) * 18));
}
}

View file

@ -49,17 +49,9 @@ public class ContainerEntityInventory extends Container
}
}
for (int i1 = 0; i1 < 3; ++i1)
for (int l = 0; l < player.getInventoryCapacity(); ++l)
{
for (int k1 = 0; k1 < 9; ++k1)
{
this.addSlotToContainer(new Slot(player, k1 + i1 * 9 + 9, 8 + k1 * 18, 102 + i1 * 18 + j));
}
}
for (int j1 = 0; j1 < 9; ++j1)
{
this.addSlotToContainer(new Slot(player, j1, 8 + j1 * 18, 160 + j));
this.addSlotToContainer(new Slot(player, l, 8 + (l % 12) * 18, 84 + (l / 12) * 18));
}
}

View file

@ -28,17 +28,9 @@ public class ContainerMerchant extends Container
});
this.addSlotToContainer(new SlotMerchantResult(playerInventory, this.merchantInventory, 2, 120, 53));
for (int i = 0; i < 3; ++i)
for (int l = 0; l < playerInventory.getInventoryCapacity(); ++l)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
this.addSlotToContainer(new Slot(playerInventory, l, 8 + (l % 12) * 18, 84 + (l / 12) * 18));
}
}

View file

@ -36,7 +36,7 @@ public class ContainerPlayer extends Container {
for (Equipment slot : Equipment.ARMOR)
{
final Equipment type = slot;
this.addSlotToContainer(new Slot(player, 27 + 9 + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
this.addSlotToContainer(new Slot(player, player.getInventoryCapacity() + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
{
public boolean canStackItems()
{
@ -52,17 +52,9 @@ public class ContainerPlayer extends Container {
});
}
for (int l = 0; l < 3; ++l)
for (int l = 0; l < player.getInventoryCapacity(); ++l)
{
for (int j1 = 0; j1 < 9; ++j1)
{
this.addSlotToContainer(new Slot(player, j1 + (l + 1) * 9, 8 + j1 * 18, 84 + l * 18));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(player, i1, 8 + i1 * 18, 142));
this.addSlotToContainer(new Slot(player, l, 8 + (l % 12) * 18, 84 + (l / 12) * 18));
}
this.onCraftMatrixChanged(this.craftMatrix);
@ -137,7 +129,7 @@ public class ContainerPlayer extends Container {
if (index == 0)
{
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, true))
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + playerIn.getInventoryCapacity(), true))
{
return null;
}
@ -146,14 +138,14 @@ public class ContainerPlayer extends Container {
}
else if (index >= 1 && index < 5)
{
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + playerIn.getInventoryCapacity(), false))
{
return null;
}
}
else if (index >= 5 && index < 5 + Equipment.ARMOR_SLOTS)
{
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + playerIn.getInventoryCapacity(), false))
{
return null;
}
@ -165,21 +157,11 @@ public class ContainerPlayer extends Container {
return null;
}
}
else if (index >= 5 + Equipment.ARMOR_SLOTS && index < 5 + Equipment.ARMOR_SLOTS + 27)
else if (index >= 5 + Equipment.ARMOR_SLOTS && index < 5 + Equipment.ARMOR_SLOTS + playerIn.getInventoryCapacity())
{
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS + 27, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
{
return null;
}
return null;
}
else if (index >= 5 + Equipment.ARMOR_SLOTS + 27 && index < 5 + Equipment.ARMOR_SLOTS + 27 + 9)
{
if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27, false))
{
return null;
}
}
else if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + 27 + 9, false))
else if (!this.mergeItemStack(itemstack1, 5 + Equipment.ARMOR_SLOTS, 5 + Equipment.ARMOR_SLOTS + playerIn.getInventoryCapacity(), false))
{
return null;
}

View file

@ -121,17 +121,9 @@ public class ContainerRepair extends Container
}
});
for (int i = 0; i < 3; ++i)
for (int l = 0; l < playerInventory.getInventoryCapacity(); ++l)
{
for (int j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
this.addSlotToContainer(new Slot(playerInventory, l, 8 + (l % 12) * 18, 84 + (l / 12) * 18));
}
}

View file

@ -29,7 +29,6 @@ public class ContainerTile extends Container
this.resourceOvercharges = new int[tile.getNumResources()];
this.resourceUndercharges = new int[tile.getNumResources()];
this.resourceEntropies = new int[tile.getNumResources()];
int i = 112;
int input = 0;
int output = 0;
@ -52,17 +51,9 @@ public class ContainerTile extends Container
++output;
}
for (int l = 0; l < 3; ++l)
for (int l = 0; l < player.getInventoryCapacity(); ++l)
{
for (int k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(player, k + l * 9 + 9, 8 + k * 18, l * 18 + i));
}
}
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(player, i1, 8 + i1 * 18, 58 + i));
this.addSlotToContainer(new Slot(player, l, 8 + (l % 12) * 18, 112 + (l / 12) * 18));
}
}

View file

@ -38,17 +38,9 @@ public class ContainerWorkbench extends Container
}
}
for (int k = 0; k < 3; ++k)
for (int l = 0; l < playerInventory.getInventoryCapacity(); ++l)
{
for (int i1 = 0; i1 < 9; ++i1)
{
this.addSlotToContainer(new Slot(playerInventory, i1 + k * 9 + 9, 8 + i1 * 18, 30 + size * 18 + k * 18));
}
}
for (int l = 0; l < 9; ++l)
{
this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 88 + size * 18));
this.addSlotToContainer(new Slot(playerInventory, l, 8 + (l % 12) * 18, 30 + size * 18 + (l / 12) * 18));
}
this.onCraftMatrixChanged(this.craftMatrix);

View file

@ -2936,7 +2936,7 @@ public class Player extends User implements Executor, IPlayer
this.entity.dropItem(stack, false, true);
}
else {
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(5 + Equipment.ARMOR_SLOTS + 27 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(5 + Equipment.ARMOR_SLOTS + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
if(slot == null || !slot.canCheatItem())
return;
stack.setSize(Math.min(slot.getItemStackLimit(stack), stack.getSize()));