-
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
1 parent
85889b8
commit 99a57a7
Showing
11 changed files
with
109 additions
and
62 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
20 changes: 14 additions & 6 deletions
20
common/src/main/java/com/github/manasmods/manascore/core/MixinItem.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 |
---|---|---|
@@ -1,18 +1,26 @@ | ||
package com.github.manasmods.manascore.core; | ||
|
||
import com.github.manasmods.manascore.attribute.ManasCoreAttributeUtils; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.level.ClipContext; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.BlockHitResult; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(Item.class) | ||
public class MixinItem { | ||
@ModifyConstant(method = "getPlayerPOVHitResult(Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/world/level/ClipContext$Fluid;)Lnet/minecraft/world/phys/BlockHitResult;", | ||
require = 4, allow = 4, constant = @Constant(doubleValue = 5.0)) | ||
private static double getReachDistance(double reachDistance, Level level, Player player) { | ||
return ManasCoreAttributeUtils.getReachDistance(player); | ||
@Inject(method = "getPlayerPOVHitResult", at = @At(value = "INVOKE_ASSIGN", | ||
target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;", shift = At.Shift.AFTER)) | ||
private static void getReachDistance(Level level, Player player, ClipContext.Fluid fluidMode, CallbackInfoReturnable<BlockHitResult> cir, | ||
@Local(ordinal = 6) float l, @Local(ordinal = 5) float k, @Local(ordinal = 7) float n, @Local(ordinal = 1) LocalRef<Vec3> vec32) { | ||
final double reach = ManasCoreAttributeUtils.getBlockReachAddition(player); | ||
vec32.set(vec32.get().add(l * reach, k * reach, n * reach)); | ||
} | ||
} |
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
63 changes: 52 additions & 11 deletions
63
common/src/main/java/com/github/manasmods/manascore/core/client/MixinGameRenderer.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 |
---|---|---|
@@ -1,30 +1,71 @@ | ||
package com.github.manasmods.manascore.core.client; | ||
|
||
import com.github.manasmods.manascore.attribute.ManasCoreAttributeUtils; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalRef; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.GameRenderer; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.objectweb.asm.Opcodes; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.injection.*; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(GameRenderer.class) | ||
public class MixinGameRenderer { | ||
@Shadow @Final Minecraft minecraft; | ||
@ModifyConstant(method = "pick", require = 1, allow = 1, constant = @Constant(doubleValue = 6.0)) | ||
private double getReachDistance(double reachDistance) { | ||
@Inject(method = "pick", at = @At(value = "INVOKE_ASSIGN", | ||
target = "Lnet/minecraft/world/phys/Vec3;add(DDD)Lnet/minecraft/world/phys/Vec3;", shift = At.Shift.AFTER)) | ||
private void getReachDistance(float partialTicks, CallbackInfo ci, @Local(ordinal = 0) double d, @Local(ordinal = 0) Vec3 vec3, | ||
@Local(ordinal = 1) Vec3 vec32, @Local(ordinal = 2) LocalRef<Vec3> vec33) { | ||
if (minecraft.player == null) return; | ||
double reach = ManasCoreAttributeUtils.getEntityReachAddition(minecraft.player); | ||
if (minecraft.gameMode != null && minecraft.gameMode.hasFarPickRange()) { | ||
double newD = d + reach; | ||
vec33.set(vec3.add(vec32.x * newD, vec32.y * newD, vec32.z * newD)); | ||
} | ||
} | ||
|
||
@ModifyArg(method = "pick", at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/world/phys/AABB;expandTowards(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/AABB;", | ||
opcode = Opcodes.GETSTATIC), index = 0) | ||
private Vec3 getEntityReachDistance(Vec3 vector, @Local(ordinal = 0) double d) { | ||
Player player = this.minecraft.player; | ||
if (player == null) return vector; | ||
|
||
double reach = ManasCoreAttributeUtils.getEntityReachAddition(minecraft.player); | ||
if (minecraft.gameMode != null && minecraft.gameMode.hasFarPickRange() && minecraft.hitResult == null) { | ||
double newD = d + reach; | ||
return vector.scale(newD); | ||
} | ||
return vector; | ||
} | ||
|
||
@ModifyArg(method = "pick", at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/world/entity/projectile/ProjectileUtil;getEntityHitResult(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;D)Lnet/minecraft/world/phys/EntityHitResult;", | ||
opcode = Opcodes.GETSTATIC), index = 5) | ||
private double getEntityDistance(double distance, @Local(ordinal = 0) double d) { | ||
Player player = this.minecraft.player; | ||
if (player == null) return reachDistance; | ||
return ManasCoreAttributeUtils.getReachDistance(player); | ||
if (player == null) return distance; | ||
|
||
double reach = ManasCoreAttributeUtils.getEntityReachAddition(minecraft.player); | ||
if (minecraft.gameMode != null && minecraft.gameMode.hasFarPickRange() && minecraft.hitResult == null) { | ||
double newD = d + reach; | ||
return newD * newD; | ||
} | ||
return distance; | ||
} | ||
|
||
@ModifyConstant(method = "pick", constant = @Constant(doubleValue = 9.0)) | ||
private double getAttackRange(double attackRange) { | ||
@Redirect(method = "pick", at = @At(value = "INVOKE", | ||
target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D", ordinal = 1, opcode = Opcodes.GETSTATIC)) | ||
private double getEntityReachDistance(Vec3 instance, Vec3 vec) { | ||
Player player = this.minecraft.player; | ||
if (player == null) return attackRange; | ||
double range = ManasCoreAttributeUtils.getAttackRange(player); | ||
return range * range; | ||
if (player == null) return instance.distanceToSqr(vec); | ||
|
||
double reach = ManasCoreAttributeUtils.getEntityReachAddition(player); | ||
return instance.distanceToSqr(vec) - reach * reach; | ||
} | ||
} |
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