Skip to content

Commit

Permalink
mixin plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jan 30, 2024
1 parent 4618c6b commit 4302c26
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.polyfrost.hytils.forge;


import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.lib.tree.*;
Expand All @@ -33,6 +34,7 @@
public class HytilsMixinPlugin implements IMixinConfigPlugin {

private boolean isOptiFine = false;
private boolean isLevelhead = false;
private boolean hasAppliedRenderHeads = false;
private boolean hasAppliedModifyName = false;

Expand All @@ -46,6 +48,7 @@ public void onLoad(String mixinPackage) {
System.out.println("OptiFine not detected, not applying OptiFine compat mixin.");
isOptiFine = false;
}
if (Loader.isModLoaded("level_head")) isLevelhead = true;
}

@Override
Expand All @@ -60,6 +63,9 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
} else if (mixinClassName.endsWith("_NoOptiFine")) {
return !isOptiFine;
}
if (mixinClassName.equals("AboveHeadRendererMixin_RemoveLevelheadPit")) {
return isLevelhead;
}
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils;
import cc.polyfrost.oneconfig.utils.hypixel.LocrawInfo;
import cc.polyfrost.oneconfig.utils.hypixel.LocrawUtil;
import club.sk1er.mods.levelhead.render.AboveHeadRender;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraftforge.client.event.RenderLivingEvent;
import org.polyfrost.hytils.config.HytilsConfig;
import org.polyfrost.hytils.handlers.game.pit.PitLagReducer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -35,7 +35,7 @@
import static org.polyfrost.hytils.handlers.game.pit.PitLagReducer.pitSpawnPos;

@Pseudo
@Mixin(value = AboveHeadRender.class, remap = false)
@Mixin(targets = "club.sk1er.mods.levelhead.render.AboveHeadRender.AboveHeadRender", remap = false)
public class AboveHeadRendererMixin_RemoveLevelheadPit {
@Inject(method = "render(Lnet/minecraftforge/client/event/RenderLivingEvent$Specials$Post;)V", at = @At("HEAD"), cancellable = true)
private void removeLevelhead(RenderLivingEvent.Specials.Post<EntityLivingBase> event, CallbackInfo ci) {
Expand Down

0 comments on commit 4302c26

Please sign in to comment.