Skip to content

Commit

Permalink
feat: Add Wildfire's Female Gender Origins compat
Browse files Browse the repository at this point in the history
  • Loading branch information
shap-po committed Aug 30, 2024
1 parent 94cbc75 commit 7d61264
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 10 deletions.
13 changes: 7 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modApi "io.github.apace100:apoli:${project.apoli_version}"
modImplementation "io.github.apace100:apoli:${project.apoli_version}"

// Optional dependencies
modCompileOnly("dev.emi:trinkets:${project.trinkets_version}") {
transitive = false
}

modCompileOnly("maven.modrinth:female-gender:${project.wildfire_gender_version}") {
transitive = false
}
}

processResources {
Expand Down Expand Up @@ -138,9 +142,6 @@ publishing {

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
mavenLocal()
}
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ yarn_mappings=1.20.4+build.3
loader_version=0.15.11

# Mod Properties
mod_version=1.3.2
mod_version=1.3.3
maven_group=com.github.shap_po.shappoli
archives_base_name=shappoli

# Dependencies
fabric_version=0.97.1+1.20.4
apoli_version=2.12.0-alpha.6+mc.1.20.4

# Optional Dependencies
trinkets_version=3.8.1
wildfire_gender_version=1.20.4-3.2.1
14 changes: 12 additions & 2 deletions src/main/java/com/github/shap_po/shappoli/ShappoliMixinPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ public String getRefMapperConfig() {

@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return !mixinClassName.contains(".integration.trinkets.") || FabricLoader.getInstance().isModLoaded("trinkets");
return isIntegrationEnabled(mixinClassName);
}

private boolean isIntegrationEnabled(String mixinClassName) {
// not an integration mixin
if (!mixinClassName.contains(".integration.")) {
return true;
}
// class name: something.something...integration.{modid}.something
String modid = mixinClassName.split("\\.integration\\.")[1].split("\\.")[0];
return FabricLoader.getInstance().isModLoaded(modid);
}

@Override
Expand All @@ -45,4 +55,4 @@ public void postApply(String targetClassName, ClassNode targetClass, String mixi

}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.github.shap_po.shappoli.mixin.integration.wildfire_gender;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.wildfire.render.BreastSide;
import com.wildfire.render.GenderLayer;
import com.wildfire.render.WildfireModelRenderer;
import io.github.apace100.apoli.component.PowerHolderComponent;
import io.github.apace100.apoli.power.ModelColorPower;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

import java.util.List;

@Mixin(GenderLayer.class)
public abstract class GenderLayerMixin<T extends LivingEntity> {
@Shadow
protected abstract void renderBreast(T entity, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int packedLightIn, int packedOverlayIn, BreastSide side);

@Shadow
protected static void renderBox(WildfireModelRenderer.ModelBox model, MatrixStack matrixStack, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
}

@WrapOperation(
method = "renderBreast",
at = @At(value = "INVOKE", target = "Lcom/wildfire/render/GenderLayer;renderBox(Lcom/wildfire/render/WildfireModelRenderer$ModelBox;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")
)
private void shappoli$modifyRenderBreastColor(WildfireModelRenderer.ModelBox model, MatrixStack matrixStack, VertexConsumer bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha, Operation<Void> original, LivingEntity entity) {
List<ModelColorPower> modelColorPowers = PowerHolderComponent.KEY.get(entity).getPowers(ModelColorPower.class);
if (!modelColorPowers.isEmpty()) {
red = modelColorPowers.stream().map(ModelColorPower::getRed).reduce((a, b) -> a * b).orElse(red);
green = modelColorPowers.stream().map(ModelColorPower::getGreen).reduce((a, b) -> a * b).orElse(green);
blue = modelColorPowers.stream().map(ModelColorPower::getBlue).reduce((a, b) -> a * b).orElse(blue);
alpha = modelColorPowers.stream().map(ModelColorPower::getAlpha).min(Float::compare).orElse(alpha);
}
original.call(model, matrixStack, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/shappoli.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"VillagerEntityMixin",
"integration.trinkets.LivingEntityMixin",
"integration.trinkets.SurvivalTrinketSlotMixin",
"integration.trinkets.TrinketSlotMixin"
"integration.trinkets.TrinketSlotMixin",
"integration.wildfire_gender.GenderLayerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
6 changes: 6 additions & 0 deletions src/test/resources/data/shappoli/powers/model_color.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "apoli:model_color",
"red": 0.5,
"green": 0.5,
"alpha": 0.7
}

0 comments on commit 7d61264

Please sign in to comment.