Jump to content

Gui Error


gamer1097

Recommended Posts

Hello I made this new gui and when I try to shift click items out of it the game crashes

 

Code

 

Block

 

 

package mods.gamersmods.fuelresourceful.block;

 

import mods.gamersmods.fuelresourceful.FuelResourceful;

import mods.gamersmods.fuelresourceful.common.ModConfig;

import mods.gamersmods.fuelresourceful.tileentity.TileEntityBlockBreaker;

import mods.gamersmods.fuelresourceful.tileentity.TileEntityBlockBreaker;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

 

public class BlockBlockBreaker extends BlockContainer

{

protected BlockBlockBreaker(int par1, Material par2Material)

{

super(par1, par2Material);

}

 

@Override

public TileEntity createNewTileEntity(World world)

{

return new TileEntityBlockBreaker();

}

    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)

    {

        if (par1World.isRemote)

        {

            return true;

        }

        else

        {

            TileEntityBlockBreaker TileEntityBlockBreaker = (TileEntityBlockBreaker)par1World.getBlockTileEntity(par2, par3, par4);

 

            if (TileEntityBlockBreaker != null)

            {

            par5EntityPlayer.openGui(FuelResourceful.instance, ModConfig.GUIIDs.BlockBreakerGui, par1World, par2, par3, par4);

            }

 

            return true;

        }

    }

}

 

 

 

TileEntity

 

 

package mods.gamersmods.fuelresourceful.tileentity;

 

import mods.gamersmods.fuelresourceful.item.ItemCompressedCoalCapsule;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.ISidedInventory;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.network.INetworkManager;

import net.minecraft.network.packet.Packet;

import net.minecraft.network.packet.Packet132TileEntityData;

import net.minecraft.tileentity.TileEntity;

 

public class TileEntityBlockBreaker extends TileEntity implements ISidedInventory

{

private ItemStack[] inv;

private byte fuelLevel;

 

public TileEntityBlockBreaker()

{

inv = new ItemStack[1];

fuelLevel = 0;

}

 

public void updateEntity()

{

if(fuelLevel == 0)

{

ItemStack stack = getStackInSlot(0);

if(stack != null && isStackValidForSlot(0, stack))

{

fuelLevel = 32;

stack.stackSize--;

if(stack.stackSize == 0)

{

stack = null;

}

setInventorySlotContents(0, stack);

}

}

}

 

public byte getFuelLevel()

{

return fuelLevel;

}

 

public void readFromNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.readFromNBT(par1NBTTagCompound);

        NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Items");

        this.inv = new ItemStack[this.getSizeInventory()];

 

        for (int i = 0; i < nbttaglist.tagCount(); ++i)

        {

            NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.tagAt(i);

            byte b0 = nbttagcompound1.getByte("Slot");

 

            if (b0 >= 0 && b0 < this.inv.length)

            {

                this.inv[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);

            }

        }

 

        this.fuelLevel = par1NBTTagCompound.getByte("fuel");

    }

 

    /**

    * Writes a tile entity to NBT.

    */

    public void writeToNBT(NBTTagCompound par1NBTTagCompound)

    {

        super.writeToNBT(par1NBTTagCompound);

        par1NBTTagCompound.setByte("fuel", this.fuelLevel);

        NBTTagList nbttaglist = new NBTTagList();

 

        for (int i = 0; i < this.inv.length; ++i)

        {

            if (this.inv != null)

            {

                NBTTagCompound nbttagcompound1 = new NBTTagCompound();

                nbttagcompound1.setByte("Slot", (byte)i);

                this.inv.writeToNBT(nbttagcompound1);

                nbttaglist.appendTag(nbttagcompound1);

            }

        }

 

        par1NBTTagCompound.setTag("Items", nbttaglist);

    }

 

@Override

public int getSizeInventory()

{

return inv.length;

}

 

@Override

public ItemStack getStackInSlot(int slot)

{

return inv[slot];

}

 

@Override

public ItemStack decrStackSize(int slot, int amt)

{

ItemStack stack = getStackInSlot(slot);

if (stack != null)

{

if (stack.stackSize <= amt)

{

setInventorySlotContents(slot, null);

}

else

{

stack = stack.splitStack(amt);

if (stack.stackSize == 0)

{

setInventorySlotContents(slot, null);

}

}

}

return stack;

}

 

@Override

public ItemStack getStackInSlotOnClosing(int slot)

{

ItemStack stack = getStackInSlot(slot);

if (stack != null) {

setInventorySlotContents(slot, null);

}

return stack;

}

 

@Override

public void setInventorySlotContents(int slot, ItemStack stack)

{

inv[slot] = stack;

if (stack != null && stack.stackSize > getInventoryStackLimit()) {

stack.stackSize = getInventoryStackLimit();

}

}

 

@Override

public Packet getDescriptionPacket()

{

  NBTTagCompound tag = new NBTTagCompound();

  this.writeToNBT(tag);

  return new Packet132TileEntityData(xCoord, yCoord, zCoord, 0, tag);

}

 

@Override

public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)

{

  NBTTagCompound tag = pkt.customParam1;

  this.readFromNBT(tag);

}

 

@Override

public String getInvName()

{

return "BlockBreaker";

}

 

@Override

public boolean isInvNameLocalized()

{

return false;

}

 

@Override

public int getInventoryStackLimit()

{

return 64;

}

 

@Override

public boolean isUseableByPlayer(EntityPlayer player)

{

return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;

}

 

@Override

public void openChest()

{

 

}

 

@Override

public void closeChest()

{

 

}

 

@Override

public boolean isStackValidForSlot(int slot, ItemStack stack)

{

return stack != null && stack.getItem().equals(Item.coal);

}

 

@Override

public int[] getAccessibleSlotsFromSide(int side)

{

int[] temp = {0};

return temp;

}

 

@Override

public boolean canInsertItem(int slot, ItemStack stack, int side)

{

int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);

int[] topBottom = {0, 1};

int[] leftRight = {2, 3};

int[] frontBack = {4, 5};

for(int i = 0; i < 2; i++)

{

if(meta == topBottom)

{

if(side == 0 || side == 1)

{

return false;

}

}

if(meta == leftRight)

{

if(side == 2 || side == 3)

{

return false;

}

}

if(meta == frontBack)

{

if(side == 4 || side == 5)

{

return false;

}

}

}

return true;

}

 

@Override

public boolean canExtractItem(int slot, ItemStack stack, int side)

{

int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);

if(meta == 0 && side == 1)

{

return true;

}

else if(meta == 1 && side == 0)

{

return true;

}

else if(meta == 2 && side == 3)

{

return true;

}

else if(meta == 3 && side == 2)

{

return true;

}

else if(meta == 4 && side == 5)

{

return true;

}

else if(meta == 5 && side == 4)

{

return true;

}

return false;

}

}

 

 

 

Container

 

 

package mods.gamersmods.fuelresourceful.tileentity;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.ICrafting;

import net.minecraft.inventory.Slot;

import net.minecraft.inventory.SlotFurnace;

import net.minecraft.item.ItemStack;

 

public class ContainerBlockBreaker extends Container

{

private TileEntityBlockBreaker tileEntity;

 

public ContainerBlockBreaker(InventoryPlayer playerInventory, TileEntityBlockBreaker tileEntity)

{

this.tileEntity = tileEntity;

 

// fuel

addSlotToContainer(new Slot(tileEntity, 0, 133, 33));

 

bindPlayerInventory(playerInventory);

}

 

@Override

public boolean canInteractWith(EntityPlayer entityPlayer)

{

return tileEntity.isUseableByPlayer(entityPlayer);

}

 

private void bindPlayerInventory(InventoryPlayer playerInventory)

{

// Inventory

for(int y = 0; y < 3; y++)

for(int x = 0; x < 9; x++)

addSlotToContainer(new Slot(playerInventory, x + y * 9 + 9, 8 + x * 18, 84 + y * 18));

// Action Bar

for(int x = 0; x < 9; x++)

addSlotToContainer(new Slot(playerInventory, x, 8 + x * 18, 142));

}

 

@Override

public ItemStack transferStackInSlot(EntityPlayer player, int slot)

{

ItemStack stack = null;

Slot slotObject = (Slot)inventorySlots.get(slot);

 

if(slotObject != null && slotObject.getHasStack())

{

ItemStack stackInSlot = slotObject.getStack();

stack = stackInSlot.copy();

 

// Merges the item into the player inventory

if(slot < 1)

{

if(!this.mergeItemStack(stackInSlot, 3, 39, true))

return null;

}

else if(!this.mergeItemStack(stackInSlot, 0, 3, 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;

}

}

 

 

 

 

Gui

 

 

package mods.gamersmods.fuelresourceful.client.gui;

 

import mods.gamersmods.fuelresourceful.tileentity.ContainerBlockBreaker;

import mods.gamersmods.fuelresourceful.tileentity.TileEntityBlockBreaker;

import mods.gamersmods.fuelresourceful.tileentity.TileEntityBrickFurnace;

import net.minecraft.client.gui.inventory.GuiContainer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.StatCollector;

 

import org.lwjgl.opengl.GL11;

 

public class GuiBlockBreaker extends GuiContainer

{

private TileEntityBlockBreaker tileEntity;

 

public GuiBlockBreaker(InventoryPlayer playerInventory, TileEntityBlockBreaker tileEntity)

{

super(new ContainerBlockBreaker(playerInventory, tileEntity));

 

this.tileEntity = tileEntity;

}

 

 

@Override

protected void drawGuiContainerForegroundLayer(int par1, int par2)

{

final String invTitle = "\u00A71Block Breaker";

fontRenderer.drawString(invTitle, (xSize / 2 - fontRenderer.getStringWidth(invTitle) / 2) + 12, 6, 4210752);

 

 

fontRenderer.drawString("\u00A76Fuel: " + tileEntity.getFuelLevel(), 6, 6, 4210752);

if(tileEntity.getFuelLevel() <= 0)

{

fontRenderer.drawString("\u00A74No Fuel!", 6, 36, 4210752);

}

 

fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);

}

 

@Override

protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)

{

GL11.glColor4f(1f, 1f, 1f, 1f);

 

mc.renderEngine.bindTexture("/mods/gamersmods/fuelresourceful/textures/gui/BlockBreakerGui.png");

 

int x = (width - xSize) / 2;

int y = (height - ySize) / 2;

drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

}

}

 

 

 

 

Error Log

 

 

2013-06-16 14:05:07 [iNFO] [sTDERR] net.minecraft.util.ReportedException: Updating screen events

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1506)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:834)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:759)

2013-06-16 14:05:07 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

2013-06-16 14:05:07 [iNFO] [sTDERR] Caused by: java.lang.IndexOutOfBoundsException: Index: 38, Size: 37

2013-06-16 14:05:07 [iNFO] [sTDERR] at java.util.ArrayList.rangeCheck(Unknown Source)

2013-06-16 14:05:07 [iNFO] [sTDERR] at java.util.ArrayList.get(Unknown Source)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.inventory.Container.mergeItemStack(Container.java:621)

2013-06-16 14:05:07 [iNFO] [sTDERR] at mods.gamersmods.fuelresourceful.tileentity.ContainerBlockBreaker.transferStackInSlot(ContainerBlockBreaker.java:57)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.inventory.Container.slotClick(Container.java:281)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.multiplayer.PlayerControllerMP.windowClick(PlayerControllerMP.java:468)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.gui.inventory.GuiContainer.handleMouseClick(GuiContainer.java:798)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.gui.inventory.GuiContainer.mouseClicked(GuiContainer.java:541)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.gui.GuiScreen.handleMouseInput(GuiScreen.java:203)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.gui.GuiScreen.handleInput(GuiScreen.java:177)

2013-06-16 14:05:07 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1499)

 

 

 

Any help will be helpful!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Sonic77 adalah pilihan tepat bagi Anda yang menginginkan pengalaman bermain slot yang unggul dengan akun pro Swiss terbaik. Berikut adalah beberapa alasan mengapa Anda harus memilih Sonic77: Slot Gacor Terbaik Kami menyajikan koleksi slot gacor terbaik dari provider terkemuka. Dengan fitur-fitur unggulan dan peluang kemenangan yang tinggi, Anda akan merasakan pengalaman bermain yang tak terlupakan. Akun Pro Swiss Berkualitas Kami menawarkan akun pro Swiss yang berkualitas dan terpercaya. Dengan akun ini, Anda dapat menikmati berbagai keuntungan eksklusif dan fasilitas premium yang tidak tersedia untuk akun reguler.
    • SV388 SITUS RESMI SABUNG AYAM 2024   Temukan situs resmi untuk sabung ayam terpercaya di tahun 2024 dengan SV388! Dengan layanan terbaik dan pengalaman bertaruh yang tak tertandingi, SV388 adalah tempat terbaik untuk pecinta sabung ayam. Daftar sekarang untuk mengakses arena sabung ayam yang menarik dan nikmati kesempatan besar untuk meraih kemenangan. Jelajahi sensasi taruhan yang tak terlupakan di tahun ini dengan SV388! [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]   JURAGANSLOT88 SITUS JUDI SLOT ONLINE TERPERCAYA 2024 Jelajahi pengalaman judi slot online terpercaya di tahun 2024 dengan JuraganSlot88! Sebagai salah satu situs terkemuka, JuraganSlot88 menawarkan berbagai pilihan permainan slot yang menarik dengan layanan terbaik dan keamanan yang terjamin. Daftar sekarang untuk mengakses sensasi taruhan yang tak terlupakan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan JuraganSlot88 [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
    • Slot Bank MEGA atau Daftar slot Bank MEGA bisa anda lakukan pada situs WINNING303 kapanpun dan dimanapun, Bermodalkan Hp saja anda bisa mengakses chat ke agen kami selama 24 jam full. keuntungan bergabung bersama kami di WINNING303 adalah anda akan mendapatkan bonus 100% khusus member baru yang bergabung dan deposit. Tidak perlu banyak, 5 ribu rupiah saja anda sudah bisa bermain bersama kami di WINNING303 . Tunggu apa lagi ? Segera Klik DAFTAR dan anda akan jadi Jutawan dalam semalam.
    • ladangtoto situs resmi ladangtoto situs terpercaya 2024   Temukan situs resmi dan terpercaya untuk tahun 2024 di LadangToto! Dengan layanan terbaik dan keamanan yang terjamin, LadangToto adalah pilihan utama untuk penggemar judi online. Daftar sekarang untuk mengakses berbagai jenis permainan taruhan, termasuk togel, kasino, dan banyak lagi. Jelajahi sensasi taruhan yang tak terlupakan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan LadangToto!" [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
    • WINNING303 DAFTAR SITUS JUDI SLOT RESMI TERPERCAYA 2024 Temukan situs judi slot resmi dan terpercaya untuk tahun 2024 di Winning303! Daftar sekarang untuk mengakses pengalaman berjudi slot yang aman dan terjamin. Dengan layanan terbaik dan reputasi yang kokoh, Winning303 adalah pilihan terbaik bagi para penggemar judi slot. Jelajahi berbagai pilihan permainan dan raih kesempatan besar untuk meraih kemenangan di tahun ini dengan Winning303 [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]] [[jumpuri:❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ > https://w303.pink/orochimaru]]
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.