From 21f3acba860ca7db33b6d4e6d1e98a0f68c7a4e6 Mon Sep 17 00:00:00 2001 From: TGGamesYT Date: Tue, 24 Feb 2026 18:30:55 +0100 Subject: [PATCH] idfk --- gradle.properties | 2 +- .../szar/client/CustomModelAnimation.java.nuh | 65 +++++++++++++ .../tggamesyt/szar/client/KidRenderer.java | 4 +- .../szar/client/NaziEntityRenderer.java | 47 +++++++++- .../szar/client/PlayerAnimations.java | 93 +++++++++++++++++++ .../szar/client/PlayerModelAdapter.java | 48 ++++++++++ .../dev/tggamesyt/szar/client/SzarClient.java | 5 +- .../szar/client/mixin/PlayerModelMixin.java | 2 + .../java/dev/tggamesyt/szar/NaziEntity.java | 55 ++++++++++- src/main/java/dev/tggamesyt/szar/Szar.java | 1 + 10 files changed, 311 insertions(+), 11 deletions(-) create mode 100644 src/client/java/dev/tggamesyt/szar/client/CustomModelAnimation.java.nuh create mode 100644 src/client/java/dev/tggamesyt/szar/client/PlayerAnimations.java create mode 100644 src/client/java/dev/tggamesyt/szar/client/PlayerModelAdapter.java diff --git a/gradle.properties b/gradle.properties index 7d7dc70..c5c25c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.18.3 # Mod Properties -mod_version=26.2.24 +mod_version=26.2.24.1 maven_group=dev.tggamesyt archives_base_name=szar # Dependencies diff --git a/src/client/java/dev/tggamesyt/szar/client/CustomModelAnimation.java.nuh b/src/client/java/dev/tggamesyt/szar/client/CustomModelAnimation.java.nuh new file mode 100644 index 0000000..5aa0f7a --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/CustomModelAnimation.java.nuh @@ -0,0 +1,65 @@ +// Save this class in your mod and generate all required imports +package dev.tggamesyt.szar.client; +import net.minecraft.client.render.entity.animation.Keyframe; + +/** + * Made with Blockbench 5.0.7 + * Exported for Minecraft version 1.19 or later with Mojang mappings + * @author Author + */ +public class CustomModelAnimation { + public static final AnimationDefinition hithand = AnimationDefinition.Builder.withLength(1.0F) + .addAnimation("LeftArm", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.1667F, KeyframeAnimations.degreeVec(-150.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.75F, KeyframeAnimations.degreeVec(-150.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .build(); + + public static final AnimationDefinition flip = AnimationDefinition.Builder.withLength(1.25F) + .addAnimation("Waist", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.5833F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.7917F, KeyframeAnimations.degreeVec(-180.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(-355.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.25F, KeyframeAnimations.degreeVec(-360.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .addAnimation("Waist", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.25F, KeyframeAnimations.posVec(0.0F, -1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.4167F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.125F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .addAnimation("RightLeg", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.5833F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.7917F, KeyframeAnimations.degreeVec(-180.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(-355.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.25F, KeyframeAnimations.degreeVec(-360.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .addAnimation("RightLeg", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.25F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.4167F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.5833F, KeyframeAnimations.posVec(0.0F, 8.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.7917F, KeyframeAnimations.posVec(0.0F, 8.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, 3.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.125F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .addAnimation("LeftLeg", new AnimationChannel(AnimationChannel.Targets.ROTATION, + new Keyframe(0.0F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.5833F, KeyframeAnimations.degreeVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.7917F, KeyframeAnimations.degreeVec(-180.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0F, KeyframeAnimations.degreeVec(-360.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .addAnimation("LeftLeg", new AnimationChannel(AnimationChannel.Targets.POSITION, + new Keyframe(0.0F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.25F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.4167F, KeyframeAnimations.posVec(0.0F, 1.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(0.5833F, KeyframeAnimations.posVec(0.0F, 9.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.0F, KeyframeAnimations.posVec(0.0F, 3.0F, 0.0F), AnimationChannel.Interpolations.LINEAR), + new Keyframe(1.125F, KeyframeAnimations.posVec(0.0F, 0.0F, 0.0F), AnimationChannel.Interpolations.LINEAR) + )) + .build(); +} \ No newline at end of file diff --git a/src/client/java/dev/tggamesyt/szar/client/KidRenderer.java b/src/client/java/dev/tggamesyt/szar/client/KidRenderer.java index ce3f61e..a3c9849 100644 --- a/src/client/java/dev/tggamesyt/szar/client/KidRenderer.java +++ b/src/client/java/dev/tggamesyt/szar/client/KidRenderer.java @@ -5,6 +5,7 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.MobEntityRenderer; +import net.minecraft.client.render.entity.animation.Animation; import net.minecraft.client.render.entity.model.EntityModelLayers; import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.client.util.math.MatrixStack; @@ -16,7 +17,8 @@ public class KidRenderer extends MobEntityRenderer(ctx.getPart(EntityModelLayers.PLAYER), false), diff --git a/src/client/java/dev/tggamesyt/szar/client/NaziEntityRenderer.java b/src/client/java/dev/tggamesyt/szar/client/NaziEntityRenderer.java index ba591e4..d2cac88 100644 --- a/src/client/java/dev/tggamesyt/szar/client/NaziEntityRenderer.java +++ b/src/client/java/dev/tggamesyt/szar/client/NaziEntityRenderer.java @@ -1,34 +1,75 @@ package dev.tggamesyt.szar.client; import dev.tggamesyt.szar.NaziEntity; +import dev.tggamesyt.szar.client.mixin.PlayerModelMixin; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.MobEntityRenderer; +import net.minecraft.client.render.entity.animation.AnimationHelper; import net.minecraft.client.render.entity.feature.HeldItemFeatureRenderer; import net.minecraft.client.render.entity.model.BipedEntityModel; -import net.minecraft.client.render.entity.model.EntityModelLayers; import net.minecraft.client.render.entity.model.PlayerEntityModel; +import net.minecraft.client.render.entity.model.EntityModelLayers; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.LivingEntity; import net.minecraft.util.Identifier; +import org.joml.Vector3f; + +import java.util.Random; public class NaziEntityRenderer extends MobEntityRenderer> { + private final Vector3f tempVec = new Vector3f(); + final PlayerModelAdapter adapter; + public NaziEntityRenderer(EntityRendererFactory.Context context) { + super( context, new PlayerEntityModel<>(context.getPart(EntityModelLayers.PLAYER), false), 0.5F ); + PlayerEntityModel base = (PlayerEntityModel) this.getModel(); + + PlayerModelAdapter a = new PlayerModelAdapter<>(base); + a.setRoot(context.getPart(EntityModelLayers.PLAYER)); + this.adapter = a; + this.addFeature(new HeldItemFeatureRenderer<>( this, context.getHeldItemRenderer() )); } - @Override public Identifier getTexture(NaziEntity entity) { return new Identifier("szar", "textures/entity/nazi.png"); } -} + @Override + public void render(NaziEntity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { + + // ehh this shit doesnt work + + final Vector3f tempVec = new Vector3f(); + // Check if the entity is currently playing the hand animation + if (entity.isPlayingHandAnim()) { + // Apply the hand animation directly from PlayerAnimations + long elapsedMillis = (long)(entity.getAnimationProgress() * 1000f); + AnimationHelper.animate( + adapter, + PlayerAnimations.hithand, + elapsedMillis, + 1.0F, + tempVec + ); + } + + super.render(entity, yaw, tickDelta, matrices, vertexConsumers, light); + } +} \ No newline at end of file diff --git a/src/client/java/dev/tggamesyt/szar/client/PlayerAnimations.java b/src/client/java/dev/tggamesyt/szar/client/PlayerAnimations.java new file mode 100644 index 0000000..b4b3c37 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/PlayerAnimations.java @@ -0,0 +1,93 @@ +package dev.tggamesyt.szar.client; +import net.minecraft.client.render.entity.animation.Animation; +import net.minecraft.client.render.entity.animation.AnimationHelper; +import net.minecraft.client.render.entity.animation.Keyframe; +import net.minecraft.client.render.entity.animation.Transformation; + +/** + * Converted from Blockbench 5.0.7 custom animation format to Minecraft Animation API. + * Exported for Minecraft 1.19+ with Yarn mappings + * Author: Original Author + */ + +public class PlayerAnimations { + + public static final Animation hithand = Animation.Builder.create(1.0F) + .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.1667F, AnimationHelper.createRotationalVector(-150.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.75F, AnimationHelper.createRotationalVector(-150.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .build(); + + public static final Animation flip = Animation.Builder.create(1.25F) + // Waist = head + body + arms + .addBoneAnimation("body", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createRotationalVector(-180.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(-355.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.25F, AnimationHelper.createRotationalVector(-360.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .addBoneAnimation("head", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createRotationalVector(-180.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(-355.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.25F, AnimationHelper.createRotationalVector(-360.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .addBoneAnimation("left_arm", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createRotationalVector(-180.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(-355.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.25F, AnimationHelper.createRotationalVector(-360.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .addBoneAnimation("right_arm", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createRotationalVector(-180.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(-355.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.25F, AnimationHelper.createRotationalVector(-360.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + // Body translation (jump/lift) + .addBoneAnimation("body", new Transformation(Transformation.Targets.TRANSLATE, + new Keyframe(0.0F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.25F, AnimationHelper.createTranslationalVector(0.0F, -1.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.4167F, AnimationHelper.createTranslationalVector(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.125F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + // Legs + .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createRotationalVector(-180.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(-355.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.25F, AnimationHelper.createRotationalVector(-360.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .addBoneAnimation("right_leg", new Transformation(Transformation.Targets.TRANSLATE, + new Keyframe(0.0F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.25F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.4167F, AnimationHelper.createTranslationalVector(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createTranslationalVector(0.0F, 8.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createTranslationalVector(0.0F, 8.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createTranslationalVector(0.0F, 3.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.125F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.ROTATE, + new Keyframe(0.0F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createRotationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.7917F, AnimationHelper.createRotationalVector(-180.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createRotationalVector(-360.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .addBoneAnimation("left_leg", new Transformation(Transformation.Targets.TRANSLATE, + new Keyframe(0.0F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.25F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.4167F, AnimationHelper.createTranslationalVector(0.0F, 1.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(0.5833F, AnimationHelper.createTranslationalVector(0.0F, 9.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.0F, AnimationHelper.createTranslationalVector(0.0F, 3.0F, 0.0F), Transformation.Interpolations.LINEAR), + new Keyframe(1.125F, AnimationHelper.createTranslationalVector(0.0F, 0.0F, 0.0F), Transformation.Interpolations.LINEAR) + )) + .build(); +} \ No newline at end of file diff --git a/src/client/java/dev/tggamesyt/szar/client/PlayerModelAdapter.java b/src/client/java/dev/tggamesyt/szar/client/PlayerModelAdapter.java new file mode 100644 index 0000000..c511fa1 --- /dev/null +++ b/src/client/java/dev/tggamesyt/szar/client/PlayerModelAdapter.java @@ -0,0 +1,48 @@ +package dev.tggamesyt.szar.client; + +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.entity.model.PlayerEntityModel; +import net.minecraft.client.render.entity.model.SinglePartEntityModel; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; + +import java.util.Optional; + +public class PlayerModelAdapter + extends SinglePartEntityModel { + public ModelPart root; + private final PlayerEntityModel playerModel; + + public PlayerModelAdapter(PlayerEntityModel playerModel) { + this.playerModel = playerModel; + } + + @Override + public ModelPart getPart() { + return root; + } + + public void setRoot(ModelPart root) { + this.root = root; + } + + @Override + public Optional getChild(String name) { + return switch (name) { + case "head" -> Optional.of(playerModel.head); + case "body" -> Optional.of(playerModel.body); + case "left_arm" -> Optional.of(playerModel.leftArm); + case "right_arm" -> Optional.of(playerModel.rightArm); + case "left_leg" -> Optional.of(playerModel.leftLeg); + case "right_leg" -> Optional.of(playerModel.rightLeg); + default -> Optional.empty(); + }; + } + + @Override + public void setAngles(T entity, float limbSwing, float limbSwingAmount, + float ageInTicks, float netHeadYaw, float headPitch) { + playerModel.setAngles(entity, limbSwing, limbSwingAmount, + ageInTicks, netHeadYaw, headPitch); + } +} \ No newline at end of file diff --git a/src/client/java/dev/tggamesyt/szar/client/SzarClient.java b/src/client/java/dev/tggamesyt/szar/client/SzarClient.java index ccb7273..473871f 100644 --- a/src/client/java/dev/tggamesyt/szar/client/SzarClient.java +++ b/src/client/java/dev/tggamesyt/szar/client/SzarClient.java @@ -1,10 +1,7 @@ package dev.tggamesyt.szar.client; import com.mojang.blaze3d.systems.RenderSystem; -import dev.tggamesyt.szar.NyanEntity; -import dev.tggamesyt.szar.PlaneEntity; -import dev.tggamesyt.szar.Szar; -import dev.tggamesyt.szar.PlaneAnimation; +import dev.tggamesyt.szar.*; import dev.tggamesyt.szar.ServerCosmetics.NameType; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap; diff --git a/src/client/java/dev/tggamesyt/szar/client/mixin/PlayerModelMixin.java b/src/client/java/dev/tggamesyt/szar/client/mixin/PlayerModelMixin.java index d401510..071829d 100644 --- a/src/client/java/dev/tggamesyt/szar/client/mixin/PlayerModelMixin.java +++ b/src/client/java/dev/tggamesyt/szar/client/mixin/PlayerModelMixin.java @@ -1,11 +1,13 @@ package dev.tggamesyt.szar.client.mixin; import dev.tggamesyt.szar.Szar; +import net.minecraft.client.model.ModelPart; import net.minecraft.client.render.entity.model.PlayerEntityModel; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffectInstance; import net.minecraft.entity.player.PlayerEntity; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; diff --git a/src/main/java/dev/tggamesyt/szar/NaziEntity.java b/src/main/java/dev/tggamesyt/szar/NaziEntity.java index 2794ed3..d4de862 100644 --- a/src/main/java/dev/tggamesyt/szar/NaziEntity.java +++ b/src/main/java/dev/tggamesyt/szar/NaziEntity.java @@ -2,8 +2,6 @@ package dev.tggamesyt.szar; import net.minecraft.entity.EntityType; import net.minecraft.entity.EquipmentSlot; -import net.minecraft.entity.ai.goal.LookAroundGoal; -import net.minecraft.entity.ai.goal.MeleeAttackGoal; import net.minecraft.entity.ai.goal.WanderAroundFarGoal; import net.minecraft.entity.attribute.DefaultAttributeContainer; import net.minecraft.entity.attribute.EntityAttributes; @@ -20,6 +18,59 @@ import org.jetbrains.annotations.Nullable; public class NaziEntity extends PathAwareEntity implements Arrestable{ + private boolean hithandPlaying = false; + private int hithandTimer = 0; // ticks remaining + private float hithandProgress = 0f; // 0 → 1 over animation duration + private int hithandCooldown = 0; // ticks remaining before we can roll again + // Call this to start the hand animation + public void playHithandAnimation() { + this.hithandPlaying = true; + this.hithandTimer = 20; // 20 ticks = 1 second + this.hithandProgress = 0f; + } + + // Whether the animation is currently playing + public boolean isPlayingHandAnim() { + return hithandPlaying; + } + + // Current animation progress (0 → 1) + public float getAnimationProgress() { + return hithandProgress; + } + + @Override + public void tick() { + super.tick(); + + // --- Handle animation playing --- + if (hithandPlaying) { + hithandTimer--; + hithandProgress = (float)(20 - hithandTimer) / 20f; + + if (hithandTimer <= 0) { + hithandPlaying = false; + hithandProgress = 0f; + + // Start 2 second cooldown (40 ticks) + hithandCooldown = 40; + } + return; // don't roll while animating + } + + // --- Handle cooldown --- + if (hithandCooldown > 0) { + hithandCooldown--; + return; // don't roll during cooldown + } + + // --- Random roll --- + // 1/200 chance per tick ≈ once every 10 seconds on average + if (this.random.nextFloat() < 0.005f) { + playHithandAnimation(); + } + } + public static boolean arrestable = false; @Nullable private HitterEntity leader; diff --git a/src/main/java/dev/tggamesyt/szar/Szar.java b/src/main/java/dev/tggamesyt/szar/Szar.java index f19d19f..669d521 100644 --- a/src/main/java/dev/tggamesyt/szar/Szar.java +++ b/src/main/java/dev/tggamesyt/szar/Szar.java @@ -86,6 +86,7 @@ public class Szar implements ModInitializer { SoundEvent.of(new Identifier("szar", "merl")); public static final Identifier PLANE_ANIM_PACKET = new Identifier(MOD_ID, "plane_anim"); + public static final Identifier NAZI_HAND_GESTURE = new Identifier("szar", "hit_hand"); public static final Identifier OPEN_URL = new Identifier(MOD_ID, "epsteinfiles"); public static final Block SZAR_BLOCK =