Skip to content

Commit

Permalink
Finish 1.20.5 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Minenash committed Apr 19, 2024
1 parent b679afa commit 9a380ed
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G
modmenu_version = 10.0.0-alpha.3

# Mod Properties
mod_version = 1.0.4+1.20.3
mod_version = 1.0.4+1.20.5
maven_group = com.minenash
archives_base_name = enhanced_attack_indicator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ public static float getProgress(float weaponProgress) {
if (Config.showBlockBreaking) {
float breakingProgress = MinecraftClient.getInstance().interactionManager.getBlockBreakingProgress();


if (breakingProgress > 0)
return breakingProgress;
return breakingProgress / 10;
}

if (Config.showRangeWeaponDraw) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package com.minenash.enhanced_attack_indicator.mixin;

import com.minenash.enhanced_attack_indicator.EnhancedAttackIndicator;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InGameHud.class)
public class InGameHudMixin {

boolean renderFullness = false;
@Unique boolean renderFullness = false;

@Redirect(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F"))
private float setBarProgress(ClientPlayerEntity player, float baseTime) {
Expand All @@ -25,16 +33,33 @@ private float setBarProgress(ClientPlayerEntity player, float baseTime) {

}

@ModifyVariable(method = "renderCrosshair", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;targetedEntity:Lnet/minecraft/entity/Entity;"), index = 5)
private boolean showPlus(boolean _original) {
boolean render = renderFullness;
renderFullness = false;
return render;
@Redirect(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/Entity;isAlive()Z"))
private boolean dontShowPlus(Entity _entity) {
return false;
}

private static final Identifier CROSSHAIR_ATTACK_INDICATOR_FULL_TEXTURE = new Identifier("hud/crosshair_attack_indicator_full");
@Inject(method = "renderCrosshair", at = @At(value = "TAIL"))
private void showPlus(DrawContext context, float tickDelta, CallbackInfo info) {
if (renderFullness) {
RenderSystem.enableBlend();
RenderSystem.blendFuncSeparate(
GlStateManager.SrcFactor.ONE_MINUS_DST_COLOR, GlStateManager.DstFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO
);
int j = context.getScaledWindowHeight() / 2 - 7 + 16;
int k = context.getScaledWindowWidth() / 2 - 8;
context.drawGuiTexture(CROSSHAIR_ATTACK_INDICATOR_FULL_TEXTURE, k, j, 16, 16);
RenderSystem.defaultBlendFunc();
RenderSystem.disableBlend();
renderFullness = false;
}
}

@Redirect(method = "renderHotbar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;getAttackCooldownProgress(F)F"))
private float setHotBarProgress(ClientPlayerEntity player, float baseTime) {
float progress = EnhancedAttackIndicator.getProgress(player.getAttackCooldownProgress(baseTime));
return progress == 2.0F ? 0.99F : progress;
}


}
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"depends": {
"fabricloader": ">=0.11.3",
"fabric": "*",
"minecraft": ">=1.20.3",
"minecraft": ">=1.20.5-",
"java": ">=17"
}
}

0 comments on commit 9a380ed

Please sign in to comment.