mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Bat ponies can now burn their eyes by looking directly at the sun
This commit is contained in:
parent
077f0b8987
commit
9824801609
3 changed files with 42 additions and 14 deletions
|
@ -13,8 +13,6 @@ import com.minelittlepony.unicopia.ability.magic.CasterView;
|
||||||
import com.minelittlepony.unicopia.block.data.Ether;
|
import com.minelittlepony.unicopia.block.data.Ether;
|
||||||
import com.minelittlepony.unicopia.client.gui.DismissSpellScreen;
|
import com.minelittlepony.unicopia.client.gui.DismissSpellScreen;
|
||||||
import com.minelittlepony.unicopia.client.sound.*;
|
import com.minelittlepony.unicopia.client.sound.*;
|
||||||
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
|
||||||
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
|
||||||
import com.minelittlepony.unicopia.entity.player.PlayerPhysics;
|
import com.minelittlepony.unicopia.entity.player.PlayerPhysics;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.entity.player.dummy.DummyClientPlayerEntity;
|
import com.minelittlepony.unicopia.entity.player.dummy.DummyClientPlayerEntity;
|
||||||
|
|
|
@ -34,10 +34,10 @@ public class SunBlindnessStatusEffect extends StatusEffect {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasSunExposure(entity)) {
|
if (entity.age % 15 == 0) {
|
||||||
entity.setStatusEffect(new StatusEffectInstance(this, (int)(state.getDuration() * 0.8F), amplifier, true, false), entity);
|
if (!hasSunExposure(entity)) {
|
||||||
} else {
|
entity.setStatusEffect(new StatusEffectInstance(this, (int)(state.getDuration() * 0.8F), Math.max(1, amplifier - 1), true, false), entity);
|
||||||
if (entity.age % 15 == 0) {
|
} else if (amplifier > 1) {
|
||||||
entity.damage(DamageSource.IN_FIRE, amplifier / 20F);
|
entity.damage(DamageSource.IN_FIRE, amplifier / 20F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.sound.SoundEvents;
|
import net.minecraft.sound.SoundEvents;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.hit.HitResult.Type;
|
||||||
import net.minecraft.util.math.*;
|
import net.minecraft.util.math.*;
|
||||||
import net.minecraft.world.GameMode;
|
import net.minecraft.world.GameMode;
|
||||||
|
|
||||||
|
@ -70,6 +71,8 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
static final TrackedData<Integer> LEVEL = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
static final TrackedData<Integer> LEVEL = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
||||||
static final TrackedData<Integer> CORRUPTION = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
static final TrackedData<Integer> CORRUPTION = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.INTEGER);
|
||||||
|
|
||||||
|
static final int INITIAL_SUN_IMMUNITY = 20;
|
||||||
|
|
||||||
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
|
private static final TrackedData<NbtCompound> EFFECT = DataTracker.registerData(PlayerEntity.class, TrackedDataHandlerRegistry.NBT_COMPOUND);
|
||||||
|
|
||||||
private final AbilityDispatcher powers = new AbilityDispatcher(this);
|
private final AbilityDispatcher powers = new AbilityDispatcher(this);
|
||||||
|
@ -103,7 +106,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
|
|
||||||
private int ticksInSun;
|
private int ticksInSun;
|
||||||
private boolean hasShades;
|
private boolean hasShades;
|
||||||
private int ticksSunImmunity = 20;
|
private int ticksSunImmunity = INITIAL_SUN_IMMUNITY;
|
||||||
|
|
||||||
private Animation animation = Animation.NONE;
|
private Animation animation = Animation.NONE;
|
||||||
private int animationMaxDuration;
|
private int animationMaxDuration;
|
||||||
|
@ -300,6 +303,7 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
&& SunBlindnessStatusEffect.isPositionExposedToSun(sw, getOrigin())) {
|
&& SunBlindnessStatusEffect.isPositionExposedToSun(sw, getOrigin())) {
|
||||||
SpawnLocator.selectSpawnPosition(sw, entity);
|
SpawnLocator.selectSpawnPosition(sw, entity);
|
||||||
}
|
}
|
||||||
|
ticksSunImmunity = INITIAL_SUN_IMMUNITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -383,6 +387,39 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getObservedSpecies() == Race.BAT && !entity.hasPortalCooldown()) {
|
if (getObservedSpecies() == Race.BAT && !entity.hasPortalCooldown()) {
|
||||||
|
boolean hasShades = entity.getEquippedStack(EquipmentSlot.HEAD).isIn(UTags.SHADES);
|
||||||
|
if (!this.hasShades && hasShades && getObservedSpecies() == Race.BAT) {
|
||||||
|
UCriteria.WEAR_SHADES.trigger(entity);
|
||||||
|
}
|
||||||
|
this.hasShades = hasShades;
|
||||||
|
|
||||||
|
if (!hasShades && ticksSunImmunity <= 0) {
|
||||||
|
float skyAngle = ((entity.world.getSkyAngle(1) + 0.25F) % 1F) * 2;
|
||||||
|
float playerAngle = (-entity.getPitch(1) / 90F) / 2F;
|
||||||
|
float playerYaw = MathHelper.wrapDegrees(entity.getHeadYaw());
|
||||||
|
|
||||||
|
if (playerYaw > 0) {
|
||||||
|
playerAngle = 1 - playerAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerYaw = Math.abs(playerYaw);
|
||||||
|
|
||||||
|
if (skyAngle < 1
|
||||||
|
&& (playerYaw > 89 && playerYaw < 92 || (playerAngle > 0.45F && playerAngle < 0.55F))
|
||||||
|
&& playerAngle > (skyAngle - 0.04F) && playerAngle < (skyAngle + 0.04F)) {
|
||||||
|
|
||||||
|
if (entity.raycast(100, 1, true).getType() == Type.MISS) {
|
||||||
|
if (!isClient()) {
|
||||||
|
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 2, true, false));
|
||||||
|
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
||||||
|
} else if (isClientPlayer()) {
|
||||||
|
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (SunBlindnessStatusEffect.hasSunExposure(entity)) {
|
if (SunBlindnessStatusEffect.hasSunExposure(entity)) {
|
||||||
if (ticksInSun < 200) {
|
if (ticksInSun < 200) {
|
||||||
ticksInSun++;
|
ticksInSun++;
|
||||||
|
@ -391,7 +428,6 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
if (ticksInSun == 1) {
|
if (ticksInSun == 1) {
|
||||||
if (!isClient()) {
|
if (!isClient()) {
|
||||||
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 1, true, false));
|
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION, 1, true, false));
|
||||||
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
|
||||||
} else if (isClientPlayer()) {
|
} else if (isClientPlayer()) {
|
||||||
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId());
|
InteractionManager.instance().playLoopingSound(entity, InteractionManager.SOUND_EARS_RINGING, entity.getId());
|
||||||
}
|
}
|
||||||
|
@ -399,12 +435,6 @@ public class Pony extends Living<PlayerEntity> implements Copyable<Pony>, Update
|
||||||
} else if (ticksInSun > 0) {
|
} else if (ticksInSun > 0) {
|
||||||
ticksInSun--;
|
ticksInSun--;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasShades = entity.getEquippedStack(EquipmentSlot.HEAD).isIn(UTags.SHADES);
|
|
||||||
if (!this.hasShades && hasShades) {
|
|
||||||
UCriteria.WEAR_SHADES.trigger(entity);
|
|
||||||
}
|
|
||||||
this.hasShades = hasShades;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isClient() && !UItems.ALICORN_AMULET.isApplicable(entity)) {
|
if (!isClient() && !UItems.ALICORN_AMULET.isApplicable(entity)) {
|
||||||
|
|
Loading…
Reference in a new issue