mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
soulstrider armor effects
This commit is contained in:
parent
607175a954
commit
8d68aa5777
2 changed files with 20 additions and 10 deletions
|
@ -12,7 +12,10 @@ import net.minecraft.world.entity.EquipmentSlot;
|
|||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
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.event.TickEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
|
@ -70,11 +73,16 @@ public class ItemArmor extends ArmorItem implements IModItem {
|
|||
public static void onAttack(LivingAttackEvent event) {
|
||||
var entity = event.getEntity();
|
||||
if (!entity.level.isClientSide) {
|
||||
if (!ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED))
|
||||
return;
|
||||
if (ItemArmor.isFullSetEquipped(entity, ModArmorMaterial.INFUSED)) {
|
||||
var source = event.getSource().getEntity();
|
||||
if (source instanceof LivingEntity)
|
||||
((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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ import java.util.function.Supplier;
|
|||
|
||||
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)),
|
||||
SKY(NaturesAura.MOD_ID + ":sky", 33, new int[]{3, 6, 8, 3}, 12, SoundEvents.ARMOR_EQUIP_DIAMOND, 2, () -> 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));
|
||||
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, 0, () -> Ingredient.of(ModItems.SKY_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 final String name;
|
||||
|
@ -26,15 +26,17 @@ public enum ModArmorMaterial implements ArmorMaterial {
|
|||
private final int enchantability;
|
||||
private final SoundEvent soundEvent;
|
||||
private final float toughness;
|
||||
private final float knockbackResistance;
|
||||
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.maxDamageFactor = maxDamageFactorIn;
|
||||
this.damageReductionAmountArray = damageReductionAmountsIn;
|
||||
this.enchantability = enchantabilityIn;
|
||||
this.soundEvent = equipSoundIn;
|
||||
this.toughness = toughness;
|
||||
this.knockbackResistance = knockbackResistance;
|
||||
this.repairMaterial = Lazy.of(repairMaterialSupplier);
|
||||
}
|
||||
|
||||
|
@ -76,6 +78,6 @@ public enum ModArmorMaterial implements ArmorMaterial {
|
|||
|
||||
@Override
|
||||
public float getKnockbackResistance() {
|
||||
return 0;
|
||||
return this.knockbackResistance;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue