| 1 | package net.minecraft.world.item.enchantment.effects;
|
| 2 |
|
| 3 | import com.mojang.serialization.Codec;
|
| 4 | import com.mojang.serialization.MapCodec;
|
| 5 | import java.util.function.Function;
|
| 6 | import net.minecraft.core.Registry;
|
| 7 | import net.minecraft.core.registries.BuiltInRegistries;
|
| 8 | import net.minecraft.server.level.ServerLevel;
|
| 9 | import net.minecraft.world.entity.Entity;
|
| 10 | import net.minecraft.world.item.enchantment.EnchantedItemInUse;
|
| 11 | import net.minecraft.world.phys.Vec3;
|
| 12 |
|
| 13 | public interface EnchantmentEntityEffect extends EnchantmentLocationBasedEffect {
|
| 14 | Codec<EnchantmentEntityEffect> CODEC = BuiltInRegistries.ENCHANTMENT_ENTITY_EFFECT_TYPE
|
| 15 | .byNameCodec()
|
| 16 | .dispatch(EnchantmentEntityEffect::codec, Function.identity());
|
| 17 |
|
| 18 | static MapCodec<? extends EnchantmentEntityEffect> bootstrap(final Registry<MapCodec<? extends EnchantmentEntityEffect>> registry) {
|
| 19 | Registry.register(registry, "all_of", AllOf.EntityEffects.CODEC);
|
| 20 | Registry.register(registry, "apply_mob_effect", ApplyMobEffect.CODEC);
|
| 21 | Registry.register(registry, "change_item_damage", ChangeItemDamage.CODEC);
|
| 22 | Registry.register(registry, "damage_entity", DamageEntity.CODEC);
|
| 23 | Registry.register(registry, "explode", ExplodeEffect.CODEC);
|
| 24 | Registry.register(registry, "ignite", Ignite.CODEC);
|
| 25 | Registry.register(registry, "apply_impulse", ApplyEntityImpulse.CODEC);
|
| 26 | Registry.register(registry, "apply_exhaustion", ApplyExhaustion.CODEC);
|
| 27 | Registry.register(registry, "play_sound", PlaySoundEffect.CODEC);
|
| 28 | Registry.register(registry, "replace_block", ReplaceBlock.CODEC);
|
| 29 | Registry.register(registry, "replace_disk", ReplaceDisk.CODEC);
|
| 30 | Registry.register(registry, "run_function", RunFunction.CODEC);
|
| 31 | Registry.register(registry, "set_block_properties", SetBlockProperties.CODEC);
|
| 32 | Registry.register(registry, "spawn_particles", SpawnParticlesEffect.CODEC);
|
| 33 | return Registry.register(registry, "summon_entity", SummonEntityEffect.CODEC);
|
| 34 | }
|
| 35 |
|
| 36 | void apply(ServerLevel serverLevel, int enchantmentLevel, EnchantedItemInUse item, Entity entity, Vec3 position);
|
| 37 |
|
| 38 | @Override
|
| 39 | default void onChangedBlock(
|
| 40 | final ServerLevel serverLevel,
|
| 41 | final int enchantmentLevel,
|
| 42 | final EnchantedItemInUse item,
|
| 43 | final Entity entity,
|
| 44 | final Vec3 position,
|
| 45 | final boolean becameActive
|
| 46 | ) {
|
| 47 | this.apply(serverLevel, enchantmentLevel, item, entity, position);
|
| 48 | }
|
| 49 |
|
| 50 | @Override
|
| 51 | MapCodec<? extends EnchantmentEntityEffect> codec();
|
| 52 | }
|
| 53 |
|