Skip to content

Commit

Permalink
Removed useless duration field in the enchantment
Browse files Browse the repository at this point in the history
  • Loading branch information
Starexify committed Jan 14, 2025
1 parent 213f34d commit 4bad760
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
{
"affected": "victim",
"effect": {
"type": "big_swords:soul_steal",
"duration": 0
"type": "big_swords:soul_steal"
},
"enchanted": "attacker"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/nova/big_swords/data/BSEnchantments.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void bootstrap(BootstrapContext<Enchantment> context) {
EnchantmentEffectComponents.POST_ATTACK,
EnchantmentTarget.ATTACKER,
EnchantmentTarget.VICTIM,
new SoulStealEffect(0)
new SoulStealEffect()
)
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.nova.big_swords.enchantments.effects;

import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
Expand All @@ -16,10 +14,8 @@
import net.nova.big_swords.init.BSItems;
import net.nova.big_swords.init.Tags;

public record SoulStealEffect(int duration) implements EnchantmentEntityEffect {
public static final MapCodec<SoulStealEffect> CODEC = RecordCodecBuilder.mapCodec(
inst -> inst.group(Codec.INT.fieldOf("duration").forGetter(p_345622_ -> p_345622_.duration)).apply(inst, SoulStealEffect::new)
);
public record SoulStealEffect() implements EnchantmentEntityEffect {
public static final MapCodec<SoulStealEffect> CODEC = MapCodec.unit(new SoulStealEffect());

@Override
public void apply(ServerLevel level, int pEnchantmentLevel, EnchantedItemInUse pItem, Entity entity, Vec3 pOrigin) {
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/net/nova/big_swords/item/ScytheItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,9 @@ public boolean releaseUsing(ItemStack stack, Level level, LivingEntity entity, i
scytheHits(player, target);
entitiesHit++;

int soulStealerEnchantment = stack.getEnchantmentLevel(BigSwordsR.getEnchantment(level, BSEnchantments.SOUL_STEALER));
if (soulStealerEnchantment > 0) {
SoulStealEffect soulStealEffect = new SoulStealEffect(200);
soulStealEffect.apply((ServerLevel) level,
soulStealerEnchantment,
new EnchantedItemInUse(stack, entity.getEquipmentSlotForItem(stack), entity),
target,
target.position()
);
}
int soulStealerEnchantmentLevel = stack.getEnchantmentLevel(BigSwordsR.getEnchantment(level, BSEnchantments.SOUL_STEALER));
if (soulStealerEnchantmentLevel > 0)
new SoulStealEffect().apply((ServerLevel) level, soulStealerEnchantmentLevel, new EnchantedItemInUse(stack, entity.getEquipmentSlotForItem(stack), entity), target, target.position());
}
}
}
Expand Down

0 comments on commit 4bad760

Please sign in to comment.