aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java285
1 files changed, 143 insertions, 142 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
index 3a3aec6d..1cc34412 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/StorageManager.java
@@ -23,7 +23,8 @@ import net.minecraft.network.play.server.S30PacketWindowItems;
import java.io.*;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -58,12 +59,12 @@ public class StorageManager {
NBTTagCompound tag = JsonToNBT.getTagFromJson(JSON_FIX_REGEX.matcher(object.toString()).replaceAll("$1:"));
Item item;
- if(tag.hasKey("id", 8)) {
+ if (tag.hasKey("id", 8)) {
item = Item.getByNameOrId(tag.getString("id"));
} else {
item = Item.getItemById(tag.getShort("id"));
}
- if(item == null) {
+ if (item == null) {
return null;
}
int stackSize = tag.getInteger("Count");
@@ -71,13 +72,13 @@ public class StorageManager {
ItemStack stack = new ItemStack(item, stackSize, damage);
- if(tag.hasKey("tag")) {
+ if (tag.hasKey("tag")) {
NBTTagCompound itemTag = tag.getCompoundTag("tag");
stack.setTagCompound(itemTag);
}
return stack;
- } catch(Exception e) {
+ } catch (Exception e) {
e.printStackTrace();
return null;
}
@@ -99,7 +100,7 @@ public class StorageManager {
} else if (tag instanceof NBTTagList) {
NBTTagList listTag = (NBTTagList) tag;
JsonArray jsonArray = new JsonArray();
- for(int i=0; i<listTag.tagCount(); i++) {
+ for (int i = 0; i < listTag.tagCount(); i++) {
jsonArray.add(loadJson(listTag.get(i)));
}
return jsonArray;
@@ -107,19 +108,19 @@ public class StorageManager {
NBTTagIntArray listTag = (NBTTagIntArray) tag;
int[] arr = listTag.getIntArray();
JsonArray jsonArray = new JsonArray();
- for(int i=0; i<arr.length; i++) {
- jsonArray.add(new JsonPrimitive(arr[i]));
+ for (int j : arr) {
+ jsonArray.add(new JsonPrimitive(j));
}
return jsonArray;
} else if (tag instanceof NBTTagByteArray) {
NBTTagByteArray listTag = (NBTTagByteArray) tag;
byte[] arr = listTag.getByteArray();
JsonArray jsonArray = new JsonArray();
- for(int i=0; i<arr.length; i++) {
- jsonArray.add(new JsonPrimitive(arr[i]));
+ for (byte b : arr) {
+ jsonArray.add(new JsonPrimitive(b));
}
return jsonArray;
- }else if (tag instanceof NBTTagShort) {
+ } else if (tag instanceof NBTTagShort) {
return new JsonPrimitive(((NBTTagShort) tag).getShort());
} else if (tag instanceof NBTTagInt) {
return new JsonPrimitive(((NBTTagInt) tag).getInt());
@@ -131,8 +132,8 @@ public class StorageManager {
return new JsonPrimitive(((NBTTagDouble) tag).getDouble());
} else if (tag instanceof NBTTagByte) {
return new JsonPrimitive(((NBTTagByte) tag).getByte());
- } else if(tag instanceof NBTTagString){
- return new JsonPrimitive(((NBTTagString)tag).getString());
+ } else if (tag instanceof NBTTagString) {
+ return new JsonPrimitive(((NBTTagString) tag).getString());
} else {
return new JsonPrimitive("Broken_Json_Deserialize_Tag");
}
@@ -142,7 +143,7 @@ public class StorageManager {
return INSTANCE;
}
- private AtomicInteger searchId = new AtomicInteger(0);
+ private final AtomicInteger searchId = new AtomicInteger(0);
public static class StoragePage {
public ItemStack[] items = new ItemStack[45];
@@ -182,7 +183,7 @@ public class StorageManager {
public int desiredStoragePage = -1;
public long storageOpenSwitchMillis = 0;
- private ItemStack[] missingBackpackStacks = new ItemStack[18];
+ private final ItemStack[] missingBackpackStacks = new ItemStack[18];
private boolean shouldRenderStorageOverlayCached = false;
@@ -190,10 +191,10 @@ public class StorageManager {
private static final Pattern ECHEST_WINDOW_REGEX = Pattern.compile("Ender Chest \\((\\d+)/(\\d+)\\)");
public void loadConfig(File file) {
- try(BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file)), StandardCharsets.UTF_8))) {
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file)), StandardCharsets.UTF_8))) {
storageConfig = GSON.fromJson(reader, StorageConfig.class);
- } catch(Exception ignored) { }
- if(storageConfig == null) {
+ } catch (Exception ignored) {}
+ if (storageConfig == null) {
storageConfig = new StorageConfig();
}
}
@@ -201,21 +202,21 @@ public class StorageManager {
public void saveConfig(File file) {
try {
file.createNewFile();
- try(BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)), StandardCharsets.UTF_8))) {
+ try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new GZIPOutputStream(new FileOutputStream(file)), StandardCharsets.UTF_8))) {
writer.write(GSON.toJson(storageConfig));
}
- } catch(Exception ignored) {
- ignored.printStackTrace();
+ } catch (Exception e) {
+ e.printStackTrace();
}
}
public ItemStack getMissingBackpackStack(int storageId) {
- if(missingBackpackStacks[storageId] != null) {
+ if (missingBackpackStacks[storageId] != null) {
return missingBackpackStacks[storageId];
}
ItemStack stack = Utils.createItemStack(Item.getItemFromBlock(Blocks.stained_glass_pane),
- "\u00a7cEmpty Backpack Slot "+(storageId+1), 12,
+ "\u00a7cEmpty Backpack Slot " + (storageId + 1), 12,
"",
"\u00a7eLeft-click a backpack",
"\u00a7eitem on this slot to place",
@@ -224,24 +225,24 @@ public class StorageManager {
missingBackpackStacks[storageId] = stack;
return stack;
}
-
+
public boolean shouldRenderStorageOverlay(String containerName) {
- if(!NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
+ if (!NotEnoughUpdates.INSTANCE.config.storageGUI.enableStorageGUI3) {
shouldRenderStorageOverlayCached = false;
return false;
}
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
shouldRenderStorageOverlayCached = false;
return false;
}
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
shouldRenderStorageOverlayCached = false;
return false;
}
- if(getCurrentWindowId() != -1 && getCurrentPageId() != -1) {
+ if (getCurrentWindowId() != -1 && getCurrentPageId() != -1) {
shouldRenderStorageOverlayCached = true;
return true;
}
@@ -255,28 +256,28 @@ public class StorageManager {
}
private StoragePage[] getPagesForProfile() {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return null;
- if(SBInfo.getInstance().currentProfile == null) return null;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return null;
+ if (SBInfo.getInstance().currentProfile == null) return null;
return storageConfig.pages.computeIfAbsent(SBInfo.getInstance().currentProfile, k -> new StoragePage[27]);
}
public StoragePage getPage(int pageIndex, boolean createPage) {
- if(pageIndex == -1) return null;
+ if (pageIndex == -1) return null;
StoragePage[] pages = getPagesForProfile();
- if(pages == null) return null;
+ if (pages == null) return null;
- if(createPage && pages[pageIndex] == null) pages[pageIndex] = new StoragePage();
+ if (createPage && pages[pageIndex] == null) pages[pageIndex] = new StoragePage();
return pages[pageIndex];
}
public void removePage(int pageIndex) {
- if(pageIndex == -1) return;
+ if (pageIndex == -1) return;
StoragePage[] pages = getPagesForProfile();
- if(pages == null) return;
+ if (pages == null) return;
pages[pageIndex] = null;
}
@@ -287,13 +288,13 @@ public class StorageManager {
private void setItemSlot(int index, ItemStack item) {
StoragePage page = getCurrentPage();
- if(page != null) {
+ if (page != null) {
page.items[index] = item;
}
}
public int getCurrentPageId() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
currentStoragePage = -1;
return -1;
}
@@ -302,62 +303,62 @@ public class StorageManager {
}
public int getCurrentWindowId() {
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) {
currentStoragePage = -1;
return -1;
}
- GuiChest chest = (GuiChest)Minecraft.getMinecraft().currentScreen;
+ GuiChest chest = (GuiChest) Minecraft.getMinecraft().currentScreen;
return chest.inventorySlots.windowId;
}
public void sendToPage(int page) {
- if(desiredStoragePage != getCurrentPageId() &&
+ if (desiredStoragePage != getCurrentPageId() &&
System.currentTimeMillis() - storageOpenSwitchMillis < 100) return;
- if(getCurrentPageId() == page) return;
+ if (getCurrentPageId() == page) return;
- if(page == 0) {
+ if (page == 0) {
NotEnoughUpdates.INSTANCE.sendChatMessage("/enderchest");
- } else if(getCurrentWindowId() != -1 && onStorageMenu) {
- if(page < 9) {
- sendMouseClick(getCurrentWindowId(), 9+page);
+ } else if (getCurrentWindowId() != -1 && onStorageMenu) {
+ if (page < 9) {
+ sendMouseClick(getCurrentWindowId(), 9 + page);
} else {
- sendMouseClick(getCurrentWindowId(), 27+page-MAX_ENDER_CHEST_PAGES);
+ sendMouseClick(getCurrentWindowId(), 27 + page - MAX_ENDER_CHEST_PAGES);
}
} else {
boolean onEnderchest = page < MAX_ENDER_CHEST_PAGES && currentStoragePage < MAX_ENDER_CHEST_PAGES;
boolean onStorage = page >= MAX_ENDER_CHEST_PAGES && currentStoragePage >= MAX_ENDER_CHEST_PAGES;
- if(currentStoragePage >= 0 && (onEnderchest || (onStorage))) {
+ if (currentStoragePage >= 0 && (onEnderchest || (onStorage))) {
int currentPageDisplay = getDisplayIdForStorageId(currentStoragePage);
int desiredPageDisplay = getDisplayIdForStorageId(page);
- if(onEnderchest && desiredPageDisplay > currentPageDisplay) {
+ if (onEnderchest && desiredPageDisplay > currentPageDisplay) {
boolean isLastPage = true;
- for(int pageN=page+1; pageN<MAX_ENDER_CHEST_PAGES; pageN++) {
- if(getDisplayIdForStorageId(pageN) >= 0) {
+ for (int pageN = page + 1; pageN < MAX_ENDER_CHEST_PAGES; pageN++) {
+ if (getDisplayIdForStorageId(pageN) >= 0) {
isLastPage = false;
break;
}
}
- if(isLastPage) {
+ if (isLastPage) {
sendMouseClick(getCurrentWindowId(), 8);
return;
}
}
- if(onStorage && page == MAX_ENDER_CHEST_PAGES) {
+ if (onStorage && page == MAX_ENDER_CHEST_PAGES) {
sendMouseClick(getCurrentWindowId(), 5);
return;
- } else if(onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size()-1) {
+ } else if (onStorage && desiredPageDisplay == storageConfig.displayToStorageIdMap.size() - 1) {
sendMouseClick(getCurrentWindowId(), 8);
return;
} else {
int delta = desiredPageDisplay - currentPageDisplay;
- if(delta == -1) {
+ if (delta == -1) {
sendMouseClick(getCurrentWindowId(), 6);
return;
- } else if(delta == 1) {
+ } else if (delta == 1) {
sendMouseClick(getCurrentWindowId(), 7);
return;
}
@@ -367,7 +368,7 @@ public class StorageManager {
storageOpenSwitchMillis = System.currentTimeMillis();
desiredStoragePage = page;
- NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage-8));
+ NotEnoughUpdates.INSTANCE.sendChatMessage("/storage " + (desiredStoragePage - 8));
}
}
@@ -379,9 +380,9 @@ public class StorageManager {
}
public int getDisplayIdForStorageId(int storageId) {
- if(storageId < 0) return -1;
- for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMap.entrySet()) {
- if(entry.getValue() == storageId) {
+ if (storageId < 0) return -1;
+ for (Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMap.entrySet()) {
+ if (entry.getValue() == storageId) {
return entry.getKey();
}
}
@@ -389,9 +390,9 @@ public class StorageManager {
}
public int getDisplayIdForStorageIdRender(int storageId) {
- if(storageId < 0) return -1;
- for(Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
- if(entry.getValue() == storageId) {
+ if (storageId < 0) return -1;
+ for (Map.Entry<Integer, Integer> entry : storageConfig.displayToStorageIdMapRender.entrySet()) {
+ if (entry.getValue() == storageId) {
return entry.getKey();
}
}
@@ -399,11 +400,11 @@ public class StorageManager {
}
public boolean onAnyClick() {
- if(onStorageMenu && desiredStoragePage >= 0) {
- if(desiredStoragePage < 9) {
- sendMouseClick(getCurrentWindowId(), 9+desiredStoragePage);
+ if (onStorageMenu && desiredStoragePage >= 0) {
+ if (desiredStoragePage < 9) {
+ sendMouseClick(getCurrentWindowId(), 9 + desiredStoragePage);
} else {
- sendMouseClick(getCurrentWindowId(), 27+desiredStoragePage-MAX_ENDER_CHEST_PAGES);
+ sendMouseClick(getCurrentWindowId(), 27 + desiredStoragePage - MAX_ENDER_CHEST_PAGES);
}
desiredStoragePage = -1;
return true;
@@ -413,7 +414,7 @@ public class StorageManager {
public void openWindowPacket(S2DPacketOpenWindow packet) {
shouldRenderStorageOverlayCached = false;
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
String windowTitle = Utils.cleanColour(packet.getWindowTitle().getUnformattedText());
@@ -423,34 +424,34 @@ public class StorageManager {
currentStoragePage = -1;
onStorageMenu = false;
- if(windowTitle.trim().equals("Storage")) {
+ if (windowTitle.trim().equals("Storage")) {
onStorageMenu = true;
- } else if(matcher.matches()) {
+ } else if (matcher.matches()) {
int page = Integer.parseInt(matcher.group(1));
- if(page > 0 && page <= 18) {
- currentStoragePage = page-1+MAX_ENDER_CHEST_PAGES;
+ if (page > 0 && page <= 18) {
+ currentStoragePage = page - 1 + MAX_ENDER_CHEST_PAGES;
int displayId = getDisplayIdForStorageId(currentStoragePage);
- if(displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
+ if (displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
StoragePage spage = getCurrentPage();
- if(spage != null) {
- spage.rows = packet.getSlotCount()/9 - 1;
+ if (spage != null) {
+ spage.rows = packet.getSlotCount() / 9 - 1;
}
}
- } else if(matcherEchest.matches()) {
+ } else if (matcherEchest.matches()) {
int page = Integer.parseInt(matcherEchest.group(1));
- if(page > 0 && page <= 9) {
- currentStoragePage = page-1;
+ if (page > 0 && page <= 9) {
+ currentStoragePage = page - 1;
int displayId = getDisplayIdForStorageId(currentStoragePage);
- if(displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
+ if (displayId >= 0) StorageOverlay.getInstance().scrollToStorage(displayId, false);
StoragePage spage = getCurrentPage();
- if(spage != null) {
- spage.rows = packet.getSlotCount()/9 - 1;
+ if (spage != null) {
+ spage.rows = packet.getSlotCount() / 9 - 1;
}
}
} else {
@@ -466,53 +467,53 @@ public class StorageManager {
}
public void setSlotPacket(S2FPacketSetSlot packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_149175_c()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_149175_c()) return;
- if(getCurrentPageId() != -1) {
+ if (getCurrentPageId() != -1) {
StoragePage page = getCurrentPage();
int slot = packet.func_149173_d();
- if(page != null && slot >= 9 && slot < 9+page.rows*9) {
- setItemSlot(packet.func_149173_d()-9, packet.func_149174_e());
+ if (page != null && slot >= 9 && slot < 9 + page.rows * 9) {
+ setItemSlot(packet.func_149173_d() - 9, packet.func_149174_e());
}
- } else if(onStorageMenu) {
- if(storagePresent == null) {
+ } else if (onStorageMenu) {
+ if (storagePresent == null) {
storagePresent = new boolean[27];
}
int slot = packet.func_149173_d();
ItemStack stack = packet.func_149174_e();
- if(slot >= 9 && slot < 18) {
- int index = slot-9;
+ if (slot >= 9 && slot < 18) {
+ int index = slot - 9;
boolean changed = false;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane) &&
stack.getMetadata() == 14) {
- if(storagePresent[index]) changed = true;
+ if (storagePresent[index]) changed = true;
storagePresent[index] = false;
removePage(index);
} else {
- if(!storagePresent[index]) changed = true;
+ if (!storagePresent[index]) changed = true;
storagePresent[index] = true;
getPage(index, true).backpackDisplayStack = stack;
}
- if(changed) {
- synchronized(storageConfig.displayToStorageIdMap) {
+ if (changed) {
+ synchronized (storageConfig.displayToStorageIdMap) {
storageConfig.displayToStorageIdMap.clear();
storageConfig.displayToStorageIdMapRender.clear();
int displayIndex = 0;
- for(int i=0; i<storagePresent.length; i++) {
- if(storagePresent[i]) {
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
storageConfig.displayToStorageIdMap.put(displayIndex, i);
- if(lastSearch != null && !lastSearch.isEmpty()){
+ if (lastSearch != null && !lastSearch.isEmpty()) {
StoragePage page = getPage(i, false);
- if(page != null) {
+ if (page != null) {
updateSearchForPage(lastSearch, page);
- if(page.matchesSearch) {
+ if (page.matchesSearch) {
storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
@@ -523,36 +524,36 @@ public class StorageManager {
}
}
}
-
- if(slot >= 27 && slot < 45) {
- int index = (slot-27)%9 + (slot-27)/9*9 + MAX_ENDER_CHEST_PAGES;
+
+ if (slot >= 27 && slot < 45) {
+ int index = (slot - 27) % 9 + (slot - 27) / 9 * 9 + MAX_ENDER_CHEST_PAGES;
boolean changed = false;
- if(stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
- if(storagePresent[index]) changed = true;
+ if (stack.getItem() == Item.getItemFromBlock(Blocks.stained_glass_pane)) {
+ if (storagePresent[index]) changed = true;
storagePresent[index] = false;
removePage(index);
} else {
- if(!storagePresent[index]) changed = true;
+ if (!storagePresent[index]) changed = true;
storagePresent[index] = true;
getPage(index, true).backpackDisplayStack = stack;
}
- if(changed) {
- synchronized(storageConfig.displayToStorageIdMap) {
+ if (changed) {
+ synchronized (storageConfig.displayToStorageIdMap) {
storageConfig.displayToStorageIdMap.clear();
storageConfig.displayToStorageIdMapRender.clear();
int displayIndex = 0;
- for(int i=0; i<storagePresent.length; i++) {
- if(storagePresent[i]) {
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
storageConfig.displayToStorageIdMap.put(displayIndex, i);
- if(lastSearch != null && !lastSearch.isEmpty()){
+ if (lastSearch != null && !lastSearch.isEmpty()) {
StoragePage page = getPage(i, false);
- if(page != null) {
+ if (page != null) {
updateSearchForPage(lastSearch, page);
- if(page.matchesSearch) {
+ if (page.matchesSearch) {
storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
}
@@ -567,32 +568,32 @@ public class StorageManager {
}
public void updateSearchForPage(String searchStr, StoragePage page) {
- if(page == null) {
+ if (page == null) {
return;
}
- if(page.rows <= 0) {
+ if (page.rows <= 0) {
page.matchesSearch = true;
return;
}
- if(page.searchedId > searchId.get()) {
+ if (page.searchedId > searchId.get()) {
page.searchedId = -1;
return;
}
- if(page.searchedId == searchId.get()) {
+ if (page.searchedId == searchId.get()) {
return;
}
page.searchedId = searchId.get();
- if(searchStr == null || searchStr.trim().isEmpty()) {
+ if (searchStr == null || searchStr.trim().isEmpty()) {
page.matchesSearch = true;
return;
}
- for(ItemStack stack : page.items) {
- if(stack != null && NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchStr)) {
+ for (ItemStack stack : page.items) {
+ if (stack != null && NotEnoughUpdates.INSTANCE.manager.doesStackMatchSearch(stack, searchStr)) {
page.matchesSearch = true;
return;
}
@@ -601,21 +602,21 @@ public class StorageManager {
}
public void searchDisplay(String searchStr) {
- if(storagePresent == null) return;
+ if (storagePresent == null) return;
- synchronized(storageConfig.displayToStorageIdMapRender) {
+ synchronized (storageConfig.displayToStorageIdMapRender) {
storageConfig.displayToStorageIdMapRender.clear();
lastSearch = searchStr;
int sid = searchId.incrementAndGet();
int displayIndex = 0;
- for(int i=0; i<storagePresent.length; i++) {
- if(storagePresent[i]) {
+ for (int i = 0; i < storagePresent.length; i++) {
+ if (storagePresent[i]) {
StoragePage page = getPage(i, false);
- if(page != null) {
- if(page.rows > 0) {
+ if (page != null) {
+ if (page.rows > 0) {
updateSearchForPage(searchStr, page);
- if(page.matchesSearch) {
+ if (page.matchesSearch) {
storageConfig.displayToStorageIdMapRender.put(displayIndex++, i);
}
} else {
@@ -630,16 +631,16 @@ public class StorageManager {
}
public void setItemsPacket(S30PacketWindowItems packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_148911_c()) return;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.func_148911_c()) return;
- if(getCurrentPageId() != -1) {
+ if (getCurrentPageId() != -1) {
StoragePage page = getPage(getCurrentPageId(), false);
- if(page != null) {
- int max = Math.min(page.rows*9, packet.getItemStacks().length-9);
- for(int i=0; i<max; i++) {
- setItemSlot(i, packet.getItemStacks()[i+9]);
+ if (page != null) {
+ int max = Math.min(page.rows * 9, packet.getItemStacks().length - 9);
+ for (int i = 0; i < max; i++) {
+ setItemSlot(i, packet.getItemStacks()[i + 9]);
}
}
@@ -647,19 +648,19 @@ public class StorageManager {
}
public void clientSendWindowClick(C0EPacketClickWindow packet) {
- if(!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
- if(getCurrentWindowId() == -1 || getCurrentWindowId() != packet.getWindowId()) return;
- if(!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
- ContainerChest containerChest = (ContainerChest)((GuiChest)Minecraft.getMinecraft().currentScreen).inventorySlots;
+ if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return;
+ if (getCurrentWindowId() == -1 || getCurrentWindowId() != packet.getWindowId()) return;
+ if (!(Minecraft.getMinecraft().currentScreen instanceof GuiChest)) return;
+ ContainerChest containerChest = (ContainerChest) ((GuiChest) Minecraft.getMinecraft().currentScreen).inventorySlots;
- if(getCurrentPageId() != -1) {
+ if (getCurrentPageId() != -1) {
StoragePage page = getCurrentPage();
- if(page == null) return;
+ if (page == null) return;
IInventory inv = containerChest.getLowerChestInventory();
- int max = Math.min(9+page.rows*9, inv.getSizeInventory());
- for(int i=9; i<max; i++) {
- setItemSlot(i-9, inv.getStackInSlot(i));
+ int max = Math.min(9 + page.rows * 9, inv.getSizeInventory());
+ for (int i = 9; i < max; i++) {
+ setItemSlot(i - 9, inv.getStackInSlot(i));
}
}
}