Skip to content

Commit

Permalink
Merge pull request #825 from devs-immortal/bladechanges
Browse files Browse the repository at this point in the history
New moa sounds + improved takeoff/flying animation
  • Loading branch information
MBatt1 authored Nov 1, 2024
2 parents 803aa41 + 59d6167 commit 5575d1f
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import net.id.paradiselost.component.MoaGenes;

public enum MoaAttributes {
GROUND_SPEED(0.24F, 1F, 0.1F),
GLIDING_SPEED(0.055F, 0.25F, 0.03F),
GROUND_SPEED(0.24F, 0.8F, 0.1F),
GLIDING_SPEED(0.07F, 0.25F, 0.03F),
GLIDING_DECAY(0.5F, 0.9F, 0.06F),
JUMPING_STRENGTH(0.15F, 0.25F, 0.02F),
JUMPING_STRENGTH(0.18F, 0.28F, 0.02F),
DROP_MULTIPLIER(1, 6, 1),
MAX_HEALTH(10, 40, 5);

Expand Down
106 changes: 94 additions & 12 deletions src/main/java/net/id/paradiselost/entities/passive/moa/MoaEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,25 @@ protected void dropInventory() {
setChest(ItemStack.EMPTY);
}
}


float wingFlapSpeed = 2.5f;

public float getWingRoll() {
if (!isGliding()) {
if (dataTracker.get(AIR_TICKS) <= 1)
{
float baseWingRoll = 1.39626F;

float lDif = -baseWingRoll - curWingRoll;
if (Math.abs(lDif) > 0.005F) {

if (Math.abs(lDif) > 0.005F)
{
curWingRoll += lDif / 6;
}
} else {
curWingRoll = (MathHelper.sin(age / 1.75F) * 0.725F + 0.1F);
}
else
{
curWingRoll = (MathHelper.sin(age / wingFlapSpeed) * 0.73F + 0.1F);
}

return curWingRoll;
}

Expand All @@ -226,6 +233,70 @@ public float getLegPitch() {
return curLegPitch;
}


int moaSoundCallCooldown;
private float soundChance = 0;
private float songChance = 0;
public void attemptMoaSound()
{

if (random.nextFloat() < 0.2f + soundChance)
{
//Small chirp
if (this.random.nextFloat() > 0.05f + songChance)
{
moaSoundCallCooldown = 80 + random.nextInt(45);
songChance += 0.01f;
this.getWorld().playSound(null, this.getX(), this.getY(), this.getZ(),
ParadiseLostSoundEvents.ENTITY_MOA_AMBIENT, SoundCategory.NEUTRAL,
MathHelper.clamp(this.random.nextFloat(), 0.25f, 0.5f),
MathHelper.clamp(this.random.nextFloat(), 0.80f, 1.25f) +
MathHelper.clamp(this.random.nextFloat(), -0.3f, .3f));


}
//Little song
else
{


//So it doesn't get annoying
moaSoundCallCooldown = 200 + random.nextInt(25);
songChance = 0;

this.getWorld().playSound(null, this.getX(), this.getY(), this.getZ(),
ParadiseLostSoundEvents.ENTITY_MOA_AMBIENT_SING, SoundCategory.NEUTRAL,
MathHelper.clamp(this.random.nextFloat(), 0.5f, 0.6f),
MathHelper.clamp(this.random.nextFloat(), .85f, 1.15f) +
MathHelper.clamp(this.random.nextFloat(), 0f, .1f));
}
}
else
{
moaSoundCallCooldown = 40 + random.nextInt(30);
soundChance += 0.01f;
}
}
private boolean canFlap = true;
public void attemptMoaFlap()
{
float timeToFlap = getWingRoll();



if (getWingRoll() > 0.8 && canFlap)
{

this.getWorld().playSound(null, this.getX(), this.getY(), this.getZ(),
ParadiseLostSoundEvents.ENTITY_MOA_GLIDING, SoundCategory.NEUTRAL, 0.6F,
MathHelper.clamp(this.random.nextFloat(), 0.9f, 1.1f) + MathHelper.clamp(this.random.nextFloat(), -0.2f, 0.2f));

canFlap = false;
}
else if (getWingRoll() < -0.3f) {canFlap = true;}
}


public int getRandomEggTime() {
return 775 + this.random.nextInt(50);
}
Expand All @@ -247,14 +318,23 @@ public void tick() {
dataTracker.set(AIR_TICKS, 0);
}

if (age % 15 == 0) {
if (isGliding()) {
this.getWorld().playSound(null, this.getX(), this.getY(), this.getZ(), ParadiseLostSoundEvents.ENTITY_MOA_GLIDING, SoundCategory.NEUTRAL, 4.5F, MathHelper.clamp(this.random.nextFloat(), 0.85f, 1.2f) + MathHelper.clamp(this.random.nextFloat(), 0f, 0.35f));
} else if (random.nextFloat() < 0.057334F) {
this.getWorld().playSound(null, this.getX(), this.getY(), this.getZ(), ParadiseLostSoundEvents.ENTITY_MOA_AMBIENT, SoundCategory.NEUTRAL, 1.5F + random.nextFloat() * 2, MathHelper.clamp(this.random.nextFloat(), 0.55f, 0.7f) + MathHelper.clamp(this.random.nextFloat(), 0f, 0.25f));
}

//Ambient audio calling
if (moaSoundCallCooldown > 0)
{
moaSoundCallCooldown--;
}
else
{
attemptMoaSound();
}

if (isInAir)
{
attemptMoaFlap();
}


if (this.jumping) {
this.setVelocity(this.getVelocity().add(0.0D, 0.05D, 0.0D));
}
Expand All @@ -276,6 +356,8 @@ public void tick() {
heal(1);
genes.setHunger(hunger - 0.5F);
}

///Unused?
if (hunger < 20F && getWorld().getTime() % 10 == 0) {
produceParticlesServer(ParticleTypes.ANGRY_VILLAGER, random.nextInt(3), 1, 0);
if (hunger < 10F && hasPassengers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public final class ParadiseLostSoundEvents {


public static final SoundEvent ENTITY_MOA_AMBIENT = register("entity.moa.ambient");
public static final SoundEvent ENTITY_MOA_AMBIENT_SING = register("entity.moa.ambient.sing");
public static final SoundEvent ENTITY_MOA_GLIDING = register("entity.moa.gliding");
public static final SoundEvent ENTITY_MOA_DEATH = register("entity.moa.death");
public static final SoundEvent ENTITY_MOA_HURT = register("entity.moa.hurt");
public static final SoundEvent ENTITY_MOA_EAT = register("entity.moa.eat");
public static final SoundEvent ENTITY_MOA_LAY_EGG = register("entity.moa.lay_egg");
public static final SoundEvent ENTITY_MOA_EGG_HATCH = register("entity.moa.egg_hatch");
public static final SoundEvent ENTITY_MOA_STEP = register("entity.moa.step");

public static final SoundEvent ENTITY_NITRA_THROW = register("entity.nitra.throw");
public static final SoundEvent ENTITY_ENVOY_DAMAGE = register("entity.envoy.damage");

Expand Down
40 changes: 28 additions & 12 deletions src/main/resources/assets/paradise_lost/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
],
"subtitle": "subtitles.paradise_lost.block.blackcurrant_bush.pick_blueberries"
},




"block.portal.ambient": {
"sounds": [
"paradise_lost:block/portal/ambient"
Expand All @@ -27,7 +29,9 @@
],
"subtitle": "subtitles.paradise_lost.block.portal.trigger"
},




"block.surtrum_air.rush": {
"sounds": [
{
Expand Down Expand Up @@ -83,22 +87,32 @@
],
"subtitle": "subtitles.paradise_lost.item.bloodstone.prick"
},




"entity.moa.ambient": {
"sounds": [
{
"name": "entity.parrot.ambient",
"type": "event"
}
"paradise_lost:entity/passive/moa/moaambient1",
"paradise_lost:entity/passive/moa/moaambient2"
],
"subtitle": "subtitles.paradise_lost.entity.moa.ambient"
},

"entity.moa.ambient.sing": {
"sounds": [
"paradise_lost:entity/passive/moa/moaambient3",
"paradise_lost:entity/passive/moa/moaambient4",
"paradise_lost:entity/passive/moa/moaambient5",
"paradise_lost:entity/passive/moa/moaambient6"
],
"subtitle": "subtitles.paradise_lost.entity.moa.ambient"
},
"entity.moa.gliding": {
"sounds": [
{
"name": "entity.phantom.flap",
"type": "event"
}
"paradise_lost:entity/passive/moa/moaflap1",
"paradise_lost:entity/passive/moa/moaflap3",
"paradise_lost:entity/passive/moa/moaflap4",
"paradise_lost:entity/passive/moa/moaflap5"
],
"subtitle": "subtitles.paradise_lost.entity.moa.gliding"
},
Expand Down Expand Up @@ -174,7 +188,9 @@
],
"subtitle": "subtitles.paradise_lost.entity.envoy.damage"
},




"music.paradise": {
"sounds": [
{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 5575d1f

Please sign in to comment.