Помогите с гуи

7,166
329
1,544
Я не знаю ,что я сделал не так, вроде, все как в туторе(блок с интерфейсом). Подскажите что я не так сделал: блок есть ,но при пкм он ничего не делает). Какие надо классы скинуть скажите, скину...
 
Версия Minecraft?
Понадобиться код, где открывается гуи. Понадобиться GuiHandler. И возможно понадобиться Контейнер этого гуи.
[merge_posts_bbcode]Добавлено: 28.05.2015 13:54:13[/merge_posts_bbcode]

Где должно открываться гуи окно, не должно открываться только на серверной стороне.
---
В твоём гуи контейнере:
Код:
public boolean canInteractWith(EntityPlayer player)
Не должен возвращать только false (должно какое-то условие, либо просто true).

[merge_posts_bbcode]Добавлено: 28.05.2015 13:55:42[/merge_posts_bbcode]

А в GuiHandler убедись в правильности id'ов и id'а открытия этого гуи.
---
Больше предположений нет.
 
Слоты-то по местам стоят?Ибо у меня похожая проблема,берёшь предмет,а он не берётся
 
public class GuiResearchHandler implements IGuiHandler{

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
if( ID == 3 )
{
PacketOpenGUI packet = new PacketOpenGUI();
packet.gui_id = 3;
packet.username = player.getDisplayName();
CommonProxy.szPacket.sendTo( packet, (EntityPlayerMP)player );
}
return null;
}

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
// TODO Auto-generated method stub
return null;
}

}
 
эээм
Код:
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;

public class GuiHandler implements IGuiHandler {

    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        switch (ID) {
            case 0:
                return new ContainerInventory(player);
            default:
                return null;
        }
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        switch (ID) {
            case 0:
                return new GuiInventory(player);
            default:
                return null;
        }
    }
}
 
Так надо было?
 
Ок, Dovakin, спасибо)
 
Исправил по твоему примеру: не пашет
[merge_posts_bbcode]Добавлено: 29.05.2015 14:10:29[/merge_posts_bbcode]

Может тут че-то не так? Токо я не пойму что(

[merge_posts_bbcode]Добавлено: 29.05.2015 14:10:50[/merge_posts_bbcode]

public class ContainerResearch extends Container {
public static ContainerResearch instance=new ContainerResearch(null, TileBlockResearch.instance);

        protected TileBlockResearch tileEntity;

        public ContainerResearch (InventoryPlayer inventoryPlayer, TileBlockResearch te){
                tileEntity = te;

                //the Slot constructor takes the IInventory and the slot number in that it binds to
                //and the x-y coordinates it resides on-screen
                for (int i = 0; i < 3; i++) {
                        for (int j = 0; j < 3; j++) {
                                addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
                        }
                }

                //commonly used vanilla code that adds the player's inventory
                bindPlayerInventory(inventoryPlayer);
        }

        public ContainerResearch(InventoryPlayer inventory,
TileEntity te) {
        tileEntity = (TileBlockResearch) te;

            //the Slot constructor takes the IInventory and the slot number in that it binds to
            //and the x-y coordinates it resides on-screen
            for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {
                            addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
                    }
            }

            //commonly used vanilla code that adds the player's inventory
            bindPlayerInventory(inventory);
// TODO Auto-generated constructor stub
}

@Override
        public boolean canInteractWith(EntityPlayer player) {
                return tileEntity.isUseableByPlayer(player);
        }


        protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
                for (int i = 0; i < 3; i++) {
                        for (int j = 0; j < 9; j++) {
                                addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
                                                8 + j * 18, 84 + i * 18));
                        }
                }

                for (int i = 0; i < 9; i++) {
                        addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
                }
        }

        @Override
        public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
                ItemStack stack = null;
                Slot slotObject = (Slot) inventorySlots.get(slot);

                //null checks and checks if the item can be stacked (maxStackSize > 1)
                if (slotObject != null && slotObject.getHasStack()) {
                        ItemStack stackInSlot = slotObject.getStack();
                        stack = stackInSlot.copy();

                        //merges the item into player inventory since its in the tileEntity
                        if (slot < tileEntity.getSizeInventory()) {
                                if (!this.mergeItemStack(stackInSlot, tileEntity.getSizeInventory(), 36+tileEntity.getSizeInventory(), true)) {
                                        return null;
                                }
                        }
                        //places it into the tileEntity is possible since its in the player inventory
                        else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) {
                                return null;
                        }

                        if (stackInSlot.stackSize == 0) {
                                slotObject.putStack(null);
                        } else {
                                slotObject.onSlotChanged();
                        }

                        if (stackInSlot.stackSize == stack.stackSize) {
                                return null;
                        }
                        slotObject.onPickupFromSlot(player, stackInSlot);
                }
                return stack;
        }
}
 
Какой нахер инстанс? Тебе в Луи хендлере дают все что надо для создания объектов гуи и контейнера.
 
Да гуи и контейнер для всех блоков этого типа один
 
Назад
Сверху