soulstrider armor effects

This commit is contained in:
Ell 2023-03-02 14:40:57 +01:00
parent 607175a954
commit 8d68aa5777
2 changed files with 20 additions and 10 deletions

View file

@ -12,7 +12,10 @@ import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeModifier; import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*; import net.minecraft.world.item.*;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingAttackEvent;
@ -70,11 +73,16 @@ public class ItemArmor extends ArmorItem implements IModItem {
public static void onAttack(LivingAttackEvent event) { public static void onAttack(LivingAttackEvent event) {
var entity = event.getEntity(); var entity = event.getEntity();
if (!entity.level.isClientSide) { if (!entity.level.isClientSide) {
if (!ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) {
return; var source = event.getSource().getEntity();
var source = event.getSource().getEntity(); if (source instanceof LivingEntity)
if (source instanceof LivingEntity) ((LivingEntity) source).addEffect(new MobEffectInstance(MobEffects.WITHER, 40));
((LivingEntity) source).addEffect(new MobEffectInstance(MobEffects.WITHER, 40)); } else if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.DEPTH)) {
for (var other : entity.level.getEntitiesOfClass(LivingEntity.class, new AABB(entity.position(), Vec3.ZERO).inflate(2))) {
if (other != entity && (!(other instanceof Player otherPlayer) || !otherPlayer.isAlliedTo(entity)))
other.addEffect(new MobEffectInstance(MobEffects.MOVEMENT_SLOWDOWN, 60, 255));
}
}
} }
} }

View file

@ -15,9 +15,9 @@ import java.util.function.Supplier;
public enum ModArmorMaterial implements ArmorMaterial { public enum ModArmorMaterial implements ArmorMaterial {
INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_IRON, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)), INFUSED(NaturesAura.MOD_ID + ":infused_iron", 19, new int[]{2, 5, 6, 2}, 16, SoundEvents.ARMOR_EQUIP_IRON, 0, 0, () -> Ingredient.of(ModItems.INFUSED_IRON)),
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_DIAMOND, 2, () -> Ingredient.of(ModItems.SKY_INGOT)), SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_DIAMOND, 2, 0, () -> Ingredient.of(ModItems.SKY_INGOT)),
DEPTH(NaturesAura.MOD_ID + ":depth", 37, new int[]{3, 6, 8, 3}, 18, SoundEvents.ARMOR_EQUIP_NETHERITE, 3, () -> Ingredient.of(ModItems.DEPTH_INGOT)); DEPTH(NaturesAura.MOD_ID + ":depth", 37, new int[]{3, 6, 8, 3}, 18, SoundEvents.ARMOR_EQUIP_NETHERITE, 3, 1, () -> Ingredient.of(ModItems.DEPTH_INGOT));
private static final int[] MAX_DAMAGE_ARRAY = {13, 15, 16, 11}; private static final int[] MAX_DAMAGE_ARRAY = {13, 15, 16, 11};
private final String name; private final String name;
@ -26,15 +26,17 @@ public enum ModArmorMaterial implements ArmorMaterial {
private final int enchantability; private final int enchantability;
private final SoundEvent soundEvent; private final SoundEvent soundEvent;
private final float toughness; private final float toughness;
private final float knockbackResistance;
private final Lazy<Ingredient> repairMaterial; private final Lazy<Ingredient> repairMaterial;
ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, Supplier<Ingredient> repairMaterialSupplier) { ModArmorMaterial(String nameIn, int maxDamageFactorIn, int[] damageReductionAmountsIn, int enchantabilityIn, SoundEvent equipSoundIn, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterialSupplier) {
this.name = nameIn; this.name = nameIn;
this.maxDamageFactor = maxDamageFactorIn; this.maxDamageFactor = maxDamageFactorIn;
this.damageReductionAmountArray = damageReductionAmountsIn; this.damageReductionAmountArray = damageReductionAmountsIn;
this.enchantability = enchantabilityIn; this.enchantability = enchantabilityIn;
this.soundEvent = equipSoundIn; this.soundEvent = equipSoundIn;
this.toughness = toughness; this.toughness = toughness;
this.knockbackResistance = knockbackResistance;
this.repairMaterial = Lazy.of(repairMaterialSupplier); this.repairMaterial = Lazy.of(repairMaterialSupplier);
} }
@ -76,6 +78,6 @@ public enum ModArmorMaterial implements ArmorMaterial {
@Override @Override
public float getKnockbackResistance() { public float getKnockbackResistance() {
return 0; return this.knockbackResistance;
} }
} }