Anyone have a fix for this?
|
Hey all, the bank tabs on vencillio get messed up when you try to create a new bank tab using the only item in a tab. Also the bank tabs will mess up if you withdraw the only item inside of a tab. I have also noticed that if it is the last existing tab, there are no issues withdrawing the only item inside the bank tab. So, if I have 8 bank tabs and I withdraw the only item inside the 8th tab, it will collapse correctly. I believe the root of the problem has to do with tab collapsing, but I'm not quite sure how to fix it. If anyone has fixed it or can help lead me in the right the direction, I would be very grateful. Thanks!
Below are some gifs to demonstrate. The first one is withdrawing the only item in the bank tab. The second one is creating a new tab using the only item inside of a tab.
Here are my methods regarding bank tabs:
Code:public void withdraw(int item, int amount) { if (!player.getInterfaceManager().hasBankOpen()) { return; } if (!hasItemId(item)) { return; } int bankAmount = getItemAmount(item); int bankSlot = getItemSlot(item); if (bankAmount < amount) { amount = bankAmount; } int old = item; if (withdrawType == WithdrawTypes.NOTE) { if (!Item.getDefinition(item).canNote()) player.getClient().queueOutgoingPacket(new SendMessage("This item cannot be withdrawn as a note.")); else { item = Item.getDefinition(item).getNoteId(); } } int added = player.getInventory().add(item, amount, false); if (added > 0) { if (remove(new Item(old, added), true) > 0) { if (added == bankAmount) { int tab = getData(bankSlot, 0); changeTabAmount(tab, -1, tab == 0 && tabAmounts[0] == 1); } } } } public void collapse(int tab, int toTab) { if (tab == 0) { Arrays.fill(tabAmounts, 0); tabAmounts[0] = getTakenSlots(); shift(); update(); return; } if (toTab == 0) { player.send(new SendConfig(1000, 0)); bankTab = 0; } if (toTab == tab || tab > 9) { shift(); update(); return; } int itemSlot = getData(tab, 1); int initialTabAmount = tabAmounts[tab]; for (int fromSlot = 0; fromSlot < initialTabAmount; fromSlot++) { itemToTab(itemSlot, toTab, false); } collapse(tab + 1, tab); } public int getData(int input, int type) { int totalSlots = 0; for (int tab = 0; tab < (type == 1 ? input + 1 : 10); tab++) { if (type == 0 && input <= totalSlots + tabAmounts[tab] - 1 && input >= totalSlots) { return tab; } totalSlots += tabAmounts[tab]; } return totalSlots - 1; } public void itemToTab(int slot, int toTab, boolean refresh) { int fromTab = getData(slot, 0); if (fromTab == toTab || (toTab > 1 && tabAmounts[toTab - 1] == 0 && tabAmounts[toTab] == 0)) { return; } if (tabAmounts[fromTab] == 0) { return; } changeTabAmount(fromTab, -1, refresh); changeTabAmount(toTab, 1, false); RearrangeTypes temp = rearrangeType; rearrangeType = RearrangeTypes.INSERT; swap(getData(toTab, 1), slot); rearrangeType = temp; if (refresh) { update(); } } public void changeTabAmount(int tab, int amount, boolean collapse) { tabAmounts[tab] += amount; if (tabAmounts[tab] <= 0 && collapse) { collapse(tab, 0); } }
Anyone have a fix for this?
should be from @Override to the bottom paste this in and try it dont forget to compile after it almost looks the same I know
Code:@Override public void clear() { Arrays.fill(tabAmounts, 0); bankTab = 0; setSearching(false); super.clear(); } public void withdraw(int item, int amount) { if (!player.getInterfaceManager().hasBankOpen()) { return; } if (!hasItemId(item)) { return; } int bankAmount = getItemAmount(item); int bankSlot = getItemSlot(item); if (bankAmount < amount) { amount = bankAmount; } int old = item; if (withdrawType == WithdrawTypes.NOTE) { if (!Item.getDefinition(item).canNote()) player.getClient().queueOutgoingPacket(new SendMessage("This item cannot be withdrawn as a note.")); else { item = Item.getDefinition(item).getNoteId(); } } int added = player.getInventory().add(item, amount, false); if (added > 0) { if (remove(new Item(old, added), true) > 0) { if (added == bankAmount) { int tab = getData(bankSlot, 0); changeTabAmount(tab, -1, tab == 0 && tabAmounts[0] == 1); } } } } public void collapse(int tab, int toTab) { if (tab == 0) { Arrays.fill(tabAmounts, 0); tabAmounts[0] = getTakenSlots(); shift(); update(); return; } if (toTab == 0) { player.send(new SendConfig(1000, 0)); bankTab = 0; } if (toTab == tab || tab > 9) { shift(); update(); return; } int itemSlot = getData(tab, 1); int initialTabAmount = tabAmounts[tab]; for (int fromSlot = 0; fromSlot < initialTabAmount; fromSlot++) { itemToTab(itemSlot, toTab, false); } collapse(tab + 1, tab); } public int getData(int input, int type) { int totalSlots = 0; for (int tab = 0; tab < (type == 1 ? input + 1 : 10); tab++) { if (type == 0 && input <= totalSlots + tabAmounts[tab] - 1 && input >= totalSlots) { return tab; } totalSlots += tabAmounts[tab]; } return totalSlots - 1; } public void itemToTab(int slot, int toTab, boolean refresh) { int fromTab = getData(slot, 0); if (fromTab == toTab || (toTab > 1 && tabAmounts[toTab - 1] == 0 && tabAmounts[toTab] == 0)) { return; } changeTabAmount(fromTab, -1, refresh); changeTabAmount(toTab, 1, false); RearrangeTypes temp = rearrangeType; rearrangeType = RearrangeTypes.INSERT; swap(getData(toTab, 1), slot); rearrangeType = temp; if (refresh) { update(); } } public void changeTabAmount(int tab, int amount, boolean collapse) { tabAmounts[tab] += amount; if (tabAmounts[tab] <= 0 && collapse) { collapse(tab, 0); } } public int getTabAmount(int tab) { return tabAmounts[tab]; } public int[] getTabAmounts() { return tabAmounts; } public void setTabAmounts(int[] tabAmounts) { this.tabAmounts = tabAmounts; } public void setBankTab(int bankTab) { this.bankTab = bankTab; } public boolean isSearching() { return searching; } public void setSearching(boolean searching) { this.searching = searching; if (!isSearching()) { player.send(new SendConfig(1012, 0)); } else { player.send(new SendEnterString()); } player.send(new OutgoingPacket() { @Override public void execute(Client paramClient) { } @Override public int getOpcode() { return 187; } }); } }
There is no problem with the section of code i posted it works perfectly for me I would just delete the whole code and redo it and i mean from the top of the page to the bottom
Nice find. Here's the fix.
In the withdraw method change:
to:Code:changeTabAmount(tab, -1, tab == 0 && tabAmounts[0] == 1);
Code:changeTabAmount(tab, -1, tabAmounts[tab] == 1);
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |