-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature
crystalBeamsDisableMode
(#14)
- Loading branch information
1 parent
0c3b29c
commit 639bf15
Showing
7 changed files
with
148 additions
and
12 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
52 changes: 52 additions & 0 deletions
52
src/main/java/top/hendrixshen/tweakmyclient/helper/CrystalBeamsDisableMode.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,52 @@ | ||
package top.hendrixshen.tweakmyclient.helper; | ||
|
||
import fi.dy.masa.malilib.config.IConfigOptionListEntry; | ||
import top.hendrixshen.tweakmyclient.util.StringUtil; | ||
|
||
public enum CrystalBeamsDisableMode implements IConfigOptionListEntry { | ||
ALL("all"), | ||
FIXED("fixed"), | ||
TRACKING("tracking"); | ||
|
||
private final String name; | ||
|
||
CrystalBeamsDisableMode(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String getStringValue() { | ||
return this.name; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return StringUtil.tr(String.format("label.crystalBeamsDisableMode.%s", this.name)); | ||
} | ||
|
||
@Override | ||
public IConfigOptionListEntry cycle(boolean forward) { | ||
int id = this.ordinal(); | ||
|
||
if (forward) { | ||
if (++id >= values().length) { | ||
id = 0; | ||
} | ||
} else { | ||
if (--id < 0) { | ||
id = values().length - 1; | ||
} | ||
} | ||
return values()[id % values().length]; | ||
} | ||
|
||
@Override | ||
public IConfigOptionListEntry fromString(String value) { | ||
for (CrystalBeamsDisableMode mode : CrystalBeamsDisableMode.values()) { | ||
if (mode.name.equalsIgnoreCase(value)) { | ||
return mode; | ||
} | ||
} | ||
return CrystalBeamsDisableMode.ALL; | ||
} | ||
} |
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
68 changes: 68 additions & 0 deletions
68
...hendrixshen/tweakmyclient/mixin/disable/disableCrystalBeams/MixinEnderDragonRenderer.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,68 @@ | ||
package top.hendrixshen.tweakmyclient.mixin.disable.disableCrystalBeams; | ||
|
||
//#if MC >= 11500 | ||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import net.minecraft.client.renderer.MultiBufferSource; | ||
//#endif | ||
import net.minecraft.client.renderer.entity.EnderDragonRenderer; | ||
//#if MC < 11700 | ||
//$$ import net.minecraft.client.renderer.entity.EntityRenderDispatcher; | ||
//#endif | ||
import net.minecraft.client.renderer.entity.EntityRenderer; | ||
//#if MC >= 11700 | ||
import net.minecraft.client.renderer.entity.EntityRendererProvider; | ||
//#endif | ||
import net.minecraft.world.entity.boss.enderdragon.EnderDragon; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
import top.hendrixshen.tweakmyclient.config.Configs; | ||
import top.hendrixshen.tweakmyclient.helper.CrystalBeamsDisableMode; | ||
|
||
@Mixin(EnderDragonRenderer.class) | ||
public abstract class MixinEnderDragonRenderer extends EntityRenderer<EnderDragon> { | ||
//#if MC >= 11700 | ||
protected MixinEnderDragonRenderer(EntityRendererProvider.Context context) { | ||
super(context); | ||
//#else | ||
//$$ protected MixinEnderDragonRenderer(EntityRenderDispatcher entityRenderDispatcher) { | ||
//$$ super(entityRenderDispatcher); | ||
//#endif | ||
} | ||
|
||
@Inject( | ||
//#if MC >= 11500 | ||
method = "render(Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;FFLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V", | ||
//#else | ||
//$$ method = "render(Lnet/minecraft/world/entity/boss/enderdragon/EnderDragon;DDDFF)V", | ||
//#endif | ||
at = @At( | ||
value = "INVOKE", | ||
//#if MC >= 11500 | ||
target = "Lnet/minecraft/client/renderer/entity/EnderDragonRenderer;renderCrystalBeams(FFFFILcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V" | ||
//#else | ||
//$$ target = "Lnet/minecraft/client/renderer/entity/EnderDragonRenderer;renderCrystalBeams(DDDFDDDIDDD)V" | ||
//#endif | ||
), | ||
cancellable = true | ||
) | ||
//#if MC >= 11500 | ||
private void onRenderCrystalBeams(EnderDragon enderDragon, float f, float g, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { | ||
//#else | ||
//$$ private void onRenderCrystalBeams(EnderDragon enderDragon, double d, double e, double f, float g, float h, CallbackInfo ci) { | ||
//#endif | ||
if (Configs.disableCrystalBeams) { | ||
if (Configs.crystalBeamsDisableMode == CrystalBeamsDisableMode.FIXED) { | ||
return; | ||
} | ||
//#if MC >= 11500 | ||
|
||
poseStack.popPose(); | ||
super.render(enderDragon, f, g, poseStack, multiBufferSource, i); | ||
|
||
//#endif | ||
ci.cancel(); | ||
} | ||
} | ||
} |
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