diff options
author | syeyoung <cyong06@naver.com> | 2021-05-01 14:36:48 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-05-01 14:36:48 +0900 |
commit | 4d858161e0321c479927e7f28bf516189781914e (patch) | |
tree | 42ee5394f90afec98acdd74fbedea7971a0b195a /src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon | |
parent | c60485da3704c1ac91f614f8020c79f5a92a599e (diff) | |
download | Skyblock-Dungeons-Guide-4d858161e0321c479927e7f28bf516189781914e.tar.gz Skyblock-Dungeons-Guide-4d858161e0321c479927e7f28bf516189781914e.tar.bz2 Skyblock-Dungeons-Guide-4d858161e0321c479927e7f28bf516189781914e.zip |
all tested.
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon')
-rw-r--r-- | src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java | 41 |
1 files changed, 41 insertions, 0 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 new file mode 100644 index 00000000..1e9b4989 --- /dev/null +++ b/src/main/java/kr/syeyoung/dungeonsguide/features/impl/dungeon/FeaturePressAnyKeyToCloseChest.java @@ -0,0 +1,41 @@ +package kr.syeyoung.dungeonsguide.features.impl.dungeon; + +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.KeyInputListener; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiChest; +import net.minecraft.inventory.ContainerChest; +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 FeaturePressAnyKeyToCloseChest() { + super("Dungeon", "Press Any 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 (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(); + } + } + } +} |