Add damage type tag for knockdown bypass
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
package net.fretux.knockedback;
|
||||||
|
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.tags.TagKey;
|
||||||
|
import net.minecraft.world.damagesource.DamageType;
|
||||||
|
|
||||||
|
public final class KnockedBackDamageTags {
|
||||||
|
public static final TagKey<DamageType> BYPASS_KNOCKDOWN = TagKey.create(
|
||||||
|
Registries.DAMAGE_TYPE,
|
||||||
|
new ResourceLocation(KnockedBack.MOD_ID, "bypass_knockdown")
|
||||||
|
);
|
||||||
|
|
||||||
|
private KnockedBackDamageTags() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -167,22 +167,9 @@ public class KnockedManager {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String damageType = src.getMsgId();
|
|
||||||
boolean isFatal = player.getHealth() - event.getAmount() <= 0;
|
boolean isFatal = player.getHealth() - event.getAmount() <= 0;
|
||||||
if (isFatal) {
|
if (isFatal) {
|
||||||
if (Config.COMMON.explosionsBypassKnockdown.get() &&
|
if (src.is(KnockedBackDamageTags.BYPASS_KNOCKDOWN)) {
|
||||||
(damageType.contains("explosion") || damageType.contains("fireworks"))) {
|
|
||||||
killAndRemove(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Config.COMMON.fallDamageBypassesKnockdown.get() && damageType.contains("fall")) {
|
|
||||||
killAndRemove(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Config.COMMON.lavaBypassesKnockdown.get() &&
|
|
||||||
(damageType.contains("lava") || damageType.contains("inFire") ||
|
|
||||||
damageType.contains("fire") || damageType.contains("onFire") ||
|
|
||||||
damageType.contains("fireball") || damageType.contains("hotFloor"))) {
|
|
||||||
killAndRemove(player);
|
killAndRemove(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ public class Config {
|
|||||||
public final ForgeConfigSpec.IntValue knockedDuration;
|
public final ForgeConfigSpec.IntValue knockedDuration;
|
||||||
public final ForgeConfigSpec.IntValue executionTime;
|
public final ForgeConfigSpec.IntValue executionTime;
|
||||||
public final ForgeConfigSpec.BooleanValue totemPreventsKnockdown;
|
public final ForgeConfigSpec.BooleanValue totemPreventsKnockdown;
|
||||||
public final ForgeConfigSpec.BooleanValue explosionsBypassKnockdown;
|
|
||||||
public final ForgeConfigSpec.BooleanValue fallDamageBypassesKnockdown;
|
|
||||||
public final ForgeConfigSpec.BooleanValue lavaBypassesKnockdown;
|
|
||||||
|
|
||||||
public Common(ForgeConfigSpec.Builder builder) {
|
public Common(ForgeConfigSpec.Builder builder) {
|
||||||
builder.push("general");
|
builder.push("general");
|
||||||
@@ -37,19 +34,7 @@ public class Config {
|
|||||||
.comment("If true, Totems of Undying prevent entering the knocked state. Default: true.")
|
.comment("If true, Totems of Undying prevent entering the knocked state. Default: true.")
|
||||||
.define("totemPreventsKnockdown", true);
|
.define("totemPreventsKnockdown", true);
|
||||||
|
|
||||||
explosionsBypassKnockdown = builder
|
|
||||||
.comment("If true, explosions immediately kill instead of knocking down. Default: true.")
|
|
||||||
.define("explosionsBypassKnockdown", true);
|
|
||||||
|
|
||||||
fallDamageBypassesKnockdown = builder
|
|
||||||
.comment("If true, fatal fall damage kills instead of knocking down. Default: true.")
|
|
||||||
.define("fallDamageBypassesKnockdown", true);
|
|
||||||
|
|
||||||
lavaBypassesKnockdown = builder
|
|
||||||
.comment("If true, lava or fire damage kills instead of knocking down. Default: true.")
|
|
||||||
.define("lavaBypassesKnockdown", true);
|
|
||||||
|
|
||||||
builder.pop();
|
builder.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"replace": false,
|
||||||
|
"values": [
|
||||||
|
"minecraft:explosion",
|
||||||
|
"minecraft:player_explosion",
|
||||||
|
"minecraft:fireworks",
|
||||||
|
"minecraft:fall",
|
||||||
|
"minecraft:lava",
|
||||||
|
"minecraft:in_fire",
|
||||||
|
"minecraft:on_fire",
|
||||||
|
"minecraft:hot_floor",
|
||||||
|
"minecraft:fireball"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user