| 1 | package net.minecraft.world.item.enchantment;
|
| 2 |
|
| 3 | import java.util.List;
|
| 4 | import java.util.Optional;
|
| 5 | import java.util.function.Function;
|
| 6 | import net.minecraft.advancements.predicates.DamageSourcePredicate;
|
| 7 | import net.minecraft.advancements.predicates.FoodPredicate;
|
| 8 | import net.minecraft.advancements.predicates.GameTypePredicate;
|
| 9 | import net.minecraft.advancements.predicates.ItemPredicate;
|
| 10 | import net.minecraft.advancements.predicates.LocationPredicate;
|
| 11 | import net.minecraft.advancements.predicates.MinMaxBounds;
|
| 12 | import net.minecraft.advancements.predicates.TagPredicate;
|
| 13 | import net.minecraft.advancements.predicates.entity.EntityFlagsPredicate;
|
| 14 | import net.minecraft.advancements.predicates.entity.EntityPredicate;
|
| 15 | import net.minecraft.advancements.predicates.entity.EntityTypePredicate;
|
| 16 | import net.minecraft.advancements.predicates.entity.MovementPredicate;
|
| 17 | import net.minecraft.advancements.predicates.entity.PlayerPredicate;
|
| 18 | import net.minecraft.core.Direction;
|
| 19 | import net.minecraft.core.HolderGetter;
|
| 20 | import net.minecraft.core.HolderSet;
|
| 21 | import net.minecraft.core.Vec3i;
|
| 22 | import net.minecraft.core.particles.ParticleTypes;
|
| 23 | import net.minecraft.core.registries.Registries;
|
| 24 | import net.minecraft.data.worldgen.BootstrapContext;
|
| 25 | import net.minecraft.resources.Identifier;
|
| 26 | import net.minecraft.resources.ResourceKey;
|
| 27 | import net.minecraft.sounds.SoundEvents;
|
| 28 | import net.minecraft.tags.BlockTags;
|
| 29 | import net.minecraft.tags.DamageTypeTags;
|
| 30 | import net.minecraft.tags.EnchantmentTags;
|
| 31 | import net.minecraft.tags.EntityTypeTags;
|
| 32 | import net.minecraft.tags.ItemTags;
|
| 33 | import net.minecraft.util.Mth;
|
| 34 | import net.minecraft.util.random.WeightedList;
|
| 35 | import net.minecraft.util.valueproviders.ConstantFloat;
|
| 36 | import net.minecraft.util.valueproviders.UniformFloat;
|
| 37 | import net.minecraft.world.damagesource.DamageType;
|
| 38 | import net.minecraft.world.damagesource.DamageTypes;
|
| 39 | import net.minecraft.world.effect.MobEffects;
|
| 40 | import net.minecraft.world.entity.EntityType;
|
| 41 | import net.minecraft.world.entity.EntityTypes;
|
| 42 | import net.minecraft.world.entity.EquipmentSlotGroup;
|
| 43 | import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
| 44 | import net.minecraft.world.entity.ai.attributes.Attributes;
|
| 45 | import net.minecraft.world.item.CrossbowItem;
|
| 46 | import net.minecraft.world.item.Item;
|
| 47 | import net.minecraft.world.item.Items;
|
| 48 | import net.minecraft.world.item.enchantment.effects.AddValue;
|
| 49 | import net.minecraft.world.item.enchantment.effects.AllOf;
|
| 50 | import net.minecraft.world.item.enchantment.effects.ApplyEntityImpulse;
|
| 51 | import net.minecraft.world.item.enchantment.effects.ApplyExhaustion;
|
| 52 | import net.minecraft.world.item.enchantment.effects.ApplyMobEffect;
|
| 53 | import net.minecraft.world.item.enchantment.effects.ChangeItemDamage;
|
| 54 | import net.minecraft.world.item.enchantment.effects.DamageEntity;
|
| 55 | import net.minecraft.world.item.enchantment.effects.DamageImmunity;
|
| 56 | import net.minecraft.world.item.enchantment.effects.EnchantmentAttributeEffect;
|
| 57 | import net.minecraft.world.item.enchantment.effects.ExplodeEffect;
|
| 58 | import net.minecraft.world.item.enchantment.effects.Ignite;
|
| 59 | import net.minecraft.world.item.enchantment.effects.MultiplyValue;
|
| 60 | import net.minecraft.world.item.enchantment.effects.PlaySoundEffect;
|
| 61 | import net.minecraft.world.item.enchantment.effects.RemoveBinomial;
|
| 62 | import net.minecraft.world.item.enchantment.effects.ReplaceDisk;
|
| 63 | import net.minecraft.world.item.enchantment.effects.SetValue;
|
| 64 | import net.minecraft.world.item.enchantment.effects.SpawnParticlesEffect;
|
| 65 | import net.minecraft.world.item.enchantment.effects.SummonEntityEffect;
|
| 66 | import net.minecraft.world.level.GameType;
|
| 67 | import net.minecraft.world.level.Level;
|
| 68 | import net.minecraft.world.level.block.Block;
|
| 69 | import net.minecraft.world.level.block.Blocks;
|
| 70 | import net.minecraft.world.level.gameevent.GameEvent;
|
| 71 | import net.minecraft.world.level.levelgen.blockpredicates.BlockPredicate;
|
| 72 | import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
|
| 73 | import net.minecraft.world.level.material.Fluids;
|
| 74 | import net.minecraft.world.level.storage.loot.LootContext;
|
| 75 | import net.minecraft.world.level.storage.loot.predicates.AllOfCondition;
|
| 76 | import net.minecraft.world.level.storage.loot.predicates.AnyOfCondition;
|
| 77 | import net.minecraft.world.level.storage.loot.predicates.DamageSourceCondition;
|
| 78 | import net.minecraft.world.level.storage.loot.predicates.EnchantmentActiveCheck;
|
| 79 | import net.minecraft.world.level.storage.loot.predicates.InvertedLootItemCondition;
|
| 80 | import net.minecraft.world.level.storage.loot.predicates.LocationCheck;
|
| 81 | import net.minecraft.world.level.storage.loot.predicates.LootItemEntityPropertyCondition;
|
| 82 | import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
|
| 83 | import net.minecraft.world.level.storage.loot.predicates.MatchTool;
|
| 84 | import net.minecraft.world.level.storage.loot.predicates.WeatherCheck;
|
| 85 | import net.minecraft.world.level.storage.loot.providers.number.floats.ContextFloatProviders;
|
| 86 | import net.minecraft.world.phys.Vec3;
|
| 87 |
|
| 88 | public class Enchantments {
|
| 89 | public static final ResourceKey<Enchantment> PROTECTION = key("protection");
|
| 90 | public static final ResourceKey<Enchantment> FIRE_PROTECTION = key("fire_protection");
|
| 91 | public static final ResourceKey<Enchantment> FEATHER_FALLING = key("feather_falling");
|
| 92 | public static final ResourceKey<Enchantment> BLAST_PROTECTION = key("blast_protection");
|
| 93 | public static final ResourceKey<Enchantment> PROJECTILE_PROTECTION = key("projectile_protection");
|
| 94 | public static final ResourceKey<Enchantment> RESPIRATION = key("respiration");
|
| 95 | public static final ResourceKey<Enchantment> AQUA_AFFINITY = key("aqua_affinity");
|
| 96 | public static final ResourceKey<Enchantment> THORNS = key("thorns");
|
| 97 | public static final ResourceKey<Enchantment> DEPTH_STRIDER = key("depth_strider");
|
| 98 | public static final ResourceKey<Enchantment> FROST_WALKER = key("frost_walker");
|
| 99 | public static final ResourceKey<Enchantment> BINDING_CURSE = key("binding_curse");
|
| 100 | public static final ResourceKey<Enchantment> SOUL_SPEED = key("soul_speed");
|
| 101 | public static final ResourceKey<Enchantment> SWIFT_SNEAK = key("swift_sneak");
|
| 102 | public static final ResourceKey<Enchantment> SHARPNESS = key("sharpness");
|
| 103 | public static final ResourceKey<Enchantment> SMITE = key("smite");
|
| 104 | public static final ResourceKey<Enchantment> BANE_OF_ARTHROPODS = key("bane_of_arthropods");
|
| 105 | public static final ResourceKey<Enchantment> KNOCKBACK = key("knockback");
|
| 106 | public static final ResourceKey<Enchantment> FIRE_ASPECT = key("fire_aspect");
|
| 107 | public static final ResourceKey<Enchantment> LOOTING = key("looting");
|
| 108 | public static final ResourceKey<Enchantment> SWEEPING_EDGE = key("sweeping_edge");
|
| 109 | public static final ResourceKey<Enchantment> EFFICIENCY = key("efficiency");
|
| 110 | public static final ResourceKey<Enchantment> SILK_TOUCH = key("silk_touch");
|
| 111 | public static final ResourceKey<Enchantment> UNBREAKING = key("unbreaking");
|
| 112 | public static final ResourceKey<Enchantment> FORTUNE = key("fortune");
|
| 113 | public static final ResourceKey<Enchantment> POWER = key("power");
|
| 114 | public static final ResourceKey<Enchantment> PUNCH = key("punch");
|
| 115 | public static final ResourceKey<Enchantment> FLAME = key("flame");
|
| 116 | public static final ResourceKey<Enchantment> INFINITY = key("infinity");
|
| 117 | public static final ResourceKey<Enchantment> LUCK_OF_THE_SEA = key("luck_of_the_sea");
|
| 118 | public static final ResourceKey<Enchantment> LURE = key("lure");
|
| 119 | public static final ResourceKey<Enchantment> LOYALTY = key("loyalty");
|
| 120 | public static final ResourceKey<Enchantment> IMPALING = key("impaling");
|
| 121 | public static final ResourceKey<Enchantment> RIPTIDE = key("riptide");
|
| 122 | public static final ResourceKey<Enchantment> CHANNELING = key("channeling");
|
| 123 | public static final ResourceKey<Enchantment> MULTISHOT = key("multishot");
|
| 124 | public static final ResourceKey<Enchantment> QUICK_CHARGE = key("quick_charge");
|
| 125 | public static final ResourceKey<Enchantment> PIERCING = key("piercing");
|
| 126 | public static final ResourceKey<Enchantment> DENSITY = key("density");
|
| 127 | public static final ResourceKey<Enchantment> BREACH = key("breach");
|
| 128 | public static final ResourceKey<Enchantment> WIND_BURST = key("wind_burst");
|
| 129 | public static final ResourceKey<Enchantment> LUNGE = key("lunge");
|
| 130 | public static final ResourceKey<Enchantment> MENDING = key("mending");
|
| 131 | public static final ResourceKey<Enchantment> VANISHING_CURSE = key("vanishing_curse");
|
| 132 |
|
| 133 | public static void bootstrap(final BootstrapContext<Enchantment> context) {
|
| 134 | HolderGetter<DamageType> damageTypes = context.lookup(Registries.DAMAGE_TYPE);
|
| 135 | HolderGetter<Enchantment> enchantments = context.lookup(Registries.ENCHANTMENT);
|
| 136 | HolderGetter<Item> items = context.lookup(Registries.ITEM);
|
| 137 | HolderGetter<Block> blocks = context.lookup(Registries.BLOCK);
|
| 138 | HolderGetter<EntityType<?>> entityTypes = context.lookup(Registries.ENTITY_TYPE);
|
| 139 | register(
|
| 140 | context,
|
| 141 | PROTECTION,
|
| 142 | Enchantment.enchantment(
|
| 143 | Enchantment.definition(
|
| 144 | items.getOrThrow(ItemTags.ARMOR_ENCHANTABLE), 10, 4, Enchantment.dynamicCost(1, 11), Enchantment.dynamicCost(12, 11), 1, EquipmentSlotGroup.ARMOR
|
| 145 | )
|
| 146 | )
|
| 147 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.ARMOR_EXCLUSIVE))
|
| 148 | .withEffect(
|
| 149 | EnchantmentEffectComponents.DAMAGE_PROTECTION,
|
| 150 | new AddValue(LevelBasedValue.perLevel(1.0F)),
|
| 151 | DamageSourceCondition.hasDamageSource(
|
| 152 | DamageSourcePredicate.Builder.damageType().tag(TagPredicate.isNot(damageTypes, DamageTypeTags.BYPASSES_INVULNERABILITY))
|
| 153 | )
|
| 154 | )
|
| 155 | );
|
| 156 | register(
|
| 157 | context,
|
| 158 | FIRE_PROTECTION,
|
| 159 | Enchantment.enchantment(
|
| 160 | Enchantment.definition(
|
| 161 | items.getOrThrow(ItemTags.ARMOR_ENCHANTABLE), 5, 4, Enchantment.dynamicCost(10, 8), Enchantment.dynamicCost(18, 8), 2, EquipmentSlotGroup.ARMOR
|
| 162 | )
|
| 163 | )
|
| 164 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.ARMOR_EXCLUSIVE))
|
| 165 | .withEffect(
|
| 166 | EnchantmentEffectComponents.DAMAGE_PROTECTION,
|
| 167 | new AddValue(LevelBasedValue.perLevel(2.0F)),
|
| 168 | DamageSourceCondition.hasDamageSource(
|
| 169 | DamageSourcePredicate.Builder.damageType()
|
| 170 | .tag(TagPredicate.is(damageTypes, DamageTypeTags.IS_FIRE))
|
| 171 | .tag(TagPredicate.isNot(damageTypes, DamageTypeTags.BYPASSES_INVULNERABILITY))
|
| 172 | )
|
| 173 | )
|
| 174 | .withEffect(
|
| 175 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 176 | new EnchantmentAttributeEffect(
|
| 177 | Identifier.withDefaultNamespace("enchantment.fire_protection"),
|
| 178 | Attributes.BURNING_TIME,
|
| 179 | LevelBasedValue.perLevel(-0.15F),
|
| 180 | AttributeModifier.Operation.ADD_MULTIPLIED_BASE
|
| 181 | )
|
| 182 | )
|
| 183 | );
|
| 184 | register(
|
| 185 | context,
|
| 186 | FEATHER_FALLING,
|
| 187 | Enchantment.enchantment(
|
| 188 | Enchantment.definition(
|
| 189 | items.getOrThrow(ItemTags.FOOT_ARMOR_ENCHANTABLE), 5, 4, Enchantment.dynamicCost(5, 6), Enchantment.dynamicCost(11, 6), 2, EquipmentSlotGroup.ARMOR
|
| 190 | )
|
| 191 | )
|
| 192 | .withEffect(
|
| 193 | EnchantmentEffectComponents.DAMAGE_PROTECTION,
|
| 194 | new AddValue(LevelBasedValue.perLevel(3.0F)),
|
| 195 | DamageSourceCondition.hasDamageSource(
|
| 196 | DamageSourcePredicate.Builder.damageType()
|
| 197 | .tag(TagPredicate.is(damageTypes, DamageTypeTags.IS_FALL))
|
| 198 | .tag(TagPredicate.isNot(damageTypes, DamageTypeTags.BYPASSES_INVULNERABILITY))
|
| 199 | )
|
| 200 | )
|
| 201 | );
|
| 202 | register(
|
| 203 | context,
|
| 204 | BLAST_PROTECTION,
|
| 205 | Enchantment.enchantment(
|
| 206 | Enchantment.definition(
|
| 207 | items.getOrThrow(ItemTags.ARMOR_ENCHANTABLE), 2, 4, Enchantment.dynamicCost(5, 8), Enchantment.dynamicCost(13, 8), 4, EquipmentSlotGroup.ARMOR
|
| 208 | )
|
| 209 | )
|
| 210 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.ARMOR_EXCLUSIVE))
|
| 211 | .withEffect(
|
| 212 | EnchantmentEffectComponents.DAMAGE_PROTECTION,
|
| 213 | new AddValue(LevelBasedValue.perLevel(2.0F)),
|
| 214 | DamageSourceCondition.hasDamageSource(
|
| 215 | DamageSourcePredicate.Builder.damageType()
|
| 216 | .tag(TagPredicate.is(damageTypes, DamageTypeTags.IS_EXPLOSION))
|
| 217 | .tag(TagPredicate.isNot(damageTypes, DamageTypeTags.BYPASSES_INVULNERABILITY))
|
| 218 | )
|
| 219 | )
|
| 220 | .withEffect(
|
| 221 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 222 | new EnchantmentAttributeEffect(
|
| 223 | Identifier.withDefaultNamespace("enchantment.blast_protection"),
|
| 224 | Attributes.EXPLOSION_KNOCKBACK_RESISTANCE,
|
| 225 | LevelBasedValue.perLevel(0.15F),
|
| 226 | AttributeModifier.Operation.ADD_VALUE
|
| 227 | )
|
| 228 | )
|
| 229 | );
|
| 230 | register(
|
| 231 | context,
|
| 232 | PROJECTILE_PROTECTION,
|
| 233 | Enchantment.enchantment(
|
| 234 | Enchantment.definition(
|
| 235 | items.getOrThrow(ItemTags.ARMOR_ENCHANTABLE), 5, 4, Enchantment.dynamicCost(3, 6), Enchantment.dynamicCost(9, 6), 2, EquipmentSlotGroup.ARMOR
|
| 236 | )
|
| 237 | )
|
| 238 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.ARMOR_EXCLUSIVE))
|
| 239 | .withEffect(
|
| 240 | EnchantmentEffectComponents.DAMAGE_PROTECTION,
|
| 241 | new AddValue(LevelBasedValue.perLevel(2.0F)),
|
| 242 | DamageSourceCondition.hasDamageSource(
|
| 243 | DamageSourcePredicate.Builder.damageType()
|
| 244 | .tag(TagPredicate.is(damageTypes, DamageTypeTags.IS_PROJECTILE))
|
| 245 | .tag(TagPredicate.isNot(damageTypes, DamageTypeTags.BYPASSES_INVULNERABILITY))
|
| 246 | )
|
| 247 | )
|
| 248 | );
|
| 249 | register(
|
| 250 | context,
|
| 251 | RESPIRATION,
|
| 252 | Enchantment.enchantment(
|
| 253 | Enchantment.definition(
|
| 254 | items.getOrThrow(ItemTags.HEAD_ARMOR_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(10, 10), Enchantment.dynamicCost(40, 10), 4, EquipmentSlotGroup.HEAD
|
| 255 | )
|
| 256 | )
|
| 257 | .withEffect(
|
| 258 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 259 | new EnchantmentAttributeEffect(
|
| 260 | Identifier.withDefaultNamespace("enchantment.respiration"),
|
| 261 | Attributes.OXYGEN_BONUS,
|
| 262 | LevelBasedValue.perLevel(1.0F),
|
| 263 | AttributeModifier.Operation.ADD_VALUE
|
| 264 | )
|
| 265 | )
|
| 266 | );
|
| 267 | register(
|
| 268 | context,
|
| 269 | AQUA_AFFINITY,
|
| 270 | Enchantment.enchantment(
|
| 271 | Enchantment.definition(
|
| 272 | items.getOrThrow(ItemTags.HEAD_ARMOR_ENCHANTABLE), 2, 1, Enchantment.constantCost(1), Enchantment.constantCost(41), 4, EquipmentSlotGroup.HEAD
|
| 273 | )
|
| 274 | )
|
| 275 | .withEffect(
|
| 276 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 277 | new EnchantmentAttributeEffect(
|
| 278 | Identifier.withDefaultNamespace("enchantment.aqua_affinity"),
|
| 279 | Attributes.SUBMERGED_MINING_SPEED,
|
| 280 | LevelBasedValue.perLevel(4.0F),
|
| 281 | AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL
|
| 282 | )
|
| 283 | )
|
| 284 | );
|
| 285 | register(
|
| 286 | context,
|
| 287 | THORNS,
|
| 288 | Enchantment.enchantment(
|
| 289 | Enchantment.definition(
|
| 290 | items.getOrThrow(ItemTags.ARMOR_ENCHANTABLE),
|
| 291 | items.getOrThrow(ItemTags.CHEST_ARMOR_ENCHANTABLE),
|
| 292 | 1,
|
| 293 | 3,
|
| 294 | Enchantment.dynamicCost(10, 20),
|
| 295 | Enchantment.dynamicCost(60, 20),
|
| 296 | 8,
|
| 297 | EquipmentSlotGroup.ANY
|
| 298 | )
|
| 299 | )
|
| 300 | .withEffect(
|
| 301 | EnchantmentEffectComponents.POST_ATTACK,
|
| 302 | EnchantmentTarget.VICTIM,
|
| 303 | EnchantmentTarget.ATTACKER,
|
| 304 | AllOf.entityEffects(
|
| 305 | new DamageEntity(LevelBasedValue.constant(1.0F), LevelBasedValue.constant(5.0F), damageTypes.getOrThrow(DamageTypes.THORNS)),
|
| 306 | new ChangeItemDamage(LevelBasedValue.constant(2.0F))
|
| 307 | ),
|
| 308 | LootItemRandomChanceCondition.randomChance(ContextFloatProviders.forEnchantmentLevel(LevelBasedValue.perLevel(0.15F)))
|
| 309 | )
|
| 310 | );
|
| 311 | register(
|
| 312 | context,
|
| 313 | DEPTH_STRIDER,
|
| 314 | Enchantment.enchantment(
|
| 315 | Enchantment.definition(
|
| 316 | items.getOrThrow(ItemTags.FOOT_ARMOR_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(10, 10), Enchantment.dynamicCost(25, 10), 4, EquipmentSlotGroup.FEET
|
| 317 | )
|
| 318 | )
|
| 319 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.BOOTS_EXCLUSIVE))
|
| 320 | .withEffect(
|
| 321 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 322 | new EnchantmentAttributeEffect(
|
| 323 | Identifier.withDefaultNamespace("enchantment.depth_strider"),
|
| 324 | Attributes.WATER_MOVEMENT_EFFICIENCY,
|
| 325 | LevelBasedValue.perLevel(0.33333334F),
|
| 326 | AttributeModifier.Operation.ADD_VALUE
|
| 327 | )
|
| 328 | )
|
| 329 | );
|
| 330 | register(
|
| 331 | context,
|
| 332 | FROST_WALKER,
|
| 333 | Enchantment.enchantment(
|
| 334 | Enchantment.definition(
|
| 335 | items.getOrThrow(ItemTags.FOOT_ARMOR_ENCHANTABLE), 2, 2, Enchantment.dynamicCost(10, 10), Enchantment.dynamicCost(25, 10), 4, EquipmentSlotGroup.FEET
|
| 336 | )
|
| 337 | )
|
| 338 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.BOOTS_EXCLUSIVE))
|
| 339 | .withEffect(
|
| 340 | EnchantmentEffectComponents.DAMAGE_IMMUNITY,
|
| 341 | DamageImmunity.INSTANCE,
|
| 342 | DamageSourceCondition.hasDamageSource(
|
| 343 | DamageSourcePredicate.Builder.damageType()
|
| 344 | .tag(TagPredicate.is(damageTypes, DamageTypeTags.BURN_FROM_STEPPING))
|
| 345 | .tag(TagPredicate.isNot(damageTypes, DamageTypeTags.BYPASSES_INVULNERABILITY))
|
| 346 | )
|
| 347 | )
|
| 348 | .withEffect(
|
| 349 | EnchantmentEffectComponents.LOCATION_CHANGED,
|
| 350 | new ReplaceDisk(
|
| 351 | new LevelBasedValue.Clamped(LevelBasedValue.perLevel(3.0F, 1.0F), 0.0F, 16.0F),
|
| 352 | LevelBasedValue.constant(1.0F),
|
| 353 | new Vec3i(0, -1, 0),
|
| 354 | Optional.of(
|
| 355 | BlockPredicate.allOf(
|
| 356 | BlockPredicate.matchesTag(Direction.UP, BlockTags.AIR),
|
| 357 | BlockPredicate.matchesBlocks(Blocks.WATER),
|
| 358 | BlockPredicate.matchesFluids(Fluids.WATER),
|
| 359 | BlockPredicate.unobstructed()
|
| 360 | )
|
| 361 | ),
|
| 362 | BlockStateProvider.holderOf(Blocks.FROSTED_ICE),
|
| 363 | Optional.of(GameEvent.BLOCK_PLACE)
|
| 364 | ),
|
| 365 | AllOfCondition.allOf(
|
| 366 | LootItemEntityPropertyCondition.hasProperties(
|
| 367 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().flags(EntityFlagsPredicate.Builder.flags().setOnGround(true))
|
| 368 | ),
|
| 369 | InvertedLootItemCondition.invert(
|
| 370 | LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().vehicle(EntityPredicate.Builder.entity()))
|
| 371 | )
|
| 372 | )
|
| 373 | )
|
| 374 | );
|
| 375 | register(
|
| 376 | context,
|
| 377 | BINDING_CURSE,
|
| 378 | Enchantment.enchantment(
|
| 379 | Enchantment.definition(
|
| 380 | items.getOrThrow(ItemTags.EQUIPPABLE_ENCHANTABLE), 1, 1, Enchantment.constantCost(25), Enchantment.constantCost(50), 8, EquipmentSlotGroup.ARMOR
|
| 381 | )
|
| 382 | )
|
| 383 | .withEffect(EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)
|
| 384 | );
|
| 385 | EntityPredicate.Builder soulSpeedEffectCondition = EntityPredicate.Builder.entity()
|
| 386 | .periodicTick(5)
|
| 387 | .flags(EntityFlagsPredicate.Builder.flags().setIsFlying(false).setOnGround(true))
|
| 388 | .moving(MovementPredicate.horizontalSpeed(MinMaxBounds.Doubles.atLeast(1.0E-5F)))
|
| 389 | .movementAffectedBy(
|
| 390 | LocationPredicate.Builder.location().setBlock(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blocks, BlockTags.SOUL_SPEED_BLOCKS))
|
| 391 | );
|
| 392 | AllOfCondition.Builder soulSpeedMovementCondition = AllOfCondition.allOf(
|
| 393 | InvertedLootItemCondition.invert(
|
| 394 | LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().vehicle(EntityPredicate.Builder.entity()))
|
| 395 | ),
|
| 396 | AnyOfCondition.anyOf(
|
| 397 | AllOfCondition.allOf(
|
| 398 | EnchantmentActiveCheck.enchantmentActiveCheck(),
|
| 399 | LootItemEntityPropertyCondition.hasProperties(
|
| 400 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().flags(EntityFlagsPredicate.Builder.flags().setIsFlying(false))
|
| 401 | ),
|
| 402 | AnyOfCondition.anyOf(
|
| 403 | LootItemEntityPropertyCondition.hasProperties(
|
| 404 | LootContext.EntityTarget.THIS,
|
| 405 | EntityPredicate.Builder.entity()
|
| 406 | .movementAffectedBy(
|
| 407 | LocationPredicate.Builder.location()
|
| 408 | .setBlock(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blocks, BlockTags.SOUL_SPEED_BLOCKS))
|
| 409 | )
|
| 410 | ),
|
| 411 | LootItemEntityPropertyCondition.hasProperties(
|
| 412 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().flags(EntityFlagsPredicate.Builder.flags().setOnGround(false)).build()
|
| 413 | )
|
| 414 | )
|
| 415 | ),
|
| 416 | AllOfCondition.allOf(
|
| 417 | EnchantmentActiveCheck.enchantmentInactiveCheck(),
|
| 418 | LootItemEntityPropertyCondition.hasProperties(
|
| 419 | LootContext.EntityTarget.THIS,
|
| 420 | EntityPredicate.Builder.entity()
|
| 421 | .movementAffectedBy(
|
| 422 | LocationPredicate.Builder.location()
|
| 423 | .setBlock(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blocks, BlockTags.SOUL_SPEED_BLOCKS))
|
| 424 | )
|
| 425 | .flags(EntityFlagsPredicate.Builder.flags().setIsFlying(false))
|
| 426 | )
|
| 427 | )
|
| 428 | )
|
| 429 | );
|
| 430 | register(
|
| 431 | context,
|
| 432 | SOUL_SPEED,
|
| 433 | Enchantment.enchantment(
|
| 434 | Enchantment.definition(
|
| 435 | items.getOrThrow(ItemTags.FOOT_ARMOR_ENCHANTABLE), 1, 3, Enchantment.dynamicCost(10, 10), Enchantment.dynamicCost(25, 10), 8, EquipmentSlotGroup.FEET
|
| 436 | )
|
| 437 | )
|
| 438 | .withEffect(
|
| 439 | EnchantmentEffectComponents.LOCATION_CHANGED,
|
| 440 | AllOf.locationBasedEffects(
|
| 441 | new EnchantmentAttributeEffect(
|
| 442 | Identifier.withDefaultNamespace("enchantment.soul_speed"),
|
| 443 | Attributes.MOVEMENT_SPEED,
|
| 444 | LevelBasedValue.perLevel(0.0405F, 0.0105F),
|
| 445 | AttributeModifier.Operation.ADD_VALUE
|
| 446 | ),
|
| 447 | new EnchantmentAttributeEffect(
|
| 448 | Identifier.withDefaultNamespace("enchantment.soul_speed"),
|
| 449 | Attributes.MOVEMENT_EFFICIENCY,
|
| 450 | LevelBasedValue.constant(1.0F),
|
| 451 | AttributeModifier.Operation.ADD_VALUE
|
| 452 | )
|
| 453 | ),
|
| 454 | soulSpeedMovementCondition
|
| 455 | )
|
| 456 | .withEffect(
|
| 457 | EnchantmentEffectComponents.LOCATION_CHANGED,
|
| 458 | new ChangeItemDamage(LevelBasedValue.constant(1.0F)),
|
| 459 | AllOfCondition.allOf(
|
| 460 | LootItemRandomChanceCondition.randomChance(ContextFloatProviders.forEnchantmentLevel(LevelBasedValue.constant(0.04F))),
|
| 461 | LootItemEntityPropertyCondition.hasProperties(
|
| 462 | LootContext.EntityTarget.THIS,
|
| 463 | EntityPredicate.Builder.entity()
|
| 464 | .flags(EntityFlagsPredicate.Builder.flags().setOnGround(true))
|
| 465 | .movementAffectedBy(
|
| 466 | LocationPredicate.Builder.location()
|
| 467 | .setBlock(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blocks, BlockTags.SOUL_SPEED_BLOCKS))
|
| 468 | )
|
| 469 | )
|
| 470 | )
|
| 471 | )
|
| 472 | .withEffect(
|
| 473 | EnchantmentEffectComponents.TICK,
|
| 474 | new SpawnParticlesEffect(
|
| 475 | ParticleTypes.SOUL,
|
| 476 | SpawnParticlesEffect.inBoundingBox(),
|
| 477 | SpawnParticlesEffect.offsetFromEntityPosition(0.1F),
|
| 478 | SpawnParticlesEffect.movementScaled(-0.2F),
|
| 479 | SpawnParticlesEffect.fixedVelocity(ConstantFloat.of(0.1F)),
|
| 480 | ConstantFloat.of(1.0F)
|
| 481 | ),
|
| 482 | LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, soulSpeedEffectCondition)
|
| 483 | )
|
| 484 | .withEffect(
|
| 485 | EnchantmentEffectComponents.TICK,
|
| 486 | new PlaySoundEffect(List.of(SoundEvents.SOUL_ESCAPE), ConstantFloat.of(0.6F), UniformFloat.of(0.6F, 1.0F)),
|
| 487 | AllOfCondition.allOf(
|
| 488 | LootItemRandomChanceCondition.randomChance(0.35F), LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, soulSpeedEffectCondition)
|
| 489 | )
|
| 490 | )
|
| 491 | );
|
| 492 | register(
|
| 493 | context,
|
| 494 | SWIFT_SNEAK,
|
| 495 | Enchantment.enchantment(
|
| 496 | Enchantment.definition(
|
| 497 | items.getOrThrow(ItemTags.LEG_ARMOR_ENCHANTABLE), 1, 3, Enchantment.dynamicCost(25, 25), Enchantment.dynamicCost(75, 25), 8, EquipmentSlotGroup.LEGS
|
| 498 | )
|
| 499 | )
|
| 500 | .withEffect(
|
| 501 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 502 | new EnchantmentAttributeEffect(
|
| 503 | Identifier.withDefaultNamespace("enchantment.swift_sneak"),
|
| 504 | Attributes.SNEAKING_SPEED,
|
| 505 | LevelBasedValue.perLevel(0.15F),
|
| 506 | AttributeModifier.Operation.ADD_VALUE
|
| 507 | )
|
| 508 | )
|
| 509 | );
|
| 510 | register(
|
| 511 | context,
|
| 512 | SHARPNESS,
|
| 513 | Enchantment.enchantment(
|
| 514 | Enchantment.definition(
|
| 515 | items.getOrThrow(ItemTags.SHARP_WEAPON_ENCHANTABLE),
|
| 516 | items.getOrThrow(ItemTags.MELEE_WEAPON_ENCHANTABLE),
|
| 517 | 10,
|
| 518 | 5,
|
| 519 | Enchantment.dynamicCost(1, 11),
|
| 520 | Enchantment.dynamicCost(21, 11),
|
| 521 | 1,
|
| 522 | EquipmentSlotGroup.MAINHAND
|
| 523 | )
|
| 524 | )
|
| 525 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.DAMAGE_EXCLUSIVE))
|
| 526 | .withEffect(EnchantmentEffectComponents.DAMAGE, new AddValue(LevelBasedValue.perLevel(1.0F, 0.5F)))
|
| 527 | );
|
| 528 | register(
|
| 529 | context,
|
| 530 | SMITE,
|
| 531 | Enchantment.enchantment(
|
| 532 | Enchantment.definition(
|
| 533 | items.getOrThrow(ItemTags.WEAPON_ENCHANTABLE),
|
| 534 | items.getOrThrow(ItemTags.MELEE_WEAPON_ENCHANTABLE),
|
| 535 | 5,
|
| 536 | 5,
|
| 537 | Enchantment.dynamicCost(5, 8),
|
| 538 | Enchantment.dynamicCost(25, 8),
|
| 539 | 2,
|
| 540 | EquipmentSlotGroup.MAINHAND
|
| 541 | )
|
| 542 | )
|
| 543 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.DAMAGE_EXCLUSIVE))
|
| 544 | .withEffect(
|
| 545 | EnchantmentEffectComponents.DAMAGE,
|
| 546 | new AddValue(LevelBasedValue.perLevel(2.5F)),
|
| 547 | LootItemEntityPropertyCondition.hasProperties(
|
| 548 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(entityTypes, EntityTypeTags.SENSITIVE_TO_SMITE))
|
| 549 | )
|
| 550 | )
|
| 551 | );
|
| 552 | register(
|
| 553 | context,
|
| 554 | BANE_OF_ARTHROPODS,
|
| 555 | Enchantment.enchantment(
|
| 556 | Enchantment.definition(
|
| 557 | items.getOrThrow(ItemTags.WEAPON_ENCHANTABLE),
|
| 558 | items.getOrThrow(ItemTags.MELEE_WEAPON_ENCHANTABLE),
|
| 559 | 5,
|
| 560 | 5,
|
| 561 | Enchantment.dynamicCost(5, 8),
|
| 562 | Enchantment.dynamicCost(25, 8),
|
| 563 | 2,
|
| 564 | EquipmentSlotGroup.MAINHAND
|
| 565 | )
|
| 566 | )
|
| 567 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.DAMAGE_EXCLUSIVE))
|
| 568 | .withEffect(
|
| 569 | EnchantmentEffectComponents.DAMAGE,
|
| 570 | new AddValue(LevelBasedValue.perLevel(2.5F)),
|
| 571 | LootItemEntityPropertyCondition.hasProperties(
|
| 572 | LootContext.EntityTarget.THIS,
|
| 573 | EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(entityTypes, EntityTypeTags.SENSITIVE_TO_BANE_OF_ARTHROPODS))
|
| 574 | )
|
| 575 | )
|
| 576 | .withEffect(
|
| 577 | EnchantmentEffectComponents.POST_ATTACK,
|
| 578 | EnchantmentTarget.ATTACKER,
|
| 579 | EnchantmentTarget.VICTIM,
|
| 580 | new ApplyMobEffect(
|
| 581 | HolderSet.direct(MobEffects.SLOWNESS),
|
| 582 | LevelBasedValue.constant(1.5F),
|
| 583 | LevelBasedValue.perLevel(1.5F, 0.5F),
|
| 584 | LevelBasedValue.constant(3.0F),
|
| 585 | LevelBasedValue.constant(3.0F)
|
| 586 | ),
|
| 587 | LootItemEntityPropertyCondition.hasProperties(
|
| 588 | LootContext.EntityTarget.THIS,
|
| 589 | EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(entityTypes, EntityTypeTags.SENSITIVE_TO_BANE_OF_ARTHROPODS))
|
| 590 | )
|
| 591 | .and(DamageSourceCondition.hasDamageSource(DamageSourcePredicate.Builder.damageType().isDirect(true)))
|
| 592 | )
|
| 593 | );
|
| 594 | register(
|
| 595 | context,
|
| 596 | KNOCKBACK,
|
| 597 | Enchantment.enchantment(
|
| 598 | Enchantment.definition(
|
| 599 | items.getOrThrow(ItemTags.MELEE_WEAPON_ENCHANTABLE),
|
| 600 | 5,
|
| 601 | 2,
|
| 602 | Enchantment.dynamicCost(5, 20),
|
| 603 | Enchantment.dynamicCost(55, 20),
|
| 604 | 2,
|
| 605 | EquipmentSlotGroup.MAINHAND
|
| 606 | )
|
| 607 | )
|
| 608 | .withEffect(EnchantmentEffectComponents.KNOCKBACK, new AddValue(LevelBasedValue.perLevel(1.0F)))
|
| 609 | );
|
| 610 | register(
|
| 611 | context,
|
| 612 | FIRE_ASPECT,
|
| 613 | Enchantment.enchantment(
|
| 614 | Enchantment.definition(
|
| 615 | items.getOrThrow(ItemTags.FIRE_ASPECT_ENCHANTABLE),
|
| 616 | items.getOrThrow(ItemTags.MELEE_WEAPON_ENCHANTABLE),
|
| 617 | 2,
|
| 618 | 2,
|
| 619 | Enchantment.dynamicCost(10, 20),
|
| 620 | Enchantment.dynamicCost(60, 20),
|
| 621 | 4,
|
| 622 | EquipmentSlotGroup.MAINHAND
|
| 623 | )
|
| 624 | )
|
| 625 | .withEffect(
|
| 626 | EnchantmentEffectComponents.POST_ATTACK,
|
| 627 | EnchantmentTarget.ATTACKER,
|
| 628 | EnchantmentTarget.VICTIM,
|
| 629 | new Ignite(LevelBasedValue.perLevel(4.0F)),
|
| 630 | DamageSourceCondition.hasDamageSource(DamageSourcePredicate.Builder.damageType().isDirect(true))
|
| 631 | )
|
| 632 | );
|
| 633 | register(
|
| 634 | context,
|
| 635 | LOOTING,
|
| 636 | Enchantment.enchantment(
|
| 637 | Enchantment.definition(
|
| 638 | items.getOrThrow(ItemTags.MELEE_WEAPON_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(15, 9), Enchantment.dynamicCost(65, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 639 | )
|
| 640 | )
|
| 641 | .withEffect(
|
| 642 | EnchantmentEffectComponents.EQUIPMENT_DROPS,
|
| 643 | EnchantmentTarget.ATTACKER,
|
| 644 | EnchantmentTarget.VICTIM,
|
| 645 | new AddValue(LevelBasedValue.perLevel(0.01F)),
|
| 646 | LootItemEntityPropertyCondition.hasProperties(
|
| 647 | LootContext.EntityTarget.ATTACKER, EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(entityTypes, EntityTypes.PLAYER))
|
| 648 | )
|
| 649 | )
|
| 650 | );
|
| 651 | register(
|
| 652 | context,
|
| 653 | SWEEPING_EDGE,
|
| 654 | Enchantment.enchantment(
|
| 655 | Enchantment.definition(
|
| 656 | items.getOrThrow(ItemTags.SWEEPING_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(5, 9), Enchantment.dynamicCost(20, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 657 | )
|
| 658 | )
|
| 659 | .withEffect(
|
| 660 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 661 | new EnchantmentAttributeEffect(
|
| 662 | Identifier.withDefaultNamespace("enchantment.sweeping_edge"),
|
| 663 | Attributes.SWEEPING_DAMAGE_RATIO,
|
| 664 | new LevelBasedValue.Fraction(LevelBasedValue.perLevel(1.0F), LevelBasedValue.perLevel(2.0F, 1.0F)),
|
| 665 | AttributeModifier.Operation.ADD_VALUE
|
| 666 | )
|
| 667 | )
|
| 668 | );
|
| 669 | register(
|
| 670 | context,
|
| 671 | EFFICIENCY,
|
| 672 | Enchantment.enchantment(
|
| 673 | Enchantment.definition(
|
| 674 | items.getOrThrow(ItemTags.MINING_ENCHANTABLE), 10, 5, Enchantment.dynamicCost(1, 10), Enchantment.dynamicCost(51, 10), 1, EquipmentSlotGroup.MAINHAND
|
| 675 | )
|
| 676 | )
|
| 677 | .withEffect(
|
| 678 | EnchantmentEffectComponents.ATTRIBUTES,
|
| 679 | new EnchantmentAttributeEffect(
|
| 680 | Identifier.withDefaultNamespace("enchantment.efficiency"),
|
| 681 | Attributes.MINING_EFFICIENCY,
|
| 682 | new LevelBasedValue.LevelsSquared(1.0F),
|
| 683 | AttributeModifier.Operation.ADD_VALUE
|
| 684 | )
|
| 685 | )
|
| 686 | );
|
| 687 | register(
|
| 688 | context,
|
| 689 | SILK_TOUCH,
|
| 690 | Enchantment.enchantment(
|
| 691 | Enchantment.definition(
|
| 692 | items.getOrThrow(ItemTags.MINING_LOOT_ENCHANTABLE), 1, 1, Enchantment.constantCost(15), Enchantment.constantCost(65), 8, EquipmentSlotGroup.MAINHAND
|
| 693 | )
|
| 694 | )
|
| 695 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.MINING_EXCLUSIVE))
|
| 696 | .withEffect(EnchantmentEffectComponents.BLOCK_EXPERIENCE, new SetValue(LevelBasedValue.constant(0.0F)))
|
| 697 | );
|
| 698 | register(
|
| 699 | context,
|
| 700 | UNBREAKING,
|
| 701 | Enchantment.enchantment(
|
| 702 | Enchantment.definition(
|
| 703 | items.getOrThrow(ItemTags.DURABILITY_ENCHANTABLE), 5, 3, Enchantment.dynamicCost(5, 8), Enchantment.dynamicCost(55, 8), 2, EquipmentSlotGroup.ANY
|
| 704 | )
|
| 705 | )
|
| 706 | .withEffect(
|
| 707 | EnchantmentEffectComponents.ITEM_DAMAGE,
|
| 708 | new RemoveBinomial(new LevelBasedValue.Fraction(LevelBasedValue.perLevel(2.0F), LevelBasedValue.perLevel(10.0F, 5.0F))),
|
| 709 | MatchTool.toolMatches(ItemPredicate.Builder.item().of(items, ItemTags.ARMOR_ENCHANTABLE))
|
| 710 | )
|
| 711 | .withEffect(
|
| 712 | EnchantmentEffectComponents.ITEM_DAMAGE,
|
| 713 | new RemoveBinomial(new LevelBasedValue.Fraction(LevelBasedValue.perLevel(1.0F), LevelBasedValue.perLevel(2.0F, 1.0F))),
|
| 714 | InvertedLootItemCondition.invert(MatchTool.toolMatches(ItemPredicate.Builder.item().of(items, ItemTags.ARMOR_ENCHANTABLE)))
|
| 715 | )
|
| 716 | );
|
| 717 | register(
|
| 718 | context,
|
| 719 | FORTUNE,
|
| 720 | Enchantment.enchantment(
|
| 721 | Enchantment.definition(
|
| 722 | items.getOrThrow(ItemTags.MINING_LOOT_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(15, 9), Enchantment.dynamicCost(65, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 723 | )
|
| 724 | )
|
| 725 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.MINING_EXCLUSIVE))
|
| 726 | );
|
| 727 | register(
|
| 728 | context,
|
| 729 | POWER,
|
| 730 | Enchantment.enchantment(
|
| 731 | Enchantment.definition(
|
| 732 | items.getOrThrow(ItemTags.BOW_ENCHANTABLE), 10, 5, Enchantment.dynamicCost(1, 10), Enchantment.dynamicCost(16, 10), 1, EquipmentSlotGroup.MAINHAND
|
| 733 | )
|
| 734 | )
|
| 735 | .withEffect(
|
| 736 | EnchantmentEffectComponents.DAMAGE,
|
| 737 | new AddValue(LevelBasedValue.perLevel(1.0F, 0.5F)),
|
| 738 | LootItemEntityPropertyCondition.hasProperties(
|
| 739 | LootContext.EntityTarget.DIRECT_ATTACKER, EntityPredicate.Builder.entity().of(entityTypes, EntityTypeTags.ARROWS).build()
|
| 740 | )
|
| 741 | )
|
| 742 | );
|
| 743 | register(
|
| 744 | context,
|
| 745 | PUNCH,
|
| 746 | Enchantment.enchantment(
|
| 747 | Enchantment.definition(
|
| 748 | items.getOrThrow(ItemTags.BOW_ENCHANTABLE), 2, 2, Enchantment.dynamicCost(12, 20), Enchantment.dynamicCost(37, 20), 4, EquipmentSlotGroup.MAINHAND
|
| 749 | )
|
| 750 | )
|
| 751 | .withEffect(
|
| 752 | EnchantmentEffectComponents.KNOCKBACK,
|
| 753 | new AddValue(LevelBasedValue.perLevel(1.0F)),
|
| 754 | LootItemEntityPropertyCondition.hasProperties(
|
| 755 | LootContext.EntityTarget.DIRECT_ATTACKER, EntityPredicate.Builder.entity().of(entityTypes, EntityTypeTags.ARROWS).build()
|
| 756 | )
|
| 757 | )
|
| 758 | );
|
| 759 | register(
|
| 760 | context,
|
| 761 | FLAME,
|
| 762 | Enchantment.enchantment(
|
| 763 | Enchantment.definition(
|
| 764 | items.getOrThrow(ItemTags.BOW_ENCHANTABLE), 2, 1, Enchantment.constantCost(20), Enchantment.constantCost(50), 4, EquipmentSlotGroup.MAINHAND
|
| 765 | )
|
| 766 | )
|
| 767 | .withEffect(EnchantmentEffectComponents.PROJECTILE_SPAWNED, new Ignite(LevelBasedValue.constant(100.0F)))
|
| 768 | );
|
| 769 | register(
|
| 770 | context,
|
| 771 | INFINITY,
|
| 772 | Enchantment.enchantment(
|
| 773 | Enchantment.definition(
|
| 774 | items.getOrThrow(ItemTags.BOW_ENCHANTABLE), 1, 1, Enchantment.constantCost(20), Enchantment.constantCost(50), 8, EquipmentSlotGroup.MAINHAND
|
| 775 | )
|
| 776 | )
|
| 777 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.BOW_EXCLUSIVE))
|
| 778 | .withEffect(
|
| 779 | EnchantmentEffectComponents.AMMO_USE,
|
| 780 | new SetValue(LevelBasedValue.constant(0.0F)),
|
| 781 | MatchTool.toolMatches(ItemPredicate.Builder.item().of(items, Items.ARROW))
|
| 782 | )
|
| 783 | );
|
| 784 | register(
|
| 785 | context,
|
| 786 | LUCK_OF_THE_SEA,
|
| 787 | Enchantment.enchantment(
|
| 788 | Enchantment.definition(
|
| 789 | items.getOrThrow(ItemTags.FISHING_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(15, 9), Enchantment.dynamicCost(65, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 790 | )
|
| 791 | )
|
| 792 | .withEffect(EnchantmentEffectComponents.FISHING_LUCK_BONUS, new AddValue(LevelBasedValue.perLevel(1.0F)))
|
| 793 | );
|
| 794 | register(
|
| 795 | context,
|
| 796 | LURE,
|
| 797 | Enchantment.enchantment(
|
| 798 | Enchantment.definition(
|
| 799 | items.getOrThrow(ItemTags.FISHING_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(15, 9), Enchantment.dynamicCost(65, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 800 | )
|
| 801 | )
|
| 802 | .withEffect(EnchantmentEffectComponents.FISHING_TIME_REDUCTION, new AddValue(LevelBasedValue.perLevel(5.0F)))
|
| 803 | );
|
| 804 | register(
|
| 805 | context,
|
| 806 | LOYALTY,
|
| 807 | Enchantment.enchantment(
|
| 808 | Enchantment.definition(
|
| 809 | items.getOrThrow(ItemTags.TRIDENT_ENCHANTABLE), 5, 3, Enchantment.dynamicCost(12, 7), Enchantment.constantCost(50), 2, EquipmentSlotGroup.MAINHAND
|
| 810 | )
|
| 811 | )
|
| 812 | .withEffect(EnchantmentEffectComponents.TRIDENT_RETURN_ACCELERATION, new AddValue(LevelBasedValue.perLevel(1.0F)))
|
| 813 | );
|
| 814 | register(
|
| 815 | context,
|
| 816 | IMPALING,
|
| 817 | Enchantment.enchantment(
|
| 818 | Enchantment.definition(
|
| 819 | items.getOrThrow(ItemTags.TRIDENT_ENCHANTABLE), 2, 5, Enchantment.dynamicCost(1, 8), Enchantment.dynamicCost(21, 8), 4, EquipmentSlotGroup.MAINHAND
|
| 820 | )
|
| 821 | )
|
| 822 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.DAMAGE_EXCLUSIVE))
|
| 823 | .withEffect(
|
| 824 | EnchantmentEffectComponents.DAMAGE,
|
| 825 | new AddValue(LevelBasedValue.perLevel(2.5F)),
|
| 826 | LootItemEntityPropertyCondition.hasProperties(
|
| 827 | LootContext.EntityTarget.THIS,
|
| 828 | EntityPredicate.Builder.entity().entityType(EntityTypePredicate.of(entityTypes, EntityTypeTags.SENSITIVE_TO_IMPALING)).build()
|
| 829 | )
|
| 830 | )
|
| 831 | );
|
| 832 | register(
|
| 833 | context,
|
| 834 | RIPTIDE,
|
| 835 | Enchantment.enchantment(
|
| 836 | Enchantment.definition(
|
| 837 | items.getOrThrow(ItemTags.TRIDENT_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(17, 7), Enchantment.constantCost(50), 4, EquipmentSlotGroup.HAND
|
| 838 | )
|
| 839 | )
|
| 840 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.RIPTIDE_EXCLUSIVE))
|
| 841 | .withSpecialEffect(EnchantmentEffectComponents.TRIDENT_SPIN_ATTACK_STRENGTH, new AddValue(LevelBasedValue.perLevel(1.5F, 0.75F)))
|
| 842 | .withSpecialEffect(
|
| 843 | EnchantmentEffectComponents.TRIDENT_SOUND, List.of(SoundEvents.TRIDENT_RIPTIDE_1, SoundEvents.TRIDENT_RIPTIDE_2, SoundEvents.TRIDENT_RIPTIDE_3)
|
| 844 | )
|
| 845 | );
|
| 846 | register(
|
| 847 | context,
|
| 848 | LUNGE,
|
| 849 | Enchantment.enchantment(
|
| 850 | Enchantment.definition(
|
| 851 | items.getOrThrow(ItemTags.LUNGE_ENCHANTABLE), 5, 3, Enchantment.dynamicCost(5, 8), Enchantment.dynamicCost(25, 8), 2, EquipmentSlotGroup.HAND
|
| 852 | )
|
| 853 | )
|
| 854 | .withEffect(
|
| 855 | EnchantmentEffectComponents.POST_PIERCING_ATTACK,
|
| 856 | AllOf.entityEffects(
|
| 857 | new ChangeItemDamage(new LevelBasedValue.Constant(1.0F)),
|
| 858 | new ApplyExhaustion(LevelBasedValue.perLevel(4.0F)),
|
| 859 | new ApplyEntityImpulse(new Vec3(0.0, 0.0, 1.0), new Vec3(1.0, 0.0, 1.0), LevelBasedValue.perLevel(0.458F)),
|
| 860 | new PlaySoundEffect(List.of(SoundEvents.LUNGE_1, SoundEvents.LUNGE_2, SoundEvents.LUNGE_3), ConstantFloat.of(1.0F), ConstantFloat.of(1.0F))
|
| 861 | ),
|
| 862 | AllOfCondition.allOf(
|
| 863 | InvertedLootItemCondition.invert(
|
| 864 | LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().vehicle(EntityPredicate.Builder.entity()))
|
| 865 | ),
|
| 866 | LootItemEntityPropertyCondition.hasProperties(
|
| 867 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().flags(EntityFlagsPredicate.Builder.flags().setIsFallFlying(false))
|
| 868 | ),
|
| 869 | LootItemEntityPropertyCondition.hasProperties(
|
| 870 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().flags(EntityFlagsPredicate.Builder.flags().setIsInWater(false))
|
| 871 | ),
|
| 872 | AnyOfCondition.anyOf(
|
| 873 | InvertedLootItemCondition.invert(
|
| 874 | LootItemEntityPropertyCondition.hasProperties(
|
| 875 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().player(PlayerPredicate.Builder.player().build())
|
| 876 | )
|
| 877 | ),
|
| 878 | LootItemEntityPropertyCondition.hasProperties(
|
| 879 | LootContext.EntityTarget.THIS,
|
| 880 | EntityPredicate.Builder.entity().player(PlayerPredicate.Builder.player().setGameType(GameTypePredicate.of(GameType.CREATIVE)).build())
|
| 881 | ),
|
| 882 | LootItemEntityPropertyCondition.hasProperties(
|
| 883 | LootContext.EntityTarget.THIS,
|
| 884 | EntityPredicate.Builder.entity()
|
| 885 | .player(
|
| 886 | PlayerPredicate.Builder.player().setFood(FoodPredicate.Builder.food().withLevel(MinMaxBounds.Ints.atLeast(Mth.floor(6.0F) + 1)).build()).build()
|
| 887 | )
|
| 888 | )
|
| 889 | )
|
| 890 | )
|
| 891 | )
|
| 892 | );
|
| 893 | register(
|
| 894 | context,
|
| 895 | CHANNELING,
|
| 896 | Enchantment.enchantment(
|
| 897 | Enchantment.definition(
|
| 898 | items.getOrThrow(ItemTags.TRIDENT_ENCHANTABLE), 1, 1, Enchantment.constantCost(25), Enchantment.constantCost(50), 8, EquipmentSlotGroup.MAINHAND
|
| 899 | )
|
| 900 | )
|
| 901 | .withEffect(
|
| 902 | EnchantmentEffectComponents.POST_ATTACK,
|
| 903 | EnchantmentTarget.ATTACKER,
|
| 904 | EnchantmentTarget.VICTIM,
|
| 905 | AllOf.entityEffects(
|
| 906 | new SummonEntityEffect(HolderSet.direct(EntityTypes.LIGHTNING_BOLT.builtInRegistryHolder()), false),
|
| 907 | new PlaySoundEffect(List.of(SoundEvents.TRIDENT_THUNDER), ConstantFloat.of(5.0F), ConstantFloat.of(1.0F))
|
| 908 | ),
|
| 909 | AllOfCondition.allOf(
|
| 910 | WeatherCheck.weather().setThundering(true),
|
| 911 | LootItemEntityPropertyCondition.hasProperties(
|
| 912 | LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().located(LocationPredicate.Builder.location().setCanSeeSky(true))
|
| 913 | ),
|
| 914 | LootItemEntityPropertyCondition.hasProperties(
|
| 915 | LootContext.EntityTarget.DIRECT_ATTACKER, EntityPredicate.Builder.entity().of(entityTypes, EntityTypes.TRIDENT)
|
| 916 | )
|
| 917 | )
|
| 918 | )
|
| 919 | .withEffect(
|
| 920 | EnchantmentEffectComponents.HIT_BLOCK,
|
| 921 | AllOf.entityEffects(
|
| 922 | new SummonEntityEffect(HolderSet.direct(EntityTypes.LIGHTNING_BOLT.builtInRegistryHolder()), false),
|
| 923 | new PlaySoundEffect(List.of(SoundEvents.TRIDENT_THUNDER), ConstantFloat.of(5.0F), ConstantFloat.of(1.0F))
|
| 924 | ),
|
| 925 | AllOfCondition.allOf(
|
| 926 | WeatherCheck.weather().setThundering(true),
|
| 927 | LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().of(entityTypes, EntityTypes.TRIDENT)),
|
| 928 | LocationCheck.checkLocation(
|
| 929 | LocationPredicate.Builder.location()
|
| 930 | .setCanSeeSky(true)
|
| 931 | .setBlock(net.minecraft.advancements.predicates.BlockPredicate.Builder.block().of(blocks, BlockTags.LIGHTNING_RODS))
|
| 932 | )
|
| 933 | )
|
| 934 | )
|
| 935 | );
|
| 936 | register(
|
| 937 | context,
|
| 938 | MULTISHOT,
|
| 939 | Enchantment.enchantment(
|
| 940 | Enchantment.definition(
|
| 941 | items.getOrThrow(ItemTags.CROSSBOW_ENCHANTABLE), 2, 1, Enchantment.constantCost(20), Enchantment.constantCost(50), 4, EquipmentSlotGroup.MAINHAND
|
| 942 | )
|
| 943 | )
|
| 944 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.CROSSBOW_EXCLUSIVE))
|
| 945 | .withEffect(EnchantmentEffectComponents.PROJECTILE_COUNT, new AddValue(LevelBasedValue.perLevel(2.0F)))
|
| 946 | .withEffect(EnchantmentEffectComponents.PROJECTILE_SPREAD, new AddValue(LevelBasedValue.perLevel(10.0F)))
|
| 947 | );
|
| 948 | register(
|
| 949 | context,
|
| 950 | QUICK_CHARGE,
|
| 951 | Enchantment.enchantment(
|
| 952 | Enchantment.definition(
|
| 953 | items.getOrThrow(ItemTags.CROSSBOW_ENCHANTABLE),
|
| 954 | 5,
|
| 955 | 3,
|
| 956 | Enchantment.dynamicCost(12, 20),
|
| 957 | Enchantment.constantCost(50),
|
| 958 | 2,
|
| 959 | EquipmentSlotGroup.MAINHAND,
|
| 960 | EquipmentSlotGroup.OFFHAND
|
| 961 | )
|
| 962 | )
|
| 963 | .withSpecialEffect(EnchantmentEffectComponents.CROSSBOW_CHARGE_TIME, new AddValue(LevelBasedValue.perLevel(-0.25F)))
|
| 964 | .withSpecialEffect(
|
| 965 | EnchantmentEffectComponents.CROSSBOW_CHARGING_SOUNDS,
|
| 966 | List.of(
|
| 967 | new CrossbowItem.ChargingSounds(Optional.of(SoundEvents.CROSSBOW_QUICK_CHARGE_1), Optional.empty(), Optional.of(SoundEvents.CROSSBOW_LOADING_END)),
|
| 968 | new CrossbowItem.ChargingSounds(Optional.of(SoundEvents.CROSSBOW_QUICK_CHARGE_2), Optional.empty(), Optional.of(SoundEvents.CROSSBOW_LOADING_END)),
|
| 969 | new CrossbowItem.ChargingSounds(Optional.of(SoundEvents.CROSSBOW_QUICK_CHARGE_3), Optional.empty(), Optional.of(SoundEvents.CROSSBOW_LOADING_END))
|
| 970 | )
|
| 971 | )
|
| 972 | );
|
| 973 | register(
|
| 974 | context,
|
| 975 | PIERCING,
|
| 976 | Enchantment.enchantment(
|
| 977 | Enchantment.definition(
|
| 978 | items.getOrThrow(ItemTags.CROSSBOW_ENCHANTABLE), 10, 4, Enchantment.dynamicCost(1, 10), Enchantment.constantCost(50), 1, EquipmentSlotGroup.MAINHAND
|
| 979 | )
|
| 980 | )
|
| 981 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.CROSSBOW_EXCLUSIVE))
|
| 982 | .withEffect(EnchantmentEffectComponents.PROJECTILE_PIERCING, new AddValue(LevelBasedValue.perLevel(1.0F)))
|
| 983 | );
|
| 984 | register(
|
| 985 | context,
|
| 986 | DENSITY,
|
| 987 | Enchantment.enchantment(
|
| 988 | Enchantment.definition(
|
| 989 | items.getOrThrow(ItemTags.MACE_ENCHANTABLE), 5, 5, Enchantment.dynamicCost(5, 8), Enchantment.dynamicCost(25, 8), 2, EquipmentSlotGroup.MAINHAND
|
| 990 | )
|
| 991 | )
|
| 992 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.DAMAGE_EXCLUSIVE))
|
| 993 | .withEffect(EnchantmentEffectComponents.SMASH_DAMAGE_PER_FALLEN_BLOCK, new AddValue(LevelBasedValue.perLevel(0.5F)))
|
| 994 | );
|
| 995 | register(
|
| 996 | context,
|
| 997 | BREACH,
|
| 998 | Enchantment.enchantment(
|
| 999 | Enchantment.definition(
|
| 1000 | items.getOrThrow(ItemTags.MACE_ENCHANTABLE), 2, 4, Enchantment.dynamicCost(15, 9), Enchantment.dynamicCost(65, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 1001 | )
|
| 1002 | )
|
| 1003 | .exclusiveWith(enchantments.getOrThrow(EnchantmentTags.DAMAGE_EXCLUSIVE))
|
| 1004 | .withEffect(EnchantmentEffectComponents.ARMOR_EFFECTIVENESS, new AddValue(LevelBasedValue.perLevel(-0.15F)))
|
| 1005 | );
|
| 1006 | register(
|
| 1007 | context,
|
| 1008 | WIND_BURST,
|
| 1009 | Enchantment.enchantment(
|
| 1010 | Enchantment.definition(
|
| 1011 | items.getOrThrow(ItemTags.MACE_ENCHANTABLE), 2, 3, Enchantment.dynamicCost(15, 9), Enchantment.dynamicCost(65, 9), 4, EquipmentSlotGroup.MAINHAND
|
| 1012 | )
|
| 1013 | )
|
| 1014 | .withEffect(
|
| 1015 | EnchantmentEffectComponents.POST_ATTACK,
|
| 1016 | EnchantmentTarget.ATTACKER,
|
| 1017 | EnchantmentTarget.ATTACKER,
|
| 1018 | new ExplodeEffect(
|
| 1019 | false,
|
| 1020 | Optional.empty(),
|
| 1021 | Optional.of(LevelBasedValue.lookup(List.of(1.2F, 1.75F, 2.2F), LevelBasedValue.perLevel(1.5F, 0.35F))),
|
| 1022 | blocks.get(BlockTags.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity()),
|
| 1023 | Vec3.ZERO,
|
| 1024 | LevelBasedValue.constant(3.5F),
|
| 1025 | false,
|
| 1026 | Level.ExplosionInteraction.TRIGGER,
|
| 1027 | ParticleTypes.GUST_EMITTER_SMALL,
|
| 1028 | ParticleTypes.GUST_EMITTER_LARGE,
|
| 1029 | WeightedList.of(),
|
| 1030 | SoundEvents.WIND_CHARGE_BURST
|
| 1031 | ),
|
| 1032 | LootItemEntityPropertyCondition.hasProperties(
|
| 1033 | LootContext.EntityTarget.DIRECT_ATTACKER,
|
| 1034 | EntityPredicate.Builder.entity()
|
| 1035 | .flags(EntityFlagsPredicate.Builder.flags().setIsFlying(false))
|
| 1036 | .moving(MovementPredicate.fallDistance(MinMaxBounds.Doubles.atLeast(1.5)))
|
| 1037 | )
|
| 1038 | )
|
| 1039 | );
|
| 1040 | register(
|
| 1041 | context,
|
| 1042 | MENDING,
|
| 1043 | Enchantment.enchantment(
|
| 1044 | Enchantment.definition(
|
| 1045 | items.getOrThrow(ItemTags.DURABILITY_ENCHANTABLE), 2, 1, Enchantment.dynamicCost(25, 25), Enchantment.dynamicCost(75, 25), 4, EquipmentSlotGroup.ANY
|
| 1046 | )
|
| 1047 | )
|
| 1048 | .withEffect(EnchantmentEffectComponents.REPAIR_WITH_XP, new MultiplyValue(LevelBasedValue.constant(2.0F)))
|
| 1049 | );
|
| 1050 | register(
|
| 1051 | context,
|
| 1052 | VANISHING_CURSE,
|
| 1053 | Enchantment.enchantment(
|
| 1054 | Enchantment.definition(
|
| 1055 | items.getOrThrow(ItemTags.VANISHING_ENCHANTABLE), 1, 1, Enchantment.constantCost(25), Enchantment.constantCost(50), 8, EquipmentSlotGroup.ANY
|
| 1056 | )
|
| 1057 | )
|
| 1058 | .withEffect(EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)
|
| 1059 | );
|
| 1060 | }
|
| 1061 |
|
| 1062 | private static void register(final BootstrapContext<Enchantment> context, final ResourceKey<Enchantment> key, final Enchantment.Builder builder) {
|
| 1063 | context.register(key, builder.build(key.identifier()));
|
| 1064 | }
|
| 1065 |
|
| 1066 | private static ResourceKey<Enchantment> key(final String id) {
|
| 1067 | return ResourceKey.create(Registries.ENCHANTMENT, Identifier.withDefaultNamespace(id));
|
| 1068 | }
|
| 1069 | }
|
| 1070 |
|