-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
182 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package net.slushie.qolify.mixin; | ||
|
||
public class CreateWorldMixin { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.slushie.qolify.mixin; | ||
|
||
import net.minecraft.client.Mouse; | ||
import net.slushie.qolify.Qolify; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(Mouse.class) | ||
public class MouseMixin { | ||
@Shadow private double eventDeltaWheel; | ||
@Inject( | ||
method = "onMouseScroll", | ||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;eventDeltaWheel:D", ordinal = 7), | ||
cancellable = true | ||
) | ||
private void zoomScrollMixin(CallbackInfo info) { | ||
if (!Qolify.isZooming) return; | ||
info.cancel(); | ||
|
||
if (eventDeltaWheel < 0.0) { | ||
if (Qolify.globalFov * Qolify.zoomLevel*1.5 > Qolify.globalFov) return; | ||
Qolify.zoomLevel = Qolify.zoomLevel*1.5; | ||
} | ||
|
||
if (eventDeltaWheel > 0.0) { | ||
if (Qolify.zoomLevel/1.5 < 0.000001) return; | ||
Qolify.zoomLevel = Qolify.zoomLevel/1.5; | ||
} | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/main/java/net/slushie/qolify/mixin/PotionTimerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package net.slushie.qolify.mixin; | ||
|
||
import com.google.common.collect.Ordering; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.DrawableHelper; | ||
import net.minecraft.client.gui.hud.InGameHud; | ||
import net.minecraft.client.resource.language.I18n; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.effect.StatusEffect; | ||
import net.minecraft.entity.effect.StatusEffectInstance; | ||
import net.minecraft.util.math.MathHelper; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
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.Collection; | ||
|
||
// Set priority to 500, to load before default at 1000. This is to better cooperate with HUDTweaks. | ||
@Environment(EnvType.CLIENT) | ||
@Mixin(value = InGameHud.class, priority = 500) | ||
public abstract class PotionTimerMixin extends DrawableHelper { | ||
@Shadow @Final | ||
private MinecraftClient client; | ||
|
||
@Inject(method = "renderStatusEffectOverlay", at = @At("TAIL")) | ||
private void renderDurationOverlay(MatrixStack matrices, CallbackInfo c) { | ||
Collection<StatusEffectInstance> collection = this.client.player.getStatusEffects(); | ||
if (!collection.isEmpty()) { | ||
// Replicate vanilla placement algorithm to get the duration | ||
// labels to line up exactly right. | ||
|
||
int beneficialCount = 0; | ||
int nonBeneficialCount = 0; | ||
for (StatusEffectInstance statusEffectInstance : Ordering.natural().reverse().sortedCopy(collection)) { | ||
StatusEffect statusEffect = statusEffectInstance.getEffectType(); | ||
if (statusEffectInstance.shouldShowIcon()) { | ||
int x = this.client.getWindow().getScaledWidth(); | ||
int y = 1; | ||
|
||
if (this.client.isDemo()) { | ||
y += 15; | ||
} | ||
|
||
if (statusEffect.isBeneficial()) { | ||
beneficialCount++; | ||
x -= 25 * beneficialCount; | ||
} else { | ||
nonBeneficialCount++; | ||
x -= 25 * nonBeneficialCount; | ||
y += 26; | ||
} | ||
|
||
String duration = getDurationAsString(statusEffectInstance); | ||
int durationLength = client.textRenderer.getWidth(duration); | ||
drawStringWithShadow(matrices, client.textRenderer, duration, x + 13 - (durationLength / 2), y + 14, 0xFFFFFFFF); | ||
|
||
int amplifier = statusEffectInstance.getAmplifier(); | ||
if (amplifier > 0) { | ||
// Most langages has "translations" for amplifier 1-5, converting to roman numerals | ||
String amplifierString = (amplifier < 6) ? I18n.translate("potion.potency." + amplifier) : "**"; | ||
int amplifierLength = client.textRenderer.getWidth(amplifierString); | ||
drawStringWithShadow(matrices, client.textRenderer, amplifierString, x + 22 - amplifierLength, y + 3, 0xFFFFFFFF); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@NotNull | ||
private String getDurationAsString(StatusEffectInstance statusEffectInstance) { | ||
int ticks = MathHelper.floor((float) statusEffectInstance.getDuration()); | ||
int seconds = ticks / 20; | ||
|
||
if (ticks > 32147) { | ||
// Vanilla considers everything above this to be infinite | ||
return "**"; | ||
} else if (seconds > 60 & seconds < 600) { | ||
return seconds / 60 + ":" + seconds % 60; | ||
} else if (seconds > 600 ) { | ||
return seconds / 60 + "m"; | ||
} else { | ||
return String.valueOf(seconds); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"key.category.qolify.qolify": "Qolify", | ||
"key.qolify.zoom": "Zoom" | ||
"key.qolify.zoom": "Zoom", | ||
"key.qolify.fullbright": "Fullbright", | ||
"qolify.github": "GitHub", | ||
"qolify.modrinth": "Modrinth" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters