Skip to content

Commit

Permalink
Make option effect NPCs as well
Browse files Browse the repository at this point in the history
  • Loading branch information
maxanier committed Aug 27, 2023
1 parent aa1928b commit 7787c82
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/api/java/de/teamlapen/vampirism/api/VReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -99,7 +100,7 @@ public EntityDataAccessor<Boolean> getConvertingDataParam() {
@NotNull
@Override
public MobType getMobType() {
return VReference.VAMPIRE_CREATURE_ATTRIBUTE;
return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,7 +95,7 @@ public EntityDataAccessor<Boolean> getConvertingDataParam() {
@NotNull
@Override
public MobType getMobType() {
return VReference.VAMPIRE_CREATURE_ATTRIBUTE;
return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE;
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,7 +94,7 @@ public EntityDataAccessor<Boolean> getConvertingDataParam() {
@NotNull
@Override
public MobType getMobType() {
return VReference.VAMPIRE_CREATURE_ATTRIBUTE;
return VampirismConfig.SERVER.vampiresAreUndeadType.get() ? MobType.UNDEAD : VReference.VAMPIRE_CREATURE_ATTRIBUTE;
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends LivingEntity> type, @NotNull Level worldIn) {
Expand Down

0 comments on commit 7787c82

Please sign in to comment.