version 0.1.8

This commit is contained in:
LostInLinearPast 2026-01-02 19:50:36 +08:00
parent 5a6877e2db
commit 8ba15348ea
6 changed files with 78 additions and 52 deletions

View File

@ -173,6 +173,7 @@ tasks.named('jar', Jar).configure {
]) ])
} }
archiveFileName = "${mod_id}-${mod_version}-origin.jar"
finalizedBy 'reobfJar' finalizedBy 'reobfJar'
} }
@ -251,8 +252,12 @@ publishing {
gradle.buildFinished { gradle.buildFinished {
def javadocJar = file("build/libs/${mod_id}-${mod_version}-javadoc.jar") def javadocJar = file("build/libs/${mod_id}-${mod_version}-javadoc.jar")
def sourcesJar = file("build/libs/${mod_id}-${mod_version}-sources.jar") def sourcesJar = file("build/libs/${mod_id}-${mod_version}-sources.jar")
def allJarsJar = file("build/libs/${mod_id}-${mod_version}-all.jar")
if (javadocJar.exists()) ant.delete(file: javadocJar) if (javadocJar.exists()) ant.delete(file: javadocJar)
if (sourcesJar.exists()) ant.delete(file: sourcesJar) if (sourcesJar.exists()) ant.delete(file: sourcesJar)
if (allJarsJar.exists()) {
ant.move(file: allJarsJar, tofile: file("build/libs/${mod_id}-${mod_version}.jar"))
}
} }
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {

View File

@ -12,7 +12,7 @@ mapping_version=2023.09.03-1.20.1
mod_id=sccore mod_id=sccore
mod_name=SnowyCrescentCore mod_name=SnowyCrescentCore
mod_license=GNU AGPL 3.0 mod_license=GNU AGPL 3.0
mod_version=1.20.1-0.1.7.1 mod_version=1.20.1-0.1.8
mod_group_id=com.linearpast mod_group_id=com.linearpast
mod_authors=LostInLinearPast mod_authors=LostInLinearPast
mod_description=A lib about capability and player animator. mod_description=A lib about capability and player animator.

View File

@ -66,22 +66,35 @@ public class AnimJson {
GenericAnimationData animation = GenericAnimationData.create(new ResourceLocation(json.get(Key).getAsString())); GenericAnimationData animation = GenericAnimationData.create(new ResourceLocation(json.get(Key).getAsString()));
if(json.has(Name)) animation.withName(json.get(Name).getAsString()); if(json.has(Name)) animation.withName(json.get(Name).getAsString());
if(json.has(LyingType)) animation.withLyingType(AnimationData.LyingType.valueOf(json.get(LyingType).getAsString())); if(json.has(LyingType)) animation.withLyingType(AnimationData.LyingType.valueOf(json.get(LyingType).getAsString()));
JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject(); if(json.has(HeightModifier)) animation.withHeightModifier(json.get(HeightModifier).getAsFloat());
animation.withHeightModifier(json.get(HeightModifier).getAsFloat()) if(json.has(Priority)) animation.withCamComputePriority(json.get(Priority).getAsInt());
.withCamComputePriority(json.get(Priority).getAsInt()) if(json.has(CamPitch)) animation.withCamPitch(json.get(CamPitch).getAsFloat());
.setCamPosOffset(new Vec3( if(json.has(CamRoll)) animation.withCamRoll(json.get(CamRoll).getAsFloat());
camOffset.get("x").getAsDouble(), if(json.has(CamYaw)) animation.withCamYaw(json.get(CamYaw).getAsFloat());
camOffset.get("y").getAsDouble(), if(json.has(CamPosOffset)) {
camOffset.get("z").getAsDouble() JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject();
)) Vec3 vec3 = Vec3.ZERO;
.withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean()) if(camOffset.has("x")) vec3 = vec3.add(camOffset.get("x").getAsDouble(), 0, 0);
.withCamPitch(json.get(CamPitch).getAsFloat()) if(camOffset.has("y")) vec3 = vec3.add(0, camOffset.get("y").getAsDouble(), 0);
.withCamRoll(json.get(CamRoll).getAsFloat()) if(camOffset.has("z")) vec3 = vec3.add(0, 0, camOffset.get("z").getAsDouble());
.withCamYaw(json.get(CamYaw).getAsFloat()); if(!vec3.equals(Vec3.ZERO)) animation.setCamPosOffset(vec3);
if(camOffset.has(Relative)) animation.withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean());
}
if(json.has(WithRide)){ if(json.has(WithRide)){
Ride ride = Ride.create(); Ride ride = Ride.create();
JsonObject withRide = json.get(WithRide).getAsJsonObject(); JsonObject withRide = json.get(WithRide).getAsJsonObject();
JsonObject offsetJson = withRide.get(Offset).getAsJsonObject(); if(withRide.has(ExistTick)) ride.setExistTick(withRide.get(ExistTick).getAsInt());
if(withRide.has(XRot)) ride.setXRot(withRide.get(XRot).getAsFloat());
if(withRide.has(YRot)) ride.setYRot(withRide.get(YRot).getAsFloat());
if(withRide.has(Offset)) {
JsonObject offsetJson = withRide.get(Offset).getAsJsonObject();
Vec3 offset = new Vec3(
offsetJson.get("x").getAsDouble(),
offsetJson.get("y").getAsDouble(),
offsetJson.get("z").getAsDouble()
);
ride.withOffset(offset);
}
if(withRide.has(ComponentsAnimation)){ if(withRide.has(ComponentsAnimation)){
JsonArray elements = withRide.get(ComponentsAnimation).getAsJsonArray(); JsonArray elements = withRide.get(ComponentsAnimation).getAsJsonArray();
for (JsonElement element : elements) { for (JsonElement element : elements) {
@ -90,14 +103,6 @@ public class AnimJson {
ride.addComponentAnimation(componentKey); ride.addComponentAnimation(componentKey);
} }
} }
Vec3 offset = new Vec3(
offsetJson.get("x").getAsDouble(),
offsetJson.get("y").getAsDouble(),
offsetJson.get("z").getAsDouble()
);
ride.withOffset(offset).withExistTick(withRide.get(ExistTick).getAsInt())
.withXRot(withRide.get(XRot).getAsFloat())
.withYRot(withRide.get(YRot).getAsFloat());
animation.withRide(ride); animation.withRide(ride);
} }
return animation; return animation;

View File

@ -59,21 +59,34 @@ public class RawAnimJson {
JsonObject json = originElement.getAsJsonObject(); JsonObject json = originElement.getAsJsonObject();
RawAnimationData animation = RawAnimationData.create(new ResourceLocation(json.get(Key).getAsString())); RawAnimationData animation = RawAnimationData.create(new ResourceLocation(json.get(Key).getAsString()));
if(json.has(LyingType)) animation.withLyingType(AnimationData.LyingType.valueOf(json.get(LyingType).getAsString())); if(json.has(LyingType)) animation.withLyingType(AnimationData.LyingType.valueOf(json.get(LyingType).getAsString()));
JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject(); if(json.has(Priority)) animation.withCamComputePriority(json.get(Priority).getAsInt());
animation.withCamComputePriority(json.get(Priority).getAsInt()) if(json.has(CamPitch)) animation.withCamPitch(json.get(CamPitch).getAsFloat());
.setCamPosOffset(new Vec3( if(json.has(CamRoll)) animation.withCamRoll(json.get(CamRoll).getAsFloat());
camOffset.get("x").getAsDouble(), if(json.has(CamYaw)) animation.withCamYaw(json.get(CamYaw).getAsFloat());
camOffset.get("y").getAsDouble(), if(json.has(CamPosOffset)) {
camOffset.get("z").getAsDouble() JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject();
)) Vec3 vec3 = Vec3.ZERO;
.withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean()) if(camOffset.has("x")) vec3 = vec3.add(camOffset.get("x").getAsDouble(), 0, 0);
.withCamPitch(json.get(CamPitch).getAsFloat()) if(camOffset.has("y")) vec3 = vec3.add(0, camOffset.get("y").getAsDouble(), 0);
.withCamRoll(json.get(CamRoll).getAsFloat()) if(camOffset.has("z")) vec3 = vec3.add(0, 0, camOffset.get("z").getAsDouble());
.withCamYaw(json.get(CamYaw).getAsFloat()); if(!vec3.equals(Vec3.ZERO)) animation.setCamPosOffset(vec3);
if(camOffset.has(Relative)) animation.withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean());
}
if(json.has(WithRide)){ if(json.has(WithRide)){
Ride ride = Ride.create(); Ride ride = Ride.create();
JsonObject withRide = json.get(WithRide).getAsJsonObject(); JsonObject withRide = json.get(WithRide).getAsJsonObject();
JsonObject offsetJson = withRide.get(Offset).getAsJsonObject(); if(withRide.has(ExistTick)) ride.setExistTick(withRide.get(ExistTick).getAsInt());
if(withRide.has(XRot)) ride.setXRot(withRide.get(XRot).getAsFloat());
if(withRide.has(YRot)) ride.setYRot(withRide.get(YRot).getAsFloat());
if(withRide.has(Offset)) {
JsonObject offsetJson = withRide.get(Offset).getAsJsonObject();
Vec3 offset = new Vec3(
offsetJson.get("x").getAsDouble(),
offsetJson.get("y").getAsDouble(),
offsetJson.get("z").getAsDouble()
);
ride.withOffset(offset);
}
if(withRide.has(ComponentsAnimation)){ if(withRide.has(ComponentsAnimation)){
JsonArray elements = withRide.get(ComponentsAnimation).getAsJsonArray(); JsonArray elements = withRide.get(ComponentsAnimation).getAsJsonArray();
for (JsonElement element : elements) { for (JsonElement element : elements) {
@ -82,14 +95,6 @@ public class RawAnimJson {
ride.addComponentAnimation(componentKey); ride.addComponentAnimation(componentKey);
} }
} }
Vec3 offset = new Vec3(
offsetJson.get("x").getAsDouble(),
offsetJson.get("y").getAsDouble(),
offsetJson.get("z").getAsDouble()
);
ride.withOffset(offset).withExistTick(withRide.get(ExistTick).getAsInt())
.withXRot(withRide.get(XRot).getAsFloat())
.withYRot(withRide.get(YRot).getAsFloat());
animation.withRide(ride); animation.withRide(ride);
} }
return animation; return animation;

View File

@ -6,6 +6,9 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -26,12 +29,17 @@ public record AnimationClearPacket(@Nullable ResourceLocation layer) {
NetworkEvent.Context context = supplier.get(); NetworkEvent.Context context = supplier.get();
context.enqueueWork(() -> { context.enqueueWork(() -> {
context.setPacketHandled(true); context.setPacketHandled(true);
LocalPlayer player = Minecraft.getInstance().player; DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::handle);
if(player == null) return;
List<ResourceLocation> layers = new ArrayList<>();
if(layer != null) layers.add(layer);
else layers.addAll(AnimationRegistry.getLayers().keySet());
layers.forEach(layer -> AnimationUtils.playAnimation(player, layer, null));
}); });
} }
@OnlyIn(Dist.CLIENT)
public void handle(){
LocalPlayer player = Minecraft.getInstance().player;
if(player == null) return;
List<ResourceLocation> layers = new ArrayList<>();
if(layer != null) layers.add(layer);
else layers.addAll(AnimationRegistry.getLayers().keySet());
layers.forEach(layer -> AnimationUtils.playAnimation(player, layer, null));
}
} }

View File

@ -2,7 +2,8 @@ package com.linearpast.sccore.mixin;
import com.linearpast.sccore.SnowyCrescentCore; import com.linearpast.sccore.SnowyCrescentCore;
import com.linearpast.sccore.animation.service.AnimationService; import com.linearpast.sccore.animation.service.AnimationService;
import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo; import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
@ -23,11 +24,13 @@ public class SCCoreMixinPlugin implements IMixinConfigPlugin {
@Override @Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (targetClassName.startsWith("runData\\.")) { if (targetClassName.startsWith("runData.")) {
return "runData".equals(System.getProperty("gradle.task")); return "runData".equals(System.getProperty("gradle.task"));
} }
if (mixinClassName.startsWith("com\\.linearpast\\." + SnowyCrescentCore.MODID + "\\.mixin\\.animation")) { if (mixinClassName.startsWith("com.linearpast." + SnowyCrescentCore.MODID + ".mixin.animation.")) {
return ModList.get().isLoaded(AnimationService.AnimModId); return LoadingModList.get().getMods().stream().map(ModInfo::getModId).anyMatch(
s -> s.equals(AnimationService.AnimModId)
);
} }
return true; return true;
} }