Commit 046084f0 by Jonathan Thomas

Adding burst of heart particles for max friendship/enemy + sound effects.

parent c2711ecc
Pipeline #12873 passed with stages
in 1 minute 59 seconds
...@@ -8,6 +8,7 @@ All notable changes to **CreatureChat** are documented in this file. The format ...@@ -8,6 +8,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Added ### Added
- New friendship particles (hearts + fire) to indicate when friendship changes - New friendship particles (hearts + fire) to indicate when friendship changes
- Added sound effects for max friendship and max enemy
### Changed ### Changed
- Entity chat data now separates messages and friendship by player - Entity chat data now separates messages and friendship by player
......
...@@ -5,8 +5,8 @@ import net.minecraft.client.particle.SpriteBillboardParticle; ...@@ -5,8 +5,8 @@ import net.minecraft.client.particle.SpriteBillboardParticle;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
public class CreatureParticle extends SpriteBillboardParticle { public class BehaviorParticle extends SpriteBillboardParticle {
protected CreatureParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { protected BehaviorParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
super(world, x, y, z, velocityX, velocityY, velocityZ); super(world, x, y, z, velocityX, velocityY, velocityZ);
this.scale(2f); this.scale(2f);
this.setMaxAge(35); this.setMaxAge(35);
...@@ -15,6 +15,7 @@ public class CreatureParticle extends SpriteBillboardParticle { ...@@ -15,6 +15,7 @@ public class CreatureParticle extends SpriteBillboardParticle {
this.velocityY = 0.1; this.velocityY = 0.1;
this.velocityX *= 0.1; this.velocityX *= 0.1;
this.velocityZ *= 0.1; this.velocityZ *= 0.1;
this.collidesWithWorld = false;
} }
@Override @Override
......
...@@ -13,8 +13,8 @@ public class CreatureParticleFactory implements ParticleFactory<DefaultParticleT ...@@ -13,8 +13,8 @@ public class CreatureParticleFactory implements ParticleFactory<DefaultParticleT
} }
@Override @Override
public CreatureParticle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) { public BehaviorParticle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ) {
CreatureParticle particle = new CreatureParticle(world, x, y, z, velocityX, velocityY, velocityZ); BehaviorParticle particle = new BehaviorParticle(world, x, y, z, velocityX, velocityY, velocityZ);
particle.setSprite(this.spriteProvider); particle.setSprite(this.spriteProvider);
return particle; return particle;
} }
......
...@@ -397,13 +397,24 @@ public class EntityChatData { ...@@ -397,13 +397,24 @@ public class EntityChatData {
} }
} }
// Show particles // Emit friendship particles
if (playerData.friendship != new_friendship) { if (playerData.friendship != new_friendship) {
int friendDiff = new_friendship - playerData.friendship; int friendDiff = new_friendship - playerData.friendship;
if (friendDiff > 0) { if (friendDiff > 0) {
ParticleEmitter.emitCreatureParticle((ServerWorld) entity.getWorld(), entity, HEART_SMALL_PARTICLE); // Heart particles
if (new_friendship == 3) {
ParticleEmitter.emitCreatureParticle((ServerWorld) entity.getWorld(), entity, HEART_BIG_PARTICLE, 0.5, 10);
} else {
ParticleEmitter.emitCreatureParticle((ServerWorld) entity.getWorld(), entity, HEART_SMALL_PARTICLE, 0.1, 1);
}
} else if (friendDiff < 0) { } else if (friendDiff < 0) {
ParticleEmitter.emitCreatureParticle((ServerWorld) entity.getWorld(), entity, FIRE_SMALL_PARTICLE); // Fire particles
if (new_friendship == -3) {
ParticleEmitter.emitCreatureParticle((ServerWorld) entity.getWorld(), entity, FIRE_BIG_PARTICLE, 0.5, 10);
} else {
ParticleEmitter.emitCreatureParticle((ServerWorld) entity.getWorld(), entity, FIRE_SMALL_PARTICLE, 0.1, 1);
}
} }
} }
......
package com.owlmaddie.particle; package com.owlmaddie.particle;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.particle.DefaultParticleType;
import static com.owlmaddie.network.ServerPackets.FIRE_BIG_PARTICLE;
import static com.owlmaddie.network.ServerPackets.HEART_BIG_PARTICLE;
public class ParticleEmitter { public class ParticleEmitter {
public static void emitCreatureParticle(ServerWorld world, Entity entity, DefaultParticleType particleType) { public static void emitCreatureParticle(ServerWorld world, Entity entity, DefaultParticleType particleType, double spawnSize, int count) {
// Calculate the offset for the particle to appear above and in front of the entity // Calculate the offset for the particle to appear above and in front of the entity
float yaw = entity.getHeadYaw(); float yaw = entity.getHeadYaw();
double offsetX = -MathHelper.sin(yaw * ((float) Math.PI / 180F)) * 0.9; double offsetX = -MathHelper.sin(yaw * ((float) Math.PI / 180F)) * 0.9;
...@@ -20,6 +25,13 @@ public class ParticleEmitter { ...@@ -20,6 +25,13 @@ public class ParticleEmitter {
double z = entity.getZ() + offsetZ; double z = entity.getZ() + offsetZ;
// Emit the custom particle on the server // Emit the custom particle on the server
world.spawnParticles(particleType, x, y, z, 1, 0, 0, 0, 0); world.spawnParticles(particleType, x, y, z, count, spawnSize, spawnSize, spawnSize, 0.1F);
// Play sound when lots of hearts are emitted
if (particleType.equals(HEART_BIG_PARTICLE) && count > 1) {
world.playSound(entity, entity.getBlockPos(), SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 0.4F, 1.0F);
} else if (particleType.equals(FIRE_BIG_PARTICLE) && count > 1) {
world.playSound(entity, entity.getBlockPos(), SoundEvents.ITEM_AXE_STRIP, SoundCategory.PLAYERS, 0.8F, 1.0F);
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment