mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Players wearing the alicorn amulet will have a corrupting influence on entities that are around them
This commit is contained in:
parent
a2512f293a
commit
7e2ff3fc07
9 changed files with 157 additions and 35 deletions
|
@ -8,7 +8,7 @@ import com.minelittlepony.unicopia.InteractionManager;
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.client.sound.LoopingSoundInstance;
|
import com.minelittlepony.unicopia.client.sound.LoopingSoundInstance;
|
||||||
import com.minelittlepony.unicopia.client.sound.MotionBasedSoundInstance;
|
import com.minelittlepony.unicopia.client.sound.MotionBasedSoundInstance;
|
||||||
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;
|
||||||
|
@ -53,7 +53,7 @@ public class ClientInteractionManager extends InteractionManager {
|
||||||
SoundManager soundManager = client.getSoundManager();
|
SoundManager soundManager = client.getSoundManager();
|
||||||
|
|
||||||
if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) {
|
if (type == SOUND_EARS_RINGING && source instanceof LivingEntity) {
|
||||||
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(SunBlindnessStatusEffect.INSTANCE), USounds.ENTITY_PLAYER_EARS_RINGING, 1F, 1F));
|
soundManager.play(new LoopingSoundInstance<>((LivingEntity)source, e -> e.hasStatusEffect(UEffects.SUN_BLINDNESS), USounds.ENTITY_PLAYER_EARS_RINGING, 1F, 1F));
|
||||||
} else if (type == SOUND_BEE && source instanceof BeeEntity) {
|
} else if (type == SOUND_BEE && source instanceof BeeEntity) {
|
||||||
soundManager.playNextTick(
|
soundManager.playNextTick(
|
||||||
((BeeEntity)source).hasAngerTime()
|
((BeeEntity)source).hasAngerTime()
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.SpellType;
|
||||||
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
import com.minelittlepony.unicopia.client.KeyBindingsHandler;
|
||||||
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
import com.minelittlepony.unicopia.entity.behaviour.Disguise;
|
||||||
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
|
@ -151,10 +152,10 @@ public class UHud extends DrawableHelper {
|
||||||
|
|
||||||
protected void renderViewEffects(Pony pony, MatrixStack matrices, int scaledWidth, int scaledHeight, float tickDelta) {
|
protected void renderViewEffects(Pony pony, MatrixStack matrices, int scaledWidth, int scaledHeight, float tickDelta) {
|
||||||
|
|
||||||
boolean hasEffect = client.player.hasStatusEffect(SunBlindnessStatusEffect.INSTANCE);
|
boolean hasEffect = client.player.hasStatusEffect(UEffects.SUN_BLINDNESS);
|
||||||
|
|
||||||
if (hasEffect || (pony.getSpecies() == Race.BAT && SunBlindnessStatusEffect.hasSunExposure(client.player))) {
|
if (hasEffect || (pony.getSpecies() == Race.BAT && SunBlindnessStatusEffect.hasSunExposure(client.player))) {
|
||||||
float i = hasEffect ? (client.player.getStatusEffect(SunBlindnessStatusEffect.INSTANCE).getDuration() - tickDelta) / SunBlindnessStatusEffect.MAX_DURATION : 0;
|
float i = hasEffect ? (client.player.getStatusEffect(UEffects.SUN_BLINDNESS).getDuration() - tickDelta) / SunBlindnessStatusEffect.MAX_DURATION : 0;
|
||||||
|
|
||||||
float pulse = (1 + (float)Math.sin(client.player.age / 108F)) * 0.25F;
|
float pulse = (1 + (float)Math.sin(client.player.age / 108F)) * 0.25F;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.Owned;
|
||||||
|
import com.minelittlepony.unicopia.entity.Equine;
|
||||||
|
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||||
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectType;
|
||||||
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.world.WorldEvents;
|
||||||
|
|
||||||
|
public class CorruptInfluenceStatusEffect extends StatusEffect {
|
||||||
|
CorruptInfluenceStatusEffect(int color) {
|
||||||
|
super(StatusEffectType.NEUTRAL, color);
|
||||||
|
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 120, EntityAttributeModifier.Operation.ADDITION);
|
||||||
|
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 10, EntityAttributeModifier.Operation.ADDITION);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
|
|
||||||
|
if (entity.world.isClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity instanceof HostileEntity) {
|
||||||
|
|
||||||
|
int nearby = 0;
|
||||||
|
|
||||||
|
for (Entity i : entity.world.getOtherEntities(entity, entity.getBoundingBox().expand(40))) {
|
||||||
|
if (i.getType() == entity.getType()) {
|
||||||
|
nearby++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nearby > 1) {
|
||||||
|
if (Equine.of(entity).filter(eq -> eq instanceof Owned && ((Owned<?>)eq).getMaster() != null).isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.world.random.nextInt(2000) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (entity.world.random.nextInt(200) != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HostileEntity mob = (HostileEntity)entity;
|
||||||
|
|
||||||
|
HostileEntity clone = (HostileEntity)mob.getType().create(mob.world);
|
||||||
|
clone.copyPositionAndRotation(entity);
|
||||||
|
|
||||||
|
Equine.of(clone).ifPresent(eq -> {
|
||||||
|
((Owned<Entity>)eq).setMaster(mob);
|
||||||
|
});
|
||||||
|
mob.world.spawnEntity(clone);
|
||||||
|
|
||||||
|
if (!mob.isSilent()) {
|
||||||
|
mob.world.syncWorldEvent((PlayerEntity)null, WorldEvents.ZOMBIE_INFECTS_VILLAGER, mob.getBlockPos(), 0);
|
||||||
|
}
|
||||||
|
} else if (entity.age % 20 == 0) {
|
||||||
|
entity.damage(MagicalDamageSource.ALICORN_AMULET, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||||
|
applyUpdateEffect(target, amplifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canApplyUpdateEffect(int duration, int amplifier) {
|
||||||
|
return duration > 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
||||||
|
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
|
import net.minecraft.entity.effect.StatusEffectType;
|
||||||
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
|
||||||
|
public class FoodPoisoningStatusEffect extends StatusEffect {
|
||||||
|
|
||||||
|
FoodPoisoningStatusEffect(int color) {
|
||||||
|
super(StatusEffectType.HARMFUL, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
|
|
||||||
|
StatusEffectInstance nausea = entity.getStatusEffect(StatusEffects.NAUSEA);
|
||||||
|
if (nausea == null) {
|
||||||
|
StatusEffectInstance foodEffect = entity.getStatusEffect(this);
|
||||||
|
nausea = new StatusEffectInstance(StatusEffects.NAUSEA, foodEffect.getDuration(),
|
||||||
|
foodEffect.getAmplifier(),
|
||||||
|
true,
|
||||||
|
foodEffect.shouldShowParticles(),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
entity.addStatusEffect(nausea);
|
||||||
|
}
|
||||||
|
|
||||||
|
entity.damage(MagicalDamageSource.FOOD_POISONING, amplifier);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
||||||
|
applyUpdateEffect(target, amplifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canApplyUpdateEffect(int duration, int amplifier) {
|
||||||
|
int i = 40 >> amplifier;
|
||||||
|
return i <= 0 || duration % i == 0;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,19 +13,13 @@ import net.minecraft.entity.effect.StatusEffect;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffectType;
|
import net.minecraft.entity.effect.StatusEffectType;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.util.registry.Registry;
|
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
|
|
||||||
public class SunBlindnessStatusEffect extends StatusEffect {
|
public class SunBlindnessStatusEffect extends StatusEffect {
|
||||||
public static final int MAX_DURATION = 50;
|
public static final int MAX_DURATION = 50;
|
||||||
|
|
||||||
public static final SunBlindnessStatusEffect INSTANCE = new SunBlindnessStatusEffect(0x886F0F);
|
SunBlindnessStatusEffect(int color) {
|
||||||
|
|
||||||
private SunBlindnessStatusEffect(int color) {
|
|
||||||
super(StatusEffectType.NEUTRAL, color);
|
super(StatusEffectType.NEUTRAL, color);
|
||||||
|
|
||||||
Registry.register(Registry.STATUS_EFFECT, new Identifier("unicopia", "sun_blindness"), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,29 +1,17 @@
|
||||||
package com.minelittlepony.unicopia.entity.effect;
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.util.MagicalDamageSource;
|
|
||||||
|
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectType;
|
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
|
|
||||||
public interface UEffects {
|
public interface UEffects {
|
||||||
|
StatusEffect FOOD_POISONING = register("food_poisoning", new FoodPoisoningStatusEffect(3484199));
|
||||||
|
StatusEffect SUN_BLINDNESS = register("sun_blindness", new SunBlindnessStatusEffect(0x886F0F));
|
||||||
|
StatusEffect CORRUPT_INFLUENCE = register("corrupt_influence", new CorruptInfluenceStatusEffect(0x00FF00));
|
||||||
|
|
||||||
StatusEffect FOOD_POISONING = new CustomStatusEffect.Builder(new Identifier("unicopia", "food_poisoning"), StatusEffectType.HARMFUL, 3484199).direct((p, e, i) -> {
|
private static StatusEffect register(String name, StatusEffect effect) {
|
||||||
StatusEffectInstance nausea = e.getStatusEffect(StatusEffects.NAUSEA);
|
return Registry.register(Registry.STATUS_EFFECT, new Identifier("unicopia", name), effect);
|
||||||
if (nausea == null) {
|
}
|
||||||
StatusEffectInstance foodEffect = e.getStatusEffect(p);
|
|
||||||
nausea = new StatusEffectInstance(StatusEffects.NAUSEA, foodEffect.getDuration(),
|
|
||||||
foodEffect.getAmplifier(),
|
|
||||||
true,
|
|
||||||
foodEffect.shouldShowParticles(),
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
e.addStatusEffect(nausea);
|
static void bootstrap() {}
|
||||||
}
|
|
||||||
|
|
||||||
e.damage(MagicalDamageSource.FOOD_POISONING, i);
|
|
||||||
}).build();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.unicopia.entity.effect;
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -24,7 +23,6 @@ public interface UPotions {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bootstrap() {
|
static void bootstrap() {
|
||||||
@SuppressWarnings("unused")
|
UEffects.bootstrap();
|
||||||
StatusEffect e = SunBlindnessStatusEffect.INSTANCE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import com.minelittlepony.unicopia.entity.PonyContainer;
|
||||||
import com.minelittlepony.unicopia.entity.Living;
|
import com.minelittlepony.unicopia.entity.Living;
|
||||||
import com.minelittlepony.unicopia.entity.Trap;
|
import com.minelittlepony.unicopia.entity.Trap;
|
||||||
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
import com.minelittlepony.unicopia.entity.effect.SunBlindnessStatusEffect;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.item.toxin.Toxin;
|
import com.minelittlepony.unicopia.item.toxin.Toxin;
|
||||||
import com.minelittlepony.unicopia.network.Channel;
|
import com.minelittlepony.unicopia.network.Channel;
|
||||||
|
@ -298,7 +299,7 @@ public class Pony extends Living<PlayerEntity> implements Transmittable, Copieab
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ticksInSun == 1) {
|
if (ticksInSun == 1) {
|
||||||
entity.addStatusEffect(new StatusEffectInstance(SunBlindnessStatusEffect.INSTANCE, SunBlindnessStatusEffect.MAX_DURATION * 10, 1, true, false));
|
entity.addStatusEffect(new StatusEffectInstance(UEffects.SUN_BLINDNESS, SunBlindnessStatusEffect.MAX_DURATION * 10, 1, true, false));
|
||||||
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
UCriteria.LOOK_INTO_SUN.trigger(entity);
|
||||||
|
|
||||||
if (isClient() && isClientPlayer()) {
|
if (isClient() && isClientPlayer()) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.AwaitTickQueue;
|
||||||
import com.minelittlepony.unicopia.entity.IItemEntity;
|
import com.minelittlepony.unicopia.entity.IItemEntity;
|
||||||
import com.minelittlepony.unicopia.entity.ItemImpl;
|
import com.minelittlepony.unicopia.entity.ItemImpl;
|
||||||
import com.minelittlepony.unicopia.entity.ItemImpl.TickableItem;
|
import com.minelittlepony.unicopia.entity.ItemImpl.TickableItem;
|
||||||
|
import com.minelittlepony.unicopia.entity.effect.UEffects;
|
||||||
import com.minelittlepony.unicopia.entity.player.MagicReserves;
|
import com.minelittlepony.unicopia.entity.player.MagicReserves;
|
||||||
import com.minelittlepony.unicopia.entity.player.PlayerCharmTracker;
|
import com.minelittlepony.unicopia.entity.player.PlayerCharmTracker;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
@ -28,6 +29,7 @@ import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.entity.attribute.EntityAttributes;
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
import net.minecraft.entity.mob.MobEntity;
|
||||||
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.particle.ParticleEffect;
|
import net.minecraft.particle.ParticleEffect;
|
||||||
|
@ -200,6 +202,10 @@ public class AlicornAmuletItem extends AmuletItem implements PlayerCharmTracker.
|
||||||
w.createExplosion(player, pos.x, pos.y, pos.z, 6, DestructionType.BREAK);
|
w.createExplosion(player, pos.x, pos.y, pos.z, 6, DestructionType.BREAK);
|
||||||
}, 50);
|
}, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pony.findAllEntitiesInRange(10, e -> e instanceof MobEntity && !((MobEntity)e).hasStatusEffect(UEffects.CORRUPT_INFLUENCE)).forEach(e -> {
|
||||||
|
((MobEntity)e).addStatusEffect(new StatusEffectInstance(UEffects.CORRUPT_INFLUENCE, 1300, 1));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue