Skip to content

Commit

Permalink
Hamster ball basic movement (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sydokiddo committed Nov 13, 2024
1 parent 051ac65 commit f8e9700
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.DefaultedEntityGeoModel;

import static com.starfish_studios.hamsters.HamstersConfig.*;

@Environment(EnvType.CLIENT)
Expand Down Expand Up @@ -72,10 +71,7 @@ public void setCustomAnimations(HamsterNew animatable, long instanceId, Animatio
cheeks.setScaleZ(1.0F);
}

if (hamstersBurst) {
if (animatable.getCheekLevel() > 1)
root.setRotZ((float) Math.sin(System.currentTimeMillis() * 0.05) * 0.1F * (animatable.getCheekLevel() * 0.05F));
}
if (hamstersBurst && animatable.getCheekLevel() > 1) root.setRotZ((float) Math.sin(System.currentTimeMillis() * 0.05) * 0.1F * (animatable.getCheekLevel() * 0.05F));

// Ensures there are no strange eye glitches when the hamster is sleeping or awake.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public void render(@NotNull HamsterBall animatable, float entityYaw, float parti

@Override
protected void applyRotations(HamsterBall animatable, PoseStack poseStack, float ageInTicks, float rotationYaw, float partialTick) {
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F - rotationYaw));
float hitRotation = (float) (animatable.level().getGameTime() - animatable.lastHit) + partialTick;
if (hitRotation < 5.0F) poseStack.mulPose(Axis.YP.rotationDegrees(Mth.sin(hitRotation / 1.5F * (float) Math.PI) * 5.0F).normalize());
super.applyRotations(animatable, poseStack, ageInTicks, rotationYaw, partialTick);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,29 @@ public void handleEntityEvent(byte entityEvent) {
// region Movement

@Override
public void travel(@NotNull Vec3 vec3) {
if (this.onGround()) this.setDeltaMovement(this.getDeltaMovement().multiply(1.2D, 1.0D, 1.2D));
super.travel(vec3);
public void tick() {

super.tick();

Vec3 movement = this.getDeltaMovement();
if (movement.horizontalDistance() > 0) this.setXRot(this.getXRot() + 0.1F);
}

@Override
protected @NotNull Vec3 getRiddenInput(@NotNull Player player, @NotNull Vec3 vec3) {
return new Vec3(0.0D, 0.0D, 1.0D);
public void travel(@NotNull Vec3 vec3) {
if (!this.isInWater()) {

float friction = 0.98F;
float frictionMultiplier = this.onGround() ? friction * 0.9F : 0.9F;
Vec3 movement = this.handleRelativeFrictionAndCalculateMovement(vec3, friction);

double y = movement.y();
if (!this.level().isClientSide() && !this.isNoGravity()) y -= 0.08D;
this.setDeltaMovement(movement.x() * (double) frictionMultiplier, y * (double) 0.98F, movement.z() * (double) frictionMultiplier);

} else {
super.travel(vec3);
}
}

@Override
Expand Down

0 comments on commit f8e9700

Please sign in to comment.