mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Update status effects
This commit is contained in:
parent
f3f5a1c006
commit
8b71579539
6 changed files with 40 additions and 54 deletions
|
@ -22,13 +22,14 @@ public class ButterfingersStatusEffect extends StatusEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
amplifier = MathHelper.clamp(amplifier, 0, 5);
|
amplifier = MathHelper.clamp(amplifier, 0, 5);
|
||||||
final int scale = 500 + (int)(((5 - amplifier) / 5F) * 900);
|
final int scale = 500 + (int)(((5 - amplifier) / 5F) * 900);
|
||||||
|
|
||||||
if (entity.getWorld().random.nextInt(scale / 4) == 0) {
|
if (entity.getWorld().random.nextInt(scale / 4) == 0) {
|
||||||
applyInstantEffect(null, null, entity, amplifier, entity.getWorld().random.nextInt(scale));
|
applyInstantEffect(null, null, entity, amplifier, entity.getWorld().random.nextInt(scale));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,38 +1,36 @@
|
||||||
package com.minelittlepony.unicopia.entity.effect;
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.Owned;
|
import com.minelittlepony.unicopia.Owned;
|
||||||
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
import com.minelittlepony.unicopia.entity.Equine;
|
import com.minelittlepony.unicopia.entity.Equine;
|
||||||
import com.minelittlepony.unicopia.entity.Living;
|
import com.minelittlepony.unicopia.entity.Living;
|
||||||
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||||
import net.minecraft.entity.attribute.EntityAttributes;
|
import net.minecraft.entity.attribute.EntityAttributes;
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||||
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.HostileEntity;
|
import net.minecraft.entity.mob.HostileEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.world.WorldEvents;
|
import net.minecraft.world.WorldEvents;
|
||||||
|
|
||||||
public class CorruptInfluenceStatusEffect extends StatusEffect {
|
public class CorruptInfluenceStatusEffect extends SimpleStatusEffect {
|
||||||
|
static final Identifier CORRUPTION_MODIFIER_ID = Unicopia.id("corruption_modifier");
|
||||||
|
|
||||||
CorruptInfluenceStatusEffect(int color) {
|
CorruptInfluenceStatusEffect(int color) {
|
||||||
super(StatusEffectCategory.NEUTRAL, color);
|
super(StatusEffectCategory.NEUTRAL, color, false);
|
||||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 15, EntityAttributeModifier.Operation.ADD_VALUE);
|
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, CORRUPTION_MODIFIER_ID, 15, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 10, EntityAttributeModifier.Operation.ADD_VALUE);
|
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, CORRUPTION_MODIFIER_ID, 10, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
|
|
||||||
if (entity.getWorld().isClient) {
|
if (entity.getWorld().isClient) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof HostileEntity mob) {
|
if (entity instanceof HostileEntity mob) {
|
||||||
|
@ -41,14 +39,14 @@ public class CorruptInfluenceStatusEffect extends StatusEffect {
|
||||||
|
|
||||||
if (nearby > 1) {
|
if (nearby > 1) {
|
||||||
if (Equine.of(entity).filter(eq -> eq instanceof Owned<?> o && o.getMaster() != null).isPresent()) {
|
if (Equine.of(entity).filter(eq -> eq instanceof Owned<?> o && o.getMaster() != null).isPresent()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.getWorld().random.nextInt(2000) != 0) {
|
if (entity.getWorld().random.nextInt(2000) != 0) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (entity.getWorld().random.nextInt(200) != 0) {
|
} else if (entity.getWorld().random.nextInt(200) != 0) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
reproduce(mob);
|
reproduce(mob);
|
||||||
|
@ -57,11 +55,8 @@ public class CorruptInfluenceStatusEffect extends StatusEffect {
|
||||||
} else if (entity.age % 2000 == 0) {
|
} else if (entity.age % 2000 == 0) {
|
||||||
entity.damage(Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2);
|
entity.damage(Living.living(entity).damageOf(UDamageTypes.ALICORN_AMULET), 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return true;
|
||||||
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
|
||||||
applyUpdateEffect(target, amplifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,11 +76,11 @@ public class CorruptInfluenceStatusEffect extends StatusEffect {
|
||||||
float maxHealthDifference = mob.getMaxHealth() - clone.getMaxHealth();
|
float maxHealthDifference = mob.getMaxHealth() - clone.getMaxHealth();
|
||||||
clone.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 900000, 2));
|
clone.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 900000, 2));
|
||||||
clone.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH)
|
clone.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH)
|
||||||
.addPersistentModifier(new EntityAttributeModifier(UUID.randomUUID(), "Corruption Strength Modifier", maxHealthDifference + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
.addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, maxHealthDifference + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||||
}
|
}
|
||||||
if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE)) {
|
if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE)) {
|
||||||
clone.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE)
|
clone.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE)
|
||||||
.addPersistentModifier(new EntityAttributeModifier(UUID.randomUUID(), "Corruption Damage Modifier", mob.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
.addPersistentModifier(new EntityAttributeModifier(CORRUPTION_MODIFIER_ID, mob.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
|
|
||||||
|
import net.minecraft.component.DataComponentTypes;
|
||||||
import net.minecraft.component.type.FoodComponent;
|
import net.minecraft.component.type.FoodComponent;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
@ -13,6 +14,7 @@ import net.minecraft.entity.effect.StatusEffectCategory;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
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.registry.RegistryKeys;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
|
|
||||||
|
@ -23,12 +25,12 @@ public class FoodPoisoningStatusEffect extends StatusEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
if (entity.getWorld().isClient) {
|
if (entity.getWorld().isClient) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean showParticles = entity.getStatusEffect(this).shouldShowParticles();
|
boolean showParticles = entity.getStatusEffect(entity.getRegistryManager().get(RegistryKeys.STATUS_EFFECT).getEntry(this)).shouldShowParticles();
|
||||||
|
|
||||||
if (!entity.hasStatusEffect(StatusEffects.NAUSEA) && entity.getRandom().nextInt(12) == 0) {
|
if (!entity.hasStatusEffect(StatusEffects.NAUSEA) && entity.getRandom().nextInt(12) == 0) {
|
||||||
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1, true, showParticles, false));
|
entity.addStatusEffect(new StatusEffectInstance(StatusEffects.NAUSEA, 100, 1, true, showParticles, false));
|
||||||
|
@ -39,8 +41,10 @@ public class FoodPoisoningStatusEffect extends StatusEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EffectUtils.isPoisoned(entity) && entity.getRandom().nextInt(12) == 0 && !entity.hasStatusEffect(StatusEffects.POISON)) {
|
if (EffectUtils.isPoisoned(entity) && entity.getRandom().nextInt(12) == 0 && !entity.hasStatusEffect(StatusEffects.POISON)) {
|
||||||
StatusEffects.POISON.applyUpdateEffect(entity, 1);
|
StatusEffects.POISON.value().applyUpdateEffect(entity, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,9 +60,9 @@ public class FoodPoisoningStatusEffect extends StatusEffect {
|
||||||
|
|
||||||
public static TypedActionResult<ItemStack> apply(ItemStack stack, PlayerEntity user) {
|
public static TypedActionResult<ItemStack> apply(ItemStack stack, PlayerEntity user) {
|
||||||
@Nullable
|
@Nullable
|
||||||
FoodComponent food = stack.getItem().getFoodComponent();
|
FoodComponent food = stack.get(DataComponentTypes.FOOD);
|
||||||
|
|
||||||
if (food == null || !user.canConsume(food.isAlwaysEdible()) || !user.hasStatusEffect(UEffects.FOOD_POISONING)) {
|
if (food == null || !user.canConsume(food.canAlwaysEat()) || !user.hasStatusEffect(UEffects.FOOD_POISONING)) {
|
||||||
return TypedActionResult.pass(stack);
|
return TypedActionResult.pass(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class SeaponyGraceStatusEffect {
|
||||||
if (!stateBroken.isIn(UTags.Blocks.ANGERS_GUARDIANS)) {
|
if (!stateBroken.isIn(UTags.Blocks.ANGERS_GUARDIANS)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StructureStart start = sw.getStructureAccessor().getStructureContaining(pos, StructureKeys.MONUMENT);
|
StructureStart start = sw.getStructureAccessor().getStructureContaining(pos, key -> key == StructureKeys.MONUMENT);
|
||||||
if (start.getStructure() == null) {
|
if (start.getStructure() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package com.minelittlepony.unicopia.entity.effect;
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
import net.minecraft.entity.effect.StatusEffect;
|
||||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||||
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
|
|
||||||
public class SimpleStatusEffect extends StatusEffect {
|
public class SimpleStatusEffect extends StatusEffect {
|
||||||
|
|
||||||
|
@ -16,14 +15,8 @@ public class SimpleStatusEffect extends StatusEffect {
|
||||||
this.instant = instant;
|
this.instant = instant;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected RegistryEntry<StatusEffect> getEntry(Entity entity) {
|
||||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
return entity.getRegistryManager().get(RegistryKeys.STATUS_EFFECT).getEntry(this);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package com.minelittlepony.unicopia.entity.effect;
|
package com.minelittlepony.unicopia.entity.effect;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.UTags;
|
import com.minelittlepony.unicopia.UTags;
|
||||||
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
|
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
|
||||||
|
@ -10,40 +8,35 @@ import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.util.MeteorlogicalUtil;
|
import com.minelittlepony.unicopia.util.MeteorlogicalUtil;
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.effect.StatusEffect;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||||
import net.minecraft.entity.effect.StatusEffectCategory;
|
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
import net.minecraft.entity.effect.StatusEffects;
|
||||||
|
|
||||||
public class SunBlindnessStatusEffect extends StatusEffect {
|
public class SunBlindnessStatusEffect extends SimpleStatusEffect {
|
||||||
public static final int MAX_DURATION = 250;
|
public static final int MAX_DURATION = 250;
|
||||||
|
|
||||||
SunBlindnessStatusEffect(int color) {
|
SunBlindnessStatusEffect(int color) {
|
||||||
super(StatusEffectCategory.NEUTRAL, color);
|
super(StatusEffectCategory.NEUTRAL, color, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||||
StatusEffectInstance state = entity.getStatusEffect(this);
|
StatusEffectInstance state = entity.getStatusEffect(getEntry(entity));
|
||||||
|
|
||||||
if (state == null || isSunImmune(entity)) {
|
if (state == null || isSunImmune(entity)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.age % 15 == 0) {
|
if (entity.age % 15 == 0) {
|
||||||
if (!hasSunExposure(entity)) {
|
if (!hasSunExposure(entity)) {
|
||||||
entity.setStatusEffect(new StatusEffectInstance(this, (int)(state.getDuration() * 0.8F), Math.max(1, amplifier - 1), true, false), entity);
|
entity.setStatusEffect(new StatusEffectInstance(getEntry(entity), (int)(state.getDuration() * 0.8F), Math.max(1, amplifier - 1), true, false), entity);
|
||||||
} else {
|
} else {
|
||||||
entity.damage(Living.living(entity).damageOf(amplifier == 2 ? UDamageTypes.SUN : UDamageTypes.SUNLIGHT), amplifier / 5F);
|
entity.damage(Living.living(entity).damageOf(amplifier == 2 ? UDamageTypes.SUN : UDamageTypes.SUNLIGHT), amplifier / 5F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
return true;
|
||||||
public void applyInstantEffect(@Nullable Entity source, @Nullable Entity attacker, LivingEntity target, int amplifier, double proximity) {
|
|
||||||
applyUpdateEffect(target, amplifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue