aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/dulkirmod/mixins/MixinGuiContainer.java6
-rw-r--r--src/main/java/dulkirmod/mixins/MixinGuiUtils.java21
-rw-r--r--src/main/java/dulkirmod/mixins/MixinItemRenderer.java (renamed from src/main/java/dulkirmod/mixins/ItemRendererMixin.java)2
-rw-r--r--src/main/java/dulkirmod/mixins/MixinItemStack.java27
-rw-r--r--src/main/java/dulkirmod/mixins/MixinOldAnimations.java30
-rw-r--r--src/main/kotlin/dulkirmod/DulkirMod.kt27
-rw-r--r--src/main/kotlin/dulkirmod/config/Config.kt20
-rw-r--r--src/main/kotlin/dulkirmod/features/ScalableTooltips.kt146
-rw-r--r--src/main/resources/mcmod.info2
-rw-r--r--src/main/resources/mixins.dulkirmod.json7
10 files changed, 272 insertions, 16 deletions
diff --git a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java
index 4a50163..50118f1 100644
--- a/src/main/java/dulkirmod/mixins/MixinGuiContainer.java
+++ b/src/main/java/dulkirmod/mixins/MixinGuiContainer.java
@@ -2,6 +2,7 @@ package dulkirmod.mixins;
import dulkirmod.features.Croesus;
import dulkirmod.features.DungeonLeap;
+import dulkirmod.features.ScalableTooltips;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
@@ -43,4 +44,9 @@ public abstract class MixinGuiContainer extends GuiScreen {
this.zLevel = 0.0F;
}
}
+ @Inject(method = "onGuiClosed", at = @At("HEAD"))
+ private void onGuiClosed(CallbackInfo ci) {
+ // reset values here
+ ScalableTooltips.INSTANCE.resetPos();
+ }
}
diff --git a/src/main/java/dulkirmod/mixins/MixinGuiUtils.java b/src/main/java/dulkirmod/mixins/MixinGuiUtils.java
new file mode 100644
index 0000000..414963b
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinGuiUtils.java
@@ -0,0 +1,21 @@
+package dulkirmod.mixins;
+
+import dulkirmod.features.ScalableTooltips;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraftforge.fml.client.config.GuiUtils;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.List;
+
+@Mixin(value = {GuiUtils.class}, remap = false)
+public class MixinGuiUtils {
+
+ @Inject(method = "drawHoveringText", at = @At("HEAD"), cancellable = true)
+ private static void drawScaledHoveringText(List<String> textLines, int mouseX, int mouseY, int screenWidth, int screenHeight, int maxTextWidth, FontRenderer font, CallbackInfo ci) {
+ if (ScalableTooltips.INSTANCE.drawScaledHoveringText(textLines, mouseX, mouseY, screenWidth, screenHeight, maxTextWidth, font, ci))
+ ci.cancel();
+ }
+}
diff --git a/src/main/java/dulkirmod/mixins/ItemRendererMixin.java b/src/main/java/dulkirmod/mixins/MixinItemRenderer.java
index 0fb56e4..a81e67d 100644
--- a/src/main/java/dulkirmod/mixins/ItemRendererMixin.java
+++ b/src/main/java/dulkirmod/mixins/MixinItemRenderer.java
@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = {ItemRenderer.class})
-public class ItemRendererMixin {
+public class MixinItemRenderer {
@Shadow @Final private RenderItem itemRenderer;
diff --git a/src/main/java/dulkirmod/mixins/MixinItemStack.java b/src/main/java/dulkirmod/mixins/MixinItemStack.java
new file mode 100644
index 0000000..76440ef
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinItemStack.java
@@ -0,0 +1,27 @@
+package dulkirmod.mixins;
+import dulkirmod.features.ScalableTooltips;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.util.List;
+
+@Mixin(ItemStack.class)
+public abstract class MixinItemStack {
+
+ private static ItemStack previousStack;
+
+ @Inject(method = "getTooltip", at = @At("HEAD"))
+ public void onTooltip(EntityPlayer playerIn, boolean advanced, CallbackInfoReturnable<List<String>> cir) {
+
+ ItemStack currentStack = (ItemStack)(Object)this;
+ if (currentStack != previousStack) {
+ // reset values here for scrollable tooltips
+ ScalableTooltips.INSTANCE.resetPos();
+ previousStack = currentStack;
+ }
+ }
+}
diff --git a/src/main/java/dulkirmod/mixins/MixinOldAnimations.java b/src/main/java/dulkirmod/mixins/MixinOldAnimations.java
new file mode 100644
index 0000000..de38ddc
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinOldAnimations.java
@@ -0,0 +1,30 @@
+package dulkirmod.mixins;
+
+import dulkirmod.DulkirMod;
+import net.minecraft.client.renderer.ItemRenderer;
+import net.minecraft.item.ItemStack;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Pseudo;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+/**
+ * This method will basically just turn off all the oldanimations code that is breaking dulkirmod.
+ *
+ * It will only run if you have the global settings of Custom Animations turned on, so you can basically
+ * pick which one you want to have. Either custom animations or old. This is not a great fix, but
+ * to make them work together seamlessly I would *basically* be recoding the entirety of Old Animations into
+ * this mod, which I don't really want to do.
+ */
+
+@Pseudo
+@Mixin(targets = "club.sk1er.oldanimations.AnimationHandler", remap = false)
+public class MixinOldAnimations {
+
+ @Inject(method = "renderItemInFirstPerson", at = @At(value = "HEAD"), cancellable = true)
+ public void angy(ItemRenderer renderer, ItemStack stack, float equipProgress, float partialTicks, CallbackInfoReturnable<Boolean> cir) {
+ if (DulkirMod.Companion.getConfig().getCustomAnimations())
+ cir.setReturnValue(false);
+ }
+}
diff --git a/src/main/kotlin/dulkirmod/DulkirMod.kt b/src/main/kotlin/dulkirmod/DulkirMod.kt
index 69ac692..7022105 100644
--- a/src/main/kotlin/dulkirmod/DulkirMod.kt
+++ b/src/main/kotlin/dulkirmod/DulkirMod.kt
@@ -61,17 +61,20 @@ class DulkirMod {
fun onInit(event: FMLInitializationEvent) {
config.init()
// REGISTER Classes and such HERE
- MinecraftForge.EVENT_BUS.register(this)
- MinecraftForge.EVENT_BUS.register(ChatEvent())
- MinecraftForge.EVENT_BUS.register(NametagCleaner)
- MinecraftForge.EVENT_BUS.register(titleUtils)
- MinecraftForge.EVENT_BUS.register(ArachneTimer())
- MinecraftForge.EVENT_BUS.register(MatchoAlert())
- MinecraftForge.EVENT_BUS.register(Croesus())
- MinecraftForge.EVENT_BUS.register(ContainerNameUtil())
- MinecraftForge.EVENT_BUS.register(DungeonLeap())
- MinecraftForge.EVENT_BUS.register(AbiphoneDND())
- MinecraftForge.EVENT_BUS.register(KeeperWaypoints())
+ val mcBus = MinecraftForge.EVENT_BUS
+ mcBus.register(this)
+ mcBus.register(ChatEvent())
+ mcBus.register(NametagCleaner)
+ mcBus.register(titleUtils)
+ mcBus.register(ArachneTimer())
+ mcBus.register(MatchoAlert())
+ mcBus.register(Croesus())
+ mcBus.register(ContainerNameUtil())
+ mcBus.register(DungeonLeap())
+ mcBus.register(AbiphoneDND())
+ mcBus.register(KeeperWaypoints())
+ mcBus.register(ScalableTooltips)
+
keyBinds.forEach(ClientRegistry::registerKeyBinding)
}
@@ -118,7 +121,7 @@ class DulkirMod {
companion object {
const val MOD_ID = "dulkirmod"
const val MOD_NAME = "Dulkir Mod"
- const val MOD_VERSION = "1.1.3"
+ const val MOD_VERSION = "1.1.4"
const val CHAT_PREFIX = "§f<§3DulkirMod§f>"
val mc: Minecraft = Minecraft.getMinecraft()
diff --git a/src/main/kotlin/dulkirmod/config/Config.kt b/src/main/kotlin/dulkirmod/config/Config.kt
index 83ffe07..32f917e 100644
--- a/src/main/kotlin/dulkirmod/config/Config.kt
+++ b/src/main/kotlin/dulkirmod/config/Config.kt
@@ -56,6 +56,25 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
@Property(
type = PropertyType.SWITCH,
+ name = "Scalable Tooltips",
+ description = "more or less TOOLTIP",
+ category = "General"
+ )
+ var scaledTooltips = false
+
+ @Property(
+ type = PropertyType.DECIMAL_SLIDER,
+ name = "Tooltip Scale",
+ description = "1 is default",
+ category = "General",
+ minF = 0f,
+ maxF = 2f,
+ decimalPlaces = 1
+ )
+ var tooltipSize = 1f
+
+ @Property(
+ type = PropertyType.SWITCH,
name = "Hide Healer fairy",
description = "Probably disable when not in dungeons for now. Will fix later.",
category = "Dungeons"
@@ -525,6 +544,7 @@ object Config : Vigilant(File("./config/dulkirmod/config.toml"), "DulkirMod", so
addDependency("highlightLeapName", "highlightLeap")
addDependency("abiCallerID", "abiDND")
addDependency("hurtCamIntensity", "hurtCamSlider")
+ addDependency("tooltipSize", "scaledTooltips")
setCategoryDescription(
"Custom Animations",
diff --git a/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt b/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt
new file mode 100644
index 0000000..ae53a3b
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/ScalableTooltips.kt
@@ -0,0 +1,146 @@
+package dulkirmod.features
+
+import dulkirmod.config.Config
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.FontRenderer
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.client.renderer.RenderHelper
+import net.minecraftforge.fml.client.config.GuiUtils
+import org.lwjgl.input.Keyboard
+import org.lwjgl.input.Mouse
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
+
+object ScalableTooltips {
+ var scrollY: Int = 0
+ var scrollX: Int = 0
+ // Checks to see if large tooltips should be snapped (for larger than can fit on screen code)
+ var snapFlag: Boolean = true
+
+ fun drawScaledHoveringText(
+ textLines: List<String>,
+ mouseX: Int,
+ mouseY: Int,
+ screenWidth: Int,
+ screenHeight: Int,
+ maxTextWidth: Int,
+ font: FontRenderer,
+ ci: CallbackInfo
+ ): Boolean {
+ if(!Config.scaledTooltips) return false
+ val scale = Config.tooltipSize
+
+ // Calculate the width and height of the tooltip box
+ var width = 0
+ for (textLine in textLines) {
+ val textWidth = font.getStringWidth(textLine)
+ if (textWidth > width) {
+ width = textWidth
+ }
+ }
+ val height = (textLines.size) * font.FONT_HEIGHT
+
+ // Save the matrix state and scale it
+ GlStateManager.pushMatrix()
+ GlStateManager.scale(scale, scale, 1f)
+ GlStateManager.disableRescaleNormal()
+ RenderHelper.disableStandardItemLighting()
+ GlStateManager.disableLighting()
+ GlStateManager.disableDepth()
+
+ // Calculate the amount of translation that should be applied based on how much the user has scrolled
+ val eventDWheel = Mouse.getDWheel()
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ if (eventDWheel < 0) {
+ scrollX += Minecraft.getMinecraft().displayWidth/192
+ } else if (eventDWheel > 0) {
+ //Scrolling to access higher stuff
+ scrollX -= Minecraft.getMinecraft().displayWidth/192
+ }
+ } else {
+ if (eventDWheel < 0) {
+ scrollY -= Minecraft.getMinecraft().displayHeight/108
+ } else if (eventDWheel > 0) {
+ //Scrolling to access higher stuff
+ scrollY += Minecraft.getMinecraft().displayHeight/108
+ }
+ }
+
+ // calculates where it wants to put the tooltip based on user input
+ var x = ((mouseX + 12 + scrollX) / scale).toInt()
+ var y = ((mouseY - 12 + scrollY) / scale).toInt()
+
+ /**
+ * Extra code to account for larger tooltips:
+ * Tooltips should not initially render off the screen if they can fit, if too wide/too long for screen
+ * it will just default to normal.
+ */
+ if ((x + width + 4 > screenWidth / scale) && (width + 4 <= screenWidth / scale)) {
+ scrollX = (screenWidth - mouseX - 12 - (width + 4)* scale).toInt()
+ }
+
+ if ((y + height + 4 > screenHeight / scale) && (height + 4 <= screenHeight / scale)) {
+ scrollY = (screenHeight - mouseY + 12 - (height + 4)* scale).toInt()
+ }
+
+ /**
+ * HAVE: default x and y
+ * NEED: modify scrollx and scroll why such that updates x and y to 0 later
+ */
+ if (x < 0 && (width + 4 <= screenWidth / scale))
+ scrollX = -mouseX - 12 + 4
+ if (y < 0 && (height + 4 <= screenHeight / scale))
+ scrollY = -mouseY + 12 + 4
+
+
+ // if too large, then snap to top (if first time rendering tooltip)
+ if (snapFlag) {
+ if (width + 4 > screenWidth / scale) {
+ scrollX = -mouseX - 12 + 4
+ }
+ if (height + 4 > screenHeight / scale) {
+ scrollY = -mouseY + 12 + 4
+ }
+ snapFlag = false
+ }
+
+ //updates the position of x and y if it has been modified.
+ x = ((mouseX + 12 + scrollX) / scale).toInt()
+ y = ((mouseY - 12 + scrollY) / scale).toInt()
+
+ // Draw the background rectangle
+ val backgroundColor = -0xfeffff0
+ val zLevel = 300
+
+ GuiUtils.drawGradientRect(zLevel, x - 3, y - 4, x + width + 3, y - 3, backgroundColor, backgroundColor)
+ GuiUtils.drawGradientRect(zLevel, x - 3, y + height + 3, x + width + 3, y + height + 4, backgroundColor, backgroundColor)
+ GuiUtils.drawGradientRect(zLevel, x - 3, y - 3, x + width + 3, y + height + 3, backgroundColor, backgroundColor)
+ GuiUtils.drawGradientRect(zLevel, x - 4, y - 3, x - 3, y + height + 3, backgroundColor, backgroundColor)
+ GuiUtils.drawGradientRect(zLevel, x + width + 3, y - 3, x + width + 4, y + height + 3, backgroundColor, backgroundColor)
+ val borderColorStart = 0x505000FF
+ val borderColorEnd = borderColorStart and 0xFEFEFE shr 1 or (borderColorStart and -0x1000000)
+ GuiUtils.drawGradientRect(zLevel, x - 3, y - 3 + 1, x - 3 + 1, y + height + 3 - 1, borderColorStart, borderColorEnd)
+ GuiUtils.drawGradientRect(zLevel, x + width + 2, y - 3 + 1, x + width + 3, y + height + 3 - 1, borderColorStart, borderColorEnd)
+ GuiUtils.drawGradientRect(zLevel, x - 3, y - 3, x + width + 3, y - 3 + 1, borderColorStart, borderColorStart)
+ GuiUtils.drawGradientRect(zLevel, x - 3, y + height + 2, x + width + 3, y + height + 3, borderColorEnd, borderColorEnd)
+
+ // Render the tooltip text
+ var yStart = y
+ for (textLine in textLines) {
+ font.drawStringWithShadow(textLine, x.toFloat(), yStart.toFloat(), -1)
+ yStart += font.FONT_HEIGHT
+ }
+ // Reset matrix state
+ GlStateManager.enableLighting()
+ GlStateManager.enableDepth()
+ RenderHelper.enableStandardItemLighting()
+ GlStateManager.enableRescaleNormal()
+ GlStateManager.popMatrix()
+ return true
+ }
+
+ fun resetPos() {
+ scrollX = 0
+ scrollY = 0
+ snapFlag = true
+ }
+} \ No newline at end of file
diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info
index bdaa023..50c00dd 100644
--- a/src/main/resources/mcmod.info
+++ b/src/main/resources/mcmod.info
@@ -3,7 +3,7 @@
"modid": "dulkirmod",
"name": "Dulkir Mod",
"description": "The worst skyblock mod.",
- "version": "1.1.3",
+ "version": "1.1.4",
"mcversion": "1.8.9",
"authorList": [
"Dulkir"
diff --git a/src/main/resources/mixins.dulkirmod.json b/src/main/resources/mixins.dulkirmod.json
index 076b9ef..402acf2 100644
--- a/src/main/resources/mixins.dulkirmod.json
+++ b/src/main/resources/mixins.dulkirmod.json
@@ -4,7 +4,7 @@
"package": "dulkirmod.mixins",
"refmap": "mixins.dulkirmod.refmap.json",
"client": [
- "ItemRendererMixin",
+ "MixinItemRenderer",
"MixinEntityRenderer",
"MixinGuiContainer",
"MixinRendererManager"
@@ -12,6 +12,9 @@
"mixins": [
"MixinEntity",
"MixinEntityLivingBase",
- "MixinWorld"
+ "MixinGuiUtils",
+ "MixinItemStack",
+ "MixinWorld",
+ "MixinOldAnimations"
]
}