From 7787c82c785aad2e1bc917639032e5e95bf62e97 Mon Sep 17 00:00:00 2001 From: maxanier Date: Sun, 27 Aug 2023 22:27:39 +0200 Subject: [PATCH] Make option effect NPCs as well --- src/api/java/de/teamlapen/vampirism/api/VReference.java | 3 ++- .../vampirism/entity/converted/ConvertedDonkeyEntity.java | 3 ++- .../vampirism/entity/converted/ConvertedHorseEntity.java | 3 ++- .../vampirism/entity/converted/ConvertedMuleEntity.java | 3 ++- .../teamlapen/vampirism/entity/vampire/VampireBaseEntity.java | 2 +- .../vampirism/items/enchantment/EnchantmentVampireSlayer.java | 3 ++- .../java/de/teamlapen/vampirism/mixin/MixinPlayerEntity.java | 2 ++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/api/java/de/teamlapen/vampirism/api/VReference.java b/src/api/java/de/teamlapen/vampirism/api/VReference.java index 9bbb743112..78f4b57c96 100755 --- a/src/api/java/de/teamlapen/vampirism/api/VReference.java +++ b/src/api/java/de/teamlapen/vampirism/api/VReference.java @@ -43,8 +43,9 @@ public class VReference { */ public static MobCategory VAMPIRE_CREATURE_TYPE = MobCategory.create("vampirism_vampire", "vampirism_vampire", 30, false, false, 128); /** - * Vampire creatures have this creature attribute. + * Vampire creatures have this creature attribute. Note: There is a config option that makes Vampirism use UNDEAD type instead * Don't know why this exists alongside EnumCreatureType, but this is used by enchantments + * TODO 1.21 maybe replace with a getter method, if the config option still exists */ @SuppressWarnings("InstantiationOfUtilityClass") public static MobType VAMPIRE_CREATURE_ATTRIBUTE = new MobType(); diff --git a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedDonkeyEntity.java b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedDonkeyEntity.java index 89a92750a7..b002e6331a 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedDonkeyEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedDonkeyEntity.java @@ -2,6 +2,7 @@ import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.config.BalanceMobProps; +import de.teamlapen.vampirism.config.VampirismConfig; import de.teamlapen.vampirism.core.ModAttributes; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -99,7 +100,7 @@ public EntityDataAccessor getConvertingDataParam() { @NotNull @Override public MobType getMobType() { - return VReference.VAMPIRE_CREATURE_ATTRIBUTE; + return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE; } @Override diff --git a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedHorseEntity.java b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedHorseEntity.java index 2d09f9c0b2..7297fde1ee 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedHorseEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedHorseEntity.java @@ -2,6 +2,7 @@ import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.config.BalanceMobProps; +import de.teamlapen.vampirism.config.VampirismConfig; import de.teamlapen.vampirism.core.ModAttributes; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -94,7 +95,7 @@ public EntityDataAccessor getConvertingDataParam() { @NotNull @Override public MobType getMobType() { - return VReference.VAMPIRE_CREATURE_ATTRIBUTE; + return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE; } @NotNull diff --git a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedMuleEntity.java b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedMuleEntity.java index 51d3c1c0b9..09c637c5c1 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedMuleEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedMuleEntity.java @@ -2,6 +2,7 @@ import de.teamlapen.vampirism.api.VReference; import de.teamlapen.vampirism.config.BalanceMobProps; +import de.teamlapen.vampirism.config.VampirismConfig; import de.teamlapen.vampirism.core.ModAttributes; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; @@ -93,7 +94,7 @@ public EntityDataAccessor getConvertingDataParam() { @NotNull @Override public MobType getMobType() { - return VReference.VAMPIRE_CREATURE_ATTRIBUTE; + return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE; } @NotNull diff --git a/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java b/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java index a5e9a7d1eb..22483fb8e0 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/vampire/VampireBaseEntity.java @@ -232,7 +232,7 @@ public EnumStrength isGettingGarlicDamage(LevelAccessor iWorld, boolean forceref @NotNull @Override public MobType getMobType() { - return VReference.VAMPIRE_CREATURE_ATTRIBUTE; + return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE; } @Override diff --git a/src/main/java/de/teamlapen/vampirism/items/enchantment/EnchantmentVampireSlayer.java b/src/main/java/de/teamlapen/vampirism/items/enchantment/EnchantmentVampireSlayer.java index 2b24df4907..ce836d68ad 100755 --- a/src/main/java/de/teamlapen/vampirism/items/enchantment/EnchantmentVampireSlayer.java +++ b/src/main/java/de/teamlapen/vampirism/items/enchantment/EnchantmentVampireSlayer.java @@ -1,6 +1,7 @@ package de.teamlapen.vampirism.items.enchantment; import de.teamlapen.vampirism.api.VReference; +import de.teamlapen.vampirism.config.VampirismConfig; import de.teamlapen.vampirism.items.PitchforkItem; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; @@ -36,7 +37,7 @@ public boolean canApplyAtEnchantingTable(@NotNull ItemStack stack) { @Override public float getDamageBonus(int level, @NotNull MobType creatureType) { - return creatureType == VReference.VAMPIRE_CREATURE_ATTRIBUTE ? 2f + Math.min(0, level - 1) * 1F : 0; + return creatureType == (VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE) ? 2f + Math.min(0, level - 1) * 1F : 0; } @Override diff --git a/src/main/java/de/teamlapen/vampirism/mixin/MixinPlayerEntity.java b/src/main/java/de/teamlapen/vampirism/mixin/MixinPlayerEntity.java index 086caf0ef8..467fa4f477 100644 --- a/src/main/java/de/teamlapen/vampirism/mixin/MixinPlayerEntity.java +++ b/src/main/java/de/teamlapen/vampirism/mixin/MixinPlayerEntity.java @@ -12,12 +12,14 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(Player.class) public abstract class MixinPlayerEntity extends MixinLivingEntity implements IVampirismPlayer { + @Unique private final VampirismPlayerAttributes vampirismPlayerAttributes = new VampirismPlayerAttributes(); private MixinPlayerEntity(@NotNull EntityType type, @NotNull Level worldIn) {