Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix spectral sight with mixins #2005

Open
wants to merge 1 commit into
base: 1.20.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ repositories {

dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"


annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${mixin_extras}"))
implementation(jarJar("io.github.llamalad7:mixinextras-forge:${mixin_extras}")) {
jarJar.ranged(it, "[${mixin_extras},)")
}

compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge:${jei_version}")
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ mod_authors=WayofTime
mod_description=Example mod description.\nNewline characters can be used and will be replaced properly.

#Mod dependencies
mixin_version=0.8.5
mixin_extras=0.2.0
jei_version=15.2.0.23
curios_version=5.3.4+1.20.1
patchouli_version=1.20.1-80-FORGE
17 changes: 17 additions & 0 deletions src/main/java/wayoftime/bloodmagic/mixin/client/MixinEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package wayoftime.bloodmagic.mixin.client;

import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;


@Mixin(Entity.class)
public class MixinEntity
{

@Shadow
public double distanceToSqr(Entity p_20281_)
{
throw new IllegalStateException("Failed to shadow distanceToSqr()");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package wayoftime.bloodmagic.mixin.client;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import wayoftime.bloodmagic.potion.BloodMagicPotions;

@Mixin(LivingEntity.class)
public abstract class MixinLivingEntity extends MixinEntity
{
@ModifyReturnValue(
method = "isCurrentlyGlowing",
at = @At(value = "RETURN")
)
public boolean isCurrentlyGlowing(boolean original){
Player player = Minecraft.getInstance().player;

if(player != null && player.hasEffect(BloodMagicPotions.SPECTRAL_SIGHT.get()))
{
double distance = (player.getEffect(BloodMagicPotions.SPECTRAL_SIGHT.get()).getAmplifier() * 32 + 24);
if (distanceToSqr(Minecraft.getInstance().player) <= (distance * distance))
{
return true;
}
}
return original;
}



}
4 changes: 3 additions & 1 deletion src/main/resources/bloodmagic.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"required": true,
"minVersion": "0.8",
"package": "wayoftime.bloodmagic.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"client.MixinEntity",
"client.MixinLivingEntity"
],
"injectors": {
"defaultRequire": 1
Expand Down