Skip to content

Commit

Permalink
add stake damage source #1149
Browse files Browse the repository at this point in the history
- bypasses armor
  • Loading branch information
Cheaterpaul committed Nov 9, 2023
1 parent bd445ba commit e494aca
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"vampirism:blood_loss",
"vampirism:vampire_on_fire",
"vampirism:dbno",
"vampirism:mother"
"vampirism:mother",
"vampirism:stake"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"vampirism:dbno",
"vampirism:stake"
]
}

This file was deleted.

5 changes: 5 additions & 0 deletions src/generated/resources/data/vampirism/damage_type/stake.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"exhaustion": 0.0,
"message_id": "vampirism.stake",
"scaling": "never"
}
2 changes: 2 additions & 0 deletions src/main/java/de/teamlapen/vampirism/core/ModDamageTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ModDamageTypes {
public static final ResourceKey<DamageType> MINION = createKey("minion");
public static final ResourceKey<DamageType> DBNO = createKey("dbno");
public static final ResourceKey<DamageType> MOTHER = createKey("mother");
public static final ResourceKey<DamageType> STAKE = createKey("stake");

private static ResourceKey<DamageType> createKey(String name) {
return ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(REFERENCE.MODID, name));
Expand All @@ -34,5 +35,6 @@ public static void createDamageTypes(BootstapContext<DamageType> context) {
context.register(MINION, new DamageType("minion", DamageScaling.NEVER, 0.1F, DamageEffects.HURT, DeathMessageType.DEFAULT));
context.register(DBNO, new DamageType(REFERENCE.MODID + ".dbno", DamageScaling.NEVER, 0.0F, DamageEffects.HURT, DeathMessageType.DEFAULT));
context.register(MOTHER, new DamageType(REFERENCE.MODID + ".mother", DamageScaling.NEVER, 0.0F, DamageEffects.THORNS, DeathMessageType.DEFAULT));
context.register(STAKE, new DamageType(REFERENCE.MODID + ".stake", DamageScaling.NEVER, 0.0F, DamageEffects.HURT, DeathMessageType.DEFAULT));
}
}
4 changes: 2 additions & 2 deletions src/main/java/de/teamlapen/vampirism/data/TagGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,10 @@ public ModDamageTypeProvider(PackOutput output, CompletableFuture<HolderLookup.P

@Override
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
this.tag(DamageTypeTags.BYPASSES_ARMOR).add(ModDamageTypes.SUN_DAMAGE, ModDamageTypes.NO_BLOOD, ModDamageTypes.VAMPIRE_ON_FIRE, ModDamageTypes.DBNO, ModDamageTypes.MOTHER);
this.tag(DamageTypeTags.BYPASSES_ARMOR).add(ModDamageTypes.SUN_DAMAGE, ModDamageTypes.NO_BLOOD, ModDamageTypes.VAMPIRE_ON_FIRE, ModDamageTypes.DBNO, ModDamageTypes.MOTHER, ModDamageTypes.STAKE);
this.tag(DamageTypeTags.BYPASSES_EFFECTS).add(ModDamageTypes.DBNO, ModDamageTypes.STAKE);
this.tag(DamageTypeTags.IS_FIRE).add(ModDamageTypes.VAMPIRE_ON_FIRE, ModDamageTypes.VAMPIRE_IN_FIRE);
this.tag(DamageTypeTags.WITCH_RESISTANT_TO).add(ModDamageTypes.SUN_DAMAGE, ModDamageTypes.VAMPIRE_ON_FIRE, ModDamageTypes.VAMPIRE_IN_FIRE, ModDamageTypes.NO_BLOOD, ModDamageTypes.HOLY_WATER);
this.tag(DamageTypeTags.BYPASSES_ENCHANTMENTS).add(ModDamageTypes.DBNO);
this.tag(ModTags.DamageTypes.ENTITY_PHYSICAL).add(DamageTypes.PLAYER_ATTACK, DamageTypes.MOB_ATTACK, DamageTypes.MOB_ATTACK_NO_AGGRO, DamageTypes.MOB_PROJECTILE, DamageTypes.ARROW, DamageTypes.STING, DamageTypes.THORNS);
this.tag(ModTags.DamageTypes.REMAINS_INVULNERABLE).add(DamageTypes.IN_WALL, DamageTypes.DROWN);
this.tag(ModTags.DamageTypes.MOTHER_RESISTANT_TO).add(DamageTypes.ON_FIRE, DamageTypes.IN_FIRE, ModDamageTypes.HOLY_WATER, DamageTypes.FREEZE, DamageTypes.MAGIC, DamageTypes.INDIRECT_MAGIC);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/teamlapen/vampirism/items/StakeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public boolean hurtEnemy(@NotNull ItemStack stack, @NotNull LivingEntity target,
if (!attacker.getCommandSenderWorld().isClientSide) {
if (target instanceof IVampireMob || (target instanceof Player && Helper.isVampire(((Player) target)))) {
if (canKillInstant(target, attacker)) {
DamageHandler.hurtVanilla(target, sources -> attacker instanceof Player ? sources.playerAttack((Player) attacker) : sources.mobAttack(attacker), 10000F);
DamageHandler.hurtModded(target, sources -> sources.stake(attacker), 10000F);
if (attacker instanceof ServerPlayer) {
ModAdvancements.TRIGGER_HUNTER_ACTION.trigger((ServerPlayer) attacker, HunterActionCriterionTrigger.Action.STAKE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.damagesource.DamageType;
import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -65,6 +66,10 @@ public DamageSource mother() {
return this.mother;
}

public DamageSource stake(LivingEntity attacker) {
return new DamageSource(this.damageTypes.getHolderOrThrow(ModDamageTypes.STAKE), attacker);
}

public MinionDamageSource minion(@NotNull MinionEntity<?> entity) {
return new MinionDamageSource(this.damageTypes.getHolderOrThrow(ModDamageTypes.MINION), entity);
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/vampirism/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@
"death.attack.vampirism_dbno.missing": "After nearly dying, they gave up",
"death.attack.vampirism.mother": "%1$s died because they were too close to the Ancient Remains",
"death.attack.vampirism.mother.player": "%1$s came to close to the Ancient Remains whilst fighting %2$s",
"death.attack.vampirism.stake": "%1$s was pierced through the heart by %2$s",
"death.attack.vampirism.stake.item": "%1$s was pierced through the heart by %2$s using %3$s",
"__comment": "task_entity_tags",
"entity_tag.vampirism.hunter": "Hunter entities",
"entity_tag.vampirism.advanced_hunter": "Advanced hunters",
Expand Down

0 comments on commit e494aca

Please sign in to comment.