diff options
author | syeyoung <cyong06@naver.com> | 2021-01-04 11:15:45 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-01-04 11:15:45 +0900 |
commit | ec76162b0017cbfb546038e4d55a1f062d99412a (patch) | |
tree | 0717987280063d3c9a3db4c0eba098872e94ccc3 /src/main/java/kr/syeyoung/dungeonsguide/features | |
parent | b5418383f1fa304b05bfee61c2d773ab26204152 (diff) | |
download | Skyblock-Dungeons-Guide-ec76162b0017cbfb546038e4d55a1f062d99412a.tar.gz Skyblock-Dungeons-Guide-ec76162b0017cbfb546038e4d55a1f062d99412a.tar.bz2 Skyblock-Dungeons-Guide-ec76162b0017cbfb546038e4d55a1f062d99412a.zip |
will it fix it!?
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java | 1 | ||||
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java | 39 |
2 files changed, 30 insertions, 10 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java index 6b79487d..dcf46281 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureCooldownCounter.java @@ -43,7 +43,6 @@ public class FeatureCooldownCounter extends GuiFeature implements TickListener { if (skyblockStatus.isOnSkyblock()) leftDungeonTime = System.currentTimeMillis(); else return; - System.out.println("think he left"); } wasInDungeon = skyblockStatus.isOnDungeon(); } diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java index 79fbfce6..33d2c9eb 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/FeatureInstaCloseChest.java @@ -11,7 +11,9 @@ import kr.syeyoung.dungeonsguide.utils.AhUtils; import kr.syeyoung.dungeonsguide.utils.TextUtils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.client.event.GuiOpenEvent; @@ -22,26 +24,24 @@ import java.util.Comparator; import java.util.Set; import java.util.TreeSet; -public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenListener { +public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenListener, TickListener { public FeatureInstaCloseChest() { super("QoL", "Auto-Close Secret Chest", "Automatically closes Secret Chest as soon as you open it\nCan put item price threshold by clicking edit", "qol.autoclose", false); parameters.put("threshold", new FeatureParameter<Integer>("threshold", "Price Threshold", "The maximum price of item for chest to be closed. Default 1m", 1000000, "integer")); } SkyblockStatus skyblockStatus = e.getDungeonsGuide().getSkyblockStatus(); + private boolean check; @Override public void onGuiOpen(GuiOpenEvent event) { + if (!this.isEnabled()) return; + if (!skyblockStatus.isOnDungeon()) return; if (!(event.gui instanceof GuiChest)) return; - int threshold = this.<Integer>getParameter("threshold").getValue(); - - int priceSum = 0; - for (ItemStack inventoryItemStack : ((GuiChest) event.gui).inventorySlots.inventoryItemStacks) { - priceSum += getPrice(inventoryItemStack); - } - - if (priceSum < threshold) Minecraft.getMinecraft().thePlayer.closeScreen(); + ContainerChest ch = (ContainerChest) ((GuiChest)event.gui).inventorySlots; + if (!"container.chest".equals(ch.getLowerChestInventory().getName())) return; + check = true; } public int getPrice(ItemStack itemStack) { @@ -93,4 +93,25 @@ public class FeatureInstaCloseChest extends SimpleFeature implements GuiOpenList } } } + + @Override + public void onTick() { + if (!this.isEnabled()) return; + if (check) { + check = false; + + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if (screen instanceof GuiChest){ + int priceSum = 0; + for (ItemStack inventoryItemStack : ((GuiChest) screen).inventorySlots.inventoryItemStacks) { + priceSum += getPrice(inventoryItemStack); + } + + int threshold = this.<Integer>getParameter("threshold").getValue(); + if (priceSum < threshold) { + Minecraft.getMinecraft().thePlayer.closeScreen(); + } + } + } + } } |