diff options
author | syeyoung <cyong06@naver.com> | 2021-05-01 15:10:46 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-05-01 15:10:46 +0900 |
commit | 24d899045d4d20c9cfcdfd216202ad5a6b110405 (patch) | |
tree | 02c365c481971e33f69313efb9159f693277a58c /src/main/java/kr | |
parent | a989ca821cf45dd3e44fb4da0a058fa99acaa615 (diff) | |
download | Skyblock-Dungeons-Guide-24d899045d4d20c9cfcdfd216202ad5a6b110405.tar.gz Skyblock-Dungeons-Guide-24d899045d4d20c9cfcdfd216202ad5a6b110405.tar.bz2 Skyblock-Dungeons-Guide-24d899045d4d20c9cfcdfd216202ad5a6b110405.zip |
press anything
Diffstat (limited to 'src/main/java/kr')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java index 1e9b4989..bc535e2d 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java @@ -1,8 +1,10 @@ package kr.syeyoung.dungeonsguide.features.impl.dungeon; +import kr.syeyoung.dungeonsguide.e; import kr.syeyoung.dungeonsguide.features.FeatureParameter; import kr.syeyoung.dungeonsguide.features.SimpleFeature; import kr.syeyoung.dungeonsguide.features.impl.boss.FeatureChestPrice; +import kr.syeyoung.dungeonsguide.features.listener.GuiClickListener; import kr.syeyoung.dungeonsguide.features.listener.KeyInputListener; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -12,15 +14,40 @@ import net.minecraft.inventory.IInventory; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.fml.common.gameevent.InputEvent; -public class FeaturePressAnyKeyToCloseChest extends SimpleFeature implements KeyInputListener { +public class FeaturePressAnyKeyToCloseChest extends SimpleFeature implements KeyInputListener, GuiClickListener { public FeaturePressAnyKeyToCloseChest() { - super("Dungeon", "Press Any Key to close Secret Chest", "dungeon.presskeytoclose"); + super("Dungeon", "Press Any Mouse Button or Key to close Secret Chest", "dungeon.presskeytoclose"); parameters.put("threshold", new FeatureParameter<Integer>("threshold", "Price Threshold", "The maximum price of item for chest to be closed. Default 1m", 1000000, "integer")); } @Override public void onKeyInput(GuiScreenEvent.KeyboardInputEvent keyboardInputEvent) { GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if (!e.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + + if (screen instanceof GuiChest){ + ContainerChest ch = (ContainerChest) ((GuiChest)screen).inventorySlots; + if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) + || "Chest".equals(ch.getLowerChestInventory().getName()))) return; + IInventory actualChest = ch.getLowerChestInventory(); + + int priceSum = 0; + for (int i = 0; i < actualChest.getSizeInventory(); i++) { + priceSum += FeatureChestPrice.getPrice(actualChest.getStackInSlot(i)); + } + + int threshold = this.<Integer>getParameter("threshold").getValue(); + if (priceSum < threshold) { + Minecraft.getMinecraft().thePlayer.closeScreen(); + } + } + } + + @Override + public void onMouseInput(GuiScreenEvent.MouseInputEvent.Pre mouseInputEvent) { + GuiScreen screen = Minecraft.getMinecraft().currentScreen; + if (!e.getDungeonsGuide().getSkyblockStatus().isOnDungeon()) return; + if (screen instanceof GuiChest){ ContainerChest ch = (ContainerChest) ((GuiChest)screen).inventorySlots; if (!("Large Chest".equals(ch.getLowerChestInventory().getName()) |