Skip to content

Commit

Permalink
embeddium compat + lenient mixins
Browse files Browse the repository at this point in the history
  • Loading branch information
Treetrain1 committed Oct 16, 2023
1 parent 1d92980 commit 8061161
Show file tree
Hide file tree
Showing 19 changed files with 49 additions and 42 deletions.
7 changes: 2 additions & 5 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ Make sure to clear this after each release

What's new:
-----------------
- Removed embedded NBT Crafting (backported from 1.20.2)
- Updated block registration to start on class load
- Updated liquid block renderer mixin requirements to 0
- Changed creative tab handling to be more safe
- Updated embedded FrozenLib to 1.3.13
- Updated mixins to be more lenient if they can't be applied
- Added compatibility for Embeddium if used on Forge via Sinytra Connector
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# Mod Properties
mod_id = wilderwild
mod_version = 2.1.7
mod_version = 2.1.8
mod_loader = Fabric
maven_group = net.frozenblock
archives_base_name = WilderWild
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.List;
import java.util.Set;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import net.fabricmc.loader.api.VersionParsingException;
import net.frozenblock.lib.FrozenBools;
import net.frozenblock.wilderwild.misc.WilderPreMixinInjectConstants;
import org.jetbrains.annotations.NotNull;
Expand All @@ -31,6 +33,7 @@

public class WilderWildMixinPlugin implements IMixinConfigPlugin {
private static final String MIXIN_PATH = "net.frozenblock.wilderwild.mixin.";
private static final boolean FORGE = FabricLoader.getInstance().isModLoaded("connector");

@Override
public void onLoad(String mixinPackage) {
Expand All @@ -46,9 +49,16 @@ public String getRefMapperConfig() {
@Override
public boolean shouldApplyMixin(String targetClassName, @NotNull String mixinClassName) {
if (mixinClassName.contains("sodium")) {
if (FORGE)
try {
return FabricLoader.getInstance().isModLoaded("embeddium") && FabricLoader.getInstance().getModContainer("embeddium").orElseThrow().getMetadata().getVersion().compareTo(Version.parse("0.2")) > 0;
} catch (VersionParsingException e) {
return false;
}
return FrozenBools.HAS_SODIUM && FabricLoader.getInstance().getModContainer("sodium").orElseThrow().getMetadata().getVersion().getFriendlyString().contains("0.5.");
}
if (mixinClassName.contains("LiquidBlockRenderer") || mixinClassName.contains("CloudRenderer") || mixinClassName.contains("EntityRenderDispatcher")) {
if (FORGE) return !FabricLoader.getInstance().isModLoaded("embeddium");
return !FrozenBools.HAS_SODIUM;
}
if (mixinClassName.contains("fallingleaves")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class MerpSlimeRenderer {
@Unique
private static final ResourceLocation WILDERWILD$MERP_SLIME = WilderSharedConstants.id("textures/entity/slime/merp_slime.png");

@Inject(method = "getTextureLocation(Lnet/minecraft/world/entity/monster/Slime;)Lnet/minecraft/resources/ResourceLocation;", at = @At("RETURN"), cancellable = true)
@Inject(method = "getTextureLocation(Lnet/minecraft/world/entity/monster/Slime;)Lnet/minecraft/resources/ResourceLocation;", at = @At("RETURN"), cancellable = true, require = 0)
public void wilderWild$getTextureLocation(@NotNull Slime slimeEntity, CallbackInfoReturnable<ResourceLocation> info) {
if (Objects.equals(ChatFormatting.stripFormatting(slimeEntity.getName().getString()), "Merp")) {
info.setReturnValue(WILDERWILD$MERP_SLIME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ScottTheWozMixin {
@Final
private User user;

@Inject(method = "getSplash", at = @At("TAIL"), cancellable = true)
@Inject(method = "getSplash", at = @At("TAIL"), cancellable = true, require = 0)
public void wilderWild$getSplash(CallbackInfoReturnable<String> info) {
String lowerName = this.user.getName().toLowerCase();
if (this.user != null && (RANDOM.nextInt(this.splashes.size()) == 42 || lowerName.contains("scot") || lowerName.contains("skot") || lowerName.contains("sct") || lowerName.contains("skt"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public final class UppyBalloo {
@Unique
private static final ResourceLocation WILDERWILD$UPPY_BALLOO = WilderSharedConstants.id("textures/entity/pig/uppy_balloo.png");

@Inject(method = "getTextureLocation(Lnet/minecraft/world/entity/animal/Pig;)Lnet/minecraft/resources/ResourceLocation;", at = @At("RETURN"), cancellable = true)
@Inject(method = "getTextureLocation(Lnet/minecraft/world/entity/animal/Pig;)Lnet/minecraft/resources/ResourceLocation;", at = @At("RETURN"), cancellable = true, require = 0)
public void wilderWild$getTextureLocation(Pig pig, CallbackInfoReturnable<ResourceLocation> info) {
String string = ChatFormatting.stripFormatting(pig.getName().getString());
if (string != null && string.equalsIgnoreCase("a view from the top")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class AllayModelMixin extends HierarchicalModel<Allay> implement
@Final
private ModelPart root;

@Inject(method = "setupAnim(Lnet/minecraft/world/entity/animal/allay/Allay;FFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;lerp(FFF)F"))
@Inject(method = "setupAnim(Lnet/minecraft/world/entity/animal/allay/Allay;FFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;lerp(FFF)F"), require = 0)
private void wilderWild$setupAnim(Allay allay, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, CallbackInfo info) {
if (EntityConfig.get().allay.keyframeAllayDance) {
this.root.yRot = 0.0F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public class EntityRenderDispatcherMixin {
@Unique
private static BlockState wilderWild$currentBlockState;

@ModifyExpressionValue(method = "renderBlockShadow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkAccess;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"))
@ModifyExpressionValue(method = "renderBlockShadow", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/chunk/ChunkAccess;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), require = 0)
private static BlockState wilderWild$captureBlockState(BlockState original) {
wilderWild$currentBlockState = original;
return original;
}

@Inject(method = "renderBlockShadow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LightTexture;getBrightness(Lnet/minecraft/world/level/dimension/DimensionType;I)F", shift = At.Shift.BEFORE), cancellable = true)
@Inject(method = "renderBlockShadow", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/LightTexture;getBrightness(Lnet/minecraft/world/level/dimension/DimensionType;I)F", shift = At.Shift.BEFORE), cancellable = true, require = 0)
private static void wilderWild$stopRenderIfMesoglea(PoseStack.Pose pose, VertexConsumer vertexConsumer, ChunkAccess chunkAccess, LevelReader levelReader, BlockPos blockPos, double d, double e, double f, float g, float h, CallbackInfo info) {
if (wilderWild$currentBlockState.getBlock() instanceof MesogleaBlock && (wilderWild$currentBlockState.hasProperty(BlockStateProperties.WATERLOGGED) && wilderWild$currentBlockState.getValue(BlockStateProperties.WATERLOGGED))) {
info.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class LevelRendererMixin {
@Nullable
private ClientLevel level;

@ModifyExpressionValue(method = "levelEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0))
@ModifyExpressionValue(method = "levelEvent", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), require = 0)
private Comparable<Boolean> wilderWild$shriekerGargle(Comparable<Boolean> original, int eventId, BlockPos pos, int data) {
if (BlockConfig.get().shriekerGargling) {
if (original.compareTo(true) == 0 || this.level.getFluidState(pos.above()).is(FluidTags.WATER)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
@Mixin(BubbleColumnAmbientSoundHandler.class)
public class BubbleColumnAmbientSoundHandlerMixin {

@WrapOperation(method = "method_29714(Lnet/minecraft/world/level/block/state/BlockState;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z", ordinal = 0))
@WrapOperation(method = "method_29714(Lnet/minecraft/world/level/block/state/BlockState;)Z", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z", ordinal = 0), require = 0)
private static boolean wilderWild$filterWithMesoglea(BlockState state, Block block, Operation<Boolean> operation) {
return operation.call(state, block) || MesogleaBlock.hasBubbleColumn(state);
}

@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z", ordinal = 0))
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;is(Lnet/minecraft/world/level/block/Block;)Z", ordinal = 0), require = 0)
private static boolean wilderWild$mesogleaAndBubbleCheck(BlockState state, Block block, Operation<Boolean> operation) {
return operation.call(state, block) || MesogleaBlock.hasBubbleColumn(state);
}

@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0))
@WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), require = 0)
private static Comparable<Boolean> wilderWild$blockStateValueCheckWithMesoglea(BlockState state, Property<?> property, Operation<Comparable<Boolean>> operation) {
return state.hasProperty(BubbleColumnBlock.DRAG_DOWN) ? operation.call(state, property) : MesogleaBlock.isDraggingDown(state);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ public class WardenAnimationOverwrites {
@Final
@Mutable
@Shadow
public static AnimationDefinition WARDEN_EMERGE;
private static AnimationDefinition WARDEN_EMERGE;

@Final
@Mutable
@Shadow
public static AnimationDefinition WARDEN_SNIFF;
private static AnimationDefinition WARDEN_SNIFF;

@Shadow
@Final
@Mutable
public static AnimationDefinition WARDEN_DIG;
private static AnimationDefinition WARDEN_DIG;

@Inject(method = "<clinit>", at = @At("TAIL"))
@Inject(method = "<clinit>", at = @At("TAIL"), require = 0)
private static void wilderWild$config(CallbackInfo info) {
//TODO: config option for improved & dig
WARDEN_DIG = AnimationDefinition.Builder.withLength(5.167667f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public class WardenModelMixin<T extends Warden> {
@Shadow
protected ModelPart rightArm;

@Inject(at = @At("TAIL"), method = "animateTendrils", locals = LocalCapture.CAPTURE_FAILHARD)
@Inject(at = @At("TAIL"), method = "animateTendrils", locals = LocalCapture.CAPTURE_FAILHARD, require = 0)
private void wilderWild$animateCustomTendrils(T warden, float animationProgress, float tickDelta, CallbackInfo info, float cos) { //CUSTOM TENDRIL ANIMATION
float sin = warden.getTendrilAnimation(tickDelta) * (float) (-Math.sin((double) animationProgress * 2.25D) * Math.PI * 0.1F);
float sin = warden.getTendrilAnimation(tickDelta) * (float) (-Math.sin(animationProgress * 2.25D) * Math.PI * 0.1F);

if (EntityConfig.get().warden.wardenCustomTendrils) {
this.leftTendril.xRot = cos;
Expand All @@ -93,7 +93,7 @@ public class WardenModelMixin<T extends Warden> {
}
}

@Inject(method = "setupAnim(Lnet/minecraft/world/entity/monster/warden/Warden;FFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/WardenModel;animate(Lnet/minecraft/world/entity/AnimationState;Lnet/minecraft/client/animation/AnimationDefinition;F)V", ordinal = 0, shift = At.Shift.BEFORE))
@Inject(method = "setupAnim(Lnet/minecraft/world/entity/monster/warden/Warden;FFFFF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/WardenModel;animate(Lnet/minecraft/world/entity/AnimationState;Lnet/minecraft/client/animation/AnimationDefinition;F)V", ordinal = 0, shift = At.Shift.BEFORE), require = 0)
private void wilderWild$setupAnim(T wardenEntity, float angle, float distance, float anim, float headYaw, float headPitch, CallbackInfo info) {
boolean canSwim = !wardenEntity.hasPose(Pose.EMERGING) && !wardenEntity.hasPose(Pose.DIGGING) && !wardenEntity.hasPose(Pose.DYING) && !((WilderWarden) wardenEntity).wilderWild$getSwimmingDyingAnimationState().isStarted() && !((WilderWarden) wardenEntity).wilderWild$getKirbyDeathAnimationState().isStarted();
boolean shouldMoveLimbs = !wardenEntity.hasPose(Pose.ROARING) && !wardenEntity.hasPose(Pose.EMERGING) && !wardenEntity.hasPose(Pose.DIGGING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ public class CloudRendererMixin {
return MiscConfig.get().cloudMovement && ClientWindManager.shouldUseWind();
}

@ModifyVariable(method = "renderClouds", at = @At(value = "STORE"), ordinal = 4)
@ModifyVariable(method = "renderClouds", at = @At(value = "STORE"), ordinal = 4, require = 0)
private double wilderWild$modifyXScroll(double original) {
return (this.wilderWild$useWind = wilderWild$useWind())
? 0
: original;
}

@ModifyVariable(method = "renderClouds", at = @At(value = "STORE"), ordinal = 5)
@ModifyVariable(method = "renderClouds", at = @At(value = "STORE"), ordinal = 5, require = 0)
private double wilderWild$modifyX(double original, PoseStack poseStack, Matrix4f projectionMatrix, float partialTick, double camX) {
return this.wilderWild$useWind
? original - WilderClientWindManager.getCloudX(partialTick)
: original;
}

@ModifyVariable(method = "renderClouds", at = @At("STORE"), ordinal = 6)
@ModifyVariable(method = "renderClouds", at = @At("STORE"), ordinal = 6, require = 0)
private double wilderWild$modifyY(double original, PoseStack poseStack, Matrix4f projectionMatrix, float partialTick, double camX, double camY) {
return this.wilderWild$useWind
? original + Mth.clamp(WilderClientWindManager.getCloudY(partialTick), -10D, 10D)
: original;
}

@ModifyVariable(method = "renderClouds", at = @At("STORE"), ordinal = 7)
@ModifyVariable(method = "renderClouds", at = @At("STORE"), ordinal = 7, require = 0)
private double wilderWild$modifyZ(double original, PoseStack poseStack, Matrix4f projectionMatrix, float partialTick, double camX, double camY, double camZ) {
return this.wilderWild$useWind
? original - WilderClientWindManager.getCloudZ(partialTick)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ public class FallingLeafParticleMixin {
return MiscConfig.get().cloudMovement && ClientWindManager.shouldUseWind();
}

@ModifyExpressionValue(method = "tick", at = @At(value = "FIELD", target = "Lrandommcsomethin/fallingleaves/util/Wind;windX:F"))
@ModifyExpressionValue(method = "tick", at = @At(value = "FIELD", target = "Lrandommcsomethin/fallingleaves/util/Wind;windX:F"), require = 0)
private float wilderWild$modifyWindX(float original) {
if (wilderWild$useWind()) {
return (float) ClientWindManager.windX * 0.7F;
}
return original;
}

@ModifyExpressionValue(method = "tick", at = @At(value = "FIELD", target = "Lrandommcsomethin/fallingleaves/util/Wind;windZ:F"))
@ModifyExpressionValue(method = "tick", at = @At(value = "FIELD", target = "Lrandommcsomethin/fallingleaves/util/Wind;windZ:F"), require = 0)
private float wilderWild$modifyWindZ(float original) {
if (wilderWild$useWind()) {
return (float) ClientWindManager.windZ * 0.7F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class DesertDustParticleMixin {
return MiscConfig.get().cloudMovement && ClientWindManager.shouldUseWind();
}

@Inject(method = "tick", at = @At("TAIL"))
@Inject(method = "tick", at = @At("TAIL"), require = 0)
private void wilderWild$modifyWind(CallbackInfo info) {
if (wilderWild$useWind()) {
DesertDustParticle.class.cast(this).xd = Mth.clamp(ClientWindManager.windX * 3, -0.4, 0.4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RainDropParticleMixin {
return MiscConfig.get().cloudMovement && ClientWindManager.shouldUseWind();
}

@Inject(method = "tick", at = @At("TAIL"))
@Inject(method = "tick", at = @At("TAIL"), require = 0)
private void wilderWild$modifyWind(CallbackInfo info) {
if (wilderWild$useWind()) {
RainDropParticle.class.cast(this).xd += Mth.clamp(ClientWindManager.windX, -0.003, 0.003);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SnowFlakeParticleMixin {
return MiscConfig.get().cloudMovement && ClientWindManager.shouldUseWind();
}

@Inject(method = "tick", at = @At("TAIL"))
@Inject(method = "tick", at = @At("TAIL"), require = 0)
private void wilderWild$modifyWind(CallbackInfo info) {
if (wilderWild$useWind()) {
SnowFlakeParticle.class.cast(this).xd += Mth.clamp(ClientWindManager.windX, -0.0015, 0.0015);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ public class CloudRendererMixin {
return MiscConfig.get().cloudMovement && ClientWindManager.shouldUseWind();
}

@ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 2)
@ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 2, require = 0)
private float wilderWild$modifyY(float original, @Nullable ClientLevel world, LocalPlayer player, PoseStack matrices, Matrix4f projectionMatrix, float ticks, float tickDelta, double cameraX, double cameraY, double cameraZ) {
return (this.wilderWild$useWind = wilderWild$useWind())
? (float) (original + 0.33D + Mth.clamp(WilderClientWindManager.getCloudY(tickDelta) * 12, -10, 10))
: original;
}

@ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 4)
@ModifyVariable(method = "render", at = @At(value = "STORE"), ordinal = 4, require = 0)
private double wilderWild$modifyX(double original, @Nullable ClientLevel world, LocalPlayer player, PoseStack matrices, Matrix4f projectionMatrix, float ticks, float tickDelta, double cameraX, double cameraY, double cameraZ) {
return this.wilderWild$useWind
? cameraX - WilderClientWindManager.getCloudX(tickDelta) * 12
: original;
}

@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 5)
@ModifyVariable(method = "render", at = @At("STORE"), ordinal = 5, require = 0)
private double wilderWild$modifyZ(double original, @Nullable ClientLevel world, LocalPlayer player, PoseStack matrices, Matrix4f projectionMatrix, float ticks, float tickDelta, double cameraX, double cameraY, double cameraZ) {
return this.wilderWild$useWind
? (cameraZ + 0.33D) - WilderClientWindManager.getCloudZ(tickDelta) * 12
Expand Down
Loading

0 comments on commit 8061161

Please sign in to comment.