mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 23:27:59 +01:00
Add particle effects and sound effects when adding/removing the wings of icarus
This commit is contained in:
parent
f8e19cc17a
commit
1992a1fd53
3 changed files with 31 additions and 17 deletions
|
@ -2,11 +2,11 @@ package com.minelittlepony.unicopia;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
|
||||||
public enum FlightType {
|
public enum FlightType {
|
||||||
NONE,
|
NONE,
|
||||||
CREATIVE,
|
|
||||||
AVIAN,
|
AVIAN,
|
||||||
INSECTOID,
|
INSECTOID,
|
||||||
ARTIFICIAL;
|
ARTIFICIAL;
|
||||||
|
@ -27,12 +27,8 @@ public enum FlightType {
|
||||||
return !isGrounded();
|
return !isGrounded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canFlyCreative() {
|
public boolean canFlyCreative(PlayerEntity player) {
|
||||||
return this == CREATIVE || this == INSECTOID;
|
return this == INSECTOID || player.isCreative() || player.isSpectator();
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canFlySurvival() {
|
|
||||||
return canFly() && !canFlyCreative();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SoundEvent getWingFlapSound() {
|
public SoundEvent getWingFlapSound() {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.minelittlepony.unicopia.entity.player.MagicReserves.Bar;
|
||||||
import com.minelittlepony.unicopia.item.AmuletItem;
|
import com.minelittlepony.unicopia.item.AmuletItem;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
||||||
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
|
import com.minelittlepony.unicopia.projectile.ProjectileUtil;
|
||||||
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
import com.minelittlepony.unicopia.util.NbtSerialisable;
|
||||||
import com.minelittlepony.unicopia.util.MutableVector;
|
import com.minelittlepony.unicopia.util.MutableVector;
|
||||||
|
@ -30,6 +31,7 @@ import net.minecraft.entity.damage.DamageSource;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.util.Tickable;
|
import net.minecraft.util.Tickable;
|
||||||
|
@ -43,7 +45,7 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
||||||
|
|
||||||
private float thrustScale = 0;
|
private float thrustScale = 0;
|
||||||
|
|
||||||
private FlightType lastFlightType;
|
private FlightType lastFlightType = FlightType.NONE;
|
||||||
|
|
||||||
public boolean isFlyingEither = false;
|
public boolean isFlyingEither = false;
|
||||||
public boolean isFlyingSurvival = false;
|
public boolean isFlyingSurvival = false;
|
||||||
|
@ -83,16 +85,19 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
||||||
public float getWingAngle() {
|
public float getWingAngle() {
|
||||||
float spreadAmount = -0.5F;
|
float spreadAmount = -0.5F;
|
||||||
|
|
||||||
|
PlayerEntity entity = pony.getMaster();
|
||||||
|
|
||||||
if (isFlying()) {
|
if (isFlying()) {
|
||||||
//spreadAmount += Math.sin(pony.getEntity().age / 4F) * 8;
|
//spreadAmount += Math.sin(pony.getEntity().age / 4F) * 8;
|
||||||
spreadAmount += isGliding() ? 3 : thrustScale * 60;
|
spreadAmount += isGliding() ? 3 : thrustScale * 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pony.getEntity().isSneaking()) {
|
if (entity.isSneaking()) {
|
||||||
spreadAmount += 2;
|
spreadAmount += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
spreadAmount += Math.sin(pony.getEntity().age / 9F) / 9F;
|
spreadAmount += MathHelper.clamp(-entity.getVelocity().y, 0, 2);
|
||||||
|
spreadAmount += Math.sin(entity.age / 9F) / 9F;
|
||||||
spreadAmount = MathHelper.clamp(spreadAmount, -2, 5);
|
spreadAmount = MathHelper.clamp(spreadAmount, -2, 5);
|
||||||
|
|
||||||
return pony.getInterpolator().interpolate("wingSpreadAmount", spreadAmount, 10);
|
return pony.getInterpolator().interpolate("wingSpreadAmount", spreadAmount, 10);
|
||||||
|
@ -121,7 +126,13 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
||||||
|
|
||||||
FlightType type = getFlightType();
|
FlightType type = getFlightType();
|
||||||
|
|
||||||
entity.abilities.allowFlying = type.canFlyCreative();
|
if (type != lastFlightType && (lastFlightType.isArtifical() || type.isArtifical())) {
|
||||||
|
ParticleUtils.spawnParticles(ParticleTypes.CLOUD, entity, 10);
|
||||||
|
|
||||||
|
entity.world.playSound(entity.getX(), entity.getY(), entity.getZ(), SoundEvents.BLOCK_BELL_RESONATE, SoundCategory.PLAYERS, 0.1125F, 1.5F, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.abilities.allowFlying = type.canFlyCreative(entity);
|
||||||
|
|
||||||
if (!creative) {
|
if (!creative) {
|
||||||
entity.abilities.flying |= (type.canFly() || entity.abilities.allowFlying) && isFlyingEither;
|
entity.abilities.flying |= (type.canFly() || entity.abilities.allowFlying) && isFlyingEither;
|
||||||
|
@ -195,8 +206,8 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
||||||
entity.world.playSoundFromEntity(null, entity, SoundEvents.BLOCK_CHAIN_STEP, SoundCategory.PLAYERS, 0.13F, 0.5F);
|
entity.world.playSoundFromEntity(null, entity, SoundEvents.BLOCK_CHAIN_STEP, SoundCategory.PLAYERS, 0.13F, 0.5F);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.world.random.nextInt(50) == 0) {
|
if (entity.world.random.nextInt(20) == 0) {
|
||||||
stack.damage(1, entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST));
|
stack.damage(1 + entity.world.random.nextInt(50), entity, e -> e.sendEquipmentBreakStatus(EquipmentSlot.CHEST));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getFlightType().canFly()) {
|
if (!getFlightType().canFly()) {
|
||||||
|
@ -420,9 +431,6 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
||||||
}
|
}
|
||||||
|
|
||||||
private FlightType getFlightType() {
|
private FlightType getFlightType() {
|
||||||
if (pony.getMaster().isCreative() || pony.getMaster().isSpectator()) {
|
|
||||||
return FlightType.CREATIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UItems.PEGASUS_AMULET.isApplicable(pony.getMaster())) {
|
if (UItems.PEGASUS_AMULET.isApplicable(pony.getMaster())) {
|
||||||
return FlightType.ARTIFICIAL;
|
return FlightType.ARTIFICIAL;
|
||||||
|
@ -443,7 +451,7 @@ public class PlayerPhysics extends EntityPhysics<Pony> implements Tickable, Moti
|
||||||
|
|
||||||
FlightType type = getFlightType();
|
FlightType type = getFlightType();
|
||||||
|
|
||||||
entity.abilities.allowFlying = type.canFlyCreative();
|
entity.abilities.allowFlying = type.canFlyCreative(entity);
|
||||||
|
|
||||||
if (type.canFly() || entity.abilities.allowFlying) {
|
if (type.canFly() || entity.abilities.allowFlying) {
|
||||||
entity.abilities.flying |= flying;
|
entity.abilities.flying |= flying;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
import com.minelittlepony.unicopia.particle.ParticleUtils;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
@ -17,6 +18,7 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.attribute.EntityAttribute;
|
import net.minecraft.entity.attribute.EntityAttribute;
|
||||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.StringVisitable;
|
import net.minecraft.text.StringVisitable;
|
||||||
|
@ -53,6 +55,14 @@ public class AmuletItem extends WearableItem {
|
||||||
if (isChargable() && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack) {
|
if (isChargable() && entity instanceof LivingEntity && ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack) {
|
||||||
consumeEnergy(stack, drain);
|
consumeEnergy(stack, drain);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
if (this == UItems.PEGASUS_AMULET
|
||||||
|
&& entity.world.getTime() % 6 == 0
|
||||||
|
&& entity instanceof LivingEntity
|
||||||
|
&& ((LivingEntity) entity).getEquippedStack(EquipmentSlot.CHEST) == stack
|
||||||
|
&& isApplicable((LivingEntity)entity)) {
|
||||||
|
ParticleUtils.spawnParticles(ParticleTypes.COMPOSTER, entity, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue