Не работает GUI

Версия Minecraft
1.12.2
103
2
2
Захотел сделать свою печку, взял TileEntity, Block, Gui, Container от ванильной печи. Если тыкаю пкм по печи, то открывается GUI только с надписью container.IronFurnace и всё.
Код:
public class GuiHandler implements IGuiHandler {


    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        if(ID == DifferentThings.GUI_EVILEMERALD_CHEST) return new ContainerEvilEmeraldChest(player.inventory, (TileEntityEvilEmeraldChest)world.getTileEntity(new BlockPos(x,y,z)),player);
        if(ID == DifferentThings.GUI_IRON_FURNACE) return new GuiIronFurnace(player.inventory, (TileEntityIronFurnace)world.getTileEntity(new BlockPos(x,y,z)));
        return null;

    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
    {
        if(ID == DifferentThings.GUI_EVILEMERALD_CHEST) return new GuiEvilEmeraldChest(player.inventory, (TileEntityEvilEmeraldChest)world.getTileEntity(new BlockPos(x,y,z)),player);
        if(ID == DifferentThings.GUI_IRON_FURNACE) return new GuiIronFurnace(player.inventory, (TileEntityIronFurnace)world.getTileEntity(new BlockPos(x,y,z)));
        return null;
    }


}
в Main мода написано
Код:
@EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
        proxy.postInit(event);
    }

    public static final CreativeTabs CTAB = new CreativeTabs("differentthings")
    {
        @Override
        public ItemStack getTabIconItem()
        {
            return new ItemStack(ItemsRegister.EVILEMERALD);
        }
    };

    public static final int GUI_EVILEMERALD_CHEST = 1;
    public static final int GUI_IRON_FURNACE = 2;

    static {
        FluidRegistry.enableUniversalBucket();
    }
Код:
@SideOnly(Side.CLIENT)
public class GuiIronFurnace extends GuiContainer
{
    private static final ResourceLocation FURNACE_GUI_TEXTURES = new ResourceLocation("textures/gui/container/furnace.png");
    /** The player inventory bound to this GUI. */
    private final InventoryPlayer playerInventory;
    private final IInventory tileFurnace;

    public GuiIronFurnace(InventoryPlayer playerInv, IInventory furnaceInv)
    {
        super(new ContainerIronFurnace(playerInv, furnaceInv));
        this.playerInventory = playerInv;
        this.tileFurnace = furnaceInv;
    }

    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
        this.drawDefaultBackground();
        super.drawScreen(mouseX, mouseY, partialTicks);
        this.renderHoveredToolTip(mouseX, mouseY);
    }

    /**
     * Draw the foreground layer for the GuiContainer (everything in front of the items)
     */
    protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
    {
        String s = this.tileFurnace.getDisplayName().getUnformattedText();
        this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
        this.fontRenderer.drawString(this.playerInventory.getDisplayName().getUnformattedText(), 8, this.ySize - 96 + 2, 4210752);
    }

    /**
     * Draws the background layer of this container (behind the items).
     */
    protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY)
    {
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.getTextureManager().bindTexture(FURNACE_GUI_TEXTURES);
        int i = (this.width - this.xSize) / 2;
        int j = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);

        if (TileEntityFurnace.isBurning(this.tileFurnace))
        {
            int k = this.getBurnLeftScaled(13);
            this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1);
        }

        int l = this.getCookProgressScaled(24);
        this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16);
    }

    private int getCookProgressScaled(int pixels)
    {
        int i = this.tileFurnace.getField(2);
        int j = this.tileFurnace.getField(3);
        return j != 0 && i != 0 ? i * pixels / j : 0;
    }

    private int getBurnLeftScaled(int pixels)
    {
        int i = this.tileFurnace.getField(1);

        if (i == 0)
        {
            i = 200;
        }

        return this.tileFurnace.getField(0) * pixels / i;
    }
}
Код:
public String getGuiID()
    {
        return String.valueOf(DifferentThings.GUI_IRON_FURNACE);
    }
 
91
1
5
Код:
public class MGuiHandler implements IGuiHandler {
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world,    int x, int y, int z) {
        TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
        switch (MConfig.GUI_CLAY_FURNACE) {
        case GuiClayFurnace.GUI_CLAY_FURNACE:
            if ((tileEntity instanceof TileEntityClayFurnace)) {
                return new ContainerClayFurnace(player.inventory, (TileEntityClayFurnace)tileEntity);
            }
        } return null;
    }

    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world,    int x, int y, int z) {
        TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
        switch (MConfig.GUI_CLAY_FURNACE) {
        case GuiClayFurnace.GUI_CLAY_FURNACE:
            if ((tileEntity instanceof TileEntityClayFurnace)) {
                return new GuiClayFurnace(player.inventory, (TileEntityClayFurnace)tileEntity);
            }
        } return null;
    }
Ты конечно можешь ID вызывать из Конфига
 
91
1
5
private static final ResourceLocation FURNACE_GUI_TEXTURES = new ResourceLocation("textures/gui/container/furnace.png");
Можешь в начале поставить класс мода, чтобы не вызывать конфликты с другими модами
private static final ResourceLocation TEXTURES = new ResourceLocation(MInformation.MOD_ID + ":textures/gui/furnace.png");
 
7,099
324
1,510
#drawGuiContainerForegroundLayer
String s = this.tileFurnace.getDisplayName().getUnformattedText(); this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 6, 4210752);
Вот этот кусок отвечает за рендер имени печки в инвентаре. Наверное, ты не синхронизируешь тайл с клиентом и там всегда дефолтная железная печка
 
7,099
324
1,510
Не могу сказать, из-за чего проблемы при копировании ванильной печки, т.к. не изучал этот вопрос. Но точно могу сказать, что не раз замечал, как люди сталкиваются с какими-то проблемами при копипасте ванильной печки. Может, стоит попробовать другой подход? Например, использовать код печки только для справки, а свое пытаться написать с чистого листа
 
103
2
2
Не могу сказать, из-за чего проблемы при копировании ванильной печки, т.к. не изучал этот вопрос. Но точно могу сказать, что не раз замечал, как люди сталкиваются с какими-то проблемами при копипасте ванильной печки. Может, стоит попробовать другой подход? Например, использовать код печки только для справки, а свое пытаться написать с чистого листа
Я понял почему не работал GUI, я в GUIHandler забыл регистрировать контейнер, а во вторых, в блоке на ПКМ было написано playerIn.openChestGUI, я убрал chest из функции и GUI стал открываться, только печка когда начинает плавить превращается в ванильную печь из майна и у неё не работает GUI, но воронкой можно забрать результат плавки.
 
Последнее редактирование:
103
2
2
Надеюсь теперь ты понимаешь почему бездумно копипастить опасно. Потом очень-очень сложно отловить ошибку.
Я просто из печки повыпиливал всё лишнее, да и не всё скопипастишь нормально.
 
7,099
324
1,510
Для других: не копипастите ванильную печку, пишите свою, нервы сэкономите и новому научитесь
 
Сверху