diff --git a/src/main/java/dev/timefall/mcdw/Mcdw.java b/src/main/java/dev/timefall/mcdw/Mcdw.java index 1c77cf55..bb213a38 100644 --- a/src/main/java/dev/timefall/mcdw/Mcdw.java +++ b/src/main/java/dev/timefall/mcdw/Mcdw.java @@ -7,6 +7,9 @@ package dev.timefall.mcdw; import dev.timefall.mcdw.configs.CompatibilityFlags; +import dev.timefall.mcdw.data.ConfigEnchantmentEnabledCondition; +import dev.timefall.mcdw.data.ConfigItemEnabledCondition; +import dev.timefall.mcdw.enchants.EnchantmentIds; import dev.timefall.mcdw.registries.*; import dev.timefall.mcdw.registries.items.*; import net.fabricmc.api.ModInitializer; @@ -25,6 +28,7 @@ public static Identifier ID(String path) { @Override public void onInitialize() { + McdwRegistries.register(); // Register Weapons // TODO CHECK ORDER AND MAKE SURE CALLED WHERE NEEDS TO BE CALLED McdwAxeItemRegistry.register(); @@ -47,6 +51,9 @@ public void onInitialize() { McdwSwordItemRegistry.register(); McdwWhipItemRegistry.register(); + EnchantmentIds.init(); + ConfigEnchantmentEnabledCondition.register(); + ConfigItemEnabledCondition.register(); CompatibilityFlags.init(); CompatRegistry.register(); EntityAttributesRegistry.register(); diff --git a/src/main/java/dev/timefall/mcdw/api/util/AOEHelper.java b/src/main/java/dev/timefall/mcdw/api/util/AOEHelper.java index b5f9ba1f..79259d44 100644 --- a/src/main/java/dev/timefall/mcdw/api/util/AOEHelper.java +++ b/src/main/java/dev/timefall/mcdw/api/util/AOEHelper.java @@ -52,7 +52,7 @@ public static List getEntitiesByConfig(LivingEntity center, Living return getEntitiesByPredicate(center, distance, predicate); } - /** Returns targets of an AOE effect from 'attacker' around 'center'. This includes 'center'. */ + /** Returns targets of an AOE statusEffect from 'attacker' around 'center'. This includes 'center'. */ public static List getEntitiesByPredicate(LivingEntity center, float distance, Predicate predicate) { return center.getEntityWorld().getEntitiesByClass(LivingEntity.class, new Box(center.getBlockPos()).expand(distance), predicate @@ -78,4 +78,4 @@ public static boolean satisfySweepConditions(LivingEntity attackingEntity, Entit && !(collateralEntity instanceof ArmorStandEntity armorStand && armorStand.isMarker()) && attackingEntity.distanceTo(collateralEntity) < distanceToCollateral; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/api/util/ProjectileEffectHelper.java b/src/main/java/dev/timefall/mcdw/api/util/ProjectileEffectHelper.java index dd165fcd..cda3d8b7 100644 --- a/src/main/java/dev/timefall/mcdw/api/util/ProjectileEffectHelper.java +++ b/src/main/java/dev/timefall/mcdw/api/util/ProjectileEffectHelper.java @@ -61,7 +61,7 @@ public class ProjectileEffectHelper { } } - //public static List mcdw$getSecondaryTargets(LivingEntity source, double distance) { + //public static List mcdw$getSecondaryTargets(LivingEntity source, double radius) { // List nearbyEntities = AOEHelper.getEntitiesByConfig(source, (float) distance); // if (nearbyEntities.size() < 2) return Collections.emptyList(); diff --git a/src/main/java/dev/timefall/mcdw/component/McdwEffectComponentTypes.java b/src/main/java/dev/timefall/mcdw/component/McdwEffectComponentTypes.java index 3e355e90..91cd0b65 100644 --- a/src/main/java/dev/timefall/mcdw/component/McdwEffectComponentTypes.java +++ b/src/main/java/dev/timefall/mcdw/component/McdwEffectComponentTypes.java @@ -8,9 +8,13 @@ package dev.timefall.mcdw.component; import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.enchants.effect.EntityAwareValueEffectType; import net.minecraft.component.ComponentType; import net.minecraft.enchantment.effect.EnchantmentEffectEntry; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; import net.minecraft.enchantment.effect.EnchantmentValueEffectType; +import net.minecraft.enchantment.effect.TargetedEnchantmentEffectType; +import net.minecraft.loot.context.LootContextTypes; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; @@ -19,10 +23,14 @@ public class McdwEffectComponentTypes { - public static final ComponentType>> ACCELERATE_CHARGE_TIME = register("accelerate_charge_time", builder -> builder); + public static final ComponentType ACCELERATE_CHARGE_TIME = register("accelerate_charge_time", builder -> builder.codec(EntityAwareValueEffectType.CODEC)); + public static final ComponentType>> ENTITY_AWARE_DAMAGE = register("entity_aware_damage", builder -> builder.codec(EnchantmentEffectEntry.createCodec(EntityAwareValueEffectType.CODEC, LootContextTypes.ENCHANTED_DAMAGE).listOf())); + public static final ComponentType>> ON_JUMP = register("on_jump", builder -> builder.codec(EnchantmentEffectEntry.createCodec(EnchantmentEntityEffectType.CODEC, LootContextTypes.ENCHANTED_ENTITY).listOf())); + public static final ComponentType>> POST_DEATH = register("post_death", builder -> builder.codec(TargetedEnchantmentEffectType.createPostAttackCodec(EnchantmentEntityEffectType.CODEC, LootContextTypes.ENCHANTED_DAMAGE).listOf())); + public static final ComponentType>> XP_REPAIR_PLAYER = register("xp_repair_player", builder -> builder.codec(EnchantmentEffectEntry.createCodec(EnchantmentValueEffectType.CODEC, LootContextTypes.ENCHANTED_ENTITY).listOf())); private static ComponentType register(String id, UnaryOperator> builderOperator) { return Registry.register(Registries.ENCHANTMENT_EFFECT_COMPONENT_TYPE, Mcdw.ID(id), (builderOperator.apply(ComponentType.builder())).build()); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/configs/McdwEnchantmentSettingsConfig.java b/src/main/java/dev/timefall/mcdw/configs/McdwEnchantmentSettingsConfig.java index 92d5353d..e59569a4 100644 --- a/src/main/java/dev/timefall/mcdw/configs/McdwEnchantmentSettingsConfig.java +++ b/src/main/java/dev/timefall/mcdw/configs/McdwEnchantmentSettingsConfig.java @@ -8,16 +8,27 @@ package dev.timefall.mcdw.configs; import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.enchants.EnchantmentIds; +import me.fzzyhmstrs.fzzy_config.annotations.IgnoreVisibility; import me.fzzyhmstrs.fzzy_config.api.ConfigApi; import me.fzzyhmstrs.fzzy_config.config.Config; +import me.fzzyhmstrs.fzzy_config.validation.collection.ValidatedList; +import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedIdentifier; +import net.minecraft.util.Identifier; -import java.util.function.Supplier; - +@SuppressWarnings("FieldMayBeFinal") +@IgnoreVisibility public class McdwEnchantmentSettingsConfig extends Config { - public static final McdwEnchantmentSettingsConfig CONFIG = ConfigApi.registerAndLoadConfig((Supplier) McdwEnchantmentSettingsConfig::new); + public static final McdwEnchantmentSettingsConfig CONFIG = ConfigApi.registerAndLoadConfig(McdwEnchantmentSettingsConfig::new); public McdwEnchantmentSettingsConfig() { super(Mcdw.ID("mcdw_enchantment_settings_config")); } -} + private ValidatedList disabledEnchantments = ValidatedIdentifier.ofSuppliedList(() -> EnchantmentIds.ENCHANTMENT_IDS).toList(); + + public boolean isEnchantmentEnabled(Identifier id){ + return !disabledEnchantments.contains(id); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/configs/stats/McdwWeaponStatsConfig.java b/src/main/java/dev/timefall/mcdw/configs/stats/McdwWeaponStatsConfig.java index 4f63bf8b..ded95255 100644 --- a/src/main/java/dev/timefall/mcdw/configs/stats/McdwWeaponStatsConfig.java +++ b/src/main/java/dev/timefall/mcdw/configs/stats/McdwWeaponStatsConfig.java @@ -13,6 +13,13 @@ import me.fzzyhmstrs.fzzy_config.annotations.IgnoreVisibility; import me.fzzyhmstrs.fzzy_config.api.ConfigApi; import me.fzzyhmstrs.fzzy_config.config.Config; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.ApiStatus; + +import java.beans.Transient; +import java.util.IdentityHashMap; +import java.util.LinkedHashMap; +import java.util.function.Supplier; @SuppressWarnings("FieldMayBeFinal") @IgnoreVisibility @@ -24,6 +31,18 @@ public McdwWeaponStatsConfig() { super(Mcdw.ID("mcdw_weapon_stats_config")); } + transient private LinkedHashMap> itemEnabledMap = new LinkedHashMap<>(); + + @ApiStatus.Internal + public void registerItemEnableCheck(Identifier id, Supplier checker){ + itemEnabledMap.put(id,checker); + } + + public boolean isItemEnabled(Identifier id) { + //supplier returns isEnabled, we negate that for disabled check + return itemEnabledMap.getOrDefault(id, () -> false).get(); + } + private McdwAxeItemStats mcdwAxeItemStats = new McdwAxeItemStats(); private McdwBowItemStats mcdwBowItemStats = new McdwBowItemStats(); private McdwCrossbowItemStats mcdwCrossbowItemStats = new McdwCrossbowItemStats(); @@ -120,4 +139,4 @@ public McdwSwordItemStats getSwordItemStats() { public McdwWhipItemStats getWhipItemStats() { return mcdwWhipItemStats; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/ConfigEnchantmentEnabledCondition.java b/src/main/java/dev/timefall/mcdw/data/ConfigEnchantmentEnabledCondition.java new file mode 100644 index 00000000..89bd66d6 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/data/ConfigEnchantmentEnabledCondition.java @@ -0,0 +1,45 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.data; + + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.configs.McdwEnchantmentSettingsConfig; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceCondition; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditionType; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions; +import net.minecraft.registry.RegistryWrapper; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.Nullable; + +public record ConfigEnchantmentEnabledCondition(Identifier enchant) implements ResourceCondition { + + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + Identifier.CODEC.fieldOf("enchant").forGetter(ConfigEnchantmentEnabledCondition::enchant) + ).apply(instance, ConfigEnchantmentEnabledCondition::new) + ); + + private static final ResourceConditionType TYPE = ResourceConditionType.create(Mcdw.ID("enchant_enabled"), CODEC); + + public static void register(){ + ResourceConditions.register(TYPE); + } + + @Override + public ResourceConditionType getType() { + return TYPE; + } + + @Override + public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) { + return McdwEnchantmentSettingsConfig.CONFIG.isEnchantmentEnabled(enchant); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/ConfigItemEnabledCondition.java b/src/main/java/dev/timefall/mcdw/data/ConfigItemEnabledCondition.java index ae1f8ccc..8b2a45b2 100644 --- a/src/main/java/dev/timefall/mcdw/data/ConfigItemEnabledCondition.java +++ b/src/main/java/dev/timefall/mcdw/data/ConfigItemEnabledCondition.java @@ -6,59 +6,41 @@ */ package dev.timefall.mcdw.data; -/* -public class ConfigItemEnabledCondition { - public static void register() { - // Register a resource condition for checking if multiple config values are all true - ResourceConditions.register(Identifier.of(Mcdw.MOD_ID, "config_enabled"), jsonObject -> { - JsonArray values = JsonHelper.getArray(jsonObject, "values"); - List booleanList = new ArrayList<>(); +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.configs.McdwEnchantmentSettingsConfig; +import dev.timefall.mcdw.configs.stats.McdwWeaponStatsConfig; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceCondition; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditionType; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions; +import net.minecraft.registry.RegistryWrapper; +import net.minecraft.util.Identifier; +import org.jetbrains.annotations.Nullable; + +public record ConfigItemEnabledCondition(Identifier item) implements ResourceCondition { + + private static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + Identifier.CODEC.fieldOf("item").forGetter(ConfigItemEnabledCondition::item) + ).apply(instance, ConfigItemEnabledCondition::new) + ); - for (JsonElement element : values) { - if (element.isJsonPrimitive()) { - String elementString = element.getAsString(); - List configClasses = Arrays.asList(elementString.split("\\.")); - try { - if (configClasses.size() > 1) { - // Retrieve the config value and add it to the boolean list - booleanList.add( - Mcdw.CONFIG - .getClass().getField(configClasses.get(0)) - .get(Mcdw.CONFIG).getClass().getField(configClasses.get(1)) - .getBoolean(Mcdw.CONFIG.getClass().getField(configClasses.get(0)) - .get(Mcdw.CONFIG))); - } else { - // Retrieve the config value and add it to the boolean list - booleanList.add(Mcdw.CONFIG.getClass().getField(elementString).getBoolean(Mcdw.CONFIG)); - } - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - } - // Check if all config values are true - return booleanList.stream().allMatch(Boolean::booleanValue); - }); + private static final ResourceConditionType TYPE = ResourceConditionType.create(Mcdw.ID("item_enabled"), CODEC); - // Register a resource condition for checking if an item is enabled - ResourceConditions.register(Identifier.of(Mcdw.MOD_ID, "item_enabled"), jsonObject -> { - JsonArray values = JsonHelper.getArray(jsonObject, "values"); + public static void register(){ + ResourceConditions.register(TYPE); + } + + @Override + public ResourceConditionType getType() { + return TYPE; + } - for (JsonElement element : values) { - if (element.isJsonPrimitive()) { - try { - // Check if the item exists in the item registry - return Registries.ITEM.get(Identifier.of(element.getAsString())) != Items.AIR; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } - // If no item is specified, default to true - return true; - }); + @Override + public boolean test(@Nullable RegistryWrapper.WrapperLookup registryLookup) { + return McdwWeaponStatsConfig.CONFIG.isItemEnabled(item); } -} - */ \ No newline at end of file +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/McdwDataGenerator.java b/src/main/java/dev/timefall/mcdw/data/McdwDataGenerator.java index ca9c08f4..682c0455 100644 --- a/src/main/java/dev/timefall/mcdw/data/McdwDataGenerator.java +++ b/src/main/java/dev/timefall/mcdw/data/McdwDataGenerator.java @@ -16,6 +16,7 @@ public class McdwDataGenerator implements DataGeneratorEntrypoint { public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); - pack.addProvider(McdwTagGenerator::new); + pack.addProvider(McdwItemTagGenerator::new); + pack.addProvider(McdwEnchantmentTagGenerator::new); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentGenerator.java b/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentGenerator.java index d992f80c..833c507f 100644 --- a/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentGenerator.java +++ b/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentGenerator.java @@ -7,11 +7,283 @@ package dev.timefall.mcdw.data; +import dev.timefall.mcdw.component.McdwEffectComponentTypes; +import dev.timefall.mcdw.enchants.EnchantmentIds; +import dev.timefall.mcdw.enchants.effect.entity.relative.DamageTakenRelativeEnchantmentEntityEffectType; +import dev.timefall.mcdw.enchants.effect.entity_aware.MultiplyStatusValueEffectType; +import dev.timefall.mcdw.enchants.effect.entity.*; +import dev.timefall.mcdw.registries.SoundEventsRegistry; +import dev.timefall.mcdw.registries.StatusEffectsRegistry; +import dev.timefall.mcdw.registries.tag.McdwEnchantmentTags; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider; +import net.fabricmc.fabric.api.resource.conditions.v1.ResourceCondition; +import net.minecraft.block.Block; +import net.minecraft.component.EnchantmentEffectComponentTypes; +import net.minecraft.component.type.AttributeModifierSlot; import net.minecraft.enchantment.Enchantment; -import net.minecraft.registry.Registerable; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.enchantment.effect.AllOfEnchantmentEffectTypes; +import net.minecraft.enchantment.effect.EnchantmentEffectTarget; +import net.minecraft.enchantment.effect.entity.PlaySoundEnchantmentEffectType; +import net.minecraft.enchantment.effect.value.AddEnchantmentEffectType; +import net.minecraft.enchantment.effect.value.MultiplyEnchantmentEffectType; +import net.minecraft.entity.damage.DamageType; +import net.minecraft.entity.damage.DamageTypes; +import net.minecraft.item.Item; +import net.minecraft.loot.condition.EntityPropertiesLootCondition; +import net.minecraft.loot.condition.RandomChanceLootCondition; +import net.minecraft.loot.condition.RandomChanceWithEnchantedBonusLootCondition; +import net.minecraft.loot.context.LootContext; +import net.minecraft.predicate.NumberRange; +import net.minecraft.predicate.entity.EntityEffectPredicate; +import net.minecraft.predicate.entity.EntityPredicate; +import net.minecraft.registry.*; +import net.minecraft.registry.entry.RegistryEntryList; +import net.minecraft.registry.tag.ItemTags; +import net.minecraft.util.math.floatprovider.ConstantFloatProvider; + +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +public class McdwEnchantmentGenerator extends FabricDynamicRegistryProvider { + + public McdwEnchantmentGenerator(FabricDataOutput output, CompletableFuture registriesFuture){ + super(output, registriesFuture); + } + + @Override + public String getName() { + return "Mcdw Enchantment Generation"; + } + + @Override + public void configure(RegistryWrapper.WrapperLookup registries, Entries entries) { + + RegistryEntryLookup damageTypeLookup = registries.getWrapperOrThrow(RegistryKeys.DAMAGE_TYPE); + RegistryEntryLookup enchantmentLookup = registries.getWrapperOrThrow(RegistryKeys.ENCHANTMENT); + RegistryEntryLookup itemLookup = registries.getWrapperOrThrow(RegistryKeys.ITEM); + RegistryEntryLookup blockLookup = registries.getWrapperOrThrow(RegistryKeys.BLOCK); + + // DYNAMO + register( + entries, + EnchantmentIds.DYNAMO, + Enchantment.builder( + Enchantment.definition( + itemLookup.getOrThrow(ItemTags.WEAPON_ENCHANTABLE), + 1, + 3, + Enchantment.leveledCost(1, 10), + Enchantment.leveledCost(16, 10), + 2, + AttributeModifierSlot.HAND + ) + ).exclusiveSet( + enchantmentLookup.getOrThrow(McdwEnchantmentTags.DAMAGE_EXCLUSIVE) + ).addEffect( + McdwEffectComponentTypes.ENTITY_AWARE_DAMAGE, + new MultiplyStatusValueEffectType(StatusEffectsRegistry.DYNAMO, EnchantmentLevelBasedValueType.linear(0.1f,0.025f),false,Optional.empty()) + ).addEffect( + McdwEffectComponentTypes.ON_JUMP, + new ApplyStackingMobEffectEnchantmentEntityEffectType( + StatusEffectsRegistry.DYNAMO, + EnchantmentLevelBasedValueType.constant(120000f), + EnchantmentLevelBasedValueType.constant(19f) + ) + ).addEffect( + EnchantmentEffectComponentTypes.POST_ATTACK, + EnchantmentEffectTarget.ATTACKER, + EnchantmentEffectTarget.ATTACKER, + new RemoveMobEffectEnchantmentEntityEffectType(StatusEffectsRegistry.DYNAMO) + ) + ); + + // ECHO + register( + entries, + EnchantmentIds.ECHO, + Enchantment.builder( + Enchantment.definition( + itemLookup.getOrThrow(ItemTags.WEAPON_ENCHANTABLE), + 1, + 3, + Enchantment.leveledCost(1, 10), + Enchantment.leveledCost(16, 10), + 2, + AttributeModifierSlot.MAINHAND + ) + ).exclusiveSet( + enchantmentLookup.getOrThrow(McdwEnchantmentTags.AOE_AND_DAMAGE_EXCLUSIVE) + ).addEffect( + EnchantmentEffectComponentTypes.POST_ATTACK, + EnchantmentEffectTarget.ATTACKER, + EnchantmentEffectTarget.VICTIM, + AllOfEnchantmentEffectTypes.allOf( + new PlaySoundEnchantmentEffectType( + SoundEventsRegistry.ECHO_SOUND_EVENT, + ConstantFloatProvider.create(0.5f), + ConstantFloatProvider.create(1f) + ), + new AOEEnchantmentEntityEffectType( + EnchantmentLevelBasedValueType.constant(3f), + new DamageTakenRelativeEnchantmentEntityEffectType( + EnchantmentLevelBasedValueType.constant(1f), + damageTypeLookup.getOrThrow(DamageTypes.GENERIC) + ), + Optional.of(EnchantmentLevelBasedValueType.linear(1f)), + true + ) + ), + () -> new RandomChanceWithEnchantedBonusLootCondition( + EnchantmentLevelBasedValueType.linear(0.15f), + enchantmentLookup.getOrThrow(EnchantmentIds.ECHO) + ) + ) + ); + + // LEECHING + register( + entries, + EnchantmentIds.LEECHING, + Enchantment.builder( + Enchantment.definition( + itemLookup.getOrThrow(ItemTags.WEAPON_ENCHANTABLE), + 1, + 3, + Enchantment.leveledCost(1, 10), + Enchantment.leveledCost(16, 10), + 2, + AttributeModifierSlot.HAND + ) + ).exclusiveSet( + enchantmentLookup.getOrThrow(McdwEnchantmentTags.HEALING_EXCLUSIVE) + ).addEffect( + McdwEffectComponentTypes.POST_DEATH, + EnchantmentEffectTarget.ATTACKER, + EnchantmentEffectTarget.VICTIM, + new LeechMobEnchantmentEntityEffectType(EnchantmentLevelBasedValueType.linear(0.4f, 0.2f)) + ) + ); + + // PAIN_CYCLE + register( + entries, + EnchantmentIds.PAIN_CYCLE, + Enchantment.builder( + Enchantment.definition( + itemLookup.getOrThrow(ItemTags.WEAPON_ENCHANTABLE), + 1, + 3, + Enchantment.leveledCost(1, 10), + Enchantment.leveledCost(16, 10), + 2, + AttributeModifierSlot.MAINHAND + ) + ).exclusiveSet( + enchantmentLookup.getOrThrow(McdwEnchantmentTags.DAMAGE_EXCLUSIVE) + ).addEffect( + EnchantmentEffectComponentTypes.DAMAGE, + new MultiplyEnchantmentEffectType(EnchantmentLevelBasedValueType.linear(2f,1f)), + EntityPropertiesLootCondition.builder( + LootContext.EntityTarget.ATTACKER, + EntityPredicate.Builder.create().effects( + EntityEffectPredicate.Builder.create().addEffect( + StatusEffectsRegistry.PAIN_CYCLE, + new EntityEffectPredicate.EffectData( + NumberRange.IntRange.exactly(4), + NumberRange.IntRange.ANY, + Optional.empty(), + Optional.empty() + ) + ) + ) + ) + ).addEffect( + EnchantmentEffectComponentTypes.POST_ATTACK, + EnchantmentEffectTarget.ATTACKER, + EnchantmentEffectTarget.ATTACKER, + new ApplyStackingMobEffectEnchantmentEntityEffectType( + RegistryEntryList.of(StatusEffectsRegistry.PAIN_CYCLE), + EnchantmentLevelBasedValueType.constant(120000f), + EnchantmentLevelBasedValueType.constant(0f), + EnchantmentLevelBasedValueType.constant(4f), + true + ) + ) + ); + + + // SOUL_DEVOURER + register( + // the enchantment registerable + entries, + // the RegistryKey of SOUL_DEVOURER, kept in the Ids class + EnchantmentIds.SOUL_DEVOURER, + //the enchantment builder itself + Enchantment.builder( + // first, the definitions. This is the "basic stats" of the enchantment. + Enchantment.definition( + // tag of valid items. I used WEAPON, but another could be used, or a custom tag made. Old way uses Sword, Axe, or MCDW Custom, so maybe needs to be custom. + // As is, this would become enchantable on tridents, maces, etc. as well as swords/axes. + itemLookup.getOrThrow(ItemTags.WEAPON_ENCHANTABLE), + // weight of the enchantment, previously the "Rarity". Used the old "VERY_RARE". + 1, + // max level, self-explanatory + 3, + //minimum enchanting cost. old style did not customize this, so I used the "default" values for these + Enchantment.leveledCost(1, 10), + //maximum enchanting cost. defaults used again + Enchantment.leveledCost(16, 10), + //Anvil Cost. I set this middle of the road, but not really sure what to do with it tbh, this is a new thing. + 2, + //valid slots the weapon can be in. I used "HAND", which enables off-hand holding. Might need to play with. + AttributeModifierSlot.HAND + ) + // next we add the exclusions. I made new tag holder class, and this is exclusive with the other "Experience" enchants. The tag includes this, by design. + ).exclusiveSet( + enchantmentLookup.getOrThrow(McdwEnchantmentTags.EXPERIENCE_EXCLUSIVE) + //Finally, the statusEffect. + ).addEffect( + //the Mob Experience modification hook. + EnchantmentEffectComponentTypes.MOB_EXPERIENCE, + //we will multiply the drops by 1 + (level / 3.0), which is the same as "1.33333 + 0.33333 for each level beyond the first". + new MultiplyEnchantmentEffectType(EnchantmentLevelBasedValueType.linear(1.33333f, 0.33333f)) + ) + ); + + // SOUL_SIPHON + register( + entries, + EnchantmentIds.SOUL_SIPHON, + Enchantment.builder( + Enchantment.definition( + itemLookup.getOrThrow(ItemTags.WEAPON_ENCHANTABLE), + 1, + 3, + Enchantment.leveledCost(1, 10), + Enchantment.leveledCost(16, 10), + 2, + AttributeModifierSlot.MAINHAND + ) + ).exclusiveSet( + enchantmentLookup.getOrThrow(McdwEnchantmentTags.EXPERIENCE_EXCLUSIVE) + ).addEffect( + EnchantmentEffectComponentTypes.MOB_EXPERIENCE, + new AddEnchantmentEffectType(EnchantmentLevelBasedValueType.linear(3f)), + //this addition happens 10% of the time + RandomChanceLootCondition.builder(0.1f) + ) + ); + -public class McdwEnchantmentGenerator { - public static void generate(Registerable enchantment) { // Thundering Enchantment } -} + + private void register(Entries entries,RegistryKey key, Enchantment.Builder builder) { + register(entries, key, builder, new ConfigEnchantmentEnabledCondition(key.getValue())); + } + private void register(Entries entries, RegistryKey key, Enchantment.Builder builder, ResourceCondition...resourceConditions) { + entries.add(key, builder.build(key.getValue()), resourceConditions); + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentTagGenerator.java b/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentTagGenerator.java new file mode 100644 index 00000000..5feaf0bf --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/data/McdwEnchantmentTagGenerator.java @@ -0,0 +1,56 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ + +package dev.timefall.mcdw.data; + +import dev.timefall.mcdw.enchants.EnchantmentIds; +import dev.timefall.mcdw.registries.tag.McdwEnchantmentTags; +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; +import net.minecraft.registry.RegistryWrapper; + +import java.util.concurrent.CompletableFuture; + +public class McdwEnchantmentTagGenerator extends FabricTagProvider.EnchantmentTagProvider { + public McdwEnchantmentTagGenerator(FabricDataOutput output, CompletableFuture completableFuture) { + super(output, completableFuture); + } + + @Override + protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { + + // ENCHANTMENT TAGS + + getOrCreateTagBuilder(McdwEnchantmentTags.AOE_EXCLUSIVE) + .setReplace(false) + .addOptional(EnchantmentIds.ECHO); + + getOrCreateTagBuilder(McdwEnchantmentTags.AOE_AND_DAMAGE_EXCLUSIVE) + .setReplace(false) + .addTag(McdwEnchantmentTags.AOE_EXCLUSIVE) + .addTag(McdwEnchantmentTags.DAMAGE_EXCLUSIVE); + + getOrCreateTagBuilder(McdwEnchantmentTags.DAMAGE_EXCLUSIVE) + .setReplace(false) + .addOptional(EnchantmentIds.DYNAMO) + .addOptional(EnchantmentIds.PAIN_CYCLE); + + getOrCreateTagBuilder(McdwEnchantmentTags.EXPERIENCE_EXCLUSIVE) + .setReplace(false) + .addOptional(EnchantmentIds.ANIMA_CONDUIT) + .addOptional(EnchantmentIds.SOUL_DEVOURER) + .addOptional(EnchantmentIds.SOUL_SIPHON); + + getOrCreateTagBuilder(McdwEnchantmentTags.HEALING_EXCLUSIVE) + .setReplace(false) + .addOptional(EnchantmentIds.ANIMA_CONDUIT) + .addOptional(EnchantmentIds.LEECHING) + .addOptional(EnchantmentIds.RADIANCE); + + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/McdwTagGenerator.java b/src/main/java/dev/timefall/mcdw/data/McdwItemTagGenerator.java similarity index 93% rename from src/main/java/dev/timefall/mcdw/data/McdwTagGenerator.java rename to src/main/java/dev/timefall/mcdw/data/McdwItemTagGenerator.java index 62999307..82a0a4cd 100644 --- a/src/main/java/dev/timefall/mcdw/data/McdwTagGenerator.java +++ b/src/main/java/dev/timefall/mcdw/data/McdwItemTagGenerator.java @@ -9,34 +9,36 @@ import dev.timefall.mcdw.Mcdw; import dev.timefall.mcdw.registries.items.*; +import dev.timefall.mcdw.registries.tag.McdwItemTags; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; -import net.minecraft.item.Item; -import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; -import net.minecraft.registry.tag.TagKey; +import net.minecraft.registry.tag.ItemTags; import net.minecraft.util.Identifier; import java.util.concurrent.CompletableFuture; -public class McdwTagGenerator extends FabricTagProvider.ItemTagProvider { - public McdwTagGenerator(FabricDataOutput output, CompletableFuture completableFuture) { +public class McdwItemTagGenerator extends FabricTagProvider.ItemTagProvider { + public McdwItemTagGenerator(FabricDataOutput output, CompletableFuture completableFuture) { super(output, completableFuture); } - private static final TagKey COMMON_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("mcdw:common_loot_pool_items")); + // moved to a tagkey class McdwItemTags + /*private static final TagKey COMMON_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("mcdw:common_loot_pool_items")); private static final TagKey UNCOMMON_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("mcdw:uncommon_loot_pool_items")); private static final TagKey RARE_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("mcdw:rare_loot_pool_items")); - private static final TagKey EPIC_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("mcdw:epic_loot_pool_items")); + private static final TagKey EPIC_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Identifier.of("mcdw:epic_loot_pool_items"));*/ @Override protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { - getOrCreateTagBuilder(COMMON_LOOT_POOL_ITEMS) + // ITEM TAGS + + getOrCreateTagBuilder(McdwItemTags.COMMON_LOOT_POOL_ITEMS) .setReplace(false) - .addOptional(Identifier.of(Mcdw.MOD_ID, McdwAxeItemRegistry.AXE_ANCHOR.toString())) - .addOptional(Identifier.of(Mcdw.MOD_ID, McdwAxeItemRegistry.AXE_AXE.toString())) + .addOptional(McdwAxeItemRegistry.AXE_ANCHOR_ID) + .addOptional(McdwAxeItemRegistry.AXE_AXE_ID) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwDaggerItemRegistry.DAGGER_DAGGER.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwDoubleAxeItemRegistry.DOUBLE_AXE_DOUBLE.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwGauntletItemRegistry.GAUNTLET_GAUNTLET.toString())) @@ -55,7 +57,7 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_KATANA.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_RAPIER.toString())); - getOrCreateTagBuilder(UNCOMMON_LOOT_POOL_ITEMS) + getOrCreateTagBuilder(McdwItemTags.UNCOMMON_LOOT_POOL_ITEMS) .setReplace(false) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwBowItemRegistry.BOW_BONEBOW.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwBowItemRegistry.BOW_BUBBLE_BOW.toString())) @@ -101,7 +103,7 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { .addOptional(Identifier.of(Mcdw.MOD_ID, McdwWhipItemRegistry.WHIP_VINE_WHIP.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwWhipItemRegistry.WHIP_WHIP.toString())); - getOrCreateTagBuilder(RARE_LOOT_POOL_ITEMS) + getOrCreateTagBuilder(McdwItemTags.RARE_LOOT_POOL_ITEMS) .setReplace(false) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwAxeItemRegistry.AXE_ENCRUSTED_ANCHOR.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwAxeItemRegistry.AXE_FIREBRAND.toString())) @@ -170,7 +172,7 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_MASTERS_KATANA.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_SPONGE_STRIKER.toString())); - getOrCreateTagBuilder(EPIC_LOOT_POOL_ITEMS) + getOrCreateTagBuilder(McdwItemTags.EPIC_LOOT_POOL_ITEMS) .setReplace(false) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwBowItemRegistry.BOW_ANCIENT_BOW.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwBowItemRegistry.BOW_HAUNTED_BOW.toString())) @@ -194,6 +196,13 @@ protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_DARK_KATANA.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_OBSIDIAN_CLAYMORE.toString())) .addOptional(Identifier.of(Mcdw.MOD_ID, McdwSwordItemRegistry.SWORD_THE_STARLESS_NIGHT.toString())); + + getOrCreateTagBuilder(McdwItemTags.ANY_WEAPON_ENCHANTABLE) + .setReplace(false) + .addTag(ItemTags.TRIDENT_ENCHANTABLE) + .addTag(ItemTags.BOW_ENCHANTABLE) + .addTag(ItemTags.CROSSBOW_ENCHANTABLE) + .addTag(ItemTags.WEAPON_ENCHANTABLE); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/data/Old_ConfigItemEnabledCondition.java b/src/main/java/dev/timefall/mcdw/data/Old_ConfigItemEnabledCondition.java new file mode 100644 index 00000000..1097d70a --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/data/Old_ConfigItemEnabledCondition.java @@ -0,0 +1,64 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.data; + + +public class Old_ConfigItemEnabledCondition { + + + + /*public static void register() { + // Register a resource condition for checking if multiple config values are all true + ResourceConditions.register(Identifier.of(Mcdw.MOD_ID, "config_enabled"), jsonObject -> { + JsonArray values = JsonHelper.getArray(jsonObject, "values"); + List booleanList = new ArrayList<>(); + + for (JsonElement element : values) { + if (element.isJsonPrimitive()) { + String elementString = element.getAsString(); + List configClasses = Arrays.asList(elementString.split("\\.")); + try { + if (configClasses.size() > 1) { + // Retrieve the config value and add it to the boolean list + booleanList.add( + Mcdw.CONFIG + .getClass().getField(configClasses.get(0)) + .get(Mcdw.CONFIG).getClass().getField(configClasses.get(1)) + .getBoolean(Mcdw.CONFIG.getClass().getField(configClasses.get(0)) + .get(Mcdw.CONFIG))); + } else { + // Retrieve the config value and add it to the boolean list + booleanList.add(Mcdw.CONFIG.getClass().getField(elementString).getBoolean(Mcdw.CONFIG)); + } + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + // Check if all config values are true + return booleanList.stream().allMatch(Boolean::booleanValue); + }); + + // Register a resource condition for checking if an item is enabled + ResourceConditions.register(Identifier.of(Mcdw.MOD_ID, "item_enabled"), jsonObject -> { + JsonArray values = JsonHelper.getArray(jsonObject, "values"); + + for (JsonElement element : values) { + if (element.isJsonPrimitive()) { + try { + // Check if the item exists in the item registry + return Registries.ITEM.get(Identifier.of(element.getAsString())) != Items.AIR; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + // If no item is specified, default to true + return true; + }); + }*/ +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/effects/EnchantmentEffects.java b/src/main/java/dev/timefall/mcdw/effects/EnchantmentEffects.java index aec5701a..9923380f 100644 --- a/src/main/java/dev/timefall/mcdw/effects/EnchantmentEffects.java +++ b/src/main/java/dev/timefall/mcdw/effects/EnchantmentEffects.java @@ -73,8 +73,7 @@ public static int soulDevourerExperience(PlayerEntity playerEntity, int amount) int soulDevourerLevel = mainHandLevel + offHandLevel; if (soulDevourerLevel > 0) - return Math.round((float) amount * (1 + ((float) soulDevourerLevel / - CONFIG.getMcdwEnchantmentStats().getSoulDevourerEnchantment().effectOffset))); + return Math.round((float) amount * (1 + ((float) soulDevourerLevel / CONFIG.getMcdwEnchantmentStats().getSoulDevourerEnchantment().effectOffset))); return amount; } diff --git a/src/main/java/dev/timefall/mcdw/effects/NewEnchantmentEffects.java b/src/main/java/dev/timefall/mcdw/effects/NewEnchantmentEffects.java index d5383b80..fef276d6 100644 --- a/src/main/java/dev/timefall/mcdw/effects/NewEnchantmentEffects.java +++ b/src/main/java/dev/timefall/mcdw/effects/NewEnchantmentEffects.java @@ -7,6 +7,119 @@ package dev.timefall.mcdw.effects; +import dev.timefall.mcdw.component.McdwEffectComponentTypes; +import dev.timefall.mcdw.enchants.effect.EntityAwareValueEffectType; +import dev.timefall.mcdw.mixin.EnchantmentAccessor; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.component.type.ItemEnchantmentsComponent; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.enchantment.effect.EnchantmentEffectEntry; +import net.minecraft.enchantment.effect.EnchantmentEffectTarget; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.enchantment.effect.TargetedEnchantmentEffectType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import org.apache.commons.lang3.mutable.MutableFloat; + public class NewEnchantmentEffects { + + //ON_DEATH: hook for effects that happen when the target dies. + public static void mcdw$onDeathHook(Entity attacker, ServerWorld world, LivingEntity victim, DamageSource damageSource) { + //first run the statusEffect in VICTIM mode on any enchantments that the victim may have + forEachEnchantment(victim,(RegistryEntry enchantment, int level, EnchantmentEffectContext context) -> mcdw$onDeathEffect(enchantment.value(),world,level,context,EnchantmentEffectTarget.VICTIM, victim, damageSource)); + //if the killer is a living entity + if (attacker instanceof LivingEntity livingAttacker){ + // run the statusEffect in ATTACKER mode on attackers enchants. + forEachEnchantment(livingAttacker,(RegistryEntry enchantment, int level, EnchantmentEffectContext context) -> mcdw$onDeathEffect(enchantment.value(),world,level,context,EnchantmentEffectTarget.ATTACKER, victim, damageSource)); + + } + } + private static void mcdw$onDeathEffect(Enchantment enchantment,ServerWorld world, int level, EnchantmentEffectContext context, EnchantmentEffectTarget target, Entity user, DamageSource damageSource) { + for (TargetedEnchantmentEffectType targetedEnchantmentEffectType : enchantment.getEffect(McdwEffectComponentTypes.POST_DEATH)) { + if (target != targetedEnchantmentEffectType.enchanted()) continue; + Enchantment.applyTargetedEffect(targetedEnchantmentEffectType, world, level, context, user, damageSource); + } + } + + + //ON_JUMP: effects applied when the user jumps + public static void mcdw$onJumpHook(ServerPlayerEntity serverPlayerEntity){ + forEachEnchantment(serverPlayerEntity,(RegistryEntry enchantment, int level, EnchantmentEffectContext context) -> mcdw$onJumpEffect(enchantment.value(),serverPlayerEntity,serverPlayerEntity.getServerWorld(),level,context)); + + } + private static void mcdw$onJumpEffect(Enchantment enchantment, ServerPlayerEntity serverPlayerEntity, ServerWorld world, int level, EnchantmentEffectContext context){ + EnchantmentAccessor.callApplyEffects( + enchantment.getEffect(McdwEffectComponentTypes.ON_JUMP), + EnchantmentAccessor.callCreateEnchantedEntityLootContext(world,level, serverPlayerEntity,serverPlayerEntity.getPos()), + effect -> effect.apply(world,level,context,serverPlayerEntity,serverPlayerEntity.getPos()) + ); + } + + + //STATUS_SCALED_DAMAGE: damage modifier event that applies status-effect-level-based damage multipliers + public static float mcdw$entityAwareDamageHook(ServerWorld world, ItemStack stack, Entity target, DamageSource damageSource, float baseDamage) { + MutableFloat mutableFloat = new MutableFloat(baseDamage); + forEachEnchantment(stack, (enchantment, level) -> mcdw$entityAwareDamageEffect(enchantment.value(),level,world,target,damageSource,mutableFloat)); + return mutableFloat.floatValue() - baseDamage; + } + private static void mcdw$entityAwareDamageEffect(Enchantment enchantment, int level, ServerWorld world, Entity target, DamageSource damageSource, MutableFloat value){ + Entity attacker = damageSource.getAttacker(); + if (attacker instanceof LivingEntity livingEntity) { + LootContext context = Enchantment.createEnchantedDamageLootContext(world, level, target, damageSource); + for (EnchantmentEffectEntry entry : enchantment.getEffect(McdwEffectComponentTypes.ENTITY_AWARE_DAMAGE)){ + if (!entry.test(context)) continue; + value.setValue(entry.effect().apply(level, value.getValue(), livingEntity)); + } + } + } + + ///////////////////// Copying EnchantmentHelper methods that are private //////////////// + + // Should probably be replaced with AW at some point, but I'm just getting things working. + + private static void forEachEnchantment(ItemStack stack, EnchantmentHelper.Consumer consumer) { + ItemEnchantmentsComponent itemEnchantmentsComponent = (ItemEnchantmentsComponent)stack.getOrDefault(DataComponentTypes.ENCHANTMENTS, (Object)ItemEnchantmentsComponent.DEFAULT); + for (Object2IntMap.Entry> entry : itemEnchantmentsComponent.getEnchantmentsMap()) { + consumer.accept(entry.getKey(), entry.getIntValue()); + } + } + + private static void forEachEnchantment(ItemStack stack, EquipmentSlot slot, LivingEntity entity, ContextAwareConsumer contextAwareConsumer) { + if (stack.isEmpty()) { + return; + } + ItemEnchantmentsComponent itemEnchantmentsComponent = stack.get(DataComponentTypes.ENCHANTMENTS); + if (itemEnchantmentsComponent == null || itemEnchantmentsComponent.isEmpty()) { + return; + } + EnchantmentEffectContext enchantmentEffectContext = new EnchantmentEffectContext(stack, slot, entity); + for (Object2IntMap.Entry> entry : itemEnchantmentsComponent.getEnchantmentsMap()) { + RegistryEntry registryEntry = entry.getKey(); + if (!(registryEntry.value()).slotMatches(slot)) continue; + contextAwareConsumer.accept(registryEntry, entry.getIntValue(), enchantmentEffectContext); + } + } + + private static void forEachEnchantment(LivingEntity entity, ContextAwareConsumer contextAwareConsumer) { + for (EquipmentSlot equipmentSlot : EquipmentSlot.values()) { + forEachEnchantment(entity.getEquippedStack(equipmentSlot), equipmentSlot, entity, contextAwareConsumer); + } + } + + @FunctionalInterface + interface ContextAwareConsumer { + public void accept(RegistryEntry var1, int var2, EnchantmentEffectContext var3); + } + // Hooks live here -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/EnchantmentIds.java b/src/main/java/dev/timefall/mcdw/enchants/EnchantmentIds.java new file mode 100644 index 00000000..6180f3a1 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/EnchantmentIds.java @@ -0,0 +1,47 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants; + +import dev.timefall.mcdw.Mcdw; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.registry.RegistryKey; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.util.Identifier; + +import java.util.ArrayList; +import java.util.List; + +public class EnchantmentIds { + + public static final List ENCHANTMENT_IDS = new ArrayList<>(); + + ///////////////// + + public static final RegistryKey ACCELERATE = EnchantmentIds.of("accelerate"); + + public static final RegistryKey ANIMA_CONDUIT = EnchantmentIds.of("anima_conduit"); + + public static final RegistryKey DYNAMO = EnchantmentIds.of("dynamo"); + public static final RegistryKey ECHO = EnchantmentIds.of("echo"); + + public static final RegistryKey LEECHING = EnchantmentIds.of("leeching"); + + public static final RegistryKey PAIN_CYCLE = EnchantmentIds.of("pain_cycle"); + + public static final RegistryKey RADIANCE = EnchantmentIds.of("radiance"); + + public static final RegistryKey SOUL_DEVOURER = EnchantmentIds.of("soul_devourer"); + public static final RegistryKey SOUL_SIPHON = EnchantmentIds.of("soul_siphon"); + + public static void init(){} + + private static RegistryKey of(String path) { + Identifier id = Mcdw.ID(path); + ENCHANTMENT_IDS.add(id); + return RegistryKey.of(RegistryKeys.ENCHANTMENT, id); + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/EntityAwareValueEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/EntityAwareValueEffectType.java new file mode 100644 index 00000000..b7c3d79b --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/EntityAwareValueEffectType.java @@ -0,0 +1,68 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.enchants.effect.entity_aware.ExperienceLevelValueEffectType; +import dev.timefall.mcdw.enchants.effect.entity_aware.MultiplyStatusValueEffectType; +import dev.timefall.mcdw.registries.McdwRegistries; +import it.unimi.dsi.fastutil.floats.FloatUnaryOperator; +import net.minecraft.entity.LivingEntity; +import net.minecraft.registry.Registry; +import net.minecraft.util.math.MathHelper; + +import java.util.function.Function; + +public interface EntityAwareValueEffectType { + + Codec CODEC = McdwRegistries.ENTITY_AWARE_VALUE_EFFECT_TYPES.getCodec().dispatch(EntityAwareValueEffectType::getCodec, Function.identity()); + + float apply(int level, float input, LivingEntity entity); + + MapCodec getCodec(); + + static void register(Registry> registry) { + Registry.register(registry, Mcdw.ID("unit"), Unit.CODEC); + Registry.register(registry, Mcdw.ID("multiply_status"), MultiplyStatusValueEffectType.CODEC); + Registry.register(registry, Mcdw.ID("experience_level"), ExperienceLevelValueEffectType.CODEC); + } + + ///////////// + + class Unit implements EntityAwareValueEffectType { + + public static final MapCodec CODEC = MapCodec.unit(new Unit()); + + @Override + public float apply(int level, float input, LivingEntity entity) { + return input; + } + + @Override + public MapCodec getCodec() { + return CODEC; + } + } + + // a UnaryOperator that clamps a float input to the provided bounds + record BoundedFloatUnaryOperator(float min, float max) implements FloatUnaryOperator { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> + instance.group( + Codec.FLOAT.fieldOf("min").forGetter(BoundedFloatUnaryOperator::min), + Codec.FLOAT.fieldOf("max").forGetter(BoundedFloatUnaryOperator::max) + ).apply(instance, BoundedFloatUnaryOperator::new) + ); + + @Override + public float apply(float x) { + return MathHelper.clamp(x, min, max); + } + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/McdwEntityEffectTypes.java b/src/main/java/dev/timefall/mcdw/enchants/effect/McdwEntityEffectTypes.java index c70d12a0..6906a581 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/effect/McdwEntityEffectTypes.java +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/McdwEntityEffectTypes.java @@ -7,5 +7,26 @@ package dev.timefall.mcdw.enchants.effect; +import com.mojang.serialization.MapCodec; +import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.enchants.effect.entity.AOEEnchantmentEntityEffectType; +import dev.timefall.mcdw.enchants.effect.entity.ApplyStackingMobEffectEnchantmentEntityEffectType; +import dev.timefall.mcdw.enchants.effect.entity.LeechMobEnchantmentEntityEffectType; +import dev.timefall.mcdw.enchants.effect.entity.RemoveMobEffectEnchantmentEntityEffectType; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; + public class McdwEntityEffectTypes { -} + + public static MapCodec AOE_EFFECT = register("aoe_effect", AOEEnchantmentEntityEffectType.CODEC); + public static MapCodec APPLY_STACKING_MOB_EFFECT = register("apply_stacking_mob_effect", ApplyStackingMobEffectEnchantmentEntityEffectType.CODEC); + public static MapCodec LEECH_MOB_EFFECT = register("leech_mob_effect", LeechMobEnchantmentEntityEffectType.CODEC); + public static MapCodec REMOVE_MOB_EFFECT = register("remove_mob_effect", RemoveMobEffectEnchantmentEntityEffectType.CODEC); + + + private static MapCodec register(String id, MapCodec codec) { + return Registry.register(Registries.ENCHANTMENT_ENTITY_EFFECT_TYPE, Mcdw.ID(id), codec); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/AOEEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/AOEEnchantmentEntityEffectType.java new file mode 100644 index 00000000..464c31f8 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/AOEEnchantmentEntityEffectType.java @@ -0,0 +1,84 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.mixin.LivingEntityAccessor; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Box; +import net.minecraft.util.math.Vec3d; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.function.Predicate; + +public record AOEEnchantmentEntityEffectType(EnchantmentLevelBasedValueType radius, EnchantmentEntityEffectType effect, Optional targetLimit, boolean ignoreTargetEntity)implements EnchantmentEntityEffectType { + + public AOEEnchantmentEntityEffectType(EnchantmentLevelBasedValueType radius, EnchantmentEntityEffectType effect){ + this(radius, effect, Optional.empty(), true); + } + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + EnchantmentLevelBasedValueType.CODEC.fieldOf("radius").forGetter(AOEEnchantmentEntityEffectType::radius), + EnchantmentEntityEffectType.CODEC.fieldOf("effect").forGetter(AOEEnchantmentEntityEffectType::effect), + EnchantmentLevelBasedValueType.CODEC.optionalFieldOf("target_limit").forGetter(AOEEnchantmentEntityEffectType::targetLimit), + Codec.BOOL.optionalFieldOf("ignore_target_entity", true).forGetter(AOEEnchantmentEntityEffectType::ignoreTargetEntity) + ).apply(instance, AOEEnchantmentEntityEffectType::new) + ); + + @Override + public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos) { + double d = (double) this.radius.getValue(level) * 2.0; + Predicate aoePredicate = e -> true; + Predicate predicate = e -> (!this.ignoreTargetEntity || e != user) && aoePredicate.test(e); + List entities = world.getEntitiesByClass(LivingEntity.class, Box.of(pos, d, d, d), predicate); + if (effect instanceof RelativeEnchantmentEntityEffectType relativeEffect) { + float damage = user instanceof LivingEntity ? ((LivingEntityAccessor)user).getLastDamageTaken() : 0f; + if (this.targetLimit.isPresent()) { + Collections.shuffle(entities); + int limit = (int) this.targetLimit.get().getValue(level); + for (LivingEntity livingEntity : entities) { + relativeEffect.applyRelative(world, level, context, livingEntity, pos, user); + --limit; + if (limit <= 0) break; + } + } else { + for (LivingEntity livingEntity : entities) { + relativeEffect.applyRelative(world, level, context, livingEntity, pos, user); + } + } + } else { + if (this.targetLimit.isPresent()) { + Collections.shuffle(entities); + int limit = (int) this.targetLimit.get().getValue(level); + for (LivingEntity livingEntity : entities) { + effect.apply(world, level, context, livingEntity, pos); + --limit; + if (limit <= 0) break; + } + } else { + for (LivingEntity livingEntity : entities) { + effect.apply(world, level, context, livingEntity, pos); + } + } + } + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/ApplyStackingMobEffectEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/ApplyStackingMobEffectEnchantmentEntityEffectType.java new file mode 100644 index 00000000..a96ac8b1 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/ApplyStackingMobEffectEnchantmentEntityEffectType.java @@ -0,0 +1,78 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.registry.RegistryCodecs; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.entry.RegistryEntryList; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.random.Random; + +import java.util.Optional; + +public record ApplyStackingMobEffectEnchantmentEntityEffectType( + RegistryEntryList toApply, + EnchantmentLevelBasedValueType duration, + EnchantmentLevelBasedValueType startingAmplifier, + EnchantmentLevelBasedValueType maxAmplifier, + boolean popIfMaxed)implements EnchantmentEntityEffectType +{ + + public ApplyStackingMobEffectEnchantmentEntityEffectType( + RegistryEntry toApply, + EnchantmentLevelBasedValueType duration, + EnchantmentLevelBasedValueType maxAmplifier) + { + this(RegistryEntryList.of(toApply), duration, EnchantmentLevelBasedValueType.constant(0f), maxAmplifier, false); + } + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + RegistryCodecs.entryList(RegistryKeys.STATUS_EFFECT).fieldOf("to_apply").forGetter(ApplyStackingMobEffectEnchantmentEntityEffectType::toApply), + EnchantmentLevelBasedValueType.CODEC.fieldOf("duration").forGetter(ApplyStackingMobEffectEnchantmentEntityEffectType::duration), + EnchantmentLevelBasedValueType.CODEC.optionalFieldOf("starting_amplifier", new EnchantmentLevelBasedValueType.Constant(0f)).forGetter(ApplyStackingMobEffectEnchantmentEntityEffectType::startingAmplifier), + EnchantmentLevelBasedValueType.CODEC.fieldOf("max_amplifier").forGetter(ApplyStackingMobEffectEnchantmentEntityEffectType::maxAmplifier), + Codec.BOOL.optionalFieldOf("pop_if_maxed",false).forGetter(ApplyStackingMobEffectEnchantmentEntityEffectType::popIfMaxed) + ).apply(instance, ApplyStackingMobEffectEnchantmentEntityEffectType::new) + ); + + @Override + public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos) { + if (user instanceof LivingEntity livingEntity){ + Random random = user.getRandom(); + Optional> optional; + if((optional = this.toApply.getRandom(random)).isPresent()){ + int durationValue = (int) this.duration.getValue(level); + StatusEffectInstance instance = livingEntity.getStatusEffect(optional.get()); + int amplifierValue = instance != null + ? Math.max((int) this.maxAmplifier.getValue(level), instance.getAmplifier() + 1) + : (int) this.startingAmplifier.getValue(level); + if (popIfMaxed && instance != null && instance.getAmplifier() == this.maxAmplifier.getValue(level)) + livingEntity.removeStatusEffect(optional.get()); + else + livingEntity.addStatusEffect(new StatusEffectInstance(optional.get(), durationValue, amplifierValue)); + } + } + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/LeechMobEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/LeechMobEnchantmentEntityEffectType.java new file mode 100644 index 00000000..1c5135a8 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/LeechMobEnchantmentEntityEffectType.java @@ -0,0 +1,42 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; + +public record LeechMobEnchantmentEntityEffectType(EnchantmentLevelBasedValueType amount)implements EnchantmentEntityEffectType +{ + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + EnchantmentLevelBasedValueType.CODEC.fieldOf("amount").forGetter(LeechMobEnchantmentEntityEffectType::amount) + ).apply(instance, LeechMobEnchantmentEntityEffectType::new) + ); + + @Override + public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos) { + if (user instanceof LivingEntity victim){ + if (context.owner() != null){ + float healthRegained = this.amount.getValue(level) * victim.getMaxHealth(); + context.owner().heal(healthRegained); + } + } + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/RelativeEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/RelativeEnchantmentEntityEffectType.java new file mode 100644 index 00000000..487208f3 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/RelativeEnchantmentEntityEffectType.java @@ -0,0 +1,58 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.enchants.effect.entity.relative.DamageTakenRelativeEnchantmentEntityEffectType; +import dev.timefall.mcdw.enchants.effect.entity.relative.MaxHealthRelativeEnchantmentEntityEffectType; +import dev.timefall.mcdw.registries.McdwRegistries; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.entity.Entity; +import net.minecraft.registry.Registry; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; + +import java.util.function.Function; + +public interface RelativeEnchantmentEntityEffectType extends EnchantmentEntityEffectType { + + Codec CODEC = McdwRegistries.RELATIVE_ENTITY_EFFECT_TYPES.getCodec().dispatch(RelativeEnchantmentEntityEffectType::getCodec, Function.identity()); + + @Override + default void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos) { + } + + void applyRelative(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos, Entity relativeTo); + + @Override + public MapCodec getCodec(); + + static void register(Registry> registry){ + Registry.register(registry, Mcdw.ID("unit"), Unit.CODEC); + Registry.register(registry, Mcdw.ID("damage_taken_relative"), DamageTakenRelativeEnchantmentEntityEffectType.CODEC); + Registry.register(registry, Mcdw.ID("max_health_relative"), MaxHealthRelativeEnchantmentEntityEffectType.CODEC); + } + + ////////////// + + class Unit implements RelativeEnchantmentEntityEffectType{ + + public static MapCodec CODEC = MapCodec.unit(new Unit()); + + @Override + public void applyRelative(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos, Entity relativeTo) { + } + + @Override + public MapCodec getCodec() { + return CODEC; + } + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/RemoveMobEffectEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/RemoveMobEffectEnchantmentEntityEffectType.java new file mode 100644 index 00000000..b48628a2 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/RemoveMobEffectEnchantmentEntityEffectType.java @@ -0,0 +1,61 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.effect.EnchantmentEntityEffectType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.registry.RegistryCodecs; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.registry.entry.RegistryEntryList; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; +import net.minecraft.util.math.random.Random; + +import java.util.Optional; + +public record RemoveMobEffectEnchantmentEntityEffectType(RegistryEntryList toRemove, boolean removeAll)implements EnchantmentEntityEffectType { + + public RemoveMobEffectEnchantmentEntityEffectType(RegistryEntry effect){ + this(RegistryEntryList.of(effect), true); + } + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + RegistryCodecs.entryList(RegistryKeys.STATUS_EFFECT).fieldOf("to_remove").forGetter(RemoveMobEffectEnchantmentEntityEffectType::toRemove), + Codec.BOOL.optionalFieldOf("remove_all", true).forGetter(RemoveMobEffectEnchantmentEntityEffectType::removeAll) + ).apply(instance, RemoveMobEffectEnchantmentEntityEffectType::new) + ); + + @Override + public void apply(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos) { + if (user instanceof LivingEntity livingEntity){ + if (!removeAll) { + Random random = user.getRandom(); + Optional> optional; + if ((optional = this.toRemove.getRandom(random)).isPresent()) { + livingEntity.removeStatusEffect(optional.get()); + } + } else { + for (var effect : this.toRemove){ + livingEntity.removeStatusEffect(effect); + } + } + } + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/relative/DamageTakenRelativeEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/relative/DamageTakenRelativeEnchantmentEntityEffectType.java new file mode 100644 index 00000000..44581926 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/relative/DamageTakenRelativeEnchantmentEntityEffectType.java @@ -0,0 +1,45 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity.relative; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.enchants.effect.entity.RelativeEnchantmentEntityEffectType; +import dev.timefall.mcdw.mixin.LivingEntityAccessor; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageType; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; + +public record DamageTakenRelativeEnchantmentEntityEffectType(EnchantmentLevelBasedValueType factor, RegistryEntry damageType) implements RelativeEnchantmentEntityEffectType +{ + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + EnchantmentLevelBasedValueType.CODEC.fieldOf("factor").forGetter(DamageTakenRelativeEnchantmentEntityEffectType::factor), + DamageType.ENTRY_CODEC.fieldOf("damage_type").forGetter(DamageTakenRelativeEnchantmentEntityEffectType::damageType) + ).apply(instance, DamageTakenRelativeEnchantmentEntityEffectType::new) + ); + + @Override + public void applyRelative(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos, Entity relativeTo) { + if (!(relativeTo instanceof LivingEntity livingEntity)) return; + float damage = ((LivingEntityAccessor)livingEntity).getLastDamageTaken(); + float f = damage * factor.getValue(level); + user.damage(new DamageSource(this.damageType, context.owner()), f); + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity/relative/MaxHealthRelativeEnchantmentEntityEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/relative/MaxHealthRelativeEnchantmentEntityEffectType.java new file mode 100644 index 00000000..c51635f1 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity/relative/MaxHealthRelativeEnchantmentEntityEffectType.java @@ -0,0 +1,45 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity.relative; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.enchants.effect.entity.RelativeEnchantmentEntityEffectType; +import dev.timefall.mcdw.mixin.LivingEntityAccessor; +import net.minecraft.enchantment.EnchantmentEffectContext; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.entity.damage.DamageType; +import net.minecraft.registry.entry.RegistryEntry; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; + +public record MaxHealthRelativeEnchantmentEntityEffectType(EnchantmentLevelBasedValueType factor, RegistryEntry damageType) implements RelativeEnchantmentEntityEffectType +{ + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + EnchantmentLevelBasedValueType.CODEC.fieldOf("factor").forGetter(MaxHealthRelativeEnchantmentEntityEffectType::factor), + DamageType.ENTRY_CODEC.fieldOf("damage_type").forGetter(MaxHealthRelativeEnchantmentEntityEffectType::damageType) + ).apply(instance, MaxHealthRelativeEnchantmentEntityEffectType::new) + ); + + @Override + public void applyRelative(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos, Entity relativeTo) { + if (!(relativeTo instanceof LivingEntity livingEntity)) return; + float health = livingEntity.getMaxHealth(); + float f = health * factor.getValue(level); + user.damage(new DamageSource(this.damageType, context.owner()), f); + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity_aware/ExperienceLevelValueEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity_aware/ExperienceLevelValueEffectType.java new file mode 100644 index 00000000..b1464cf5 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity_aware/ExperienceLevelValueEffectType.java @@ -0,0 +1,51 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity_aware; + +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.enchants.effect.EntityAwareValueEffectType; +import me.fzzyhmstrs.fzzy_config.util.Expression; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.player.PlayerEntity; + +import java.util.Map; + +public record ExperienceLevelValueEffectType(Expression expression) implements EntityAwareValueEffectType { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + Expression.Impl.getCODEC().fieldOf("expression").forGetter(ExperienceLevelValueEffectType::expression) + ).apply(instance, ExperienceLevelValueEffectType::new) + ); + + @Override + public float apply(int level, float input, LivingEntity entity) { + // bail if it's not a player. need xp + if (!(entity instanceof PlayerEntity player)) return input; + + //get xp levels + int xpLevels = player.experienceLevel; + + //prepare the Expression map + Map expressionMap = Map.of( + 'x', (double) xpLevels, + 'l', (double) level + ); + + //evaluate the expression, with a safe fallback to 0.0 added multiplier + double multiplier = expression.evalSafe(expressionMap,0.0); + + //return the multiplied input + return input * (1f + (float) multiplier); + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/effect/entity_aware/MultiplyStatusValueEffectType.java b/src/main/java/dev/timefall/mcdw/enchants/effect/entity_aware/MultiplyStatusValueEffectType.java new file mode 100644 index 00000000..978b41cf --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/enchants/effect/entity_aware/MultiplyStatusValueEffectType.java @@ -0,0 +1,57 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.enchants.effect.entity_aware; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.MapCodec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import dev.timefall.mcdw.enchants.effect.EntityAwareValueEffectType; +import net.minecraft.enchantment.EnchantmentLevelBasedValueType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.effect.StatusEffect; +import net.minecraft.entity.effect.StatusEffectInstance; +import net.minecraft.registry.Registries; +import net.minecraft.registry.entry.RegistryEntry; + +import java.util.Optional; + +public record MultiplyStatusValueEffectType(RegistryEntry statusEffect, EnchantmentLevelBasedValueType amount, boolean provideFlatBonus, Optional bounds) implements EntityAwareValueEffectType { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(instance -> + instance.group( + Registries.STATUS_EFFECT.getEntryCodec().fieldOf("status_effect").forGetter(MultiplyStatusValueEffectType::statusEffect), + EnchantmentLevelBasedValueType.CODEC.fieldOf("amount").forGetter(MultiplyStatusValueEffectType::amount), + Codec.BOOL.optionalFieldOf("provide_flat_bonus", false).forGetter(MultiplyStatusValueEffectType::provideFlatBonus), + BoundedFloatUnaryOperator.CODEC.optionalFieldOf("bounds").forGetter(MultiplyStatusValueEffectType::bounds) + ).apply(instance, MultiplyStatusValueEffectType::new) + ); + + @Override + public float apply(int level, float input, LivingEntity entity) { + //get status + StatusEffectInstance instance = entity.getStatusEffect(statusEffect); + + //if no status and we don't provide a flat bonus, short circuit back the input + if (instance == null && !provideFlatBonus) return input; + + //get the amplifier, 0 if the instance is null (this would be a flat bonus) + int amplifier = instance == null ? 0 : instance.getAmplifier(); + + //calculate the multiplier, optionally bounding it + float multiplier = (bounds.isPresent() + ? this.bounds.get().apply(this.amount.getValue(level) * (amplifier + 1f)) + : this.amount.getValue(level) * (amplifier + 1f)); + + //return the multiplied input + return input * (1f + multiplier); + } + + @Override + public MapCodec getCodec() { + return CODEC; + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/AccelerateEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/AccelerateEnchantment.java index ec2a9420..822c1c01 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/AccelerateEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/AccelerateEnchantment.java @@ -16,13 +16,14 @@ /* * Effects Needed: - * ACCELERATE_CHARGE_TIME -> New Effect Type, Custom CODEC, pain + * ACCELERATE_CHARGE_TIME -> New Effect Type, Custom CODEC, pain: MultiplyStatusValueEffectType * APPLY_STACKING_MOB_EFFECT -> Registries.ENCHANTMENT_ENTITY_EFFECT_TYPE + * FORMULA = shots * (0.06 + (0.02 * lvl)) + * BOUNDS = 0..1 > maximum 2x speed up */ /* * Effects Present: - * */ public class AccelerateEnchantment extends RangedEnchantment { diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/BurstBowstringEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/BurstBowstringEnchantment.java index cbdf6c3c..a7386cdf 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/BurstBowstringEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/BurstBowstringEnchantment.java @@ -13,8 +13,7 @@ /* * Effects Needed: - * BONUS_ARROWS_COUNT -> AddEnchantmentEffectType (add from MutableFloat of zero); - * would be like: ComponentType>> DAMAGE + * ON_JUMP -> ComponentType>> */ /* @@ -43,4 +42,4 @@ public boolean isAcceptableItem(ItemStack stack) { return stack.getItem() instanceof CrossbowItem || stack.getItem() instanceof BowItem; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/DynamoEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/DynamoEnchantment.java index eb87eddc..b7424c5a 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/DynamoEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/DynamoEnchantment.java @@ -10,12 +10,21 @@ import dev.timefall.mcdw.enchantment.types.DamageBoostEnchantment; import net.minecraft.item.*; +/* + * DONE + */ + /* * Effects Needed: + * ON_JUMP -> ComponentType>> + * MultiplyStatusValueEffectType -> deal the damage + * RemoveMobEffectEnchantmentEntityEffectType -> remove the status */ /* * Effects Present: + * DAMAGE -> deal the damage + * POST_ATTACK -> remove the status */ public class DynamoEnchantment extends DamageBoostEnchantment { @@ -39,4 +48,4 @@ public boolean isAcceptableItem(ItemStack stack) { || stack.getItem() instanceof BowItem || stack.getItem() instanceof CrossbowItem; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/EchoEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/EchoEnchantment.java index e9b39713..efdf3d15 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/EchoEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/EchoEnchantment.java @@ -15,10 +15,16 @@ /* * Effects Needed: + * AOEEnchantmentEntityEffectType */ /* * Effects Present: + * POST_ATTACK -> All Of: + * > RandomChanceWithEnchantedBonusLootCondition: 0.15 per level + * > PlaySound + * > fire the AOE effect + * Inside AOE -> */ public class EchoEnchantment extends AoEEnchantment { @@ -45,4 +51,4 @@ public boolean isAcceptableItem(ItemStack stack) { || stack.isOf(McdwDaggerItemRegistry.DAGGER_SWIFT_STRIKER); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/EnigmaResonatorEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/EnigmaResonatorEnchantment.java index bfa349bf..3b31580d 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/EnigmaResonatorEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/EnigmaResonatorEnchantment.java @@ -12,6 +12,7 @@ /* * Effects Needed: + * ExperienceLevelValueEffectType */ /* @@ -40,4 +41,4 @@ public boolean isAcceptableItem(ItemStack stack) { stack.getItem() instanceof CrossbowItem || stack.getItem() instanceof BowItem; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/LeechingEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/LeechingEnchantment.java index 0548e374..bb4ddf08 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/LeechingEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/LeechingEnchantment.java @@ -12,8 +12,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; +/* + * DONE + */ + /* * Effects Needed: + * POST_DEATH -> need new ComponentType>> + * LEECH_ENTITY -> new EnchantmentEntityEffectType */ /* diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/PainCycleEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/PainCycleEnchantment.java index 8cf6e063..2190bea3 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/PainCycleEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/PainCycleEnchantment.java @@ -12,12 +12,26 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; +/* + * DONE + */ + /* * Effects Needed: + * DAMAGE -> deal the damage + * > EntityPropertiesLootCondition -> Check if pain cycle is at stack 5 + * > MultiplyEnchantmentEffectType -> multiply by constant 2 */ /* * Effects Present: + * + * POST_ATTACK -> to apply the pain cycle + * > EntityPropertiesLootCondition -> Check if pain cycle is below 5, + * > ApplyStackingMobEffectEnchantmentEntityEffectType > max 5 > damage event moved to the status itself + * POST_ATTACK -> to remove the pain cycle + * > EntityPropertiesLootCondition -> Check if pain cycle is at stack 5 + * > RemoveMobEffectEnchantmentEntityEffectType > remove pain cycle */ public class PainCycleEnchantment extends DamageBoostEnchantment { @@ -41,4 +55,4 @@ public boolean isAcceptableItem(ItemStack stack) { return stack.getItem() instanceof SwordItem || stack.getItem() instanceof AxeItem || stack.getItem() instanceof McdwCustomWeaponItem; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulDevourerEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulDevourerEnchantment.java index 1a6e4c05..aaa5b273 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulDevourerEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulDevourerEnchantment.java @@ -12,12 +12,18 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; +/* + * DONE + */ + /* * Effects Needed: */ /* * Effects Present: + * MOB_EXPERIENCE component type + * MultiplyEnchantmentEffectType -> Linear base 1.333333, perLevelAboveFirst 0.33333 based on default 3.0 factor */ public class SoulDevourerEnchantment extends Enchantment { diff --git a/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulSiphonEnchantment.java b/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulSiphonEnchantment.java index a33af8b0..328e9d46 100644 --- a/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulSiphonEnchantment.java +++ b/src/main/java/dev/timefall/mcdw/enchants/enchantments/SoulSiphonEnchantment.java @@ -12,12 +12,19 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.SwordItem; +/* + * DONE + */ + /* * Effects Needed: */ /* * Effects Present: + * MOB_EXPERIENCE component type + * MultiplyEnchantmentEffectType -> Linear 3.0 per level + * RnadomChanceLootCondition -> 10% chance to occur */ public class SoulSiphonEnchantment extends Enchantment { @@ -41,4 +48,4 @@ public boolean isAcceptableItem(ItemStack stack) { return stack.getItem() instanceof SwordItem || stack.getItem() instanceof AxeItem || stack.getItem() instanceof McdwCustomWeaponItem; } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/mixin/EnchantmentAccessor.java b/src/main/java/dev/timefall/mcdw/mixin/EnchantmentAccessor.java new file mode 100644 index 00000000..cddd5696 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/mixin/EnchantmentAccessor.java @@ -0,0 +1,49 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.mixin; + +import net.minecraft.block.BlockState; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.enchantment.effect.EnchantmentEffectEntry; +import net.minecraft.entity.Entity; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.Vec3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +import java.util.List; +import java.util.function.Consumer; + +@Mixin(Enchantment.class) +public interface EnchantmentAccessor { + @Invoker + static void callApplyEffects(List> conditions, LootContext lootContext, Consumer effectConsumer) { + throw new UnsupportedOperationException(); + } + + @Invoker + static LootContext callCreateHitBlockLootContext(ServerWorld world, int level, Entity entity, Vec3d pos, BlockState state) { + throw new UnsupportedOperationException(); + } + + @Invoker + static LootContext callCreateEnchantedEntityLootContext(ServerWorld world, int level, Entity entity, Vec3d pos) { + throw new UnsupportedOperationException(); + } + + @Invoker + static LootContext callCreateEnchantedLocationLootContext(ServerWorld world, int level, Entity entity, boolean enchantmentActive) { + throw new UnsupportedOperationException(); + } + + @Invoker + static LootContext callCreateEnchantedItemLootContext(ServerWorld world, int level, ItemStack stack) { + throw new UnsupportedOperationException(); + } +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/mixin/EnchantmentHelperMixin.java b/src/main/java/dev/timefall/mcdw/mixin/EnchantmentHelperMixin.java new file mode 100644 index 00000000..ce058b3a --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/mixin/EnchantmentHelperMixin.java @@ -0,0 +1,27 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.mixin; + +import com.llamalad7.mixinextras.injector.ModifyReturnValue; +import dev.timefall.mcdw.effects.NewEnchantmentEffects; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.item.ItemStack; +import net.minecraft.server.world.ServerWorld; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(EnchantmentHelper.class) +public class EnchantmentHelperMixin { + + @ModifyReturnValue(method = "getDamage", at = @At("RETURN")) + private static float mcdw$hookStatusDamageEffects(float original, ServerWorld world, ItemStack stack, Entity target, DamageSource damageSource, float baseDamage){ + return original + NewEnchantmentEffects.mcdw$entityAwareDamageHook(world, stack, target, damageSource, original); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/mixin/LivingEntityAccessor.java b/src/main/java/dev/timefall/mcdw/mixin/LivingEntityAccessor.java new file mode 100644 index 00000000..cd76961d --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/mixin/LivingEntityAccessor.java @@ -0,0 +1,18 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ + +package dev.timefall.mcdw.mixin; + +import net.minecraft.entity.LivingEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(LivingEntity.class) +public interface LivingEntityAccessor { + @Accessor + float getLastDamageTaken(); +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/mixin/LivingEntityMixin.java b/src/main/java/dev/timefall/mcdw/mixin/LivingEntityMixin.java new file mode 100644 index 00000000..ceebf099 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/mixin/LivingEntityMixin.java @@ -0,0 +1,45 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.mixin; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.timefall.mcdw.effects.NewEnchantmentEffects; +import net.minecraft.entity.Entity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.server.world.ServerWorld; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(LivingEntity.class) +public class LivingEntityMixin { + + @WrapOperation(method = "onDeath", at = @At(value = "INVOKE", target = "net/minecraft/entity/Entity.onKilledOther (Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/entity/LivingEntity;)Z")) + private boolean mcdw$hookOnDeathEnchantmentEffects(Entity attacker, ServerWorld world, LivingEntity victim, Operation original, DamageSource damageSource){ + // always run the original call to chain any mixins and get the original method to run + boolean result = original.call(attacker, world, victim); + // if the thing didn't actually die, don't run the hook + if (!result) return false; + //run the on Death Hook from EnchantmentEffects + NewEnchantmentEffects.mcdw$onDeathHook(attacker, world, victim, damageSource); + //return death success + return true; + } + + @SuppressWarnings("ConstantValue") + @Inject(method = "jump", at = @At("HEAD")) + public void mcdw$onJumpEffects(CallbackInfo ci){ + if (((Object) this instanceof ServerPlayerEntity playerEntity)) { + NewEnchantmentEffects.mcdw$onJumpHook(playerEntity); + } + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/McdwRegistries.java b/src/main/java/dev/timefall/mcdw/registries/McdwRegistries.java new file mode 100644 index 00000000..5d2d5671 --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/registries/McdwRegistries.java @@ -0,0 +1,29 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ + +package dev.timefall.mcdw.registries; + +import com.mojang.serialization.MapCodec; +import dev.timefall.mcdw.Mcdw; +import dev.timefall.mcdw.enchants.effect.EntityAwareValueEffectType; +import dev.timefall.mcdw.enchants.effect.entity.RelativeEnchantmentEntityEffectType; +import net.fabricmc.fabric.api.event.registry.FabricRegistryBuilder; +import net.minecraft.registry.DefaultedRegistry; +import net.minecraft.registry.RegistryKey; + +public class McdwRegistries { + + public static final DefaultedRegistry> ENTITY_AWARE_VALUE_EFFECT_TYPES = FabricRegistryBuilder.>createDefaulted(RegistryKey.ofRegistry(Mcdw.ID("entity_aware_value_effect_types")),Mcdw.ID("unit")).buildAndRegister(); + + public static final DefaultedRegistry> RELATIVE_ENTITY_EFFECT_TYPES = FabricRegistryBuilder.>createDefaulted(RegistryKey.ofRegistry(Mcdw.ID("relative_entity_effect_types")),Mcdw.ID("unit")).buildAndRegister(); + + + public static void register(){ + EntityAwareValueEffectType.register(ENTITY_AWARE_VALUE_EFFECT_TYPES); + } + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/SoundEventsRegistry.java b/src/main/java/dev/timefall/mcdw/registries/SoundEventsRegistry.java index 868bfbad..09a98c62 100644 --- a/src/main/java/dev/timefall/mcdw/registries/SoundEventsRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/SoundEventsRegistry.java @@ -8,20 +8,18 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; public class SoundEventsRegistry { public static final Identifier ECHO_SOUND = Identifier.of("mcdw:echo_sound"); - public static final SoundEvent ECHO_SOUND_EVENT = SoundEvent.of(ECHO_SOUND); + public static final RegistryEntry ECHO_SOUND_EVENT = registerSound(ECHO_SOUND,SoundEvent.of(ECHO_SOUND)); - public static void register(){ - registerSound(ECHO_SOUND, ECHO_SOUND_EVENT); - } + public static void register(){} @SuppressWarnings("SameParameterValue") - protected static void registerSound(Identifier soundIdentifier, SoundEvent soundEvent) { - Registry.register(Registries.SOUND_EVENT, soundIdentifier, soundEvent); - + protected static RegistryEntry registerSound(Identifier soundIdentifier, SoundEvent soundEvent) { + return Registry.registerReference(Registries.SOUND_EVENT, soundIdentifier, soundEvent); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwAxeItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwAxeItemRegistry.java index d4c714cf..48ab7880 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwAxeItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwAxeItemRegistry.java @@ -5,13 +5,6 @@ * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ - package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -25,21 +18,28 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwAxeItemRegistry { - public static final McdwAxeItem AXE_ANCHOR = register("axe_anchor", McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeAnchor()); - public static final McdwAxeItem AXE_HIGHLAND = register("axe_highland", McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeHighland()); - public static final McdwAxeItem AXE_AXE = register("axe_axe", McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeAxe()); - public static final McdwAxeItem AXE_ENCRUSTED_ANCHOR = register("axe_encrusted_anchor", McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeEncrustedAnchor()); - public static final McdwAxeItem AXE_FIREBRAND = register("axe_firebrand", McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeFirebrand()); + public static final Identifier AXE_ANCHOR_ID = Mcdw.ID("axe_anchor"); + public static final Identifier AXE_HIGHLAND_ID = Mcdw.ID("axe_highland"); + public static final Identifier AXE_AXE_ID = Mcdw.ID("axe_axe"); + public static final Identifier AXE_ENCRUSTED_ANCHOR_ID = Mcdw.ID("axe_encrusted_anchor"); + public static final Identifier AXE_FIREBRAND_ID = Mcdw.ID("axe_firebrand"); - public static void register() { + public static final McdwAxeItem AXE_ANCHOR = register(AXE_ANCHOR_ID, McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeAnchor()); + public static final McdwAxeItem AXE_HIGHLAND = register(AXE_HIGHLAND_ID, McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeHighland()); + public static final McdwAxeItem AXE_AXE = register(AXE_AXE_ID, McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeAxe()); + public static final McdwAxeItem AXE_ENCRUSTED_ANCHOR = register(AXE_ENCRUSTED_ANCHOR_ID, McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeEncrustedAnchor()); + public static final McdwAxeItem AXE_FIREBRAND = register(AXE_FIREBRAND_ID, McdwWeaponStatsConfig.CONFIG.getAxeItemStats().getAxeFirebrand()); + public static void register() { } - private static McdwAxeItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwAxeItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwAxeItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -77,4 +77,4 @@ private static McdwAxeItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwBowItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwBowItemRegistry.java index ec20dbdf..ff9e512b 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwBowItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwBowItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -21,38 +14,71 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwBowItemRegistry { - public static final McdwBowItem BOW_ANCIENT_BOW = register("bow_ancient_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowAncientBow()); - public static final McdwBowItem BOW_BONEBOW = register("bow_bonebow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBonebow()); - public static final McdwBowItem BOW_BUBBLE_BOW = register("bow_bubble_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBubbleBow()); - public static final McdwBowItem BOW_BUBBLE_BURSTER = register("bow_bubble_burster", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBubbleBurster()); - public static final McdwBowItem BOW_BURST_GALE_BOW = register("bow_burst_gale_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBurstGaleBow()); - public static final McdwBowItem BOW_CALL_OF_THE_VOID = register("bow_call_of_the_void", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowCallOfTheVoid()); - public static final McdwBowItem BOW_ECHO_OF_THE_VALLEY = register("bow_echo_of_the_valley", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowEchoOfTheValley()); - public static final McdwBowItem BOW_ELITE_POWER_BOW = register("bow_elite_power_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowElitePowerBow()); - public static final McdwBowItem BOW_GREEN_MENACE = register("bow_green_menace", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowGreenMenace()); - public static final McdwBowItem BOW_HAUNTED_BOW = register("bow_haunted_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowHauntedBow()); - public static final McdwBowItem BOW_HUNTERS_PROMISE = register("bow_hunters_promise", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowHuntersPromise()); - public static final McdwBowItem BOW_HUNTING_BOW = register("bow_hunting_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowHuntingBow()); - public static final McdwBowItem BOW_LOST_SOULS = register("bow_lost_souls", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowLostSouls()); - public static final McdwBowItem BOW_MASTERS_BOW = register("bow_masters_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowMastersBow()); - public static final McdwBowItem BOW_NOCTURNAL_BOW = register("bow_nocturnal_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowNocturnalBow()); - public static final McdwBowItem BOW_PHANTOM_BOW = register("bow_phantom_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowPhantomBow()); - public static final McdwBowItem BOW_PINK_SCOUNDREL = register("bow_pink_scoundrel", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowPinkScoundrel()); - public static final McdwBowItem BOW_POWER_BOW = register("bow_power_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowPowerBow()); - public static final McdwBowItem BOW_SABREWING = register("bow_sabrewing", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowSabrewing()); - public static final McdwBowItem BOW_SHIVERING_BOW = register("bow_shivering_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowShiveringBow()); - public static final McdwBowItem BOW_SNOW_BOW = register("bow_snow_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowSnowBow()); - public static final McdwBowItem BOW_SOUL_BOW = register("bow_soul_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowSoulBow()); - public static final McdwBowItem BOW_TRICKBOW = register("bow_trickbow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowTrickbow()); - public static final McdwBowItem BOW_TWIN_BOW = register("bow_twin_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowTwinBow()); - public static final McdwBowItem BOW_TWISTING_VINE_BOW = register("bow_twisting_vine_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowTwistingVineBow()); - public static final McdwBowItem BOW_VOID_BOW = register("bow_void_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowVoidBow()); - public static final McdwBowItem BOW_WEB_BOW = register("bow_web_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWebBow()); - public static final McdwBowItem BOW_WEEPING_VINE_BOW = register("bow_weeping_vine_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWeepingVineBow()); - public static final McdwBowItem BOW_WIND_BOW = register("bow_wind_bow", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWindBow()); - public static final McdwBowItem BOW_WINTERS_TOUCH = register("bow_winters_touch", McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWintersTouch()); + + public static final Identifier BOW_ANCIENT_BOW_ID = Mcdw.ID("bow_ancient_bow"); + public static final Identifier BOW_BONEBOW_ID = Mcdw.ID("bow_bonebow"); + public static final Identifier BOW_BUBBLE_BOW_ID = Mcdw.ID("bow_bubble_bow"); + public static final Identifier BOW_BUBBLE_BURSTER_ID = Mcdw.ID("bow_bubble_burster"); + public static final Identifier BOW_BURST_GALE_BOW_ID = Mcdw.ID("bow_burst_gale_bow"); + public static final Identifier BOW_CALL_OF_THE_VOID_ID = Mcdw.ID("bow_call_of_the_void"); + public static final Identifier BOW_ECHO_OF_THE_VALLEY_ID = Mcdw.ID("bow_echo_of_the_valley"); + public static final Identifier BOW_ELITE_POWER_BOW_ID = Mcdw.ID("bow_elite_power_bow"); + public static final Identifier BOW_GREEN_MENACE_ID = Mcdw.ID("bow_green_menace"); + public static final Identifier BOW_HAUNTED_BOW_ID = Mcdw.ID("bow_haunted_bow"); + public static final Identifier BOW_HUNTERS_PROMISE_ID = Mcdw.ID("bow_hunters_promise"); + public static final Identifier BOW_HUNTING_BOW_ID = Mcdw.ID("bow_hunting_bow"); + public static final Identifier BOW_LOST_SOULS_ID = Mcdw.ID("bow_lost_souls"); + public static final Identifier BOW_MASTERS_BOW_ID = Mcdw.ID("bow_masters_bow"); + public static final Identifier BOW_NOCTURNAL_BOW_ID = Mcdw.ID("bow_nocturnal_bow"); + public static final Identifier BOW_PHANTOM_BOW_ID = Mcdw.ID("bow_phantom_bow"); + public static final Identifier BOW_PINK_SCOUNDREL_ID = Mcdw.ID("bow_pink_scoundrel"); + public static final Identifier BOW_POWER_BOW_ID = Mcdw.ID("bow_power_bow"); + public static final Identifier BOW_SABREWING_ID = Mcdw.ID("bow_sabrewing"); + public static final Identifier BOW_SHIVERING_BOW_ID = Mcdw.ID("bow_shivering_bow"); + public static final Identifier BOW_SNOW_BOW_ID = Mcdw.ID("bow_snow_bow"); + public static final Identifier BOW_SOUL_BOW_ID = Mcdw.ID("bow_soul_bow"); + public static final Identifier BOW_TRICKBOW_ID = Mcdw.ID("bow_trickbow"); + public static final Identifier BOW_TWIN_BOW_ID = Mcdw.ID("bow_twin_bow"); + public static final Identifier BOW_TWISTING_VINE_BOW_ID = Mcdw.ID("bow_twisting_vine_bow"); + public static final Identifier BOW_VOID_BOW_ID = Mcdw.ID("bow_void_bow"); + public static final Identifier BOW_WEB_BOW_ID = Mcdw.ID("bow_web_bow"); + public static final Identifier BOW_WEEPING_VINE_BOW_ID = Mcdw.ID("bow_weeping_vine_bow"); + public static final Identifier BOW_WIND_BOW_ID = Mcdw.ID("bow_wind_bow"); + public static final Identifier BOW_WINTERS_TOUCH_ID = Mcdw.ID("bow_winters_touch"); + + public static final McdwBowItem BOW_ANCIENT_BOW = register(BOW_ANCIENT_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowAncientBow()); + public static final McdwBowItem BOW_BONEBOW = register(BOW_BONEBOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBonebow()); + public static final McdwBowItem BOW_BUBBLE_BOW = register(BOW_BUBBLE_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBubbleBow()); + public static final McdwBowItem BOW_BUBBLE_BURSTER = register(BOW_BUBBLE_BURSTER_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBubbleBurster()); + public static final McdwBowItem BOW_BURST_GALE_BOW = register(BOW_BURST_GALE_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowBurstGaleBow()); + public static final McdwBowItem BOW_CALL_OF_THE_VOID = register(BOW_CALL_OF_THE_VOID_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowCallOfTheVoid()); + public static final McdwBowItem BOW_ECHO_OF_THE_VALLEY = register(BOW_ECHO_OF_THE_VALLEY_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowEchoOfTheValley()); + public static final McdwBowItem BOW_ELITE_POWER_BOW = register(BOW_ELITE_POWER_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowElitePowerBow()); + public static final McdwBowItem BOW_GREEN_MENACE = register(BOW_GREEN_MENACE_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowGreenMenace()); + public static final McdwBowItem BOW_HAUNTED_BOW = register(BOW_HAUNTED_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowHauntedBow()); + public static final McdwBowItem BOW_HUNTERS_PROMISE = register(BOW_HUNTERS_PROMISE_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowHuntersPromise()); + public static final McdwBowItem BOW_HUNTING_BOW = register(BOW_HUNTING_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowHuntingBow()); + public static final McdwBowItem BOW_LOST_SOULS = register(BOW_LOST_SOULS_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowLostSouls()); + public static final McdwBowItem BOW_MASTERS_BOW = register(BOW_MASTERS_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowMastersBow()); + public static final McdwBowItem BOW_NOCTURNAL_BOW = register(BOW_NOCTURNAL_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowNocturnalBow()); + public static final McdwBowItem BOW_PHANTOM_BOW = register(BOW_PHANTOM_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowPhantomBow()); + public static final McdwBowItem BOW_PINK_SCOUNDREL = register(BOW_PINK_SCOUNDREL_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowPinkScoundrel()); + public static final McdwBowItem BOW_POWER_BOW = register(BOW_POWER_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowPowerBow()); + public static final McdwBowItem BOW_SABREWING = register(BOW_SABREWING_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowSabrewing()); + public static final McdwBowItem BOW_SHIVERING_BOW = register(BOW_SHIVERING_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowShiveringBow()); + public static final McdwBowItem BOW_SNOW_BOW = register(BOW_SNOW_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowSnowBow()); + public static final McdwBowItem BOW_SOUL_BOW = register(BOW_SOUL_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowSoulBow()); + public static final McdwBowItem BOW_TRICKBOW = register(BOW_TRICKBOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowTrickbow()); + public static final McdwBowItem BOW_TWIN_BOW = register(BOW_TWIN_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowTwinBow()); + public static final McdwBowItem BOW_TWISTING_VINE_BOW = register(BOW_TWISTING_VINE_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowTwistingVineBow()); + public static final McdwBowItem BOW_VOID_BOW = register(BOW_VOID_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowVoidBow()); + public static final McdwBowItem BOW_WEB_BOW = register(BOW_WEB_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWebBow()); + public static final McdwBowItem BOW_WEEPING_VINE_BOW = register(BOW_WEEPING_VINE_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWeepingVineBow()); + public static final McdwBowItem BOW_WIND_BOW = register(BOW_WIND_BOW_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWindBow()); + public static final McdwBowItem BOW_WINTERS_TOUCH = register(BOW_WINTERS_TOUCH_ID, McdwWeaponStatsConfig.CONFIG.getBowItemStats().getBowWintersTouch()); //@Override //public double getProjectileDamage() { @@ -67,10 +93,12 @@ public static void register() { } - private static McdwBowItem register(String name, IMcdwWeaponStats.RangedStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwBowItem register(Identifier id, IMcdwWeaponStats.RangedStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } + private static McdwBowItem makeWeapon(IMcdwWeaponStats.RangedStats stats) { return new McdwBowItem( stats, diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwCrossbowItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwCrossbowItemRegistry.java index 115e34f9..da0e5cde 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwCrossbowItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwCrossbowItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -21,37 +14,69 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwCrossbowItemRegistry { - public static final McdwCrossbowItem CROSSBOW_AUTO_CROSSBOW = register("crossbow_auto_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowAutoCrossbow()); - public static final McdwCrossbowItem CROSSBOW_AZURE_SEEKER = register("crossbow_azure_seeker", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowAzureSeeker()); - public static final McdwCrossbowItem CROSSBOW_BABY_CROSSBOW = register("crossbow_baby_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowBabyCrossbow()); - public static final McdwCrossbowItem CROSSBOW_BURST_CROSSBOW = register("crossbow_burst_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowBurstCrossbow()); - public static final McdwCrossbowItem CROSSBOW_BUTTERFLY_CROSSBOW = register("crossbow_butterfly_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowButterflyCrossbow()); - public static final McdwCrossbowItem CROSSBOW_COG_CROSSBOW = register("crossbow_cog_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowCogCrossbow()); - public static final McdwCrossbowItem CROSSBOW_CORRUPTED_CROSSBOW = register("crossbow_corrupted_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowCorruptedCrossbow()); - public static final McdwCrossbowItem CROSSBOW_DOOM_CROSSBOW = register("crossbow_doom_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowDoomCrossbow()); - public static final McdwCrossbowItem CROSSBOW_DUAL_CROSSBOW = register("crossbow_dual_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowDualCrossbow()); - public static final McdwCrossbowItem CROSSBOW_EXPLODING_CROSSBOW = register("crossbow_exploding_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowExplodingCrossbow()); - public static final McdwCrossbowItem CROSSBOW_FERAL_SOUL_CROSSBOW = register("crossbow_feral_soul_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowFeralSoulCrossbow()); - public static final McdwCrossbowItem CROSSBOW_FIREBOLT_THROWER = register("crossbow_firebolt_thrower", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowFireboltThrower()); - public static final McdwCrossbowItem CROSSBOW_HARPOON_CROSSBOW = register("crossbow_harpoon_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowHarpoonCrossbow()); - public static final McdwCrossbowItem CROSSBOW_HARP_CROSSBOW = register("crossbow_harp_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowHarpCrossbow()); - public static final McdwCrossbowItem CROSSBOW_HEAVY_CROSSBOW = register("crossbow_heavy_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowHeavyCrossbow()); - public static final McdwCrossbowItem CROSSBOW_IMPLODING_CROSSBOW = register("crossbow_imploding_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowImplodingCrossbow()); - public static final McdwCrossbowItem CROSSBOW_LIGHTNING_HARP_CROSSBOW = register("crossbow_lightning_harp_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowLightningHarpCrossbow()); - public static final McdwCrossbowItem CROSSBOW_NAUTICAL_CROSSBOW = register("crossbow_nautical_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowNauticalCrossbow()); - public static final McdwCrossbowItem CROSSBOW_PRIDE_OF_THE_PIGLINS = register("crossbow_pride_of_the_piglins", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowPrideOfThePiglins()); - public static final McdwCrossbowItem CROSSBOW_RAPID_CROSSBOW = register("crossbow_rapid_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowRapidCrossbow()); - public static final McdwCrossbowItem CROSSBOW_SCATTER_CROSSBOW = register("crossbow_scatter_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowScatterCrossbow()); - public static final McdwCrossbowItem CROSSBOW_SHADOW_CROSSBOW = register("crossbow_shadow_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowShadowCrossbow()); - public static final McdwCrossbowItem CROSSBOW_SLAYER_CROSSBOW = register("crossbow_slayer_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSlayerCrossbow()); - public static final McdwCrossbowItem CROSSBOW_SOUL_CROSSBOW = register("crossbow_soul_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSoulCrossbow()); - public static final McdwCrossbowItem CROSSBOW_SOUL_HUNTER_CROSSBOW = register("crossbow_soul_hunter_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSoulHunterCrossbow()); - public static final McdwCrossbowItem CROSSBOW_SPELLBOUND_CROSSBOW = register("crossbow_spellbound_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSpellboundCrossbow()); - public static final McdwCrossbowItem CROSSBOW_THE_SLICER = register("crossbow_the_slicer", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowTheSlicer()); - public static final McdwCrossbowItem CROSSBOW_VEILED_CROSSBOW = register("crossbow_veiled_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowVeiledCrossbow()); - public static final McdwCrossbowItem CROSSBOW_VOIDCALLER_CROSSBOW = register("crossbow_voidcaller_crossbow", McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowVoidcallerCrossbow()); + + public static final Identifier CROSSBOW_AUTO_CROSSBOW_ID = Mcdw.ID("crossbow_auto_crossbow"); + public static final Identifier CROSSBOW_AZURE_SEEKER_ID = Mcdw.ID("crossbow_azure_seeker"); + public static final Identifier CROSSBOW_BABY_CROSSBOW_ID = Mcdw.ID("crossbow_baby_crossbow"); + public static final Identifier CROSSBOW_BURST_CROSSBOW_ID = Mcdw.ID("crossbow_burst_crossbow"); + public static final Identifier CROSSBOW_BUTTERFLY_CROSSBOW_ID = Mcdw.ID("crossbow_butterfly_crossbow"); + public static final Identifier CROSSBOW_COG_CROSSBOW_ID = Mcdw.ID("crossbow_cog_crossbow"); + public static final Identifier CROSSBOW_CORRUPTED_CROSSBOW_ID = Mcdw.ID("crossbow_corrupted_crossbow"); + public static final Identifier CROSSBOW_DOOM_CROSSBOW_ID = Mcdw.ID("crossbow_doom_crossbow"); + public static final Identifier CROSSBOW_DUAL_CROSSBOW_ID = Mcdw.ID("crossbow_dual_crossbow"); + public static final Identifier CROSSBOW_EXPLODING_CROSSBOW_ID = Mcdw.ID("crossbow_exploding_crossbow"); + public static final Identifier CROSSBOW_FERAL_SOUL_CROSSBOW_ID = Mcdw.ID("crossbow_feral_soul_crossbow"); + public static final Identifier CROSSBOW_FIREBOLT_THROWER_ID = Mcdw.ID("crossbow_firebolt_thrower"); + public static final Identifier CROSSBOW_HARPOON_CROSSBOW_ID = Mcdw.ID("crossbow_harpoon_crossbow"); + public static final Identifier CROSSBOW_HARP_CROSSBOW_ID = Mcdw.ID("crossbow_harp_crossbow"); + public static final Identifier CROSSBOW_HEAVY_CROSSBOW_ID = Mcdw.ID("crossbow_heavy_crossbow"); + public static final Identifier CROSSBOW_IMPLODING_CROSSBOW_ID = Mcdw.ID("crossbow_imploding_crossbow"); + public static final Identifier CROSSBOW_LIGHTNING_HARP_CROSSBOW_ID = Mcdw.ID("crossbow_lightning_harp_crossbow"); + public static final Identifier CROSSBOW_NAUTICAL_CROSSBOW_ID = Mcdw.ID("crossbow_nautical_crossbow"); + public static final Identifier CROSSBOW_PRIDE_OF_THE_PIGLINS_ID = Mcdw.ID("crossbow_pride_of_the_piglins"); + public static final Identifier CROSSBOW_RAPID_CROSSBOW_ID = Mcdw.ID("crossbow_rapid_crossbow"); + public static final Identifier CROSSBOW_SCATTER_CROSSBOW_ID = Mcdw.ID("crossbow_scatter_crossbow"); + public static final Identifier CROSSBOW_SHADOW_CROSSBOW_ID = Mcdw.ID("crossbow_shadow_crossbow"); + public static final Identifier CROSSBOW_SLAYER_CROSSBOW_ID = Mcdw.ID("crossbow_slayer_crossbow"); + public static final Identifier CROSSBOW_SOUL_CROSSBOW_ID = Mcdw.ID("crossbow_soul_crossbow"); + public static final Identifier CROSSBOW_SOUL_HUNTER_CROSSBOW_ID = Mcdw.ID("crossbow_soul_hunter_crossbow"); + public static final Identifier CROSSBOW_SPELLBOUND_CROSSBOW_ID = Mcdw.ID("crossbow_spellbound_crossbow"); + public static final Identifier CROSSBOW_THE_SLICER_ID = Mcdw.ID("crossbow_the_slicer"); + public static final Identifier CROSSBOW_VEILED_CROSSBOW_ID = Mcdw.ID("crossbow_veiled_crossbow"); + public static final Identifier CROSSBOW_VOIDCALLER_CROSSBOW_ID = Mcdw.ID("crossbow_voidcaller_crossbow"); + + public static final McdwCrossbowItem CROSSBOW_AUTO_CROSSBOW = register(CROSSBOW_AUTO_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowAutoCrossbow()); + public static final McdwCrossbowItem CROSSBOW_AZURE_SEEKER = register(CROSSBOW_AZURE_SEEKER_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowAzureSeeker()); + public static final McdwCrossbowItem CROSSBOW_BABY_CROSSBOW = register(CROSSBOW_BABY_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowBabyCrossbow()); + public static final McdwCrossbowItem CROSSBOW_BURST_CROSSBOW = register(CROSSBOW_BURST_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowBurstCrossbow()); + public static final McdwCrossbowItem CROSSBOW_BUTTERFLY_CROSSBOW = register(CROSSBOW_BUTTERFLY_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowButterflyCrossbow()); + public static final McdwCrossbowItem CROSSBOW_COG_CROSSBOW = register(CROSSBOW_COG_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowCogCrossbow()); + public static final McdwCrossbowItem CROSSBOW_CORRUPTED_CROSSBOW = register(CROSSBOW_CORRUPTED_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowCorruptedCrossbow()); + public static final McdwCrossbowItem CROSSBOW_DOOM_CROSSBOW = register(CROSSBOW_DOOM_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowDoomCrossbow()); + public static final McdwCrossbowItem CROSSBOW_DUAL_CROSSBOW = register(CROSSBOW_DUAL_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowDualCrossbow()); + public static final McdwCrossbowItem CROSSBOW_EXPLODING_CROSSBOW = register(CROSSBOW_EXPLODING_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowExplodingCrossbow()); + public static final McdwCrossbowItem CROSSBOW_FERAL_SOUL_CROSSBOW = register(CROSSBOW_FERAL_SOUL_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowFeralSoulCrossbow()); + public static final McdwCrossbowItem CROSSBOW_FIREBOLT_THROWER = register(CROSSBOW_FIREBOLT_THROWER_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowFireboltThrower()); + public static final McdwCrossbowItem CROSSBOW_HARPOON_CROSSBOW = register(CROSSBOW_HARPOON_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowHarpoonCrossbow()); + public static final McdwCrossbowItem CROSSBOW_HARP_CROSSBOW = register(CROSSBOW_HARP_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowHarpCrossbow()); + public static final McdwCrossbowItem CROSSBOW_HEAVY_CROSSBOW = register(CROSSBOW_HEAVY_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowHeavyCrossbow()); + public static final McdwCrossbowItem CROSSBOW_IMPLODING_CROSSBOW = register(CROSSBOW_IMPLODING_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowImplodingCrossbow()); + public static final McdwCrossbowItem CROSSBOW_LIGHTNING_HARP_CROSSBOW = register(CROSSBOW_LIGHTNING_HARP_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowLightningHarpCrossbow()); + public static final McdwCrossbowItem CROSSBOW_NAUTICAL_CROSSBOW = register(CROSSBOW_NAUTICAL_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowNauticalCrossbow()); + public static final McdwCrossbowItem CROSSBOW_PRIDE_OF_THE_PIGLINS = register(CROSSBOW_PRIDE_OF_THE_PIGLINS_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowPrideOfThePiglins()); + public static final McdwCrossbowItem CROSSBOW_RAPID_CROSSBOW = register(CROSSBOW_RAPID_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowRapidCrossbow()); + public static final McdwCrossbowItem CROSSBOW_SCATTER_CROSSBOW = register(CROSSBOW_SCATTER_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowScatterCrossbow()); + public static final McdwCrossbowItem CROSSBOW_SHADOW_CROSSBOW = register(CROSSBOW_SHADOW_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowShadowCrossbow()); + public static final McdwCrossbowItem CROSSBOW_SLAYER_CROSSBOW = register(CROSSBOW_SLAYER_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSlayerCrossbow()); + public static final McdwCrossbowItem CROSSBOW_SOUL_CROSSBOW = register(CROSSBOW_SOUL_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSoulCrossbow()); + public static final McdwCrossbowItem CROSSBOW_SOUL_HUNTER_CROSSBOW = register(CROSSBOW_SOUL_HUNTER_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSoulHunterCrossbow()); + public static final McdwCrossbowItem CROSSBOW_SPELLBOUND_CROSSBOW = register(CROSSBOW_SPELLBOUND_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowSpellboundCrossbow()); + public static final McdwCrossbowItem CROSSBOW_THE_SLICER = register(CROSSBOW_THE_SLICER_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowTheSlicer()); + public static final McdwCrossbowItem CROSSBOW_VEILED_CROSSBOW = register(CROSSBOW_VEILED_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowVeiledCrossbow()); + public static final McdwCrossbowItem CROSSBOW_VOIDCALLER_CROSSBOW = register(CROSSBOW_VOIDCALLER_CROSSBOW_ID, McdwWeaponStatsConfig.CONFIG.getCrossbowItemStats().getCrossbowVoidcallerCrossbow()); //@Override @@ -67,10 +92,12 @@ public static void register() { } - private static McdwCrossbowItem register(String name, IMcdwWeaponStats.RangedStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwCrossbowItem register(Identifier id, IMcdwWeaponStats.RangedStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } + private static McdwCrossbowItem makeWeapon(IMcdwWeaponStats.RangedStats stats) { return new McdwCrossbowItem( stats, diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwDaggerItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwDaggerItemRegistry.java index 3bb81981..448a0d5d 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwDaggerItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwDaggerItemRegistry.java @@ -18,28 +18,43 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwDaggerItemRegistry { - public static final McdwDaggerItem DAGGER_BACKSTABBER = register("dagger_backstabber_", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerBackstabber()); - public static final McdwDaggerItem DAGGER_DAGGER = register("dagger_dagger", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerDagger()); - public static final McdwDaggerItem DAGGER_CHILL_GALE_KNIFE = register("dagger_chill_gale_knife", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerChillGaleKnife()); - public static final McdwDaggerItem DAGGER_FANGS_OF_FROST = register("dagger_fangs_of_frost", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerFangsOfFrost()); - public static final McdwDaggerItem DAGGER_MOON = register("dagger_moon", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerMoon()); - public static final McdwDaggerItem DAGGER_RESOLUTE_TEMPEST_KNIFE = register("dagger_resolute_tempest_knife", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerResoluteTempestKnife()); - public static final McdwDaggerItem DAGGER_SHEAR_DAGGER = register("dagger_shear_dagger", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerShearDagger()); - public static final McdwDaggerItem DAGGER_SWIFT_STRIKER = register("dagger_swift_striker", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerSwiftStriker()); - public static final McdwDaggerItem DAGGER_TEMPEST_KNIFE = register("dagger_tempest_knife", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerTempestKnife()); - public static final McdwDaggerItem DAGGER_THE_BEGINNING = register("dagger_the_beginning", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerTheBeginning()); - public static final McdwDaggerItem DAGGER_THE_END = register("dagger_the_end", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerTheEnd()); - public static final McdwDaggerItem DAGGER_VOID_TOUCHED_BLADE = register("dagger_void_touched_blade", McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerVoidTouchedBlade()); + public static final Identifier DAGGER_BACKSTABBER_ID = Mcdw.ID("dagger_backstabber_"); + public static final Identifier DAGGER_DAGGER_ID = Mcdw.ID("dagger_dagger"); + public static final Identifier DAGGER_CHILL_GALE_KNIFE_ID = Mcdw.ID("dagger_chill_gale_knife"); + public static final Identifier DAGGER_FANGS_OF_FROST_ID = Mcdw.ID("dagger_fangs_of_frost"); + public static final Identifier DAGGER_MOON_ID = Mcdw.ID("dagger_moon"); + public static final Identifier DAGGER_RESOLUTE_TEMPEST_KNIFE_ID = Mcdw.ID("dagger_resolute_tempest_knife"); + public static final Identifier DAGGER_SHEAR_DAGGER_ID = Mcdw.ID("dagger_shear_dagger"); + public static final Identifier DAGGER_SWIFT_STRIKER_ID = Mcdw.ID("dagger_swift_striker"); + public static final Identifier DAGGER_TEMPEST_KNIFE_ID = Mcdw.ID("dagger_tempest_knife"); + public static final Identifier DAGGER_THE_BEGINNING_ID = Mcdw.ID("dagger_the_beginning"); + public static final Identifier DAGGER_THE_END_ID = Mcdw.ID("dagger_the_end"); + public static final Identifier DAGGER_VOID_TOUCHED_BLADE_ID = Mcdw.ID("dagger_void_touched_blade"); + + public static final McdwDaggerItem DAGGER_BACKSTABBER = register(DAGGER_BACKSTABBER_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerBackstabber()); + public static final McdwDaggerItem DAGGER_DAGGER = register(DAGGER_DAGGER_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerDagger()); + public static final McdwDaggerItem DAGGER_CHILL_GALE_KNIFE = register(DAGGER_CHILL_GALE_KNIFE_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerChillGaleKnife()); + public static final McdwDaggerItem DAGGER_FANGS_OF_FROST = register(DAGGER_FANGS_OF_FROST_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerFangsOfFrost()); + public static final McdwDaggerItem DAGGER_MOON = register(DAGGER_MOON_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerMoon()); + public static final McdwDaggerItem DAGGER_RESOLUTE_TEMPEST_KNIFE = register(DAGGER_RESOLUTE_TEMPEST_KNIFE_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerResoluteTempestKnife()); + public static final McdwDaggerItem DAGGER_SHEAR_DAGGER = register(DAGGER_SHEAR_DAGGER_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerShearDagger()); + public static final McdwDaggerItem DAGGER_SWIFT_STRIKER = register(DAGGER_SWIFT_STRIKER_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerSwiftStriker()); + public static final McdwDaggerItem DAGGER_TEMPEST_KNIFE = register(DAGGER_TEMPEST_KNIFE_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerTempestKnife()); + public static final McdwDaggerItem DAGGER_THE_BEGINNING = register(DAGGER_THE_BEGINNING_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerTheBeginning()); + public static final McdwDaggerItem DAGGER_THE_END = register(DAGGER_THE_END_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerTheEnd()); + public static final McdwDaggerItem DAGGER_VOID_TOUCHED_BLADE = register(DAGGER_VOID_TOUCHED_BLADE_ID, McdwWeaponStatsConfig.CONFIG.getDaggerItemStats().getDaggerVoidTouchedBlade()); public static void register() { } - private static McdwDaggerItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwDaggerItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwDaggerItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -77,4 +92,4 @@ private static McdwDaggerItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwDoubleAxeItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwDoubleAxeItemRegistry.java index 2a603b01..6963af9d 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwDoubleAxeItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwDoubleAxeItemRegistry.java @@ -1,10 +1,3 @@ -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ - /* * Timefall Development License 1.2 * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. @@ -24,20 +17,28 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwDoubleAxeItemRegistry { - public static final McdwDoubleAxeItem DOUBLE_AXE_CURSED = register("double_axe_cursed", McdwWeaponStatsConfig.CONFIG.getDoubleAxeItemStats().getDoubleAxeCursed()); - public static final McdwDoubleAxeItem DOUBLE_AXE_DOUBLE = register("double_axe_double", McdwWeaponStatsConfig.CONFIG.getDoubleAxeItemStats().getDoubleAxeDouble()); - public static final McdwDoubleAxeItem DOUBLE_AXE_WHIRLWIND = register("double_axe_whirlwind", McdwWeaponStatsConfig.CONFIG.getDoubleAxeItemStats().getDoubleAxeWhirlwind()); + + public static final Identifier DOUBLE_AXE_CURSED_ID = Mcdw.ID("double_axe_cursed"); + public static final Identifier DOUBLE_AXE_DOUBLE_ID = Mcdw.ID("double_axe_double"); + public static final Identifier DOUBLE_AXE_WHIRLWIND_ID = Mcdw.ID("double_axe_whirlwind"); + + public static final McdwDoubleAxeItem DOUBLE_AXE_CURSED = register(DOUBLE_AXE_CURSED_ID, McdwWeaponStatsConfig.CONFIG.getDoubleAxeItemStats().getDoubleAxeCursed()); + public static final McdwDoubleAxeItem DOUBLE_AXE_DOUBLE = register(DOUBLE_AXE_DOUBLE_ID, McdwWeaponStatsConfig.CONFIG.getDoubleAxeItemStats().getDoubleAxeDouble()); + public static final McdwDoubleAxeItem DOUBLE_AXE_WHIRLWIND = register(DOUBLE_AXE_WHIRLWIND_ID, McdwWeaponStatsConfig.CONFIG.getDoubleAxeItemStats().getDoubleAxeWhirlwind()); public static void register() { } - private static McdwDoubleAxeItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwDoubleAxeItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } + private static McdwDoubleAxeItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { if (CompatibilityFlags.isReachExtensionEnabled) { return new McdwDoubleAxeItem( @@ -73,4 +74,4 @@ private static McdwDoubleAxeItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwGauntletItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwGauntletItemRegistry.java index 81e715c4..27c47ab3 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwGauntletItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwGauntletItemRegistry.java @@ -1,10 +1,3 @@ -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ - /* * Timefall Development License 1.2 * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. @@ -24,20 +17,28 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwGauntletItemRegistry { - public static final McdwGauntletItem GAUNTLET_GAUNTLET = register("gauntlet_gauntlet", McdwWeaponStatsConfig.CONFIG.getGauntletItemStats().getGauntletGauntlet()); - public static final McdwGauntletItem GAUNTLET_MAULER = register("gauntlet_mauler", McdwWeaponStatsConfig.CONFIG.getGauntletItemStats().getGauntletMauler()); - public static final McdwGauntletItem GAUNTLET_SOUL_FIST = register("gauntlet_soul_fist", McdwWeaponStatsConfig.CONFIG.getGauntletItemStats().getGauntletSoulFist()); + + public static final Identifier GAUNTLET_GAUNTLET_ID = Mcdw.ID("gauntlet_gauntlet"); + public static final Identifier GAUNTLET_MAULER_ID = Mcdw.ID("gauntlet_mauler"); + public static final Identifier GAUNTLET_SOUL_FIST_ID = Mcdw.ID("gauntlet_soul_fist"); + + public static final McdwGauntletItem GAUNTLET_GAUNTLET = register(GAUNTLET_GAUNTLET_ID, McdwWeaponStatsConfig.CONFIG.getGauntletItemStats().getGauntletGauntlet()); + public static final McdwGauntletItem GAUNTLET_MAULER = register(GAUNTLET_MAULER_ID, McdwWeaponStatsConfig.CONFIG.getGauntletItemStats().getGauntletMauler()); + public static final McdwGauntletItem GAUNTLET_SOUL_FIST = register(GAUNTLET_SOUL_FIST_ID, McdwWeaponStatsConfig.CONFIG.getGauntletItemStats().getGauntletSoulFist()); public static void register() { } - private static McdwGauntletItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwGauntletItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } + private static McdwGauntletItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { if (CompatibilityFlags.isReachExtensionEnabled) { return new McdwGauntletItem( @@ -73,4 +74,4 @@ private static McdwGauntletItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwGlaiveItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwGlaiveItemRegistry.java index 7b42a4f0..daa5e68d 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwGlaiveItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwGlaiveItemRegistry.java @@ -1,10 +1,3 @@ -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ - /* * Timefall Development License 1.2 * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. @@ -24,20 +17,27 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwGlaiveItemRegistry { - public static final McdwGlaiveItem GLAIVE_CACKLING_BROOM = register("glaive_cackling_broom", McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveCacklingBroom()); - public static final McdwGlaiveItem GLAIVE_GLAIVE = register("glaive_glaive", McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveGlaive()); - public static final McdwGlaiveItem GLAIVE_GRAVE_BANE = register("glaive_grave_bane", McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveGraveBane()); - public static final McdwGlaiveItem GLAIVE_VENOM_GLAIVE = register("glaive_venom_glaive", McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveVenomGlaive()); + + public static final Identifier GLAIVE_CACKLING_BROOM_ID = Mcdw.ID("glaive_cackling_broom"); + public static final Identifier GLAIVE_GLAIVE_ID = Mcdw.ID("glaive_glaive"); + public static final Identifier GLAIVE_GRAVE_BANE_ID = Mcdw.ID("glaive_grave_bane"); + public static final Identifier GLAIVE_VENOM_GLAIVE_ID = Mcdw.ID("glaive_venom_glaive"); + + public static final McdwGlaiveItem GLAIVE_CACKLING_BROOM = register(GLAIVE_CACKLING_BROOM_ID, McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveCacklingBroom()); + public static final McdwGlaiveItem GLAIVE_GLAIVE = register(GLAIVE_GLAIVE_ID, McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveGlaive()); + public static final McdwGlaiveItem GLAIVE_GRAVE_BANE = register(GLAIVE_GRAVE_BANE_ID, McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveGraveBane()); + public static final McdwGlaiveItem GLAIVE_VENOM_GLAIVE = register(GLAIVE_VENOM_GLAIVE_ID, McdwWeaponStatsConfig.CONFIG.getGlaiveItemStats().getGlaiveVenomGlaive()); public static void register() { } - - private static McdwGlaiveItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwGlaiveItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwHammerItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwHammerItemRegistry.java index 88997bf8..6e775a19 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwHammerItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwHammerItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -23,23 +16,35 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwHammerItemRegistry { - public static final McdwHammerItem HAMMER_BONECLUB = register("hammer_boneclub", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerBoneclub()); - public static final McdwHammerItem HAMMER_BONE_CUDGEL = register("hammer_bone_cudgel", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerBoneCudgel()); - public static final McdwHammerItem HAMMER_FLAIL = register("hammer_flail", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerFlail()); - public static final McdwHammerItem HAMMER_GRAVITY = register("hammer_gravity", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerGravity()) ; - public static final McdwHammerItem HAMMER_GREAT_HAMMER = register("hammer_great_hammer", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerGreatHammer()); - public static final McdwHammerItem HAMMER_MACE = register("hammer_mace", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerMace()); - public static final McdwHammerItem HAMMER_STORMLANDER = register("hammer_stormlander", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerStormlander()); - public static final McdwHammerItem HAMMER_SUNS_GRACE = register("hammer_suns_grace", McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerSunsGrace()); + + public static final Identifier HAMMER_BONECLUB_ID = Mcdw.ID("hammer_boneclub"); + public static final Identifier HAMMER_BONE_CUDGEL_ID = Mcdw.ID("hammer_bone_cudgel"); + public static final Identifier HAMMER_FLAIL_ID = Mcdw.ID("hammer_flail"); + public static final Identifier HAMMER_GRAVITY_ID = Mcdw.ID("hammer_gravity"); + public static final Identifier HAMMER_GREAT_HAMMER_ID = Mcdw.ID("hammer_great_hammer"); + public static final Identifier HAMMER_MACE_ID = Mcdw.ID("hammer_mace"); + public static final Identifier HAMMER_STORMLANDER_ID = Mcdw.ID("hammer_stormlander"); + public static final Identifier HAMMER_SUNS_GRACE_ID = Mcdw.ID("hammer_suns_grace"); + + public static final McdwHammerItem HAMMER_BONECLUB = register(HAMMER_BONECLUB_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerBoneclub()); + public static final McdwHammerItem HAMMER_BONE_CUDGEL = register(HAMMER_BONE_CUDGEL_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerBoneCudgel()); + public static final McdwHammerItem HAMMER_FLAIL = register(HAMMER_FLAIL_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerFlail()); + public static final McdwHammerItem HAMMER_GRAVITY = register(HAMMER_GRAVITY_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerGravity()) ; + public static final McdwHammerItem HAMMER_GREAT_HAMMER = register(HAMMER_GREAT_HAMMER_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerGreatHammer()); + public static final McdwHammerItem HAMMER_MACE = register(HAMMER_MACE_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerMace()); + public static final McdwHammerItem HAMMER_STORMLANDER = register(HAMMER_STORMLANDER_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerStormlander()); + public static final McdwHammerItem HAMMER_SUNS_GRACE = register(HAMMER_SUNS_GRACE_ID, McdwWeaponStatsConfig.CONFIG.getHammerItemStats().getHammerSunsGrace()); public static void register() { } - private static McdwHammerItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwHammerItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } @@ -78,4 +83,4 @@ private static McdwHammerItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwLongbowItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwLongbowItemRegistry.java index fafcde14..89d42be2 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwLongbowItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwLongbowItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -21,11 +14,17 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwLongbowItemRegistry { - public static final McdwLongbowItem LONGBOW_GUARDIAN_BOW = register("longbow_guardian_bow", McdwWeaponStatsConfig.CONFIG.getLongbowItemStats().getLongbowGuardianBow()); - public static final McdwLongbowItem LONGBOW_LONGBOW = register("longbow_longbow", McdwWeaponStatsConfig.CONFIG.getLongbowItemStats().getLongbowLongbow()); - public static final McdwLongbowItem LONGBOW_RED_SNAKE = register("longbow_red_snake", McdwWeaponStatsConfig.CONFIG.getLongbowItemStats().getLongbowRedSnake()); + + public static final Identifier LONGBOW_GUARDIAN_BOW_ID = Mcdw.ID("longbow_guardian_bow"); + public static final Identifier LONGBOW_LONGBOW_ID = Mcdw.ID("longbow_longbow"); + public static final Identifier LONGBOW_RED_SNAKE_ID = Mcdw.ID("longbow_red_snake"); + + public static final McdwLongbowItem LONGBOW_GUARDIAN_BOW = register(LONGBOW_GUARDIAN_BOW_ID, McdwWeaponStatsConfig.CONFIG.getLongbowItemStats().getLongbowGuardianBow()); + public static final McdwLongbowItem LONGBOW_LONGBOW = register(LONGBOW_LONGBOW_ID, McdwWeaponStatsConfig.CONFIG.getLongbowItemStats().getLongbowLongbow()); + public static final McdwLongbowItem LONGBOW_RED_SNAKE = register(LONGBOW_RED_SNAKE_ID, McdwWeaponStatsConfig.CONFIG.getLongbowItemStats().getLongbowRedSnake()); //@Override //public double getProjectileDamage() { @@ -40,8 +39,9 @@ public static void register() { } - private static McdwLongbowItem register(String name, IMcdwWeaponStats.RangedStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwLongbowItem register(Identifier id, IMcdwWeaponStats.RangedStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwLongbowItem makeWeapon(IMcdwWeaponStats.RangedStats stats) { diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwPickaxeItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwPickaxeItemRegistry.java index 2436a644..933b1fd6 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwPickaxeItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwPickaxeItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -24,19 +17,27 @@ import net.minecraft.item.PickaxeItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwPickaxeItemRegistry { - public static final McdwPickaxeItem PICK_DIAMOND_PICKAXE_VAR = register("pickaxe_diamond_pickaxe_var", McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeDiamondPickaxeVar()); - public static final McdwPickaxeItem PICK_HAILING_PINNACLE = register("pickaxe_hailing_pinnacle", McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeHailingPinnacle()); - public static final McdwPickaxeItem PICK_HOWLING_PICK = register("pickaxe_howling_pick", McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeHowlingPick()); - public static final McdwPickaxeItem PICK_MOUNTAINEER_PICK = register("pickaxe_mountineer_pick", McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeMountineerPick()); + + public static final Identifier PICK_DIAMOND_PICKAXE_VAR_ID = Mcdw.ID("pickaxe_diamond_pickaxe_var"); + public static final Identifier PICK_HAILING_PINNACLE_ID = Mcdw.ID("pickaxe_hailing_pinnacle"); + public static final Identifier PICK_HOWLING_PICK_ID = Mcdw.ID("pickaxe_howling_pick"); + public static final Identifier PICK_MOUNTAINEER_PICK_ID = Mcdw.ID("pickaxe_mountineer_pick"); + + public static final McdwPickaxeItem PICK_DIAMOND_PICKAXE_VAR = register(PICK_DIAMOND_PICKAXE_VAR_ID, McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeDiamondPickaxeVar()); + public static final McdwPickaxeItem PICK_HAILING_PINNACLE = register(PICK_HAILING_PINNACLE_ID, McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeHailingPinnacle()); + public static final McdwPickaxeItem PICK_HOWLING_PICK = register(PICK_HOWLING_PICK_ID, McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeHowlingPick()); + public static final McdwPickaxeItem PICK_MOUNTAINEER_PICK = register(PICK_MOUNTAINEER_PICK_ID, McdwWeaponStatsConfig.CONFIG.getPickaxeItemStats().getPickaxeMountineerPick()); public static void register() { } - private static McdwPickaxeItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwPickaxeItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwPickaxeItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwScytheItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwScytheItemRegistry.java index 1b6265b1..f1b9e0d7 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwScytheItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwScytheItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -24,19 +17,27 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwScytheItemRegistry { - public static final McdwScytheItem SCYTHE_FROST_SCYTHE = register("scythe_frost_scythe", McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheFrostScythe()); - public static final McdwScytheItem SCYTHE_JAILORS_SCYTHE = register("scythe_jailors_scythe", McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheJailorsScythe()); - public static final McdwScytheItem SCYTHE_SKULL_SCYTHE = register("scythe_skull_scythe", McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheSkullScythe()); - public static final McdwScytheItem SCYTHE_SOUL_SCYTHE = register("scythe_soul_scythe", McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheSoulScythe()); + + public static final Identifier SCYTHE_FROST_SCYTHE_ID = Mcdw.ID("scythe_frost_scythe"); + public static final Identifier SCYTHE_JAILORS_SCYTHE_ID = Mcdw.ID("scythe_jailors_scythe"); + public static final Identifier SCYTHE_SKULL_SCYTHE_ID = Mcdw.ID("scythe_skull_scythe"); + public static final Identifier SCYTHE_SOUL_SCYTHE_ID = Mcdw.ID("scythe_soul_scythe"); + + public static final McdwScytheItem SCYTHE_FROST_SCYTHE = register(SCYTHE_FROST_SCYTHE_ID, McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheFrostScythe()); + public static final McdwScytheItem SCYTHE_JAILORS_SCYTHE = register(SCYTHE_JAILORS_SCYTHE_ID, McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheJailorsScythe()); + public static final McdwScytheItem SCYTHE_SKULL_SCYTHE = register(SCYTHE_SKULL_SCYTHE_ID, McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheSkullScythe()); + public static final McdwScytheItem SCYTHE_SOUL_SCYTHE = register(SCYTHE_SOUL_SCYTHE_ID, McdwWeaponStatsConfig.CONFIG.getScytheItemStats().getScytheSoulScythe()); public static void register() { } - private static McdwScytheItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwScytheItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwScytheItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -74,4 +75,4 @@ private static McdwScytheItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwShieldItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwShieldItemRegistry.java index a43dc95e..9293b9bd 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwShieldItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwShieldItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -21,18 +14,25 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwShieldItemRegistry { - public static final McdwShieldItem SHIELD_ROYAL_GUARD_SHIELD = register("shield_royal_guard_shield", McdwWeaponStatsConfig.CONFIG.getShieldItemStats().getShieldRoyalGuardShield()); - public static final McdwShieldItem SHIELD_TOWER_GUARD_SHIELD = register("shield_tower_guard_shield", McdwWeaponStatsConfig.CONFIG.getShieldItemStats().getShieldTowerGuardShield()); - public static final McdwShieldItem SHIELD_VANGUARD_SHIELD = register("shield_vanguard_shield", McdwWeaponStatsConfig.CONFIG.getShieldItemStats().getShieldVanguardShield()); + + public static final Identifier SHIELD_ROYAL_GUARD_SHIELD_ID = Mcdw.ID("shield_royal_guard_shield"); + public static final Identifier SHIELD_TOWER_GUARD_SHIELD_ID = Mcdw.ID("shield_tower_guard_shield"); + public static final Identifier SHIELD_VANGUARD_SHIELD_ID = Mcdw.ID("shield_vanguard_shield"); + + public static final McdwShieldItem SHIELD_ROYAL_GUARD_SHIELD = register(SHIELD_ROYAL_GUARD_SHIELD_ID, McdwWeaponStatsConfig.CONFIG.getShieldItemStats().getShieldRoyalGuardShield()); + public static final McdwShieldItem SHIELD_TOWER_GUARD_SHIELD = register(SHIELD_TOWER_GUARD_SHIELD_ID, McdwWeaponStatsConfig.CONFIG.getShieldItemStats().getShieldTowerGuardShield()); + public static final McdwShieldItem SHIELD_VANGUARD_SHIELD = register(SHIELD_VANGUARD_SHIELD_ID, McdwWeaponStatsConfig.CONFIG.getShieldItemStats().getShieldVanguardShield()); public static void register() { } - private static McdwShieldItem register(String name, IMcdwWeaponStats.ShieldStats stats){ - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwShieldItem register(Identifier id, IMcdwWeaponStats.ShieldStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwShieldItem makeWeapon(IMcdwWeaponStats.ShieldStats stats) { @@ -45,4 +45,4 @@ private static McdwShieldItem makeWeapon(IMcdwWeaponStats.ShieldStats stats) { .maxCount(1) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwShortbowItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwShortbowItemRegistry.java index f828b812..48234a2c 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwShortbowItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwShortbowItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -21,12 +14,19 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwShortbowItemRegistry { - public static final McdwShortbowItem SHORTBOW_LOVE_SPELL_BOW = register("shortbow_love_spell_bow", McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowLoveSpellBow()); - public static final McdwShortbowItem SHORTBOW_MECHANICAL_SHORTBOW = register("shortbow_mechanical_shortbow", McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowMechanicalShortbow()); - public static final McdwShortbowItem SHORTBOW_PURPLE_STORM = register("shortbow_purple_storm", McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowPurpleStorm()); - public static final McdwShortbowItem SHORTBOW_SHORTBOW = register("shortbow_shortbow", McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowShortbow()); + + public static final Identifier SHORTBOW_LOVE_SPELL_BOW_ID = Mcdw.ID("shortbow_love_spell_bow"); + public static final Identifier SHORTBOW_MECHANICAL_SHORTBOW_ID = Mcdw.ID("shortbow_mechanical_shortbow"); + public static final Identifier SHORTBOW_PURPLE_STORM_ID = Mcdw.ID("shortbow_purple_storm"); + public static final Identifier SHORTBOW_SHORTBOW_ID = Mcdw.ID("shortbow_shortbow"); + + public static final McdwShortbowItem SHORTBOW_LOVE_SPELL_BOW = register(SHORTBOW_LOVE_SPELL_BOW_ID, McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowLoveSpellBow()); + public static final McdwShortbowItem SHORTBOW_MECHANICAL_SHORTBOW = register(SHORTBOW_MECHANICAL_SHORTBOW_ID, McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowMechanicalShortbow()); + public static final McdwShortbowItem SHORTBOW_PURPLE_STORM = register(SHORTBOW_PURPLE_STORM_ID, McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowPurpleStorm()); + public static final McdwShortbowItem SHORTBOW_SHORTBOW = register(SHORTBOW_SHORTBOW_ID, McdwWeaponStatsConfig.CONFIG.getShortbowItemStats().getShortbowShortbow()); //@Override //public double getProjectileDamage() { @@ -41,8 +41,9 @@ public static void register() { } - private static McdwShortbowItem register(String name, IMcdwWeaponStats.RangedStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwShortbowItem register(Identifier id, IMcdwWeaponStats.RangedStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwShortbowItem makeWeapon(IMcdwWeaponStats.RangedStats stats) { diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwSickleItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwSickleItemRegistry.java index 6f2e1d34..25444df5 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwSickleItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwSickleItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -24,19 +17,26 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwSickleItemRegistry { - public static final McdwSickleItem SICKLE_LAST_LAUGH_GOLD = register("sickle_last_laugh_gold", McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleLastLaughGold()); - public static final McdwSickleItem SICKLE_LAST_LAUGH_SILVER = register("sickle_last_laugh_silver", McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleLastLaughSilver()); - public static final McdwSickleItem SICKLE_NIGHTMARES_BITE = register("sickle_nightmares_bite", McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleNightmaresBite()); - public static final McdwSickleItem SICKLE_SICKLE = register("sickle_sickle", McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleSickle()); - public static void register() { + public static final Identifier SICKLE_LAST_LAUGH_GOLD_ID = Mcdw.ID("sickle_last_laugh_gold"); + public static final Identifier SICKLE_LAST_LAUGH_SILVER_ID = Mcdw.ID("sickle_last_laugh_silver"); + public static final Identifier SICKLE_NIGHTMARES_BITE_ID = Mcdw.ID("sickle_nightmares_bite"); + public static final Identifier SICKLE_SICKLE_ID = Mcdw.ID("sickle_sickle"); + public static final McdwSickleItem SICKLE_LAST_LAUGH_GOLD = register(SICKLE_LAST_LAUGH_GOLD_ID, McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleLastLaughGold()); + public static final McdwSickleItem SICKLE_LAST_LAUGH_SILVER = register(SICKLE_LAST_LAUGH_SILVER_ID, McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleLastLaughSilver()); + public static final McdwSickleItem SICKLE_NIGHTMARES_BITE = register(SICKLE_NIGHTMARES_BITE_ID, McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleNightmaresBite()); + public static final McdwSickleItem SICKLE_SICKLE = register(SICKLE_SICKLE_ID, McdwWeaponStatsConfig.CONFIG.getSickleItemStats().getSickleSickle()); + + public static void register() { } - private static McdwSickleItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwSickleItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwSickleItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwSoulDaggerItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwSoulDaggerItemRegistry.java index 3d2c111b..e43d5c6c 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwSoulDaggerItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwSoulDaggerItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -24,18 +17,25 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwSoulDaggerItemRegistry { - public static final McdwSoulDaggerItem SOUL_DAGGER_ETERNAL_KNIFE = register("soul_dagger_eternal_knife", McdwWeaponStatsConfig.CONFIG.getSoulDaggerItemStats().getSoul_dagger_eternal_knife()); - public static final McdwSoulDaggerItem SOUL_DAGGER_SOUL_KNIFE = register("soul_dagger_soul_knife", McdwWeaponStatsConfig.CONFIG.getSoulDaggerItemStats().getSoul_dagger_soul_knife()); - public static final McdwSoulDaggerItem SOUL_DAGGER_TRUTHSEEKER = register("soul_dagger_truthseeker", McdwWeaponStatsConfig.CONFIG.getSoulDaggerItemStats().getSoul_dagger_truthseeker()); + + public static final Identifier SOUL_DAGGER_ETERNAL_KNIFE_ID = Mcdw.ID("soul_dagger_eternal_knife"); + public static final Identifier SOUL_DAGGER_SOUL_KNIFE_ID = Mcdw.ID("soul_dagger_soul_knife"); + public static final Identifier SOUL_DAGGER_TRUTHSEEKER_ID = Mcdw.ID("soul_dagger_truthseeker"); + + public static final McdwSoulDaggerItem SOUL_DAGGER_ETERNAL_KNIFE = register(SOUL_DAGGER_ETERNAL_KNIFE_ID, McdwWeaponStatsConfig.CONFIG.getSoulDaggerItemStats().getSoul_dagger_eternal_knife()); + public static final McdwSoulDaggerItem SOUL_DAGGER_SOUL_KNIFE = register(SOUL_DAGGER_SOUL_KNIFE_ID, McdwWeaponStatsConfig.CONFIG.getSoulDaggerItemStats().getSoul_dagger_soul_knife()); + public static final McdwSoulDaggerItem SOUL_DAGGER_TRUTHSEEKER = register(SOUL_DAGGER_TRUTHSEEKER_ID, McdwWeaponStatsConfig.CONFIG.getSoulDaggerItemStats().getSoul_dagger_truthseeker()); public static void register() { } - private static McdwSoulDaggerItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwSoulDaggerItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwSoulDaggerItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwSpearItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwSpearItemRegistry.java index 006e0856..a562b6b7 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwSpearItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwSpearItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -24,18 +17,25 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwSpearItemRegistry { - public static final McdwSpearItem SPEAR_SPEAR = register("spear_spear", McdwWeaponStatsConfig.CONFIG.getSpearItemStats().getSpearSpear()); - public static final McdwSpearItem SPEAR_WHISPERING_SPEAR = register("spear_whispering_spear", McdwWeaponStatsConfig.CONFIG.getSpearItemStats().getSpearWhisperingSpear()); - public static final McdwSpearItem SPEAR_FORTUNE_SPEAR = register("spear_fortune_spear", McdwWeaponStatsConfig.CONFIG.getSpearItemStats().getSpearFortuneSpear()); + + public static final Identifier SPEAR_SPEAR_ID = Mcdw.ID("spear_spear"); + public static final Identifier SPEAR_WHISPERING_SPEAR_ID = Mcdw.ID("spear_whispering_spear"); + public static final Identifier SPEAR_FORTUNE_SPEAR_ID = Mcdw.ID("spear_fortune_spear"); + + public static final McdwSpearItem SPEAR_SPEAR = register(SPEAR_SPEAR_ID, McdwWeaponStatsConfig.CONFIG.getSpearItemStats().getSpearSpear()); + public static final McdwSpearItem SPEAR_WHISPERING_SPEAR = register(SPEAR_WHISPERING_SPEAR_ID, McdwWeaponStatsConfig.CONFIG.getSpearItemStats().getSpearWhisperingSpear()); + public static final McdwSpearItem SPEAR_FORTUNE_SPEAR = register(SPEAR_FORTUNE_SPEAR_ID, McdwWeaponStatsConfig.CONFIG.getSpearItemStats().getSpearFortuneSpear()); public static void register() { } - private static McdwSpearItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwSpearItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwSpearItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -73,4 +73,4 @@ private static McdwSpearItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwStaffItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwStaffItemRegistry.java index fbd13255..756e1dde 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwStaffItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwStaffItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -24,18 +17,25 @@ import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwStaffItemRegistry { - public static final McdwStaffItem STAFF_BATTLESTAFF = register("staff_battlestaff", McdwWeaponStatsConfig.CONFIG.getStaffItemStats().getStaffBattlestaff()); - public static final McdwStaffItem STAFF_BATTLESTAFF_OF_TERROR = register("staff_battlestaff_of_terror", McdwWeaponStatsConfig.CONFIG.getStaffItemStats().getStaffBattlestaffOfTerror()); - public static final McdwStaffItem STAFF_GROWING_STAFF = register("staff_battlestaff_growing_staff", McdwWeaponStatsConfig.CONFIG.getStaffItemStats().getStaffGrowingStaff()); + + public static final Identifier STAFF_BATTLESTAFF_ID = Mcdw.ID("staff_battlestaff"); + public static final Identifier STAFF_BATTLESTAFF_OF_TERROR_ID = Mcdw.ID("staff_battlestaff_of_terror"); + public static final Identifier STAFF_GROWING_STAFF_ID = Mcdw.ID("staff_battlestaff_growing_staff"); + + public static final McdwStaffItem STAFF_BATTLESTAFF = register(STAFF_BATTLESTAFF_ID, McdwWeaponStatsConfig.CONFIG.getStaffItemStats().getStaffBattlestaff()); + public static final McdwStaffItem STAFF_BATTLESTAFF_OF_TERROR = register(STAFF_BATTLESTAFF_OF_TERROR_ID, McdwWeaponStatsConfig.CONFIG.getStaffItemStats().getStaffBattlestaffOfTerror()); + public static final McdwStaffItem STAFF_GROWING_STAFF = register(STAFF_GROWING_STAFF_ID, McdwWeaponStatsConfig.CONFIG.getStaffItemStats().getStaffGrowingStaff()); public static void register() { } - private static McdwStaffItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwStaffItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwStaffItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -74,4 +74,4 @@ private static McdwStaffItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwSwordItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwSwordItemRegistry.java index a7b07df3..df3bc7e8 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwSwordItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwSwordItemRegistry.java @@ -4,13 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -20,42 +13,71 @@ import dev.timefall.mcdw.configs.CompatibilityFlags; import dev.timefall.mcdw.configs.stats.IMcdwWeaponStats; import dev.timefall.mcdw.configs.stats.McdwWeaponStatsConfig; -import net.minecraft.item.*; +import net.minecraft.item.Item; +import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwSwordItemRegistry { - public static final McdwSwordItem SWORD_BEE_STINGER = register("sword_bee_stinger", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordBeeStinger()); - public static final McdwSwordItem SWORD_BROADSWORD = register("sword_broadsword", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordBroadsword()); - public static final McdwSwordItem SWORD_BROKEN_SAWBLADE = register("sword_broken_sawblade", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordBrokenSawblade()); - public static final McdwSwordItem SWORD_CLAYMORE = register("sword_claymore", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordClaymore()); - public static final McdwSwordItem SWORD_CORAL_BLADE = register("sword_coral_blade", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordCoralBlade()); - public static final McdwSwordItem SWORD_CUTLASS = register("sword_cutlass", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordCutlass()); - public static final McdwSwordItem SWORD_DANCERS_SWORD = register("sword_dancers_sword", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordDancersSword()); - public static final McdwSwordItem SWORD_DARK_KATANA = register("sword_dark_katana", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordDarkKatana()); - public static final McdwSwordItem SWORD_DIAMOND_SWORD_VAR = register("sword_diamond_sword_var", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordDiamondSwordVar()); - public static final McdwSwordItem SWORD_FREEZING_FOIL = register("sword_freezing_foil", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordFreezingFoil()); - public static final McdwSwordItem SWORD_FROST_SLAYER = register("sword_frost_slayer", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordFrostSlayer()); - public static final McdwSwordItem SWORD_GREAT_AXEBLADE = register("sword_great_axeblade", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordGreatAxeblade()); - public static final McdwSwordItem SWORD_HAWKBRAND = register("sword_hawkbrand", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordHawkbrand()); - public static final McdwSwordItem SWORD_HEARTSTEALER = register("sword_heartstealer", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordHeartstealer()); - public static final McdwSwordItem SWORD_IRON_SWORD_VAR = register("sword_iron_sword_var", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordIronSwordVar()); - public static final McdwSwordItem SWORD_KATANA = register("sword_katana", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordKatana()); - public static final McdwSwordItem SWORD_MASTERS_KATANA = register("sword_masters_katana", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordMastersKatana()); - public static final McdwSwordItem SWORD_MECHANIZED_SAWBLADE = register("sword_mechanized_sawblade", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordMechanizedSawblade()); - public static final McdwSwordItem SWORD_NAMELESS_BLADE = register("sword_nameless_blade", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordNamelessBlade()); - public static final McdwSwordItem SWORD_OBSIDIAN_CLAYMORE = register("sword_obsidian_claymore", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordObsidianClaymore()); - public static final McdwSwordItem SWORD_RAPIER = register("sword_rapier", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordRapier()); - public static final McdwSwordItem SWORD_SINISTER_SWORD = register("sword_sinister_sword", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordSinisterSword()); - public static final McdwSwordItem SWORD_SPONGE_STRIKER = register("sword_sponge_striker", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordSpongeStriker()); - public static final McdwSwordItem SWORD_THE_STARLESS_NIGHT = register("sword_the_starless_night", McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordTheStarlessNight()); + + public static final Identifier SWORD_BEE_STINGER_ID = Mcdw.ID("sword_bee_stinger"); + public static final Identifier SWORD_BROADSWORD_ID = Mcdw.ID("sword_broadsword"); + public static final Identifier SWORD_BROKEN_SAWBLADE_ID = Mcdw.ID("sword_broken_sawblade"); + public static final Identifier SWORD_CLAYMORE_ID = Mcdw.ID("sword_claymore"); + public static final Identifier SWORD_CORAL_BLADE_ID = Mcdw.ID("sword_coral_blade"); + public static final Identifier SWORD_CUTLASS_ID = Mcdw.ID("sword_cutlass"); + public static final Identifier SWORD_DANCERS_SWORD_ID = Mcdw.ID("sword_dancers_sword"; + public static final Identifier SWORD_DARK_KATANA_ID = Mcdw.ID("sword_dark_katana"); + public static final Identifier SWORD_DIAMOND_SWORD_VAR_ID = Mcdw.ID("sword_diamond_sword_var"); + public static final Identifier SWORD_FREEZING_FOIL_ID = Mcdw.ID("sword_freezing_foil"); + public static final Identifier SWORD_FROST_SLAYER_ID = Mcdw.ID("sword_frost_slayer"); + public static final Identifier SWORD_GREAT_AXEBLADE_ID = Mcdw.ID("sword_great_axeblade"); + public static final Identifier SWORD_HAWKBRAND_ID = Mcdw.ID("sword_hawkbrand"); + public static final Identifier SWORD_HEARTSTEALER_ID = Mcdw.ID("sword_heartstealer"); + public static final Identifier SWORD_IRON_SWORD_VAR_ID = Mcdw.ID("sword_iron_sword_var"); + public static final Identifier SWORD_KATANA_ID = Mcdw.ID("sword_katana"); + public static final Identifier SWORD_MASTERS_KATANA_ID = Mcdw.ID("sword_masters_katana"); + public static final Identifier SWORD_MECHANIZED_SAWBLADE_ID = Mcdw.ID("sword_mechanized_sawblade"); + public static final Identifier SWORD_NAMELESS_BLADE_ID = Mcdw.ID("sword_nameless_blade"); + public static final Identifier SWORD_OBSIDIAN_CLAYMORE_ID = Mcdw.ID("sword_obsidian_claymore"); + public static final Identifier SWORD_RAPIER_ID = Mcdw.ID("sword_rapier"); + public static final Identifier SWORD_SINISTER_SWORD_ID = Mcdw.ID("sword_sinister_sword"); + public static final Identifier SWORD_SPONGE_STRIKER_ID = Mcdw.ID("sword_sponge_striker"); + public static final Identifier SWORD_THE_STARLESS_NIGHT_ID = Mcdw.ID("sword_the_starless_night"); + + public static final McdwSwordItem SWORD_BEE_STINGER = register(SWORD_BEE_STINGER_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordBeeStinger()); + public static final McdwSwordItem SWORD_BROADSWORD = register(SWORD_BROADSWORD_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordBroadsword()); + public static final McdwSwordItem SWORD_BROKEN_SAWBLADE = register(SWORD_BROKEN_SAWBLADE_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordBrokenSawblade()); + public static final McdwSwordItem SWORD_CLAYMORE = register(SWORD_CLAYMORE_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordClaymore()); + public static final McdwSwordItem SWORD_CORAL_BLADE = register(SWORD_CORAL_BLADE_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordCoralBlade()); + public static final McdwSwordItem SWORD_CUTLASS = register(SWORD_CUTLASS_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordCutlass()); + public static final McdwSwordItem SWORD_DANCERS_SWORD = register(SWORD_DANCERS_SWORD_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordDancersSword()); + public static final McdwSwordItem SWORD_DARK_KATANA = register(SWORD_DARK_KATANA_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordDarkKatana()); + public static final McdwSwordItem SWORD_DIAMOND_SWORD_VAR = register(SWORD_DIAMOND_SWORD_VAR_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordDiamondSwordVar()); + public static final McdwSwordItem SWORD_FREEZING_FOIL = register(SWORD_FREEZING_FOIL_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordFreezingFoil()); + public static final McdwSwordItem SWORD_FROST_SLAYER = register(SWORD_FROST_SLAYER_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordFrostSlayer()); + public static final McdwSwordItem SWORD_GREAT_AXEBLADE = register(SWORD_GREAT_AXEBLADE_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordGreatAxeblade()); + public static final McdwSwordItem SWORD_HAWKBRAND = register(SWORD_HAWKBRAND_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordHawkbrand()); + public static final McdwSwordItem SWORD_HEARTSTEALER = register(SWORD_HEARTSTEALER_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordHeartstealer()); + public static final McdwSwordItem SWORD_IRON_SWORD_VAR = register(SWORD_IRON_SWORD_VAR_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordIronSwordVar()); + public static final McdwSwordItem SWORD_KATANA = register(SWORD_KATANA_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordKatana()); + public static final McdwSwordItem SWORD_MASTERS_KATANA = register(SWORD_MASTERS_KATANA_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordMastersKatana()); + public static final McdwSwordItem SWORD_MECHANIZED_SAWBLADE = register(SWORD_MECHANIZED_SAWBLADE_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordMechanizedSawblade()); + public static final McdwSwordItem SWORD_NAMELESS_BLADE = register(SWORD_NAMELESS_BLADE_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordNamelessBlade()); + public static final McdwSwordItem SWORD_OBSIDIAN_CLAYMORE = register(SWORD_OBSIDIAN_CLAYMORE_ID , McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordObsidianClaymore()); + public static final McdwSwordItem SWORD_RAPIER = register(SWORD_RAPIER_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordRapier()); + public static final McdwSwordItem SWORD_SINISTER_SWORD = register(SWORD_SINISTER_SWORD_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordSinisterSword()); + public static final McdwSwordItem SWORD_SPONGE_STRIKER = register(SWORD_SPONGE_STRIKER_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordSpongeStriker()); + public static final McdwSwordItem SWORD_THE_STARLESS_NIGHT = register(SWORD_THE_STARLESS_NIGHT_ID, McdwWeaponStatsConfig.CONFIG.getSwordItemStats().getSwordTheStarlessNight()); public static void register() { } - private static McdwSwordItem register(String name, IMcdwWeaponStats.MeleeStats stats) { - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwSwordItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwSwordItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -93,4 +115,4 @@ private static McdwSwordItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ) ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/items/McdwWhipItemRegistry.java b/src/main/java/dev/timefall/mcdw/registries/items/McdwWhipItemRegistry.java index 63134772..5d3aca61 100644 --- a/src/main/java/dev/timefall/mcdw/registries/items/McdwWhipItemRegistry.java +++ b/src/main/java/dev/timefall/mcdw/registries/items/McdwWhipItemRegistry.java @@ -4,14 +4,6 @@ * * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt */ - -/* - * Timefall Development License 1.2 - * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. - * - * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt - */ - package dev.timefall.mcdw.registries.items; import dev.timefall.mcdw.Mcdw; @@ -25,17 +17,22 @@ import net.minecraft.item.SwordItem; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; public class McdwWhipItemRegistry { - public static final McdwWhipItem WHIP_WHIP = register("whip_whip", McdwWeaponStatsConfig.CONFIG.getWhipItemStats().getWhipWhip()); - public static final McdwWhipItem WHIP_VINE_WHIP = register("whip_vine_whip", McdwWeaponStatsConfig.CONFIG.getWhipItemStats().getWhipVineWhip()); - public static void register() { + public static final Identifier WHIP_WHIP_ID = Mcdw.ID("whip_whip"); + public static final Identifier WHIP_VINE_WHIP_ID = Mcdw.ID("whip_vine_whip"); + public static final McdwWhipItem WHIP_WHIP = register(WHIP_WHIP_ID, McdwWeaponStatsConfig.CONFIG.getWhipItemStats().getWhipWhip()); + public static final McdwWhipItem WHIP_VINE_WHIP = register(WHIP_VINE_WHIP_ID, McdwWeaponStatsConfig.CONFIG.getWhipItemStats().getWhipVineWhip()); + + public static void register() { } - private static McdwWhipItem register(String name, IMcdwWeaponStats.MeleeStats stats){ - return Registry.register(Registries.ITEM, Mcdw.ID(name), makeWeapon(stats)); + private static McdwWhipItem register(Identifier id, IMcdwWeaponStats.MeleeStats stats) { + McdwWeaponStatsConfig.CONFIG.registerItemEnableCheck(id,() -> stats.isEnabled); + return Registry.register(Registries.ITEM, id, makeWeapon(stats)); } private static McdwWhipItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { @@ -74,4 +71,4 @@ private static McdwWhipItem makeWeapon(IMcdwWeaponStats.MeleeStats stats) { ); } -} +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/tag/McdwEnchantmentTags.java b/src/main/java/dev/timefall/mcdw/registries/tag/McdwEnchantmentTags.java new file mode 100644 index 00000000..030e452f --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/registries/tag/McdwEnchantmentTags.java @@ -0,0 +1,23 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.registries.tag; + +import dev.timefall.mcdw.Mcdw; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.item.Item; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; +import net.minecraft.util.Identifier; + +public class McdwEnchantmentTags { + + public static final TagKey AOE_EXCLUSIVE = TagKey.of(RegistryKeys.ENCHANTMENT, Mcdw.ID("aoe_exclusive")); + public static final TagKey AOE_AND_DAMAGE_EXCLUSIVE = TagKey.of(RegistryKeys.ENCHANTMENT, Mcdw.ID("aoe_and_damage_exclusive")); + public static final TagKey DAMAGE_EXCLUSIVE = TagKey.of(RegistryKeys.ENCHANTMENT, Mcdw.ID("damage_exclusive")); + public static final TagKey EXPERIENCE_EXCLUSIVE = TagKey.of(RegistryKeys.ENCHANTMENT, Mcdw.ID("experience_exclusive")); + public static final TagKey HEALING_EXCLUSIVE = TagKey.of(RegistryKeys.ENCHANTMENT, Mcdw.ID("healing_exclusive")); +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/registries/tag/McdwItemTags.java b/src/main/java/dev/timefall/mcdw/registries/tag/McdwItemTags.java new file mode 100644 index 00000000..ba351ccb --- /dev/null +++ b/src/main/java/dev/timefall/mcdw/registries/tag/McdwItemTags.java @@ -0,0 +1,24 @@ +/* + * Timefall Development License 1.2 + * Copyright (c) 2020-2024. Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. + * + * This software's content is licensed under the Timefall Development License 1.2. You can find this license information here: https://github.com/Timefall-Development/Timefall-Development-Licence/blob/main/TimefallDevelopmentLicense1.2.txt + */ +package dev.timefall.mcdw.registries.tag; + +import dev.timefall.mcdw.Mcdw; +import net.minecraft.item.Item; +import net.minecraft.registry.RegistryKeys; +import net.minecraft.registry.tag.TagKey; + +public class McdwItemTags { + + public static final TagKey COMMON_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Mcdw.ID("common_loot_pool_items")); + public static final TagKey UNCOMMON_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Mcdw.ID("uncommon_loot_pool_items")); + public static final TagKey RARE_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Mcdw.ID("rare_loot_pool_items")); + public static final TagKey EPIC_LOOT_POOL_ITEMS = TagKey.of(RegistryKeys.ITEM, Mcdw.ID("epic_loot_pool_items")); + + //except for tridents...? + public static final TagKey ANY_WEAPON_ENCHANTABLE = TagKey.of(RegistryKeys.ITEM, Mcdw.ID("any_weapon_enchantable")); + +} \ No newline at end of file diff --git a/src/main/java/dev/timefall/mcdw/statuseffects/PainCycleStatusEffect.java b/src/main/java/dev/timefall/mcdw/statuseffects/PainCycleStatusEffect.java index 5e7a0c11..c9190f8c 100644 --- a/src/main/java/dev/timefall/mcdw/statuseffects/PainCycleStatusEffect.java +++ b/src/main/java/dev/timefall/mcdw/statuseffects/PainCycleStatusEffect.java @@ -15,21 +15,22 @@ public PainCycleStatusEffect(StatusEffectCategory category, int color) { super(category, color); } - private int painCounter = 0; - @Override public boolean canApplyUpdateEffect(int duration, int amplifier){ return true; } + @Override + public void onApplied(LivingEntity entity, int amplifier) { + entity.damage(entity.getDamageSources().magic(), 1f); + } + @Override public boolean applyUpdateEffect(LivingEntity entity, int amplifier) { super.applyUpdateEffect(entity, amplifier); - painCounter++; - if (painCounter == 300) { + if (entity.getWorld().getTime() % 300L == 0) { entity.damage(entity.getWorld().getDamageSources().magic(), 2); - painCounter = 0; } return false; } -} +} \ No newline at end of file diff --git a/src/main/resources/mcdw.mixins.json b/src/main/resources/mcdw.mixins.json index c8904ab6..ac6b9a93 100644 --- a/src/main/resources/mcdw.mixins.json +++ b/src/main/resources/mcdw.mixins.json @@ -4,6 +4,11 @@ "compatibilityLevel": "JAVA_8", "plugin": "dev.timefall.mcdw.mixin.old_mixins.McdwMixinPlugin", "mixins": [ + "EnchantmentAccessor", + "EnchantmentHelperAccessor", + "EnchantmentHelperMixin", + "LivingEntityAccessor", + "LivingEntityMixin" ], "client": [ ],