Skip to content

Commit

Permalink
Fix Origins 1.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocohead committed Jun 20, 2021
1 parent 9a43f61 commit 077defc
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ loader_version=0.10.8
fabric_version=0.31.0+1.16
fabric_asm_version=v2.2

mod_version = 1.11.5
mod_version = 1.11.6
maven_group = me.modmuss50
archives_base_name = optifabric
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);
}
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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public boolean getAsBoolean() {
Mixins.addConfiguration("optifabric.compat.now-playing.mixins.json");
}

if (isPresent("origins", mod -> compareVersions(Pattern.compile("^1\\.16(\\.\\d)?-").matcher(mod.getVersion().getFriendlyString()).find() ? ">=1.16-0.2.0" : ">=0.4.1", mod))) {
if (isPresent("origins", mod -> compareVersions(Pattern.compile("^1\\.16(\\.\\d)?-").matcher(mod.getVersion().getFriendlyString()).find() ? ">=1.16-0.2.0" : ">=0.4.1 <1.0", mod))) {
if (isPresent("origins", mod -> !Pattern.compile("^1\\.16(\\.\\d)?-").matcher(mod.getVersion().getFriendlyString()).find() || compareVersions(">=1.16.3-0.4.0", mod))) {
Mixins.addConfiguration("optifabric.compat.origins.mixins.json");
}
Expand All @@ -160,6 +160,10 @@ public boolean getAsBoolean() {
});
}

if (isPresent("apoli")) {
Mixins.addConfiguration("optifabric.compat.apoli.mixins.json");
}

if (isPresent("staffofbuilding")) {
Mixins.addConfiguration("optifabric.compat.staffofbuilding.mixins.json");
}
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/optifabric.compat.apoli.mixins.json
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"
]
}

0 comments on commit 077defc

Please sign in to comment.