Skip to content

Commit

Permalink
fix: better combat issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Senior-S committed Nov 10, 2024
1 parent d38cb04 commit 41c937d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,7 @@ server/*
build/
.gradle/

.env
*.env

# End of https://www.toptal.com/developers/gitignore/api/intellij+all,maven,java
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.6
1.1.7
20 changes: 20 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ plugins {
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id "com.modrinth.minotaur" version "2.+"
}

modrinth {
token = System.getenv("MODRINTH_TOKEN") // Remember to have the MODRINTH_TOKEN environment variable set or else this will fail - just make sure it stays private!
projectId = "justleveling-fork" // This can be the project ID or the slug. Either will work!
versionNumber = "1.1.7" // You don't need to set this manually. Will fail if Modrinth has this version already
versionType = "release" // This is the default -- can also be `beta` or `alpha`
uploadFile = jar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = ["1.20.1"] // Must be an array, even with only one version
loaders = ["forge"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
dependencies { // A special DSL for creating dependencies
// scope.type
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
// The type can either be `project` or `version`
required.project "curios" // Creates a new required dependency on Fabric API
required.project "cloth-config"

optional.version "yacl", "3.4.2+1.20.1-forge" // Creates a new optional dependency on this specific version of Sodium
}
}

apply plugin: 'org.spongepowered.mixin'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod_name=JustLevelingFork
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=APACHE
# The mod version. See https://semver.org/
mod_version=1.1.6
mod_version=1.1.7
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import net.bettercombat.client.collision.TargetFinder;
import net.bettercombat.client.collision.WeaponHitBoxes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.ForgeMod;
Expand All @@ -25,17 +27,26 @@
public abstract class MixTargetFinder {
@Inject(method = {"findAttackTargetResult"}, at = {@At("HEAD")}, cancellable = true, remap = false)
private static void findAttackTargetResult(Player player, Entity cursorTarget, WeaponAttributes.Attack attack, double attackRange, CallbackInfoReturnable<TargetFinder.TargetResult> info) {
if(player == null || cursorTarget == null){
if(player == null || cursorTarget == null || !ForgeMod.ENTITY_REACH.isPresent()){
return;
}
info.cancel();

Vec3 origin = TargetFinder.getInitialTracingPoint(player);
List<Entity> entities = TargetFinder.getInitialTargets(player, cursorTarget, attackRange);
if (!AttackRangeExtensions.sources().isEmpty()) {
attackRange = apply$AttackRangeModifiers(player, attackRange);
}
attackRange += Objects.requireNonNull(Objects.requireNonNull(player.getAttribute(ForgeMod.ENTITY_REACH.get())).getModifier(UUID.fromString("96a891fe-5919-418d-8205-f50464391509"))).getAmount();
AttributeInstance playerReach = player.getAttribute(ForgeMod.ENTITY_REACH.get());
if (playerReach == null) {
return;
}
AttributeModifier modifier = playerReach.getModifier(UUID.fromString("96a891fe-5919-418d-8205-f50464391509"));
if (modifier == null){
return;
}
info.cancel();

attackRange += modifier.getAmount();

// Quality equipment directly changes the register function through reflection.
// So I need to "replicate" what the reflection does here.
Expand Down

0 comments on commit 41c937d

Please sign in to comment.