aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java98
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java43
2 files changed, 106 insertions, 35 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
index b88eca99..65092752 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/FishingHelper.java
@@ -1,6 +1,7 @@
package io.github.moulberry.notenoughupdates.miscfeatures;
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
+import io.github.moulberry.notenoughupdates.core.ChromaColour;
import io.github.moulberry.notenoughupdates.util.SpecialColour;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.block.state.IBlockState;
@@ -76,42 +77,71 @@ public class FishingHelper {
private static final ResourceLocation FISHING_WARNING_EXCLAM = new ResourceLocation(
"notenoughupdates:fishing_warning_exclam.png");
+ public boolean renderWarning() {
+ if (warningState == PlayerWarningState.NOTHING) return false;
+
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning &&
+ warningState == PlayerWarningState.FISH_INCOMING)
+ return false;
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR &&
+ warningState == PlayerWarningState.FISH_HOOKED)
+ return false;
+
+ float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f;
+
+ float centerOffset = 0.5f / 8f;
+ Minecraft.getMinecraft().getTextureManager().bindTexture(FISHING_WARNING_EXCLAM);
+ Utils.drawTexturedRect(
+ centerOffset - 4f / 8f,
+ -20 / 8f,
+ 1f,
+ 2f,
+ 0 + offset,
+ 0.5f + offset,
+ 0,
+ 1,
+ GL11.GL_NEAREST
+ );
+ return true;
+ }
+
public void onRenderBobber(EntityFishHook hook) {
- if (Minecraft.getMinecraft().thePlayer.fishEntity == hook && warningState != PlayerWarningState.NOTHING) {
-
- if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarning &&
- warningState == PlayerWarningState.FISH_INCOMING)
- return;
- if (!NotEnoughUpdates.INSTANCE.config.fishing.incomingFishWarningR &&
- warningState == PlayerWarningState.FISH_HOOKED)
- return;
-
- GlStateManager.disableCull();
- GlStateManager.disableLighting();
- GL11.glDepthFunc(GL11.GL_ALWAYS);
- GlStateManager.scale(1, -1, 1);
-
- float offset = warningState == PlayerWarningState.FISH_HOOKED ? 0.5f : 0f;
-
- float centerOffset = 0.5f / 8f;
- Minecraft.getMinecraft().getTextureManager().bindTexture(FISHING_WARNING_EXCLAM);
- Utils.drawTexturedRect(
- centerOffset - 4f / 8f,
- -20 / 8f,
- 1f,
- 2f,
- 0 + offset,
- 0.5f + offset,
- 0,
- 1,
- GL11.GL_NEAREST
- );
-
- GlStateManager.scale(1, -1, 1);
- GL11.glDepthFunc(GL11.GL_LEQUAL);
- GlStateManager.enableLighting();
- GlStateManager.enableCull();
+ if (Minecraft.getMinecraft().thePlayer.fishEntity != hook) return;
+ GlStateManager.pushMatrix();
+ GlStateManager.disableCull();
+ GlStateManager.disableLighting();
+ GL11.glDepthFunc(GL11.GL_ALWAYS);
+ GlStateManager.scale(1, -1, 1);
+ boolean isExclamationMarkPresent = renderWarning();
+ GlStateManager.scale(0.1, 0.1, 1);
+ drawFishingTimer(hook, isExclamationMarkPresent);
+ GL11.glDepthFunc(GL11.GL_LEQUAL);
+ GlStateManager.enableLighting();
+ GlStateManager.enableCull();
+ GlStateManager.popMatrix();
+ }
+
+ private void drawFishingTimer(EntityFishHook hook, boolean isExclamationMarkPresent) {
+ if (!NotEnoughUpdates.INSTANCE.config.fishing.fishingTimer) return;
+ float baseHeight = isExclamationMarkPresent ? 20 : 0;
+ int ticksExisted = hook.ticksExisted;
+ float seconds = ticksExisted / 20F;
+ int color;
+ if (seconds > 30) {
+ color = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.fishing.fishingTimerColor30SecPlus);
+ } else {
+ color = ChromaColour.specialToChromaRGB(NotEnoughUpdates.INSTANCE.config.fishing.fishingTimerColor);
}
+
+ Utils.drawStringCentered(
+ String.format("%.02fs", seconds),
+ Minecraft.getMinecraft().fontRendererObj,
+ 0,
+ -baseHeight - Minecraft.getMinecraft().fontRendererObj.FONT_HEIGHT,
+ false,
+ color
+ );
+
}
public void addEntity(int entityId, Entity entity) {
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java
index f1587d5d..9d1367b0 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Fishing.java
@@ -1,7 +1,13 @@
package io.github.moulberry.notenoughupdates.options.seperateSections;
import com.google.gson.annotations.Expose;
-import io.github.moulberry.notenoughupdates.core.config.annotations.*;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorBoolean;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorColour;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class Fishing {
@Expose
@@ -204,4 +210,39 @@ public class Fishing {
@ConfigEditorColour
@ConfigAccordionId(id = 4)
public String otherRodColour = "0:255:0:0:0";
+
+ @ConfigOption(
+ name = "Fishing Timer",
+ desc = ""
+ )
+ @ConfigEditorAccordion(id = 6)
+ public boolean fishingAccordion = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Display a Fishing Timer",
+ desc = "Display a timer above your bobber showing your current time"
+ )
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 6)
+ public boolean fishingTimer = false;
+
+ @Expose
+ @ConfigOption(
+ name = "Fishing timer color",
+ desc = "Color of the fishing timer"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 6)
+ public String fishingTimerColor = "0:255:0:0:0";
+
+ @Expose
+ @ConfigOption(
+ name = "Fishing timer color (30s)",
+ desc = "Color of the fishing timer after 30 seconds or more have passed"
+ )
+ @ConfigEditorColour
+ @ConfigAccordionId(id = 6)
+ public String fishingTimerColor30SecPlus = "0:255:0:0:0";
+
}