Jump to content

Recommended Posts

Posted

Overview

 

 

Hello, I have a custom gui, it is suppose to be a bank, I have 9 tabs in the gui and 468 slot on each page, so I have everything working the way I want it too, except the saving and loading. I will post my code now, but I will give more info in a spoiler at the bottom of this post and the problem is a spoiler underneath this spoiler. Please ask is you need more code because I have had this problem for a while and I can't seem to figure it out. I may have over complicated this, and I am open for ideas on how I could have mad this simpler. All help and criticism is appreciated, Thank You

 

 

Problem

 

When I load the items from the nbt data, for some reason, it puts the them into the correct tab and slot, but it also puts an invisible item that appears after you click the same slot in a different tab. I have a scroll system that lets the player scroll through each tab because there are 468 slots. So when I put the item in a slot that I have to scroll down to look at it does that invisible item thing and duplicates the item in each tab

 

 

Bank Container

 

package mod.xtronius.rc_mod.container;

 

import mod.xtronius.rc_mod.inventory.InvBank;

import mod.xtronius.rc_mod.lib.ExtendedPlayer;

import mod.xtronius.rc_mod.tileEntity.slot.SlotBank;

import mod.xtronius.rc_mod.tileEntity.slot.SlotFurnace1;

import mod.xtronius.rc_mod.tileEntity.slot.SlotGhost;

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.item.ItemArmor;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.util.IIcon;

import net.minecraft.world.World;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class BankContainer extends Container

{

public InvBank invBank;

private final EntityPlayer player;

    private World worldObj;

    private ICrafting crafter;

    private int xPos;

    private int yPos;

    private int zPos;

   

    public boolean isClosed = true;

   

    public ItemStack[] ItemDisplay = new ItemStack[8];

 

    public BankContainer(InventoryPlayer playerInv, World world, int x, int y, int z) {

      this.invBank = new InvBank(this, world, playerInv.player, x, y, z);

     

      this.worldObj = world;

      this.player = playerInv.player;

      this.xPos = x;

      this.yPos = y;

      this.xPos = z;

       

      int slotIndex = 0;

      byte slotSize = 18;

      short xOffset = 6;

      short yOffset = 12;

     

      /** Bank Slots*/

      for(int collum = 0; collum < 13; collum++) {

      for(int row = 0; row < 6; row++) {

      this.addSlotToContainer(new SlotBank(this.invBank, collum + row * 13, slotSize * collum + xOffset, slotSize * row + yOffset));

      if(slotIndex < 78)

      slotIndex++;

      }

      }

     

        byte slotSize1 = 18;

        short xOffset1 = 6;

        short yOffset1 = 143;

        int row;

        /** Inv Slots*/

        for (row = 0; row < 3; ++row) {

            for (int collum = 0; collum < 9; ++collum) {

                this.addSlotToContainer(new Slot(playerInv, collum + row * 9 + 9, collum * slotSize1 + xOffset1, row * slotSize1 + yOffset1));

            }

        }

        /** Hot-Bar Slots*/

        for (row = 0; row < 9; ++row) {

            this.addSlotToContainer(new Slot(playerInv, row, row * 18 + xOffset1, 198));

        }

        /** Armor Slots 1 collom*/

        int i = 0;

        for (i = 0; i < 4; ++i) {

            final int k = i;

            int yOS;

           

            if(k == 0) yOS = 126;

            else if(k == 1) yOS = 162;

            else if(k == 2) yOS = 180;

            else yOS = 198;

           

           

            this.addSlotToContainer(new Slot(playerInv, playerInv.getSizeInventory() - 1 - i, 169, yOS) {

                private static final String __OBFID = "CL_00001755";

               

                public int getSlotStackLimit() {

                    return 1;

                }

                public boolean isItemValid(ItemStack par1ItemStack) {

                    if (par1ItemStack == null) return false;

                    return par1ItemStack.getItem().isValidArmor(par1ItemStack, k, player);

                }

               

                @SideOnly(Side.CLIENT)

                public IIcon getBackgroundIconIndex() {

                    return ItemArmor.func_94602_b(k);

                }

            });

        }

    }

   

    public InvBank getInv() {

      return this.invBank;

    }

 

    public void addCraftingToCrafters(ICrafting par1ICrafting) {

    this.crafter = par1ICrafting;

        super.addCraftingToCrafters(par1ICrafting);

    }

 

    public void detectAndSendChanges() {

        super.detectAndSendChanges();

       

        for (int i = 0; i < this.crafters.size(); ++i) {

            ICrafting icrafting = (ICrafting)this.crafters.get(i);

        }

    }

   

    @SideOnly(Side.CLIENT)

    public void updateProgressBar(int par1, int par2) {}

 

    public boolean canInteractWith(EntityPlayer par1EntityPlayer) { return true; }

   

    public void onContainerClosed(EntityPlayer player) {

    if(!player.worldObj.isRemote)

    saveInventoryToPlayer(player);

        super.onContainerClosed(player);

        this.removeCraftingFromCrafters(crafter);

        this.isClosed = true;

    }

   

    private void saveInventoryToPlayer(EntityPlayer player) {

   

    ExtendedPlayer props = ExtendedPlayer.get(player);

   

    if(props != null) {

    for(int i = 0; i < this.invBank.bankTab0ItemStacks.length; i++) {

 

    if(this.invBank.bankTab0ItemStacks != null)

    props.playerBankStorage = this.invBank.bankTab0ItemStacks;

       

    if(this.invBank.bankTab1ItemStacks != null)

    props.playerBankStorage[i+(468*1)] = this.invBank.bankTab1ItemStacks;

   

    if(this.invBank.bankTab2ItemStacks != null)

    props.playerBankStorage[i+(468*2)] = this.invBank.bankTab2ItemStacks;

       

    if(this.invBank.bankTab3ItemStacks != null)

    props.playerBankStorage[i+(468*3)] = this.invBank.bankTab3ItemStacks;

       

    if(this.invBank.bankTab4ItemStacks != null)

    props.playerBankStorage[i+(468*4)] = this.invBank.bankTab4ItemStacks;

   

    if(this.invBank.bankTab5ItemStacks != null)

    props.playerBankStorage[i+(468*5)] = this.invBank.bankTab5ItemStacks;

   

    if(this.invBank.bankTab6ItemStacks != null)

    props.playerBankStorage[i+(468*6)] = this.invBank.bankTab6ItemStacks;

   

    if(this.invBank.bankTab7ItemStacks != null)

    props.playerBankStorage[i+(468*7)] = this.invBank.bankTab7ItemStacks;

 

    if(this.invBank.bankTab8ItemStacks != null)

    props.playerBankStorage[i+(468*8)] = this.invBank.bankTab8ItemStacks;

    }

    }

    }

 

    public ItemStack transferStackInSlot(EntityPlayer player, int par2) {

        ItemStack itemstack = null;

        Slot slot = (Slot)this.inventorySlots.get(par2);

 

        if (slot == null && !slot.getHasStack()) {

            ItemStack itemstack1 = slot.getStack();

            itemstack = itemstack1.copy();

            return itemstack;

        }

        return null;

    }

}

 

Bank Inventory

 

package mod.xtronius.rc_mod.inventory;

 

import mod.xtronius.rc_mod.rc_mod;

import mod.xtronius.rc_mod.container.BankContainer;

import mod.xtronius.rc_mod.container.Furnace1Container;

import mod.xtronius.rc_mod.furnaceRecipies.RCCastFurnace1Recipes;

import mod.xtronius.rc_mod.furnaceRecipies.RCIngotFurnace1Recipes;

import mod.xtronius.rc_mod.handlers.RCTickHandler;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.EntityPlayerMP;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.crafting.FurnaceRecipes;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.world.World;

import net.minecraftforge.common.IExtendedEntityProperties;

 

public class InvBank implements IExtendedEntityProperties ,  IInventory {

 

public BankContainer eventHandler;

  private World worldObj;

  private EntityPlayer player;

 

private String type = "SERVER";

   

    private RCTickHandler tick = RCTickHandler.intance;

   

    public ItemStack[] bankTab0ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab1ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab2ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab3ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab4ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab5ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab6ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab7ItemStacks = new ItemStack[468];

    public ItemStack[] bankTab8ItemStacks = new ItemStack[468];

   

    public int currentSelectedTab = 0;

    private int currentTopRow = 0;

 

    public InvBank(Container container, World world, EntityPlayer player, int x, int y, int z) {

    this.eventHandler = (BankContainer) container;

    this.worldObj = world;

        this.player = player;

  }

 

 

  public ItemStack[] getStacksWithInt(int id) {

  switch(id) {

  case 0: return bankTab0ItemStacks;

  case 1: return bankTab1ItemStacks;

  case 2: return bankTab2ItemStacks;

  case 3: return bankTab3ItemStacks;

  case 4: return bankTab4ItemStacks;

  case 5: return bankTab5ItemStacks;

  case 6: return bankTab6ItemStacks;

  case 7: return bankTab7ItemStacks;

  case 8: return bankTab8ItemStacks;

  default: System.out.println("[Rune-Craft][Mod-Error] MethodName: getStacksWithInt Error: variable id is null"); return bankTab0ItemStacks;

  }

  }

 

    public int getSizeInventory() { return 468; }

 

    public ItemStack getStackInSlot(int slotIndex) {

    return this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex];

    }

 

    public String getInvName() { return "container.bank"; }

 

    public boolean isInvNameLocalized() { return false; }

 

    public ItemStack getStackInSlotOnClosing(int slotIndex) {

//        if (this.getStacksWithInt(this.currentSelectedTab) != null) {

//            ItemStack itemstack = this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex];

//            return itemstack;

//        }

    return null;

    }

   

    public ItemStack decrStackSize(int slotIndex, int par2) {

        if (this.getStacksWithInt(this.currentSelectedTab) != null) {

            ItemStack itemstack;

 

            if (this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex].stackSize <= par2) {

                itemstack = this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex];

                this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex] = null;

                this.eventHandler.onCraftMatrixChanged(this);

                return itemstack;

            }

            else {

                itemstack = this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex].splitStack(par2);

 

                if (this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex].stackSize == 0) {

                this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex] = null;

                }

 

                this.eventHandler.onCraftMatrixChanged(this);

                return itemstack;

            }

        }

return null;

    }

   

    public boolean hasInvSpace() {

   

    int result = 0;

 

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

    if(this.bankTab0ItemStacks != null) result ++;

   

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

    if(this.bankTab1ItemStacks != null) result ++;

   

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

    if(this.bankTab2ItemStacks != null) result ++;

   

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

    if(this.bankTab3ItemStacks != null) result ++;

   

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

    if(this.bankTab4ItemStacks != null) result ++;

   

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

    if(this.bankTab5ItemStacks != null) result ++;

   

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

    if(this.bankTab6ItemStacks != null) result ++;

   

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

    if(this.bankTab7ItemStacks != null) result ++;

   

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

    if(this.bankTab8ItemStacks != null) result ++;

   

if(result < 468) return true;

 

return false;

    }

 

    public void setInventorySlotContents(int slotIndex, ItemStack stack) {

    if(hasInvSpace()) this.getStacksWithInt(this.currentSelectedTab)[(this.getCurrentTopRow() * 13) + slotIndex] = stack;

    }

   

    /* Rune-Craft - Method**/

    public void setInventorySlotContents(int bankItemStackIndex, int slotIndex, ItemStack stack) {

    this.getStacksWithInt(bankItemStackIndex)[slotIndex] = stack;

    }

 

    /**

    * Returns the maximum stack size for a inventory slot. Seems to always be 64, possibly will be extended. *Isn't

    * this more of a set than a get?*

    */

    public int getInventoryStackLimit()

    {

        return 127;

    }

 

    /**

    * Called when an the contents of an Inventory change, usually

    */

    public void onInventoryChanged() {}

 

    /**

    * Do not make give this method the name canInteractWith because it clashes with Container

    */

    public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)

    {

        return true;

    }

 

    /**

    * Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.

    */

    public boolean isItemValidForSlot(int par1, ItemStack par2ItemStack)

    {

        return true;

    }

 

  @Override

  public void saveNBTData(NBTTagCompound compound) {

 

  }

 

  @Override

  public void loadNBTData(NBTTagCompound compound) {

 

  }

 

  @Override

  public void init(Entity entity, World world) {

 

  }

 

@Override

public String getInventoryName() {

return this.getInvName();

}

 

@Override

public boolean hasCustomInventoryName() {

return false;

}

 

@Override

public void markDirty() {

}

 

@Override

public void openInventory() {

 

}

 

@Override

public void closeInventory() {

 

}

 

public int getCurrentTopRow() { return currentTopRow; }

 

 

public void setCurrentTopRow(int currentTopRow) {

this.currentTopRow = currentTopRow;

}

 

public EntityPlayer getPlayer() {

return player;

}

}

 

Bank Gui

 

package mod.xtronius.rc_mod.gui.inv;

 

import io.netty.buffer.ByteBuf;

import io.netty.buffer.Unpooled;

import mod.xtronius.rc_mod.rc_mod;

import mod.xtronius.rc_mod.container.BankContainer;

import mod.xtronius.rc_mod.handlers.RCTickHandler;

import mod.xtronius.rc_mod.inventory.InvBank;

import mod.xtronius.rc_mod.lib.Reference;

import mod.xtronius.rc_mod.packetHandling.packets.generalPackets.PacketBankScroll;

import mod.xtronius.rc_mod.packetHandling.packets.generalPackets.PacketBankTab;

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.GuiButton;

import net.minecraft.client.gui.GuiScreen;

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

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

import net.minecraft.client.renderer.OpenGlHelper;

import net.minecraft.client.renderer.RenderHelper;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraft.client.resources.I18n;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.network.play.client.C17PacketCustomPayload;

import net.minecraft.potion.Potion;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.tileentity.TileEntityBeacon;

import net.minecraft.util.ResourceLocation;

import net.minecraft.world.World;

 

import org.lwjgl.input.Mouse;

import org.lwjgl.opengl.GL11;

import org.lwjgl.opengl.GL12;

 

import cpw.mods.fml.common.network.FMLOutboundHandler;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

@SideOnly(Side.CLIENT)

public class GuiBank extends GuiContainer

{

    private static final ResourceLocation furnaceGuiTextures = new ResourceLocation(Reference.MOD_Gui, "textures/gui/container/GuiBank3.png");

    private static BankContainer container;

    private InvBank invBank;

    public EntityPlayer player;

    private int scrollButtonY = 10;

    public static float currentScroll;

   

    private RightArrowButton bankRightArrowButton;

    private LeftArrowButton bankLeftArrowButton;

    private BankScrollButton bankScrollButton;

   

    private BankTabButton bankTabButton0;

    private BankTabButton bankTabButton1;

    private BankTabButton bankTabButton2;

    private BankTabButton bankTabButton3;

    private BankTabButton bankTabButton4;

    private BankTabButton bankTabButton5;

    private BankTabButton bankTabButton6;

    private BankTabButton bankTabButton7;

    private BankTabButton bankTabButton8;

    private boolean buttonsNotDrawn;

   

    private boolean isScrolling = false;

   

    public static int minY;

    public static int maxY;

   

    private float xSizeFloat;

 

    private float ySizeFloat;

   

    private int currentTopRow = 0;

   

    private int currentScrollingProg = 0;

    private int prevScrollingProg = 0;

   

    private RCTickHandler tickHandler = RCTickHandler.intance;

   

    public GuiBank(InventoryPlayer playerInv, World world, int x, int y, int z) {

    super(container = new BankContainer(playerInv, world, x, y, z));

        this.invBank = container.getInv();

        tickHandler.BankContainerMapCLIENT.put(playerInv.player, container);

        this.player = playerInv.player;

        this.xSize = 256;

        this.ySize = 219;

    }

   

    public void initGui() {

        super.initGui();

        minY = this.guiTop + 12;

        maxY = this.guiTop + 104;

       

        rc_mod.bankScrollPacket.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);

    rc_mod.bankScrollPacket.get(Side.CLIENT).writeOutbound(new PacketBankScroll(0));

   

    rc_mod.bankScrollPacket.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);

    rc_mod.bankScrollPacket.get(Side.CLIENT).writeOutbound(new PacketBankTab(0));

   

    this.invBank.setCurrentTopRow(0);

    this.invBank.currentSelectedTab = 0;

   

       

        this.buttonList.add(this.bankRightArrowButton = new GuiBank.RightArrowButton(-1, this.guiLeft + 246, this.guiTop - 19, 10, 15));

        this.buttonList.add(this.bankLeftArrowButton = new GuiBank.LeftArrowButton(-2, this.guiLeft + 0, this.guiTop - 19, 10, 15));

       

       

        this.buttonList.add(this.bankScrollButton = new GuiBank.BankScrollButton(-12, this.guiLeft + 240, minY, 12, 15));

       

        this.buttonList.add(this.bankTabButton0 = new GuiBank.BankTabButton(-3, 1, this.guiLeft + 15, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton1 = new GuiBank.BankTabButton(-4, 2, this.guiLeft + 40, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton2 = new GuiBank.BankTabButton(-5, 3, this.guiLeft + 65, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton3 = new GuiBank.BankTabButton(-6, 4, this.guiLeft + 90, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton4 = new GuiBank.BankTabButton(-7, 5, this.guiLeft + 115, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton5 = new GuiBank.BankTabButton(-8, 6, this.guiLeft + 140, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton6 = new GuiBank.BankTabButton(-9, 7, this.guiLeft + 165, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton7 = new GuiBank.BankTabButton(-10, 8, this.guiLeft + 190, this.guiTop - 27, 25, 27));

        this.buttonList.add(this.bankTabButton8 = new GuiBank.BankTabButton(-11, 7, this.guiLeft + 215, this.guiTop - 27, 25, 27));

        this.buttonsNotDrawn = true;

       

        this.setActiveTab(this.getTab(this.invBank.currentSelectedTab), 0, true);

    }

   

    public void updateScreen() {

        super.updateScreen();

       

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

        this.invBank.eventHandler.ItemDisplay = this.invBank.getStacksWithInt(i+1)[0];

       

        if(this.invBank.currentSelectedTab == 0)

        this.bankLeftArrowButton.enabled = false;

        else

        this.bankLeftArrowButton.enabled = true;

        if(this.invBank.currentSelectedTab == 8)

        this.bankRightArrowButton.enabled = false;

        else

        this.bankRightArrowButton.enabled = true;

       

        if(this.isScrolling && Mouse.isButtonDown(0)) {

        this.bankScrollButton.yPosition = this.bankScrollButton.mouseY - (this.bankScrollButton.width/2);       

        if(this.bankScrollButton.yPosition < this.minY)

        this.bankScrollButton.yPosition = this.minY;

        if(this.bankScrollButton.yPosition > this.maxY)

        this.bankScrollButton.yPosition = this.maxY;

       

        float scrollTranslationSize = (this.maxY - this.minY);

       

        float percentBarScrolled = (this.bankScrollButton.yPosition-this.minY)/scrollTranslationSize;

        currentTopRow = (int) (percentBarScrolled * 30);

       

            this.invBank.setCurrentTopRow(currentTopRow);

       

        this.currentScrollingProg = currentTopRow;

      }

      if(this.isScrolling && !Mouse.isButtonDown(0))

        this.isScrolling = false;

    }

   

    private GuiBank.BankTabButton getTab(int i) {

    switch(i) {

    case 0: return this.bankTabButton0;

    case 1: return this.bankTabButton1;

    case 2: return this.bankTabButton2;

    case 3: return this.bankTabButton3;

    case 4: return this.bankTabButton4;

    case 5: return this.bankTabButton5;

    case 6: return this.bankTabButton6;

    case 7: return this.bankTabButton7;

    case 8: return this.bankTabButton8;

    }

    return null;

    }

   

    protected void actionPerformed(GuiButton button) {

        if (button.id == -2 && this.invBank.currentSelectedTab >= 0) {

            this.invBank.currentSelectedTab--;

           

            for(int i = 0; i < 9; i++){

      if(i == this.invBank.currentSelectedTab) {

      this.setActiveTab(this.getTab(this.invBank.currentSelectedTab), i, true);

      updateTabIndex(this.invBank.currentSelectedTab);

      }

      else

      this.setActiveTab(this.getTab(i), i, false);

      }

        }

        else if (button.id == -1 && this.invBank.currentSelectedTab <= 8) {

        this.invBank.currentSelectedTab++;

       

        for(int i = 0; i < 9; i++){

      if(i == (this.invBank.currentSelectedTab)) {

      this.setActiveTab(this.getTab(this.invBank.currentSelectedTab), i, true);

      updateTabIndex(this.invBank.currentSelectedTab);

      }

      else

      this.setActiveTab(this.getTab(i), i, false);

      }

        }

        else if (button.id == -3) {

          if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 0;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 0) {

          this.setActiveTab(guiTabButton, 0, true);

          }

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

          }

        }

        else if (button.id == -4) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 1;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 1)

          this.setActiveTab(guiTabButton, 1, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

       

        else if (button.id == -5) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 2;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 2)

          this.setActiveTab(guiTabButton, 2, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

       

        else if (button.id == -6) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 3;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 3)

          this.setActiveTab(guiTabButton, 3, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

       

        else if (button.id == -7) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 4;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 4)

          this.setActiveTab(guiTabButton, 4, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

       

        else if (button.id == -8) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 5;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 5)

          this.setActiveTab(guiTabButton, 5, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

        else if (button.id == -9) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 6;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 6)

          this.setActiveTab(guiTabButton, 6, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

        else if (button.id == -10) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 7;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 7)

          this.setActiveTab(guiTabButton, 7, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

        else if (button.id == -11) {

            if(button instanceof GuiBank.BankTabButton) {

          GuiBank.BankTabButton guiTabButton = (BankTabButton) button;

          this.invBank.currentSelectedTab = 8;

          updateTabIndex(this.invBank.currentSelectedTab);

          for(int i = 0; i < 9; i++){

          if(i == 8)

          this.setActiveTab(guiTabButton, 8, true);

          else

          this.setActiveTab(this.getTab(i), i, false);

          }

            }

        }

        else if(button.id == -12) {

        if(button instanceof GuiBank.BankScrollButton) {

        GuiBank.BankScrollButton scrollButton = (BankScrollButton) button;

        this.isScrolling =  true;

        }

        }

    }

   

    public void handleMouseInput() {

    super.handleMouseInput();

    int yD = Mouse.getEventY();

    this.currentScroll = yD;

    }

   

    protected void drawGuiContainerForegroundLayer(int par1, int par2) {

        // String s = invFurnace.isInvNameLocalized() ? invFurnace.getInvName() : I18n.getString(invFurnace.getInvName());

//    String s = "Bank";

//        this.fontRendererObj.drawString(s, ((this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2) + 1), 6, 8355711);

        //this.fontRendererObj.drawString(I18n.getString("container.inventory"), 8, this.ySize - 96, 8355711);

        this.fontRendererObj.drawString("inventory", 8, this.ySize - 96, 8355711);

//      this.buttonList.add(this.bankTabButton1 = new GuiBank.BankTabButton(-4, 2, this.guiLeft + 40, this.guiTop - 27, 25, 27));

       

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[0], 45, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[1], 70, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[2], 95, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[3], 120, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[4], 145, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[5], 170, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[6], 195, -20);

        this.itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), this.container.ItemDisplay[7], 220, -20);

    }

 

    /**

    * Draw the background layer for the GuiContainer (everything behind the items)

    */

    protected void drawGuiContainerBackgroundLayer(float x, int y, int z) {

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        this.mc.getTextureManager().bindTexture(furnaceGuiTextures);

        int k = (this.width - this.xSize) / 2;

        int l = (this.height - this.ySize) / 2;

        this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);

       

        int startingXPos = this.guiLeft;

        int startingYPos = this.guiTop;

       

        this.renderPlayerArmorModel(startingXPos + 187 + 21, startingYPos + 126 + 66, 30, (float)(startingXPos + 187 + 28) - this.xSizeFloat, (float)(startingYPos + 126 + 23 - 50) - this.ySizeFloat, this.mc.thePlayer);

    }

   

    private void renderPlayerArmorModel(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_) {

        GL11.glEnable(GL11.GL_COLOR_MATERIAL);

        GL11.glPushMatrix();

        GL11.glTranslatef((float)p_147046_0_, (float)p_147046_1_, 50.0F);

        GL11.glScalef((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_);

        GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);

        float f2 = p_147046_5_.renderYawOffset;

        float f3 = p_147046_5_.rotationYaw;

        float f4 = p_147046_5_.rotationPitch;

        float f5 = p_147046_5_.prevRotationYawHead;

        float f6 = p_147046_5_.rotationYawHead;

        GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);

        RenderHelper.enableStandardItemLighting();

        GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);

        GL11.glRotatef(-((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);

        p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F;

        p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F;

        p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F;

        p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw;

        p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw;

        GL11.glTranslatef(0.0F, p_147046_5_.yOffset, 0.0F);

        RenderManager.instance.playerViewY = 180.0F;

        RenderManager.instance.renderEntityWithPosYaw(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);

        p_147046_5_.renderYawOffset = f2;

        p_147046_5_.rotationYaw = f3;

        p_147046_5_.rotationPitch = f4;

        p_147046_5_.prevRotationYawHead = f5;

        p_147046_5_.rotationYawHead = f6;

        GL11.glPopMatrix();

        RenderHelper.disableStandardItemLighting();

        GL11.glDisable(GL12.GL_RESCALE_NORMAL);

        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);

        GL11.glDisable(GL11.GL_TEXTURE_2D);

        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);

    }

   

    private void setActiveTab(GuiBank.BankTabButton button, int i, boolean var1) {

    button.isActive = var1;

    }

   

   

    private void updateTabIndex(int i) {

    rc_mod.bankTabPacket.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER);

    rc_mod.bankTabPacket.get(Side.CLIENT).writeOutbound(new PacketBankTab(i));

    container.invBank.currentSelectedTab = i;

    }

   

    public void drawScreen(int par1, int par2, float par3)

    {

        super.drawScreen(par1, par2, par3);

        this.xSizeFloat = (float)par1;

        this.ySizeFloat = (float)par2;

    }

   

    @SideOnly(Side.CLIENT)

    static class Button extends GuiButton {

            private final ResourceLocation field_146145_o;

            public int mouseX = 0;

            public int mouseY = 0;

            public final int width;

            public final int height;

            private boolean field_146142_r;

            public boolean isHighlighted =  false;

            public boolean isActive = false;

            private static final String __OBFID = "CL_00000743";

 

            protected Button(int id, int x, int y, ResourceLocation texture, int width, int height) {

                super(id, x, y, width, height, "");

                this.field_146145_o = texture;

                this.width = width;

                this.height = height;

            }

 

            /**

            * Draws this button to the screen.

            */

            public void drawButton(Minecraft mc, int x, int y) {

                if (this.visible) {

                mc.getTextureManager().bindTexture(GuiBank.furnaceGuiTextures);

                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

                    this.field_146123_n = x >= this.xPosition && y >= this.yPosition && x < this.xPosition + this.width && y < this.yPosition + this.height;

                    this.isHighlighted = field_146123_n;

                    this.mouseX = x;

                    this.mouseY = y;

                    short v = 0;

                    int u = 0;

                   

                    if(this.id == -1) {

                    v = 219;

                    if(this.field_146123_n) {

                    u = 146;

                    } else {

                    u = 136;

                    }

                    } else if(this.id == -2){

                    v = 234;

                    if(this.field_146123_n) {

                    u = 146;

                    } else {

                    u = 136;

                    }

                    } else if(this instanceof GuiBank.BankTabButton) {

                    v = 219;

                    if(isActive) {

                    u = 181;

                    } else if(this.field_146123_n) {

                    u = 181;

                    } else {

                    u = 156;

                    }

                    } else if(this instanceof GuiBank.BankScrollButton) {

                v = 219;

//                 if(this.field_146123_n) {

//                 u = 112;

//                 } else {

                u = 124;

//                 }

                }

 

                    this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v, this.width, this.height);

 

                    if (!GuiBank.furnaceGuiTextures.equals(this.field_146145_o)) {

                    mc.getTextureManager().bindTexture(this.field_146145_o);

                    }

 

                    this.drawTexturedModalRect(this.xPosition, this.yPosition, u, v, this.width, this.height);

                }

            }

 

            public boolean func_146141_c() {

                return this.field_146142_r;

            }

 

            public void func_146140_b(boolean p_146140_1_) {

                this.field_146142_r = p_146140_1_;

            }

        }

 

    @SideOnly(Side.CLIENT)

    class RightArrowButton extends GuiBank.Button {

        public RightArrowButton(int id, int x, int y, int width, int height)

        {

            super(id, x, y, GuiBank.furnaceGuiTextures, width, height);

        }

 

        public void func_146111_b(int p_146111_1_, int p_146111_2_)

        {

            GuiBank.this.drawCreativeTabHoveringText(I18n.format("gui.rightArrow", new Object[0]), p_146111_1_, p_146111_2_);

        }

    }

 

    @SideOnly(Side.CLIENT)

    class LeftArrowButton extends GuiBank.Button {

        public LeftArrowButton(int id, int x, int y, int width, int height)

        {

            super(id, x, y, GuiBank.furnaceGuiTextures, width, height);

        }

 

        public void func_146111_b(int p_146111_1_, int p_146111_2_)

        {

            GuiBank.this.drawCreativeTabHoveringText(I18n.format("gui.leftArrow", new Object[0]), p_146111_1_, p_146111_2_);

        }

    }

   

    @SideOnly(Side.CLIENT)

    class BankTabButton extends GuiBank.Button {

    int tabNum = 0;

        public BankTabButton(int id, int tabNum, int x, int y, int width, int height)

        {

            super(id, x, y, GuiBank.furnaceGuiTextures, width, height);

            this.tabNum = tabNum;

        }

 

        public void func_146111_b(int p_146111_1_, int p_146111_2_)

        {

            GuiBank.this.drawCreativeTabHoveringText(I18n.format("gui.tab" + tabNum, new Object[0]), p_146111_1_, p_146111_2_);

        }

    }

   

    @SideOnly(Side.CLIENT)

    class BankScrollButton extends GuiBank.Button {

        public BankScrollButton(int id, int x, int y, int width, int height) {

            super(id, x, y, GuiBank.furnaceGuiTextures, width, height);

        }

    }

}

 

 

Extended Player Properties

 

package mod.xtronius.rc_mod.lib;

 

import java.util.HashMap;

 

import cpw.mods.fml.common.network.FMLOutboundHandler;

import cpw.mods.fml.relauncher.Side;

import mod.xtronius.rc_mod.rc_mod;

import mod.xtronius.rc_mod.container.BankContainer;

import mod.xtronius.rc_mod.handlers.RCTickHandler;

import mod.xtronius.rc_mod.packetHandling.packets.generalPackets.PacketBankInvSync;

import mod.xtronius.rc_mod.packetHandling.packets.generalPackets.PacketInitCombatStyle;

import mod.xtronius.rc_mod.packetHandling.packets.generalPackets.PacketSwitchCombatStyle;

import mod.xtronius.rc_mod.proxy.CommonProxy;

import mod.xtronius.rc_mod.util.enumClasses.MeleCombatStyles;

import net.minecraft.block.Block;

import net.minecraft.entity.Entity;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.nbt.NBTTagList;

import net.minecraft.world.World;

import net.minecraftforge.common.IExtendedEntityProperties;

 

public class ExtendedPlayer implements IExtendedEntityProperties

{

 

private HashMap<String, Integer> playerLvl = new HashMap<String, Integer>();

private HashMap<String, Double> playerExp = new HashMap<String, Double>();

private HashMap<String, Double> playerExpUntilNextLvl = new HashMap<String, Double>();

 

/*Array of the level names for display**/

public static String AttackStr = "Attack", StrengthStr = "Strength", DefenceStr  = "Defense", RangeStr = "Range", PrayerStr = "Prayer", MageStr = "Mage", RuneCraftingStr = "Rune Crafting", ConstructionStr = "Construction", DungeoneeringStr = "Dungeoneering", ConstitutionStr = "Constitution", AgilityStr = "Agility", HerbloreStr = "Herblore", ThievingStr = "Thieving", CraftingStr = "Crafting", FletchingStr = "Fletching", SlayerStr = "Slayer", HuntingStr = "Hunting", MiningStr = "Mining", SmithingStr = "Smithing", FishingStr = "Fishing", CookingStr = "Cooking", FireMakingStr = "Fire Making", WoodCuttingStr = "Wood Cutting", FarmingStr = "Farming", SummoningStr = "Summoning";

public static String[] SkillsStr = new String[] {AttackStr, StrengthStr, DefenceStr, RangeStr, PrayerStr, MageStr, RuneCraftingStr, ConstructionStr, DungeoneeringStr, ConstitutionStr, AgilityStr, HerbloreStr, ThievingStr, CraftingStr, FletchingStr, SlayerStr, HuntingStr, MiningStr, SmithingStr, FishingStr, CookingStr, FireMakingStr, WoodCuttingStr, FarmingStr, SummoningStr};

 

/*Array of the level names for saving**/

public static String AttackNoSpaceStr = "Attack", StrengthNoSpaceStr = "Strength", DefenceNoSpaceStr = "Defense", RangeNoSpaceStr = "Range", PrayerNoSpaceStr = "Prayer", MageNoSpaceStr = "Mage", RuneCraftingNoSpaceStr = "RuneCrafting", ConstructionNoSpaceStr = "Construction", DungeoneeringNoSpaceStr = "Dungeoneering", ConstitutionNoSpaceStr = "Constitution", AgilityNoSpaceStr = "Agility", HerbloreNoSpaceStr = "Herblore", ThievingNoSpaceStr = "Thieving", CraftingNoSpaceStr = "Crafting", FletchingNoSpaceStr = "Fletching", SlayerNoSpaceStr = "Slayer", HuntingNoSpaceStr = "Hunting", MiningNoSpaceStr = "Mining", SmithingNoSpaceStr = "Smithing", FishingNoSpaceStr = "Fishing", CookingNoSpaceStr = "Cooking", FireMakingNoSpaceStr = "FireMaking", WoodCuttingNoSpaceStr = "WoodCutting", FarmingNoSpaceStr = "Farming", SummoningNoSpaceStr = "Summoning";

public static String[] SkillsNoSpaceStr = new String[] {AttackNoSpaceStr, StrengthNoSpaceStr, DefenceNoSpaceStr, RangeNoSpaceStr, PrayerNoSpaceStr, MageNoSpaceStr, RuneCraftingNoSpaceStr, ConstructionNoSpaceStr, DungeoneeringNoSpaceStr, ConstitutionNoSpaceStr, AgilityNoSpaceStr, HerbloreNoSpaceStr, ThievingNoSpaceStr, CraftingNoSpaceStr, FletchingNoSpaceStr, SlayerNoSpaceStr, HuntingNoSpaceStr, MiningNoSpaceStr, SmithingNoSpaceStr, FishingNoSpaceStr, CookingNoSpaceStr, FireMakingNoSpaceStr, WoodCuttingNoSpaceStr, FarmingNoSpaceStr, SummoningStr};

 

public final static String EXT_PROP_NAME = "ExtendedPlayer";

 

private final EntityPlayer player;

private boolean resetNBT = false;

 

private Enum currentMeleAttackStyle = MeleCombatStyles.ATTACK;

private int meleCombatStyleGuiCoolDown = 0;

 

public int attackCoolDown = 0;

 

public ItemStack[] playerBankStorage = new ItemStack[4212];

 

public ExtendedPlayer(EntityPlayer player) {

this.player = player;

//init values to store

 

for(int lvlID = 0; lvlID < this.SkillsNoSpaceStr.length; lvlID++) {

if(this.playerLvl.get(this.SkillsNoSpaceStr[lvlID] + "Lvl") == null && this.playerExp.get(this.SkillsNoSpaceStr[lvlID] + "Exp") == null && this.playerExpUntilNextLvl.get(this.SkillsNoSpaceStr[lvlID] + "ExpUntilNextLvl") == null) {

this.playerLvl.put(this.SkillsNoSpaceStr[lvlID] + "Lvl", 1);

this.playerExp.put(this.SkillsNoSpaceStr[lvlID] + "Exp", (double) 0);

this.playerExpUntilNextLvl.put(this.SkillsNoSpaceStr[lvlID] + "ExpUntilNextLvl", (double) 83);

}

}

}

 

public static final void register(EntityPlayer player) {

player.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer(player));

}

 

public static final ExtendedPlayer get(EntityPlayer player) {

return (ExtendedPlayer) player.getExtendedProperties(EXT_PROP_NAME);

}

 

private static String getSaveKey(EntityPlayer player) {

return player.getDisplayName() + ":" + EXT_PROP_NAME;

}

 

@Override

public void saveNBTData(NBTTagCompound compound) {

 

NBTTagCompound properties = new NBTTagCompound();

 

if(!this.player.worldObj.isRemote) {

 

/** Null Check Init */

properties.setString("RC_Mod", "NullCheckForNBT");

 

/** Lvl Saving */

for(int lvlID = 0; lvlID < this.SkillsNoSpaceStr.length; lvlID++) {

properties.setInteger(this.SkillsNoSpaceStr[lvlID] + "Lvl", this.playerLvl.get(this.SkillsNoSpaceStr[lvlID] + "Lvl"));

properties.setDouble(this.SkillsNoSpaceStr[lvlID] + "Exp", this.playerExp.get(this.SkillsNoSpaceStr[lvlID] + "Exp"));

properties.setDouble(this.SkillsNoSpaceStr[lvlID] + "ExpUntilNextLvl", this.playerExpUntilNextLvl.get(this.SkillsNoSpaceStr[lvlID] + "ExpUntilNextLvl"));

}

 

properties.setString("MeleAttackStyle", this.currentMeleAttackStyle.toString());

 

compound.setTag(EXT_PROP_NAME, properties);

 

/** Bank Handling */

    NBTTagList nbttaglist = new NBTTagList();

     

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

            if (this.playerBankStorage != null) {

            System.out.println("Slot: " + i + " Is not Null!!!");

                NBTTagCompound nbttagcompound1 = new NBTTagCompound();

                nbttagcompound1.setInteger("BankSlot", i);

                this.playerBankStorage.writeToNBT(nbttagcompound1);

                nbttaglist.appendTag(nbttagcompound1);

            }

        }

        compound.setTag("BankItems", nbttaglist);

}

}

 

@Override

public void loadNBTData(NBTTagCompound compound) {

 

this.resetNBT = false;

NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);

 

if(!this.player.worldObj.isRemote) {

 

/** Null Check */

if(properties.hasKey("RC_Mod") && this.resetNBT == false) {

 

/** Lvl Loading */

for(int lvlID = 0; lvlID < this.SkillsNoSpaceStr.length; lvlID++) {

this.playerLvl.put(this.SkillsNoSpaceStr[lvlID] + "Lvl", properties.getInteger(this.SkillsNoSpaceStr[lvlID] + "Lvl"));

this.playerExp.put(this.SkillsNoSpaceStr[lvlID] + "Exp", properties.getDouble(this.SkillsNoSpaceStr[lvlID] + "Exp"));

this.playerExpUntilNextLvl.put(this.SkillsNoSpaceStr[lvlID] + "ExpUntilNextLvl", properties.getDouble(this.SkillsNoSpaceStr[lvlID] + "ExpUntilNextLvl"));

}

 

this.currentMeleAttackStyle = Enum.valueOf(MeleCombatStyles.class, properties.getString("MeleAttackStyle"));

 

/** Bank Handling */

 

BankContainer bank = new BankContainer(this.player.inventory, this.player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);

RCTickHandler.BankContainerMapSERVER.put(this.player, bank);

 

NBTTagList nbttaglist = (NBTTagList) compound.getTag("BankItems");

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

 

NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);

int j = nbttagcompound1.getInteger("BankSlot");

System.out.println("This tag has a slot number of: " + j);

 

if (j >= 0 && j < this.playerBankStorage.length) {

this.playerBankStorage[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1);

}

}

 

for(int slotIndex = 0; slotIndex < this.playerBankStorage.length; slotIndex++) {

 

ItemStack stack = this.playerBankStorage[slotIndex];

if(bank != null) {

if(stack != null) {

if(slotIndex < 468)

bank.invBank.setInventorySlotContents(0, slotIndex, stack);

if(slotIndex < 468 * 2)

bank.invBank.setInventorySlotContents(1, slotIndex, stack);

if(slotIndex < 468 * 3)

bank.invBank.setInventorySlotContents(2, slotIndex, stack);

if(slotIndex < 468 * 4)

bank.invBank.setInventorySlotContents(3, slotIndex, stack);

if(slotIndex < 468 * 5)

bank.invBank.setInventorySlotContents(4, slotIndex, stack);

if(slotIndex < 468 * 6)

bank.invBank.setInventorySlotContents(5, slotIndex, stack);

if(slotIndex < 468 * 7)

bank.invBank.setInventorySlotContents(6, slotIndex, stack);

if(slotIndex < 468 * 8)

bank.invBank.setInventorySlotContents(7, slotIndex, stack);

if(slotIndex < 468 * 9)

bank.invBank.setInventorySlotContents(8, slotIndex, stack);

 

System.out.println(bank.invBank.getStackInSlot(slotIndex));

System.out.println("Setting Stack: " + this.playerBankStorage[slotIndex] + " To Slot: " + slotIndex);

}

}

}

}

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

this.playerBankStorage = null;

this.saveNBTData(compound);

}

}

 

public static void saveProxyData(EntityPlayer player) {

ExtendedPlayer playerData = ExtendedPlayer.get(player);

NBTTagCompound savedData = new NBTTagCompound();

 

playerData.saveNBTData(savedData);

CommonProxy.storeEntityData(getSaveKey(player), savedData);

}

 

public static void loadProxyData(EntityPlayer player) {

ExtendedPlayer playerData = ExtendedPlayer.get(player);

NBTTagCompound savedData = CommonProxy.getEntityData(getSaveKey(player));

 

if(savedData != null) {

playerData.loadNBTData(savedData);

}

//TODO sync the playerData in the Server and the Client by sending many packets

}

 

public int getMeleCombatStyleInt() {

int result = 0;

if(this.currentMeleAttackStyle != null)

if(this.currentMeleAttackStyle == MeleCombatStyles.ATTACK)

result = 0;

if(this.currentMeleAttackStyle == MeleCombatStyles.STRENGTH)

result = 1;

if(this.currentMeleAttackStyle == MeleCombatStyles.DEFENSE)

result = 2;

if(this.currentMeleAttackStyle == MeleCombatStyles.SHARED)

result = 3;

 

return result;

}

 

public Enum getMeleCombatStyle() { if(this.currentMeleAttackStyle != null) return this.currentMeleAttackStyle; return MeleCombatStyles.ATTACK; }

public void setMeleCombatStyle(Enum style) {if(style != null) this.currentMeleAttackStyle = style;}

 

public int getMeleCombatStyleGuiCoolDown() { return meleCombatStyleGuiCoolDown; }

public void setMeleCombatStyleGuiCoolDown(int meleCombatStyleGuiCoolDown) { this.meleCombatStyleGuiCoolDown = meleCombatStyleGuiCoolDown; }

 

public int getLvl(String lvl) { if(this.playerLvl.get(lvl + "Lvl") != null) return this.playerLvl.get(lvl + "Lvl"); return 0; }

public void setLvl(String lvl, int value) { this.playerLvl.put(lvl + "Lvl", value); }

 

public double getExp(String lvl) { if(this.playerExp.get(lvl + "Exp") != null) return this.playerExp.get(lvl + "Exp"); return 0; }

public void setExp(String lvl, double value) { this.playerExp.put(lvl + "Exp", value); }

 

public double getExpUntilNextLvl(String lvl) { if(this.playerExpUntilNextLvl.get(lvl + "ExpUntilNextLvl") != null) return this.playerExpUntilNextLvl.get(lvl + "ExpUntilNextLvl"); return 0; }

public void setExpUntilNextLvl(String lvl, double value) { this.playerExpUntilNextLvl.put(lvl + "ExpUntilNextLvl", value); }

 

@Override

public void init(Entity entity, World world) {}

}

 

 

Extra Info

 

 

So I have an Item Stack Array for each tab I have, so 9 in total. so when the player closes the gui, it loops through each Item Stack in each of the Arrays and puts them in 1 big Item Stack array in the Extened Player Class. From there, when the game is saved it goes through each Item Stack in the array and if it is not null, then it creates a new nbttagcompund and recores the slot number in there and then the item stack.(I don't think there is a problem with the Saving) Then When it loads it gets the nbt tag list and gets every compound and accoringly sorts them into big Item Stack Array and then creats a bank container and puts the items in there.

 

 

Don't be afraid to ask question when modding, there are no stupid question! Unless you don't know java then all your questions are stupid!

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

    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } }  
    • All versions of Minecraft Forge suddenly black screen even without mods (tried reinstalling original Minecraft, Java, updating drivers doesn't work)
    • When i join minecraft all ok, when i join world all working fine, but when i open indentity menu, i get this The game crashed whilst unexpected error Error: java.lang.NullPointerException: Cannot invoke "top.ribs.scguns.common.Gun$Projectile.getDamage()" because "this.projectile" is null crash report here https://paste.ee/p/0vKaf
  • Topics

×
×
  • Create New...

Important Information

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