-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Showing
3 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/main/java/com/aetherteam/aether/mixin/AetherMixinPlugin.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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.aetherteam.aether.mixin; | ||
|
||
import org.objectweb.asm.tree.ClassNode; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; | ||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class AetherMixinPlugin implements IMixinConfigPlugin { | ||
private boolean isOptiFineInstalled = false; | ||
|
||
@Override | ||
public void onLoad(String mixinPackage) { | ||
try { | ||
Class.forName("optifine.Installer", false, getClass().getClassLoader()); | ||
isOptiFineInstalled = true; | ||
} catch (ClassNotFoundException e) { | ||
} | ||
} | ||
|
||
@Override | ||
public String getRefMapperConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { | ||
if (this.isOptiFineInstalled) { | ||
if (mixinClassName.equals("com.aetherteam.aether.mixin.mixins.client.BossHealthOverlayMixin")) return false; | ||
if (mixinClassName.equals("com.aetherteam.aether.mixin.mixins.client.optifine.BossHealthOverlayMixin")) return true; | ||
} | ||
|
||
return !mixinClassName.equals("com.aetherteam.aether.mixin.mixins.client.optifine.BossHealthOverlayMixin"); | ||
} | ||
|
||
@Override | ||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) { | ||
} | ||
|
||
@Override | ||
public List<String> getMixins() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
} | ||
|
||
@Override | ||
public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/aetherteam/aether/mixin/mixins/client/optifine/BossHealthOverlayMixin.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.aetherteam.aether.mixin.mixins.client.optifine; | ||
|
||
import com.aetherteam.aether.client.event.hooks.GuiHooks; | ||
import net.minecraft.client.gui.components.BossHealthOverlay; | ||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
|
||
@Mixin(BossHealthOverlay.class) | ||
public class BossHealthOverlayMixin { | ||
/** | ||
* Cancels the {@link CustomizeGuiOverlayEvent.BossEventProgress} GUI event after the event hook has been called for it. | ||
* Made as a workaround for Jade's boss bar pushdown.<br> | ||
* This modifies the assignment of the {@link CustomizeGuiOverlayEvent.BossEventProgress} event variable. | ||
* @param event The original {@link CustomizeGuiOverlayEvent.BossEventProgress} parameter value. | ||
* @return The modified {@link CustomizeGuiOverlayEvent.BossEventProgress} parameter value. | ||
*/ | ||
@ModifyVariable(at = @At(value = "STORE"), method = "render(Lnet/minecraft/client/gui/GuiGraphics;)V", index = 9) | ||
@SuppressWarnings({"MixinAnnotationTarget", "InvalidInjectorMethodSignature"}) | ||
private Object event(Object event) { | ||
CustomizeGuiOverlayEvent.BossEventProgress e = (CustomizeGuiOverlayEvent.BossEventProgress)event; | ||
e.setCanceled(GuiHooks.BOSS_EVENTS.containsKey(e.getBossEvent().getId())); | ||
return event; | ||
} | ||
} |
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