- 929
- 30
- 66
Всем привет, сделал инвентарь для блока , по этому гайду -> Client, Server и GUI Container
Такой вопрос , при открытии инвентаря блока нет инвентаря игрока.
Такой вопрос , при открытии инвентаря блока нет инвентаря игрока.
for (int i = 0; i < 3; ++i) {
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));
}
for (int i = 0; i < 3; ++i) {
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));
}
public ContainerTutorial(TileGuiContainer tile, IInventory ff) {
this.tile = tile;
int i = (this.numRows - 4) * 18;
int j;
int k;
addSlotToContainer(new RespectedSlot(tile, 0, 20, 20));
addSlotToContainer(new RespectedSlot(tile, 1, 38, 20));
addSlotToContainer(new RespectedSlot(tile, 2, 56, 20));
addSlotToContainer(new RespectedSlot(tile, 3, 20, 38));
addSlotToContainer(new RespectedSlot(tile, 4, 38, 38));
addSlotToContainer(new RespectedSlot(tile, 5, 56, 38));
addSlotToContainer(new RespectedSlot(tile, 6, 20, 56));
addSlotToContainer(new RespectedSlot(tile, 7, 38, 56));
addSlotToContainer(new RespectedSlot(tile, 8, 56, 56));
for (j = 0; j < 3; ++j)
{
for (k = 0; k < 9; ++k)
{
this.addSlotToContainer(new Slot(ff, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i));
}
}
for (j = 0; j < 9; ++j)
{
this.addSlotToContainer(new Slot(ff, j, 8 + j * 18, 161 + i));
}
}
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
switch (ID) {
case TUT_GUI:
/*5*/ return new ContainerTutorial((TileGuiContainer) world.getTileEntity(x, y, z));
}
return null;
}
return new ContainerTutorial((TileGuiContainer) world.getTileEntity(x, y, z), player.inventory);
IInventory
на InventoryPlayer
и работает спасибо,но если я нажму по предмету shift+lkm у меня просто краш at net.minecraft.inventory.Container.retrySlotClick(Container.java:517)
at net.minecraft.inventory.Container.slotClick(Container.java:288)
transferStackInSlot
, это все делается там. Переопредели его и можно сделать на примере печки.