• 1.93516469471555

    posted a message on [1.12.2] Issue with Custom Furnace (no error) [Solved]

    I fixed it, it was an issue with handling non-static values using a gui, I now have the clicks entirely handled in the tile entity class and it's working perfectly.

    Posted in: Mod Development
  • 0

    posted a message on [1.12.2] Issue with Custom Furnace (no error) [Solved]

    I tried to create a forge, essentially a custom furnace in which each recipe has a varying number of the same input item and you select an output you want to make and press a custom button to start forging.

    Everything seems to work, however, when it starts forging, the effects of the forging are reverted immediately (ie. the stack in the input slot, and last time I checked with stackable fuel, fuel slot are reverted to before forging started), and the output is a fake item.

    Any help is appreciated, I've been losing my mind over this because there's no error, it just doesn't want to work.


    update code in Tile Entity class

    public void update() {
    ItemStack input = this.handler.getStackInSlot(0);
    ItemStack fuel = this.handler.getStackInSlot(1);

    setState(false, this.getWorld(), this.getPos());
    if(this.isCurrentlyActive && !(this.getCookTime()>0)){
    int inputCount = AdamantineForgeRecipes.getInstance().getInputCount(this.result);
    if(input.getCount() >= inputCount && input.getItem() == AdamantineForgeRecipes.getInstance().getForgingInput(this.result).getItem()) {
    //Set the total cook time to the cook time of the recipe
    if(this.getCookTime()>0 && (this.isBurning() || !fuel.isEmpty())) {
    if(!this.isBurning()) {
    setState(true, this.getWorld(), this.getPos());

    if(this.isBurning() && !fuel.isEmpty()) {
    if(fuel.getItem() != Items.LAVA_BUCKET)
    this.handler.setStackInSlot(1, new ItemStack(Items.BUCKET));

    this.handler.setStackInSlot(1, ItemStack.EMPTY);
    if(this.getCookTime() == this.getTotalCookTime()) {
    if(this.handler.getStackInSlot(2).getCount() == 0)
    this.handler.insertItem(2, this.result, false);

    onClick code in Tile Entity class

    * Sets currently active if forge button is clicked, and sets result based on result button selected.
    * @param guiLeft The left side of the gui.
    * @param guiTop The top of the gui.
    * @param mouseX The x position of the mouse.
    * @param mouseY The y position of the mouse.
    public void onClick(int guiLeft, int guiTop, int mouseX, int mouseY) {
    //If mouse clicked the forge button
    if(mouseX>(guiLeft+61) && mouseX<(guiLeft+84)){
    if(mouseY>(guiTop+50) && mouseY<(guiTop+61)) {
    if(!this.isCurrentlyActive() && this.canSmelt())
    this.setCurrentlyActive(true); //Set the forge to be active
    }else if(mouseX>(guiLeft+93) && mouseX<(guiLeft+129)) { //If mouse clicked a left column result button
    if(mouseY > (guiTop+10) && mouseY < (guiTop+22)) { //If mouse clicked sword button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_SWORD)); //Set the result to corresponding button
    }else if (mouseY > (guiTop+23) && mouseY < (guiTop+35)) { //If mouse clicked pickaxe button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_PICKAXE)); //Set the result to corresponding button
    }else if(mouseY>(guiTop+36) && mouseY<(guiTop+48)) { //If mouse clicked axe button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_AXE)); //Set the result to corresponding button
    }else if(mouseY>(guiTop+49) && mouseY<(guiTop+61)) { //If mouse clicked shovel button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_SHOVEL)); //Set the result to corresponding button
    }else if(mouseY>(guiTop+62) && mouseY<(guiTop+74)) { //If mouse clicked hoe button
    if (!this.isCurrentlyActive())
    this.setResult(new ItemStack(ModItems.ADAMANTINE_HOE)); //Set the result to corresponding button
    }else if(mouseX>(guiLeft+131) && mouseX<(guiLeft+167)) { //If mouse clicked a right column result button
    if(mouseY > (guiTop+17) && mouseY < (guiTop+29)) { //If mouse clicked helmet button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_HELMET)); //Set the result to corresponding button
    }else if (mouseY > (guiTop+30) && mouseY < (guiTop+42)) { //If mouse clicked chestplate button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_CHESTPLATE)); //Set the result to corresponding button
    }else if (mouseY > (guiTop+43) && mouseY < (guiTop+55)) { //If mouse clicked leggings button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_LEGGINGS)); //Set the result to corresponding button
    }else if (mouseY > (guiTop+56) && mouseY < (guiTop+68)) { //If mouse clicked boots button
    this.setResult(new ItemStack(ModItems.ADAMANTINE_BOOTS)); //Set the result to corresponding button

     Handling of button press in gui

    protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    super.mouseClicked(mouseX, mouseY, mouseButton);

    if(Minecraft.getMinecraft().currentScreen instanceof GuiAdamantineForge) {
    if(mouseButton == 0)
    this.tileEntity.onClick(this.guiLeft, this.guiTop, mouseX, mouseY);


    Posted in: Mod Development
  • To post a comment, please or register a new account.