This commit is contained in:
ItsBlackGear 2022-08-24 22:03:33 -04:00
parent 71d03eb2d4
commit a8ea9d276c
11 changed files with 72 additions and 65 deletions

View file

@ -5,7 +5,7 @@ dependencies {
}
architectury {
common()
common("forge", "fabric")
}
loom {
@ -20,8 +20,5 @@ 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.
}
repositories {}
}

View file

@ -7,6 +7,10 @@ import net.minecraft.client.model.geom.PartPose;
//<>
public interface Animated {
static Animated of(ModelPart part) {
return Animated.class.cast(part);
}
static void translate(ModelPart part, Vector3f vec) {
part.x += vec.x();
part.y += vec.y();
@ -19,35 +23,35 @@ public interface Animated {
part.zRot += vec.z();
}
static void scale(ModelPart part, Vector3f vec) {
((Animated)(Object)part).increaseXScale(vec.x());
((Animated)(Object)part).increaseYScale(vec.y());
((Animated)(Object)part).increaseZScale(vec.z());
static void scaleY(ModelPart part, Vector3f vec) {
Animated.of(part).scaleXTo(vec.x());
Animated.of(part).scaleYTo(vec.y());
Animated.of(part).scaleZTo(vec.z());
}
PartPose getDefaultPose();
PartPose resetToDefault();
void setDefaultPose(PartPose pose);
void setDefault(PartPose pose);
static void resetPose(ModelPart part) {
part.loadPose(((Animated)(Object)part).getDefaultPose());
static void resetToDefault(ModelPart part) {
part.loadPose(Animated.of(part).resetToDefault());
}
float xScale();
float scaleX();
void setXScale(float x);
void scaleX(float x);
void increaseXScale(float x);
void scaleXTo(float x);
float yScale();
float scaleY();
void setYScale(float y);
void scaleY(float y);
void increaseYScale(float y);
void scaleYTo(float y);
float zScale();
float scaleZ();
void setZScale(float z);
void scaleZ(float z);
void increaseZScale(float z);
void scaleZTo(float z);
}

View file

@ -33,7 +33,7 @@ public record Transformation(Target target, Keyframe... keyframes) {
public static class Targets {
public static final Target TRANSLATE = Animated::translate;
public static final Target ROTATE = Animated::rotate;
public static final Target SCALE = Animated::scale;
public static final Target SCALE = Animated::scaleY;
}
public interface Interpolation {

View file

@ -52,7 +52,7 @@ public class AllayModel extends HierarchicalModel<Allay> implements ArmedModel {
@Override
public void setupAnim(Allay entity, float angle, float distance, float animationProgress, float yaw, float pitch) {
this.root().getAllParts().forEach(Animated::resetPose);
this.root().getAllParts().forEach(Animated::resetToDefault);
this.head.xRot = pitch * ((float)Math.PI / 180F);
this.head.yRot = yaw * ((float)Math.PI / 180F);
float f = animationProgress * 20.0F * ((float)Math.PI / 180F) + distance;

View file

@ -61,7 +61,7 @@ public class FrogModel<T extends Frog> extends AnimatedModel<T> {
@Override
public void setupAnim(T entity, float angle, float distance, float animationProgress, float yaw, float pitch) {
this.root.getAllParts().forEach(Animated::resetPose);
this.root.getAllParts().forEach(Animated::resetToDefault);
float speedMultiplier = Math.min((float)entity.getDeltaMovement().lengthSqr() * 200.0F, 8.0F);
this.animate(entity.longJumpingAnimationState, FrogAnimations.LONG_JUMPING, animationProgress);
this.animate(entity.croakingAnimationState, FrogAnimations.CROAKING, animationProgress);

View file

@ -75,7 +75,7 @@ public class WardenModel<T extends Warden> extends AnimatedModel<T> {
@Override
public void setupAnim(T entity, float angle, float distance, float animationProgress, float yaw, float pitch) {
this.root.getAllParts().forEach(Animated::resetPose);
this.root.getAllParts().forEach(Animated::resetToDefault);
float tickDelta = animationProgress - (float)entity.tickCount;
this.setHeadAngle(yaw, pitch);
this.setLimbAngles(angle, distance);

View file

@ -10,6 +10,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Unit;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.ai.Brain;
import net.minecraft.world.entity.ai.behavior.Behavior;
import net.minecraft.world.entity.ai.behavior.BehaviorUtils;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
@ -22,9 +23,10 @@ public class Roar extends Behavior<Warden> {
@Override
protected void start(ServerLevel level, Warden warden, long time) {
warden.getBrain().setMemoryWithExpiry(WBMemoryModules.ROAR_SOUND_DELAY.get(), Unit.INSTANCE, 25L);
warden.getBrain().eraseMemory(MemoryModuleType.WALK_TARGET);
LivingEntity target = warden.getBrain().getMemory(WBMemoryModules.ROAR_TARGET.get()).get();
Brain<Warden> brain = warden.getBrain();
brain.setMemoryWithExpiry(WBMemoryModules.ROAR_SOUND_DELAY.get(), Unit.INSTANCE, 25L);
brain.eraseMemory(MemoryModuleType.WALK_TARGET);
LivingEntity target = brain.getMemory(WBMemoryModules.ROAR_TARGET.get()).get();
BehaviorUtils.lookAtEntity(warden, target);
warden.setPose(Poses.ROARING.get());
warden.increaseAngerAt(target, 20, false);

View file

@ -27,40 +27,40 @@ public abstract class ModelPartMixin implements Animated, Drawable {
@Shadow @Final private Map<String, ModelPart> children;
@Shadow public abstract void translateAndRotate(PoseStack pose);
private float xScale = 1.0F;
private float yScale = 1.0F;
private float zScale = 1.0F;
private float scaleX = 1.0F;
private float scaleY = 1.0F;
private float scaleZ = 1.0F;
private PartPose defaultPose = PartPose.ZERO;
private boolean skipDraw;
@Override
public PartPose getDefaultPose() {
public PartPose resetToDefault() {
return this.defaultPose;
}
@Override
public void setDefaultPose(PartPose pose) {
public void setDefault(PartPose pose) {
this.defaultPose = pose;
}
@Inject(method = "loadPose", at = @At("TAIL"))
private void wb$load(PartPose pose, CallbackInfo ci) {
this.xScale = 1.0F;
this.yScale = 1.0F;
this.zScale = 1.0F;
this.scaleX = 1.0F;
this.scaleY = 1.0F;
this.scaleZ = 1.0F;
}
@Inject(method = "copyFrom", at = @At("TAIL"))
private void wb$copy(ModelPart part, CallbackInfo ci) {
this.setXScale(((Animated)(Object)part).xScale());
this.setYScale(((Animated)(Object)part).yScale());
this.setZScale(((Animated)(Object)part).zScale());
this.scaleX(Animated.of(part).scaleX());
this.scaleY(Animated.of(part).scaleY());
this.scaleZ(Animated.of(part).scaleZ());
}
@Inject(method = "translateAndRotate", at = @At("TAIL"))
private void wb$moveAndScale(PoseStack stack, CallbackInfo ci) {
if (this.xScale != 1.0F || this.yScale != 1.0F || this.zScale != 1.0F) {
stack.scale(this.xScale, this.yScale, this.zScale);
if (this.scaleX != 1.0F || this.scaleY != 1.0F || this.scaleZ != 1.0F) {
stack.scale(this.scaleX, this.scaleY, this.scaleZ);
}
}
@ -72,60 +72,59 @@ public abstract class ModelPartMixin implements Animated, Drawable {
pose.pushPose();
this.translateAndRotate(pose);
for (ModelPart part : this.children.values()) {
part.render(pose, consumer, light, delta, red, green, blue, alpha);
}
for (ModelPart part : this.children.values()) part.render(pose, consumer, light, delta, red, green, blue, alpha);
pose.popPose();
}
}
ci.cancel();
}
}
@Override
public float xScale() {
return this.xScale;
public float scaleX() {
return this.scaleX;
}
@Override
public void setXScale(float x) {
this.xScale = x;
public void scaleX(float x) {
this.scaleX = x;
}
@Override
public void increaseXScale(float x) {
this.xScale += x;
public void scaleXTo(float x) {
this.scaleX += x;
}
@Override
public float yScale() {
return this.yScale;
public float scaleY() {
return this.scaleY;
}
@Override
public void setYScale(float y) {
this.yScale = y;
public void scaleY(float y) {
this.scaleY = y;
}
@Override
public void increaseYScale(float y) {
this.yScale += y;
public void scaleYTo(float y) {
this.scaleY += y;
}
@Override
public float zScale() {
return this.zScale;
public float scaleZ() {
return this.scaleZ;
}
@Override
public void setZScale(float z) {
this.zScale = z;
public void scaleZ(float z) {
this.scaleZ = z;
}
@Override
public void increaseZScale(float z) {
this.zScale += z;
public void scaleZTo(float z) {
this.scaleZ += z;
}
@Override

View file

@ -17,7 +17,7 @@ public class PartDefinitionMixin {
@Inject(method = "bake", at = @At(value = "RETURN"), cancellable = true)
private void wb$bake(int i, int j, CallbackInfoReturnable<ModelPart> cir) {
((Animated)(Object)cir.getReturnValue()).setDefaultPose(this.partPose);
Animated.of(cir.getReturnValue()).setDefault(this.partPose);
cir.setReturnValue(cir.getReturnValue());
}
}

View file

@ -7,6 +7,10 @@ architectury {
fabric()
}
loom {
accessWidenerPath.set(project(":common").file("src/main/resources/wildbackport.accesswidener"))
}
configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
@ -60,6 +64,7 @@ sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
from commonSources.archiveFile.map { zipTree(it) }
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
components.java {

View file

@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
minecraft_version=1.18.2
archives_base_name=wildbackport
mod_version=1.0.0