Доброго времени суток. Делаю свою gui но тут вылезла проблема. Предметы в слотах игрока не перетаскиваются.
ContainerCraft:
package ru.berhtadal.gui.container;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerCraftStation extends Container
{
public ContainerCraftStation(InventoryPlayer playerInv){
// MAIN PLAYER INVENTORY
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 9; x++) {
addSlotToContainer(new Slot(playerInv, x + (y * 9) + 9, 8 + x * 18, 84 + y * 18));
}
}
// PLAYER HOTBAR INVENTORY
for (int i = 0; i < 9; i++) {
addSlotToContainer(new Slot(playerInv, i, 8 + (i * 18), 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack stack = ItemStack.EMPTY;
Slot slot = inventorySlots.get(index);
if (slot != null && slot.getHasStack()) {
ItemStack stackInSlot = slot.getStack();
stack = stackInSlot.copy();
int containerSlots = inventorySlots.size() - player.inventory.mainInventory.size();
if (index < containerSlots) {
if (!this.mergeItemStack(stackInSlot, containerSlots, inventorySlots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (!this.mergeItemStack(stackInSlot, 0, containerSlots, false)) {
return ItemStack.EMPTY;
}
if (stackInSlot.getCount() == 0) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}
slot.onTake(player, stackInSlot);
}
return stack;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}
GuiCraftStationContainer:
package ru.berhtadal.gui;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import ru.berhtadal.gui.container.ContainerCraftStation;
public class GuiCraftStationContainer extends GuiContainer {
public GuiCraftStationContainer(InventoryPlayer playerInv) {
super(new ContainerCraftStation(playerInv));
xSize = 176;
ySize = 166;
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
mc.getTextureManager().bindTexture(new ResourceLocation("bh:textures/gui/container.png"));
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}
}
Последнее редактирование: