aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadeleaan <70163122+Madeleaan@users.noreply.github.com>2024-07-06 16:11:23 +0200
committerGitHub <noreply@github.com>2024-07-06 16:11:23 +0200
commit2d3f55358e5bd69c3cfd9789459bb6fafdab7209 (patch)
tree38d91c12dd3093dbf60ce6608e4744485d260e4f
parent2964f061ff29df7da59e27ca92271283172d3be1 (diff)
downloadnotenoughupdates-2d3f55358e5bd69c3cfd9789459bb6fafdab7209.tar.gz
notenoughupdates-2d3f55358e5bd69c3cfd9789459bb6fafdab7209.tar.bz2
notenoughupdates-2d3f55358e5bd69c3cfd9789459bb6fafdab7209.zip
Add grappling hook cooldown overlay (#1208)
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java73
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java20
2 files changed, 83 insertions, 10 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
index 96fa6248..3042227f 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/ItemCooldowns.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2024 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -28,11 +28,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S23PacketBlockChange;
import net.minecraft.util.BlockPos;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
+import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
@@ -47,10 +49,12 @@ public class ItemCooldowns {
Pattern.compile("\\u00a7r\\u00a7aYou used your \\u00a7r\\u00a7..+ \\u00a7r\\u00a7aPickaxe Ability!\\u00a7r");
private static final Pattern BONZO_ABILITY_ACTIVATION =
- Pattern.compile("\\u00a7r\\u00a7aYour \\u00a7r\\u00a7[9|5](\\u269A )*Bonzo's Mask \\u00a7r\\u00a7asaved your life!\\u00a7r");
+ Pattern.compile(
+ "\\u00a7r\\u00a7aYour \\u00a7r\\u00a7[9|5](\\u269A )*Bonzo's Mask \\u00a7r\\u00a7asaved your life!\\u00a7r");
private static final Pattern SPIRIT_ABILITY_ACTIVATION =
- Pattern.compile("\\u00a7r\\u00a76Second Wind Activated\\u00a7r\\u00a7a! \\u00a7r\\u00a7aYour Spirit Mask saved your life!\\u00a7r");
+ Pattern.compile(
+ "\\u00a7r\\u00a76Second Wind Activated\\u00a7r\\u00a7a! \\u00a7r\\u00a7aYour Spirit Mask saved your life!\\u00a7r");
private static final Pattern SPRAYONATOR_ACTIVATION =
Pattern.compile("§r§a§lSPRAYONATOR! §r§7You sprayed §r§aPlot §r§7- §r§b.* §r§7with §r§a.*§r§7!§r");
@@ -62,6 +66,7 @@ public class ItemCooldowns {
private static long bonzomaskCooldownMillisRemaining = -1;
private static long spiritMaskCooldownMillisRemaining = -1;
private static long sprayonatorCooldownMillisRemaining = -1;
+ private static long grappleCooldownMillisRemaining = -1;
public static boolean firstLoad = true;
public static long firstLoadMillis = 0;
@@ -73,6 +78,14 @@ public class ItemCooldowns {
private static long spiritMaskCooldown = -1;
private static long sprayonatorCooldown = -1;
+ private static long grappleCooldown = 2000;
+ private static HashSet<String> grappleSetIds = new HashSet<String>() {{
+ add("BAT_PERSON_BOOTS");
+ add("BAT_PERSON_LEGGINGS");
+ add("BAT_PERSON_CHESTPLATE");
+ add("BAT_PERSON_HELMET");
+ }};
+
public static TreeMap<Long, BlockData> blocksClicked = new TreeMap<>();
private static int tickCounter = 0;
@@ -140,6 +153,9 @@ public class ItemCooldowns {
if (sprayonatorCooldownMillisRemaining >= 0) {
sprayonatorCooldownMillisRemaining -= millisDelta;
}
+ if (grappleCooldownMillisRemaining >= 0) {
+ grappleCooldownMillisRemaining -= millisDelta;
+ }
}
}
@@ -150,6 +166,22 @@ public class ItemCooldowns {
pickaxeCooldown = -1;
}
+ @SubscribeEvent
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR ||
+ event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
+ ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
+ String internalname =
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(held).resolveInternalName();
+ if (internalname != null) {
+ if (grappleCooldownMillisRemaining < 0 && internalname.equals("GRAPPLING_HOOK") &&
+ Minecraft.getMinecraft().thePlayer.fishEntity != null) {
+ grappleCooldownMillisRemaining = getGrappleCooldownWithArmor();
+ }
+ }
+ }
+ }
+
public static long getTreecapCooldownWithPet() {
if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableCooldownInItemDurability) {
return 0;
@@ -167,6 +199,22 @@ public class ItemCooldowns {
return 2000;
}
+ public static long getGrappleCooldownWithArmor() {
+ if (!NotEnoughUpdates.INSTANCE.config.itemOverlays.enableGrappleOverlay) {
+ return 0;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ ItemStack armorPiece = Minecraft.getMinecraft().thePlayer.getCurrentArmor(i);
+ String internal =
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(armorPiece).resolveInternalName();
+ if (internal != null) {
+ if (!grappleSetIds.contains(internal)) return grappleCooldown;
+ } else return grappleCooldown;
+ }
+ return 0;
+ }
+
public static void blockClicked(BlockPos pos) {
long currentTime = System.currentTimeMillis();
blocksClicked.put(currentTime, new BlockData(pos));
@@ -197,7 +245,8 @@ public class ItemCooldowns {
public static void onBlockMined() {
ItemStack held = Minecraft.getMinecraft().thePlayer.getHeldItem();
- String internalname = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(held).resolveInternalName();
+ String internalname =
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(held).resolveInternalName();
if (internalname != null) {
if (treecapitatorCooldownMillisRemaining < 0 &&
(internalname.equals("TREECAPITATOR_AXE") || internalname.equals("JUNGLE_AXE"))) {
@@ -257,7 +306,8 @@ public class ItemCooldowns {
private static void setSpecificCooldown(ItemStack stack, Item item) {
if (stack != null && stack.hasTagCompound()) {
- String internalname = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(stack).resolveInternalName();
+ String internalname =
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(stack).resolveInternalName();
if (internalname != null) {
switch (item) {
@@ -265,10 +315,12 @@ public class ItemCooldowns {
if (isPickaxe(internalname)) pickaxeCooldown = setCooldown(stack);
break;
case BONZO_MASK:
- if (internalname.equals("BONZO_MASK") || internalname.equals("STARRED_BONZO_MASK")) bonzoMaskCooldown = setCooldown(stack);
+ if (internalname.equals("BONZO_MASK") || internalname.equals("STARRED_BONZO_MASK"))
+ bonzoMaskCooldown = setCooldown(stack);
break;
case SPIRIT_MASK:
- if (internalname.equals("SPIRIT_MASK") || internalname.equals("STARRED_SPIRIT_MASK")) spiritMaskCooldown = setCooldown(stack);
+ if (internalname.equals("SPIRIT_MASK") || internalname.equals("STARRED_SPIRIT_MASK"))
+ spiritMaskCooldown = setCooldown(stack);
break;
case SPRAYONATOR:
if (internalname.equals("SPRAYONATOR")) sprayonatorCooldown = setCooldown(stack);
@@ -299,7 +351,8 @@ public class ItemCooldowns {
return durabilityOverrideMap.get(stack);
}
- String internalname = NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(stack).resolveInternalName();
+ String internalname =
+ NotEnoughUpdates.INSTANCE.manager.createItemResolutionQuery().withItemStack(stack).resolveInternalName();
if (internalname == null) {
durabilityOverrideMap.put(stack, -1f);
return -1;
@@ -329,6 +382,10 @@ public class ItemCooldowns {
return durability;
}
+ // Grappling Hook
+ if (internalname.equals("GRAPPLING_HOOK")) {
+ return grappleCooldownMillisRemaining / 2000f;
+ }
// Bonzo Mask
if (NotEnoughUpdates.INSTANCE.config.itemOverlays.bonzoAbility &&
(internalname.equals("BONZO_MASK") || internalname.equals("STARRED_BONZO_MASK"))) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java
index 9b339fc4..10fd3503 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 NotEnoughUpdates contributors
+ * Copyright (C) 2022-2024 NotEnoughUpdates contributors
*
* This file is part of NotEnoughUpdates.
*
@@ -409,7 +409,7 @@ public class ItemOverlays {
public boolean enableScytheOverlay = true;
@ConfigOption(
- name="Custom Wither Cloak",
+ name = "Custom Wither Cloak",
desc = ""
)
@ConfigEditorAccordion(id = 8)
@@ -489,6 +489,22 @@ public class ItemOverlays {
@ConfigEditorInfoText()
public boolean customWitherCloakCredit = false;
+ @ConfigOption(
+ name = "Grappling hook Overlay",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 9)
+ public boolean grappleAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Enable grappling hook overlay",
+ desc = "Show the cooldown of grappling hook in the item durability"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 9)
+ public boolean enableGrappleOverlay = true;
+
@Expose
@ConfigOption(
name = "Use Durability for Cooldowns",