This commit is contained in:
parent
4e1b7d8ade
commit
288c1d6e59
@ -0,0 +1,2 @@
|
||||
// 1.21.1 2024-09-29T04:05:48.3198307 Custom Enchants/Enchantment Generator
|
||||
4e507987cd1905de26693915dff86bcadec7e9a0 data\customenchants\enchantment\thundering.json
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"anvil_cost": 7,
|
||||
"description": {
|
||||
"translate": "enchantment.customenchants.thundering"
|
||||
},
|
||||
"effects": {
|
||||
"minecraft:post_attack": [
|
||||
{
|
||||
"affected": "victim",
|
||||
"effect": {
|
||||
"type": "customenchants:lightning",
|
||||
"amount": {
|
||||
"type": "minecraft:linear",
|
||||
"base": 0.5,
|
||||
"per_level_above_first": 0.15
|
||||
}
|
||||
},
|
||||
"enchanted": "attacker"
|
||||
}
|
||||
]
|
||||
},
|
||||
"max_cost": {
|
||||
"base": 1,
|
||||
"per_level_above_first": 15
|
||||
},
|
||||
"max_level": 5,
|
||||
"min_cost": {
|
||||
"base": 1,
|
||||
"per_level_above_first": 10
|
||||
},
|
||||
"slots": [
|
||||
"hand"
|
||||
],
|
||||
"supported_items": "#minecraft:enchantable/sword",
|
||||
"weight": 15
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.itzilly.enchantments.effects;
|
||||
|
||||
import com.mojang.serialization.MapCodec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import net.minecraft.enchantment.EnchantmentEffectContext;
|
||||
import net.minecraft.enchantment.EnchantmentLevelBasedValue;
|
||||
import net.minecraft.enchantment.effect.EnchantmentEntityEffect;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.SpawnReason;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public record LightningEnchantmentEffect(EnchantmentLevelBasedValue amount) implements EnchantmentEntityEffect {
|
||||
public static final MapCodec<LightningEnchantmentEffect> CODEC = RecordCodecBuilder.mapCodec(
|
||||
instance -> instance.group(
|
||||
EnchantmentLevelBasedValue.CODEC.fieldOf("amount").forGetter(LightningEnchantmentEffect::amount)
|
||||
).apply(instance, LightningEnchantmentEffect::new));
|
||||
|
||||
@Override
|
||||
public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity target, Vec3d pos) {
|
||||
if(target instanceof LivingEntity living) {
|
||||
float numberOfStrikes = this.amount.getValue(level);
|
||||
|
||||
BlockPos targetPosition = living.getBlockPos();
|
||||
for (int i = 0; i < numberOfStrikes; i++) {
|
||||
EntityType.LIGHTNING_BOLT.spawn(world, targetPosition, SpawnReason.TRIGGERED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapCodec<? extends EnchantmentEntityEffect> getCodec() {
|
||||
return CODEC;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user