forked from Chocohead/OptiFabric
-
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.
Fixes Chocohead#248 Fixes Chocohead#263
- Loading branch information
Showing
5 changed files
with
122 additions
and
2 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
75 changes: 75 additions & 0 deletions
75
src/main/java/me/modmuss50/optifabric/compat/apoli/mixin/BackgroundRendererMixin.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,75 @@ | ||
package me.modmuss50.optifabric.compat.apoli.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Constant; | ||
import org.spongepowered.asm.mixin.injection.ModifyConstant; | ||
import org.spongepowered.asm.mixin.injection.ModifyVariable; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import net.minecraft.client.render.BackgroundRenderer; | ||
import net.minecraft.client.render.BackgroundRenderer.FogType; | ||
import net.minecraft.client.render.Camera; | ||
|
||
import me.modmuss50.optifabric.compat.InterceptingMixin; | ||
import me.modmuss50.optifabric.compat.Shim; | ||
|
||
@Mixin(BackgroundRenderer.class) | ||
@InterceptingMixin("io/github/apace100/apoli/mixin/BackgroundRendererMixin") | ||
abstract class BackgroundRendererMixin { | ||
@ModifyVariable(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;getFocusedEntity()Lnet/minecraft/entity/Entity;", ordinal = 3), ordinal = 0) | ||
private static double optifabric_modifyD(double original, Camera camera) { | ||
return modifyD(original, camera); | ||
} | ||
|
||
@Shim | ||
private static native double modifyD(double original, Camera camera); | ||
|
||
@Redirect(method = "setupFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;fogStart(F)V", remap = false), remap = false) | ||
private static void optifabric_redirectFogStart(float start, Camera camera, FogType fogType) { | ||
redirectFogStart(start, camera, fogType); | ||
} | ||
|
||
@Redirect(method = "setupFog", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;fogEnd(F)V", remap = false), remap = false) | ||
private static void optifabric_redirectFogEnd(float end, Camera camera, FogType fogType) { | ||
redirectFogEnd(end, camera, fogType); | ||
} | ||
|
||
@Shim | ||
private static native void redirectFogStart(float start, Camera camera, FogType fogType); | ||
|
||
@Shim | ||
private static native void redirectFogEnd(float end, Camera camera, FogType fogType); | ||
|
||
@ModifyConstant(method = "setupFog", constant = @Constant(floatValue = 0.25F, ordinal = 0), remap = false) | ||
private static float optifabric_modifyLavaVisibilitySNoPotion(float original, Camera camera) { | ||
return modifyLavaVisibilitySNoPotion(original, camera); | ||
} | ||
|
||
@ModifyConstant(method = "setupFog", constant = @Constant(floatValue = 1F, ordinal = 1), remap = false) | ||
private static float optifabric_modifyLavaVisibilityVNoPotion(float original, Camera camera) { | ||
return modifyLavaVisibilityVNoPotion(original, camera); | ||
} | ||
|
||
@ModifyConstant(method = "setupFog", constant = @Constant(floatValue = 0F, ordinal = 0), remap = false) | ||
private static float optifabric_modifyLavaVisibilitySWithPotion(float original, Camera camera) { | ||
return modifyLavaVisibilitySWithPotion(original, camera); | ||
} | ||
|
||
@ModifyConstant(method = "setupFog", constant = @Constant(floatValue = 3F, ordinal = 0), remap = false) | ||
private static float optifabric_modifyLavaVisibilityVWithPotion(float original, Camera camera) { | ||
return modifyLavaVisibilityVWithPotion(original, camera); | ||
} | ||
|
||
@Shim | ||
private static native float modifyLavaVisibilitySNoPotion(float original, Camera camera); | ||
|
||
@Shim | ||
private static native float modifyLavaVisibilityVNoPotion(float original, Camera camera); | ||
|
||
@Shim | ||
private static native float modifyLavaVisibilitySWithPotion(float original, Camera camera); | ||
|
||
@Shim | ||
private static native float modifyLavaVisibilityVWithPotion(float original, Camera camera); | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/me/modmuss50/optifabric/compat/apoli/mixin/ElytraFeatureRendererMixin.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,32 @@ | ||
package me.modmuss50.optifabric.compat.apoli.mixin; | ||
|
||
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.CallbackInfoReturnable; | ||
|
||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.feature.ElytraFeatureRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.Items; | ||
|
||
import me.modmuss50.optifabric.compat.InterceptingMixin; | ||
import me.modmuss50.optifabric.compat.Shim; | ||
|
||
@Mixin(ElytraFeatureRenderer.class) | ||
@InterceptingMixin("io/github/apace100/apoli/mixin/ElytraFeatureRendererMixin") | ||
abstract class ElytraFeatureRendererMixin { | ||
@Shim | ||
private native Item modifyEquippedStackToElytra(ItemStack stack, MatrixStack matrices, VertexConsumerProvider vertexConsumerProvider, int light, LivingEntity entity, | ||
float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch); | ||
|
||
@Inject(method = "shouldRender", at = @At("HEAD"), remap = false, cancellable = true) | ||
public void shouldRender(ItemStack stack, LivingEntity entity, CallbackInfoReturnable<Boolean> call) { | ||
if (modifyEquippedStackToElytra(stack, null, null, 0, entity, 0, 0, 0, 0, 0, 0) == Items.ELYTRA) { | ||
call.setReturnValue(true); //Let's take the positive approach that those parameters are never needed | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"parent": "optifabric.mixins.json", | ||
"package": "me.modmuss50.optifabric.compat.apoli.mixin", | ||
"plugin": "me.modmuss50.optifabric.compat.origins.OriginsMixinPlugin", | ||
"mixins": [ | ||
"BackgroundRendererMixin", | ||
"ElytraFeatureRendererMixin" | ||
] | ||
} |