Привет всем) Проблема: есть блок с тайлом и у него должно быть гуи. Но при клике пкм по блоку оно не открывается. Игра не крашится, но в консоль пишет это.
Сам тайл наследуется от TileEntityLockable и встраивает интерфейсы ITickable, ISidedInventory
ContainerSpoilMachine делал на примере контейнера печки.
В СommonProxy в init такая строчка
Если кто может подсказать, что делаю не так, то буду очень благодарен)) Спасибо!
Код:
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
if (!worldIn.isRemote)
{
TileEntitySpoilMachine tileEntity = (TileEntitySpoilMachine) worldIn.getTileEntity(pos);
if (tileEntity instanceof TileEntitySpoilMachine)
{
player.displayGUIChest((TileEntitySpoilMachine)tileEntity);
}
}
return true;
}
Сам тайл наследуется от TileEntityLockable и встраивает интерфейсы ITickable, ISidedInventory
Код:
@Override
public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
return new ContainerSpoilMachine(playerInventory, this);
}
ContainerSpoilMachine делал на примере контейнера печки.
Код:
public class GuiSpoilMachine extends GuiContainer
{
private static final ResourceLocation TEXTURES = new ResourceLocation(ExperimentalProject.MODID + "gui/gui.png");
private final InventoryPlayer player;
private final TileEntitySpoilMachine tileentity;
public GuiSpoilMachine(InventoryPlayer player, TileEntitySpoilMachine tileentity)
{
super(new ContainerSpoilMachine(player, tileentity));
this.player = player;
this.tileentity = tileentity;
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
{
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.getTextureManager().bindTexture(TEXTURES);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
}
}
Код:
public class GuiHandler implements IGuiHandler
{
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
ContainerSpoilMachine gui = new ContainerSpoilMachine(player.inventory, (TileEntitySpoilMachine)world.getTileEntity(new BlockPos(x,y,z)));
return gui;
}
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
GuiSpoilMachine gui = new GuiSpoilMachine(player.inventory, (TileEntitySpoilMachine) world.getTileEntity(new BlockPos(x,y,z)));
return gui;
}
}
В СommonProxy в init такая строчка
NetworkRegistry.INSTANCE.registerGuiHandler(ExperimentalProject.instance, new GuiHandler());
Если кто может подсказать, что делаю не так, то буду очень благодарен)) Спасибо!