Strange actions (1.7.1)

Started by LueLusten on

Topic category: Help with MCreator software

Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Strange actions (1.7.1)
Mon, 06/26/2017 - 20:21 (edited)

OK I made a gui with a button

the button checks if you have a item before it will trigger the action, if the items is on you it will
consume the time it then will give you a 4 items, this all works fine without a problem.

But everytime I lets say open a chest or use the item it gives me a bucket back as it still 
thinks it was the old item, what the hell is going on here ????

 

It consumes a milk bucket and gives you 4 butter bars, then it goes all strange.

 

**Edit for got to say was in 1.7.1

Edited by LueLusten on Mon, 06/26/2017 - 20:21
Joined Nov 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have just tested this again
Mon, 06/26/2017 - 18:35

I have just tested this again and it's still not working I even built it and ran it from normal MC

Soon as I do anything like open a chest or brake a block or anything it just truns my butter back in to the milk bucket

GUI:

[spoiler]

package mod.mcreator;

import org.lwjgl.opengl.GL11;
import org.lwjgl.input.Keyboard;

import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;

import net.minecraft.world.World;
import net.minecraft.util.ResourceLocation;
import net.minecraft.server.MinecraftServer;
import net.minecraft.item.ItemStack;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Container;
import net.minecraft.init.Items;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.GuiButton;

import java.util.Random;

@SuppressWarnings("unchecked")
public class mcreator_butterChurnerOpen {

    public static Object instance;

    public static int GUIID = 2;

    public mcreator_butterChurnerOpen() {
    }

    public void load(FMLInitializationEvent event) {
    }

    public void registerRenderers() {
    }

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {
    }

    public static IInventory inherited;

    public static class GuiContainerMod extends Container {

        World world = null;
        EntityPlayer entity = null;
        int i, j, k;

        public GuiContainerMod(World world, int i, int j, int k, EntityPlayer player) {

            this.world = world;
            this.entity = player;
            this.i = i;
            this.j = j;
            this.k = k;

        }

        @Override
        public boolean canInteractWith(EntityPlayer player) {
            return true;
        }

        protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
            int i;
            int j;

            for (i = 0; i < 3; ++i) {
                for (j = 0; j < 9; ++j) {
                    this.addSlotToContainer(new Slot(inventoryPlayer, j + (i + 1) * 9, 8 + j * 18, 84 + i * 18));
                }
            }

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

        @Override
        public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
            ItemStack itemstack = null;
            Slot slot = (Slot) this.inventorySlots.get(index);

            if (slot != null && slot.getHasStack()) {
                ItemStack itemstack1 = slot.getStack();
                itemstack = itemstack1.copy();

                if (index < 9) {
                    if (!this.mergeItemStack(itemstack1, 9, (45 - 9), true)) {// fixes
                                                                                // shiftclick
                                                                                // error
                        return null;
                    }
                } else if (!this.mergeItemStack(itemstack1, 0, 9, false)) {
                    return null;
                }

                if (itemstack1.stackSize == 0) {
                    slot.putStack((ItemStack) null);
                } else {
                    slot.onSlotChanged();
                }

                if (itemstack1.stackSize == itemstack.stackSize) {
                    return null;
                }

                slot.onPickupFromSlot(playerIn, itemstack1);
            }

            return itemstack;
        }

        public void onContainerClosed(EntityPlayer playerIn) {
            super.onContainerClosed(playerIn);

        }
    }

    public static class GuiWindow extends GuiContainer {

        int i = 0;
        int j = 0;
        int k = 0;
        EntityPlayer entity = null;

        public GuiWindow(World world, int i, int j, int k, EntityPlayer entity) {
            super(new GuiContainerMod(world, i, j, k, entity));
            this.i = i;
            this.j = j;
            this.k = k;
            this.entity = entity;
            this.xSize = 176;
            this.ySize = 116;
        }

        private static final ResourceLocation texture = new ResourceLocation("ButterChurnerOpen.png");

        protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

            this.mc.renderEngine.bindTexture(texture);
            int k = (this.width - this.xSize) / 2;
            int l = (this.height - this.ySize) / 2;
            this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);

            zLevel = 100.0F;

            this.mc.renderEngine.bindTexture(new ResourceLocation("butter.png"));
            this.drawTexturedModalRect((this.guiLeft + 6), (this.guiTop + 9), 0, 0, 256, 256);

        }

        protected void mouseClicked(int par1, int par2, int par3) throws java.io.IOException {
            super.mouseClicked(par1, par2, par3);

        }

        public void updateScreen() {
            super.updateScreen();
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;

        }

        @Override
        protected void keyTyped(char par1, int par2) throws java.io.IOException {

            super.keyTyped(par1, par2);

        }

        protected void drawGuiContainerForegroundLayer(int par1, int par2) {
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;
            this.fontRendererObj.drawString("Churn Butter", (17), (11), 0xffcc00);

        }

        public void onGuiClosed() {
            super.onGuiClosed();
            Keyboard.enableRepeatEvents(false);
        }

        public void initGui() {
            super.initGui();
            this.guiLeft = (this.width - 176) / 2;
            this.guiTop = (this.height - 166) / 2;
            Keyboard.enableRepeatEvents(true);
            this.buttonList.clear();
            int posX = (this.width) / 2;
            int posY = (this.height) / 2;
            this.buttonList.add(new GuiButton(0, this.guiLeft + 57, this.guiTop + 47, 60, 20, "Churn"));

        }

        protected void actionPerformed(GuiButton button) {
            MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
            World world = server.worldServers[0];

            if (button.id == 0) {

                if (entity.inventory.hasItemStack(new ItemStack(Items.MILK_BUCKET))) {

                    if (true) {
                        if (entity instanceof EntityPlayer)
                            ((EntityPlayer) entity).inventory.clearMatchingItems(Items.MILK_BUCKET, -1, 1, null);
                    }

                    if (true) {
                        if (entity instanceof EntityPlayer)
                            ((EntityPlayer) entity).inventory.addItemStackToInventory(new ItemStack(mcreator_butter.block, 4));
                    }

                }

            }

        }

        public boolean doesGuiPauseGame() {
            return false;
        }

    }

}[/spoiler]

Why is this bloody happening