new: CripplingEnchantmentEffect, blindness and weakness
Some checks failed
build / build (push) Failing after 3s

This commit is contained in:
2025-12-23 01:22:32 -06:00
parent d70bacfb6a
commit 8a8a2724b1
7 changed files with 51 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
// 1.21.11 -999999999-01-01T00:00:00 More Spear Enchantments/ModEnchantmentGenerator // 1.21.11 -999999999-01-01T00:00:00 More Spear Enchantments/ModEnchantmentGenerator
f288993ccfd4a1a816cceedb4192d4250a1aee2e data/more_spear_enchants/enchantment/poisoning.json 9b422d06a47d72f3038701f2dee8ba2b69f0ae48 data/more_spear_enchants/enchantment/crippling.json
26301511d9703bb0aa4f568054802c48bd441405 data/more_spear_enchants/enchantment/thundering.json 5344ffb88ac84ee106698b33d2a371acb43e9e32 data/more_spear_enchants/enchantment/poisoning.json
a05e3914c688a81cb95ed0afed46f7a5149bf228 data/more_spear_enchants/enchantment/withering.json 32bf712156f43dd8d319f624514d5a2988cd9ea9 data/more_spear_enchants/enchantment/thundering.json
fae6996317beaa6871f6706360cd2f6b4e4d9ab7 data/more_spear_enchants/enchantment/withering.json

View File

@@ -0,0 +1,36 @@
{
"anvil_cost": 5,
"description": {
"translate": "enchantment.more_spear_enchants.crippling"
},
"effects": {
"minecraft:post_attack": [
{
"affected": "victim",
"effect": {
"type": "more_spear_enchants:crippling",
"duration": {
"type": "minecraft:linear",
"base": 2.0,
"per_level_above_first": 1.0
}
},
"enchanted": "attacker"
}
]
},
"max_cost": {
"base": 1,
"per_level_above_first": 15
},
"max_level": 3,
"min_cost": {
"base": 1,
"per_level_above_first": 10
},
"slots": [
"hand"
],
"supported_items": "#more_spear_enchants:spears",
"weight": 10
}

View File

@@ -8,7 +8,7 @@
{ {
"affected": "victim", "affected": "victim",
"effect": { "effect": {
"type": "more_spear_enchants:poisoning_effect", "type": "more_spear_enchants:poison",
"duration": { "duration": {
"type": "minecraft:linear", "type": "minecraft:linear",
"base": 3.0, "base": 3.0,

View File

@@ -8,7 +8,7 @@
{ {
"affected": "victim", "affected": "victim",
"effect": { "effect": {
"type": "more_spear_enchants:lightning_effect", "type": "more_spear_enchants:lightning",
"amount": { "amount": {
"type": "minecraft:linear", "type": "minecraft:linear",
"base": 0.4, "base": 0.4,

View File

@@ -8,7 +8,7 @@
{ {
"affected": "victim", "affected": "victim",
"effect": { "effect": {
"type": "more_spear_enchants:withering_effect", "type": "more_spear_enchants:withering",
"duration": { "duration": {
"type": "minecraft:linear", "type": "minecraft:linear",
"base": 2.0, "base": 2.0,

View File

@@ -29,6 +29,11 @@ public class ModEnchantmentEffects {
public static void registerModEnchantmentEffects() { public static void registerModEnchantmentEffects() {
MoreSpearEnchantments.LOGGER.info("Registering EnchantmentEffects for " + MoreSpearEnchantments.MOD_ID); MoreSpearEnchantments.LOGGER.info("Registering EnchantmentEffects for " + MoreSpearEnchantments.MOD_ID);
register("lightning", LightningEnchantmentEffect.CODEC);
register("poison", PoisonEnchantmentEffect.CODEC);
register("withering", WitheringEnchantmentEffect.CODEC);
register("crippling", CripplingEnchantmentEffect.CODEC);
} }
} }

View File

@@ -13,10 +13,10 @@ import net.minecraft.enchantment.EnchantmentLevelBasedValue;
import net.minecraft.enchantment.effect.EnchantmentEntityEffect; import net.minecraft.enchantment.effect.EnchantmentEntityEffect;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
public record CripplingEnchantmentEffect(EnchantmentLevelBasedValue duartion) implements EnchantmentEntityEffect { public record CripplingEnchantmentEffect(EnchantmentLevelBasedValue duration) implements EnchantmentEntityEffect {
public static final MapCodec<CripplingEnchantmentEffect> CODEC = RecordCodecBuilder.mapCodec(instance -> public static final MapCodec<CripplingEnchantmentEffect> CODEC = RecordCodecBuilder.mapCodec(instance ->
instance.group( instance.group(
EnchantmentLevelBasedValue.CODEC.fieldOf("duration").forGetter(CripplingEnchantmentEffect::duartion) EnchantmentLevelBasedValue.CODEC.fieldOf("duration").forGetter(CripplingEnchantmentEffect::duration)
).apply(instance, CripplingEnchantmentEffect::new) ).apply(instance, CripplingEnchantmentEffect::new)
); );
@@ -24,7 +24,7 @@ public record CripplingEnchantmentEffect(EnchantmentLevelBasedValue duartion) im
public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity target, Vec3d pos) { public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity target, Vec3d pos) {
if (target instanceof LivingEntity victim) { if (target instanceof LivingEntity victim) {
if (context.owner() != null && context.owner() instanceof PlayerEntity player) { if (context.owner() != null && context.owner() instanceof PlayerEntity player) {
int Duration = (int) (this.duartion.getValue(level) * 50); // Convert to ticks int Duration = (int) (this.duration.getValue(level) * 50); // Convert to ticks
int slownessAmplifier = level - 1; // Level 1 = Slowness 0, Level 2 = Slowness I, Level 3 = Slowness II int slownessAmplifier = level - 1; // Level 1 = Slowness 0, Level 2 = Slowness I, Level 3 = Slowness II
int weaknessAmplifier = level - 1; // Level 1 = Weakness 0, Level 2 = Weakness I, Level 3 = Weakness II int weaknessAmplifier = level - 1; // Level 1 = Weakness 0, Level 2 = Weakness I, Level 3 = Weakness II
victim.addStatusEffect(new StatusEffectInstance( victim.addStatusEffect(new StatusEffectInstance(