diff --git a/LICENSE b/LICENSE index aaead621..8727c248 100644 --- a/LICENSE +++ b/LICENSE @@ -1,32 +1,60 @@ -Timefall Development License 1.1 +Timefall Development License 1.2 -Copyright (c) 2020-2023 Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. +Copyright (c) 2020-2024 Chronosacaria, Kluzzio, Timefall Development. All Rights Reserved. Permissions are hereby granted, below, to any person having a copy of this software and/or its associated files: -Usage - You may use this software for private and public use. You may use this software as a library or integrate it with your code. This software may not be bundled with your code in any way, shape or form. -Copying - You may copy this software for private use or to contribute to this software. -Modification - You may modify this software for private use or to contribute to this software. -Publishing - You may not publish copies of this software. -Distributing - You may not distribute this software. -Sublicensing - You may not sublicense this software. -Selling - You may not sell this software, any part of this software, or restrict its access behind any paywall to monetised link. +Usage - You may use this software for private and public use. You may use this software as a library or + integrate it with your code. This software may not be bundled with your code in any way, shape or + form. +Copying - You may copy this software for private use or to contribute to this software. +Modification - You may modify this software for private use or to contribute to this software. +Publishing - You may not publish copies of this software. +Distributing - You may not distribute this software. +Sublicensing - You may not sublicense this software. +Selling - You may not sell this software, any part of this software, or restrict its access behind any paywall + to monetised link. + +Special Cases and Commercial Usage Clarification: +In the cases of special or commercial use, including, but not limited to the production of other Minecraft mods, any +member of Timefall Development who are noted as the copyright holders of this software may provide written consent to +grant you a non-exclusive, non-transferable, world-wide license usage of any aspect of this software. This consent can +be revoked at any time by any member of Timefall Development. Modpack Clarification: -Permission is granted for Modpacks to include this software as long as the copy of this software in the pack is done via a manifest which would download this software from its respective CurseForge or Modrinth page. In the case of explicit written permission by a copyright holder, this software may permitted to be used as an override, allowing for the direct integration with the Modpack in question. In the case of a resource pack, it may be added directly to a modpack's download. +Permission is granted for Modpacks to include this software as long as the copy of this software in the pack is done +via a manifest which would download this software from its respective CurseForge or Modrinth page. In the case of +explicit written permission by a copyright holder, this software may permitted to be used as an override, allowing for +the direct integration with the Modpack in question. In the case of a resource pack, it may be added directly to a +modpack's download. Content Creator Clarification: -Permission is granted to Content Creators to make use of and monetise content that is created using this software. Whilst not required of a Content Creator, a link back to the CurseForge or Modrinth page of this software is greatly appreciated and encouraged. +Permission is granted to Content Creators to make use of and monetise content that is created using this software. +Whilst not required of a Content Creator, a link back to the CurseForge or Modrinth page of this software is greatly +appreciated and encouraged. Porting Clarification: -Permission is not granted to any user of this software to make ports of this software to another mod loader. This means that if this software was created for the Fabric Mod Loader, it may not be ported to the Forge Mod Loader or Quilt Mod Loader without express written permission from the copyright holders. Permission is granted to any user to fork the repository of this software and create a port to a different mod loader if, and only if, the port is to be submitted to the copyright holders as a Pull Request wherever this software's source code is hosted by the copyright holders. The submitter of the Pull Request containing the porting code agrees that Timefall Development is free to negotiate the terms for the use of the submitted code. This includes, but will often not be the case that, submissions are used without compensation of any kind. +Permission is not granted to any user of this software to make ports of this software to another mod loader. This means +that if this software was created for the Fabric Mod Loader, it may not be ported to the Forge Mod Loader or Quilt Mod +Loader without express written permission from the copyright holders. Permission is granted to any user to fork the +repository of this software and create a port to a different mod loader if, and only if, the port is to be submitted to +the copyright holders as a Pull Request wherever this software's source code is hosted by the copyright holders. The +submitter of the Pull Request containing the porting code agrees that Timefall Development is free to negotiate the +terms for the use of the submitted code. This includes, but will often not be the case that, submissions are used +without compensation of any kind. Definition of 'Our Sources' in this license: -Our Sources in this license means a copy of this software or its associated files that come directly from the owners of this software, an example are the files uploaded by us on our CurseForge or Modrinth Pages. +Our Sources in this license means a copy of this software or its associated files that come directly from the owners of +this software, an example are the files uploaded by us on our CurseForge or Modrinth Pages. Definition of "Content Creator" in this license: -Content Creator, in this license, means anyone who creates content on YouTube or Twitch regardless of affiliation or partner status. +Content Creator, in this license, means anyone who creates content on YouTube or Twitch regardless of affiliation or +partner status. -The above copyright notice and these permission notices shall be included in all copies or substantial portions of the Software. +The above copyright notice and these permission notices shall be included in all copies or substantial portions of the +Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 6924f831..f4cf79d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G loader_version=0.14.21 # Mod Properties - mod_version=9.0.1 + mod_version=9.0.2 maven_group=chronosacaria archives_base_name=mcdw diff --git a/src/main/java/chronosacaria/mcdw/api/interfaces/IInnateEnchantment.java b/src/main/java/chronosacaria/mcdw/api/interfaces/IInnateEnchantment.java index f84e4678..da56b688 100644 --- a/src/main/java/chronosacaria/mcdw/api/interfaces/IInnateEnchantment.java +++ b/src/main/java/chronosacaria/mcdw/api/interfaces/IInnateEnchantment.java @@ -6,7 +6,6 @@ import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import org.jetbrains.annotations.Nullable; import java.util.Map; @@ -30,14 +29,13 @@ public interface IInnateEnchantment { * The following code is from Spectrum and can be found here:
* Preenchanted#getDefaultEnchantedStack */ - default @Nullable ItemStack getInnateEnchantedStack(Item item) { + default ItemStack getInnateEnchantedStack(Item item) { ItemStack itemStack = new ItemStack(item); if (Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) { Map map = getInnateEnchantments(); if (map != null) { - if (Mcdw.CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) - for (Enchantment enchantment : map.keySet()) - itemStack.addEnchantment(enchantment, map.get(enchantment)); + for (Enchantment enchantment : map.keySet()) + itemStack.addEnchantment(enchantment, map.get(enchantment)); } } return itemStack; diff --git a/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java b/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java index 7c8ff337..ea9c789e 100644 --- a/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java +++ b/src/main/java/chronosacaria/mcdw/api/util/CleanlinessHelper.java @@ -6,13 +6,17 @@ import chronosacaria.mcdw.bases.McdwShortbow; import chronosacaria.mcdw.configs.CompatibilityFlags; import chronosacaria.mcdw.enums.EnchantmentsID; +import chronosacaria.mcdw.enums.SettingsID; import chronosacaria.mcdw.registries.EnchantsRegistry; import net.minecraft.client.resource.language.I18n; +import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ToolMaterial; +import net.minecraft.item.ToolMaterials; import net.minecraft.registry.Registries; import net.minecraft.registry.tag.ItemTags; import net.minecraft.sound.SoundCategory; @@ -24,6 +28,8 @@ import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; +import static chronosacaria.mcdw.Mcdw.CONFIG; + public class CleanlinessHelper { static final Random random = new Random(); @@ -186,4 +192,48 @@ public static void addPPEEnchantments(ItemStack itemStack, IMcdwEnchantedArrow p ppe.mcdw$setWildRageLevel(wildRageLevel); } } + + public static Map mcdw$checkInnateEnchantmentEnabled(int level, Object... enchantments) { + LinkedHashMap enchantmentIntegerLinkedHashMap = new LinkedHashMap<>(); + for (Object enchantment : enchantments) { + if (enchantment instanceof EnchantmentsID id) { + if (CONFIG.mcdwEnchantmentsConfig.ENCHANTMENT_CONFIG.get(id).mcdw$getIsEnabled() + && CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) { + enchantmentIntegerLinkedHashMap.put(EnchantsRegistry.enchantments.get(id), level); + } + } else if (enchantment instanceof Enchantment vanillaEnchantment + && CONFIG.mcdwEnchantmentSettingsConfig.ENABLE_ENCHANTMENT_SETTINGS.get(SettingsID.ENABLE_INNATE_ENCHANTMENTS)) { + enchantmentIntegerLinkedHashMap.put(vanillaEnchantment, level); + } + } + return enchantmentIntegerLinkedHashMap; + } + + public static String materialToString(ToolMaterial toolMaterial) { + if (toolMaterial == ToolMaterials.WOOD) + return "wood"; + else if (toolMaterial == ToolMaterials.STONE) + return "stone"; + else if (toolMaterial == ToolMaterials.GOLD) + return "gold"; + else if (toolMaterial == ToolMaterials.IRON) + return "iron"; + else if (toolMaterial == ToolMaterials.DIAMOND) + return "diamond"; + else if (toolMaterial == ToolMaterials.NETHERITE) + return "netherite"; + else + return "none"; + } + + public static ToolMaterial stringToMaterial(String material) { + return switch (material) { + case "wood" -> ToolMaterials.WOOD; + case "stone" -> ToolMaterials.STONE; + case "gold" -> ToolMaterials.GOLD; + case "diamond" -> ToolMaterials.DIAMOND; + case "netherite" -> ToolMaterials.NETHERITE; + default -> ToolMaterials.IRON; + }; + } } diff --git a/src/main/java/chronosacaria/mcdw/configs/McdwEnableItemsConfig.java b/src/main/java/chronosacaria/mcdw/configs/McdwEnableItemsConfig.java index 5c16fe1a..289e469c 100644 --- a/src/main/java/chronosacaria/mcdw/configs/McdwEnableItemsConfig.java +++ b/src/main/java/chronosacaria/mcdw/configs/McdwEnableItemsConfig.java @@ -8,86 +8,9 @@ @Config(name = "mcdw_items_registry") public class McdwEnableItemsConfig implements ConfigData { - - public final LinkedHashMap SWORDS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap AXES_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap DOUBLE_AXES_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap DAGGERS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap SOUL_DAGGERS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap HAMMERS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap GAUNTLETS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap SICKLES_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap SCYTHES_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap PICKS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap GLAIVES_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap SPEARS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap STAVES_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap WHIPS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap BOWS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap SHORTBOWS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap LONGBOWS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap CROSSBOWS_ENABLED = new LinkedHashMap<>(); - public final LinkedHashMap SHIELDS_ENABLED = new LinkedHashMap<>(); public final LinkedHashMap ITEMS_ENABLED = new LinkedHashMap<>(); public McdwEnableItemsConfig() { - for (SwordsID swordsID : SwordsID.values()) - SWORDS_ENABLED.put(swordsID, true); - - for (AxesID axesID : AxesID.values()) - AXES_ENABLED.put(axesID, true); - - for (DoubleAxesID doubleAxesID : DoubleAxesID.values()) - DOUBLE_AXES_ENABLED.put(doubleAxesID, true); - - for (DaggersID daggersID : DaggersID.values()) - DAGGERS_ENABLED.put(daggersID, true); - - for (SoulDaggersID soulDaggersID : SoulDaggersID.values()) - SOUL_DAGGERS_ENABLED.put(soulDaggersID, true); - - for (HammersID hammersID : HammersID.values()) - HAMMERS_ENABLED.put(hammersID, true); - - for (GauntletsID gauntletsID : GauntletsID.values()) - GAUNTLETS_ENABLED.put(gauntletsID, true); - - for (SicklesID sicklesID : SicklesID.values()) - SICKLES_ENABLED.put(sicklesID, true); - - for (ScythesID scythesID : ScythesID.values()) - SCYTHES_ENABLED.put(scythesID, true); - - for (PicksID picksID : PicksID.values()) - PICKS_ENABLED.put(picksID, true); - - for (GlaivesID glaivesID : GlaivesID.values()) - GLAIVES_ENABLED.put(glaivesID, true); - - for (SpearsID spearsID : SpearsID.values()) - SPEARS_ENABLED.put(spearsID, true); - - for (StavesID stavesID : StavesID.values()) - STAVES_ENABLED.put(stavesID, true); - - for (WhipsID whipsID : WhipsID.values()) - WHIPS_ENABLED.put(whipsID, true); - - for (BowsID bowsID : BowsID.values()) - BOWS_ENABLED.put(bowsID, true); - - for (ShortbowsID shortBowsID : ShortbowsID.values()) - SHORTBOWS_ENABLED.put(shortBowsID, true); - - for (LongbowsID longBowsID : LongbowsID.values()) - LONGBOWS_ENABLED.put(longBowsID, true); - - for (CrossbowsID crossbowsID : CrossbowsID.values()) - CROSSBOWS_ENABLED.put(crossbowsID, true); - - for (ShieldsID shieldsID : ShieldsID.values()) - SHIELDS_ENABLED.put(shieldsID, true); - for (ItemsID itemsID : ItemsID.values()) ITEMS_ENABLED.put(itemsID, true); } diff --git a/src/main/java/chronosacaria/mcdw/configs/McdwNewLootConfig.java b/src/main/java/chronosacaria/mcdw/configs/McdwNewLootConfig.java index f8934ee9..cbc061ea 100644 --- a/src/main/java/chronosacaria/mcdw/configs/McdwNewLootConfig.java +++ b/src/main/java/chronosacaria/mcdw/configs/McdwNewLootConfig.java @@ -42,7 +42,7 @@ public class McdwNewLootConfig implements ConfigData { public final LinkedHashMap SHIELD_SPAWN_RATES = new LinkedHashMap<>(); public McdwNewLootConfig(){ - WEAPONS_ENABLED_IN_LOOTTABLES.put(SettingsID.ENABLE_WEAPONS_IN_LOOTTABLES, true); + WEAPONS_ENABLED_IN_LOOTTABLES.put(SettingsID.ENABLE_WEAPONS_IN_LOOT_TABLES, true); /* LOOT TABLES */ diff --git a/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java b/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java index bfbf1516..3c1fd3f8 100644 --- a/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java +++ b/src/main/java/chronosacaria/mcdw/configs/McdwNewStatsConfig.java @@ -4,8 +4,6 @@ import me.shedaniel.autoconfig.ConfigData; import me.shedaniel.autoconfig.annotation.Config; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.Comment; -import net.minecraft.item.ToolMaterial; -import net.minecraft.item.ToolMaterials; import java.util.Arrays; import java.util.LinkedHashMap; @@ -43,89 +41,52 @@ public class McdwNewStatsConfig implements ConfigData { public final LinkedHashMap crossbowStats = new LinkedHashMap<>(); public final LinkedHashMap shieldStats = new LinkedHashMap<>(); - // Stats Convenience Methods - protected IMeleeWeaponID.MeleeStats meleeWeaponStats(String material, int damage, float attackSpeed, String[] repairIngredient, IMeleeWeaponID iMeleeWeaponID) { - return iMeleeWeaponID.getWeaponItemStats(this).meleeStats(material, damage, attackSpeed, repairIngredient); - } - protected IMeleeWeaponID.MeleeStats advancedMeleeWeaponStats(IMeleeWeaponID iMeleeWeaponID) { - return meleeWeaponStats(materialToString(iMeleeWeaponID.getMaterial()), iMeleeWeaponID.getDamage(), iMeleeWeaponID.getAttackSpeed(), iMeleeWeaponID.getRepairIngredient(), iMeleeWeaponID); - } - - protected IRangedWeaponID.RangedStats rangedWeaponStats(String material, double projectileDamage, int drawSpeed, float range, String[] repairIngredient, IRangedWeaponID iRangedWeaponID) { - return iRangedWeaponID.getWeaponItemStats(this).rangedStats(material, projectileDamage, drawSpeed, range, repairIngredient); - } - protected IRangedWeaponID.RangedStats advancedRangedWeaponStats(IRangedWeaponID iRangedWeaponID) { - return rangedWeaponStats(materialToString(iRangedWeaponID.getMaterial()), iRangedWeaponID.getProjectileDamage(), iRangedWeaponID.getDrawSpeed(), iRangedWeaponID.getRange(), iRangedWeaponID.getRepairIngredient(), iRangedWeaponID); - } - - protected IShieldID.ShieldStats shieldStats(String material, String[] repairIngredient, IShieldID iShieldID) { - return iShieldID.getWeaponItemStats(this).shieldStats(material, repairIngredient); - } - protected IShieldID.ShieldStats advancedShieldStats(IShieldID iShieldID) { - return shieldStats(materialToString(iShieldID.getMaterial()), iShieldID.getRepairIngredient(), iShieldID); - } - public McdwNewStatsConfig() { for (SwordsID swordsID : SwordsID.values()) - swordStats.put(swordsID, new IMeleeWeaponID.MeleeStats()); + swordStats.put(swordsID, swordsID.getMeleeStats()); for (AxesID axesID : AxesID.values()) - axeStats.put(axesID, new IMeleeWeaponID.MeleeStats()); + axeStats.put(axesID, axesID.getMeleeStats()); for (DoubleAxesID doubleAxesID : DoubleAxesID.values()) - doubleAxeStats.put(doubleAxesID, new IMeleeWeaponID.MeleeStats()); + doubleAxeStats.put(doubleAxesID, doubleAxesID.getMeleeStats()); for (DaggersID daggersID : DaggersID.values()) - daggerStats.put(daggersID, new IMeleeWeaponID.MeleeStats()); + daggerStats.put(daggersID, daggersID.getMeleeStats()); for (SoulDaggersID soulDaggersID : SoulDaggersID.values()) - soulDaggerStats.put(soulDaggersID, new IMeleeWeaponID.MeleeStats()); + soulDaggerStats.put(soulDaggersID, soulDaggersID.getMeleeStats()); for (HammersID hammersID : HammersID.values()) - hammerStats.put(hammersID, new IMeleeWeaponID.MeleeStats()); + hammerStats.put(hammersID, hammersID.getMeleeStats()); for (GauntletsID gauntletsID : GauntletsID.values()) - gauntletStats.put(gauntletsID, new IMeleeWeaponID.MeleeStats()); + gauntletStats.put(gauntletsID, gauntletsID.getMeleeStats()); for (SicklesID sicklesID : SicklesID.values()) - sickleStats.put(sicklesID, new IMeleeWeaponID.MeleeStats()); + sickleStats.put(sicklesID, sicklesID.getMeleeStats()); for (ScythesID scythesID : ScythesID.values()) - scytheStats.put(scythesID, new IMeleeWeaponID.MeleeStats()); + scytheStats.put(scythesID, scythesID.getMeleeStats()); for (PicksID picksID : PicksID.values()) - pickStats.put(picksID, new IMeleeWeaponID.MeleeStats()); + pickStats.put(picksID, picksID.getMeleeStats()); for (GlaivesID glaivesID : GlaivesID.values()) - glaiveStats.put(glaivesID, new IMeleeWeaponID.MeleeStats()); + glaiveStats.put(glaivesID, glaivesID.getMeleeStats()); for (SpearsID spearsID : SpearsID.values()) - spearStats.put(spearsID, new IMeleeWeaponID.MeleeStats()); + spearStats.put(spearsID, spearsID.getMeleeStats()); for (StavesID stavesID : StavesID.values()) - staffStats.put(stavesID, new IMeleeWeaponID.MeleeStats()); + staffStats.put(stavesID, stavesID.getMeleeStats()); for (WhipsID whipsID : WhipsID.values()) - whipStats.put(whipsID, new IMeleeWeaponID.MeleeStats()); + whipStats.put(whipsID, whipsID.getMeleeStats()); for (BowsID bowsID : BowsID.values()) - bowStats.put(bowsID, new IRangedWeaponID.RangedStats()); + bowStats.put(bowsID, bowsID.getRangedStats()); for (ShortbowsID shortBowsID : ShortbowsID.values()) - shortbowStats.put(shortBowsID, new IRangedWeaponID.RangedStats()); + shortbowStats.put(shortBowsID, shortBowsID.getRangedStats()); for (LongbowsID longBowsID : LongbowsID.values()) - longbowStats.put(longBowsID, new IRangedWeaponID.RangedStats()); + longbowStats.put(longBowsID, longBowsID.getRangedStats()); for (CrossbowsID crossbowsID : CrossbowsID.values()) - crossbowStats.put(crossbowsID, new IRangedWeaponID.RangedStats()); + crossbowStats.put(crossbowsID, crossbowsID.getRangedStats()); for (ShieldsID shieldsID : ShieldsID.values()) - shieldStats.put(shieldsID, new IShieldID.ShieldStats()); + shieldStats.put(shieldsID, shieldsID.getShieldStats()); // Stats Hash Assign - Arrays.stream(IMeleeWeaponID.values()).forEach(this::advancedMeleeWeaponStats); - Arrays.stream(IRangedWeaponID.values()).forEach(this::advancedRangedWeaponStats); - Arrays.stream(ShieldsID.values()).forEach(this::advancedShieldStats); + Arrays.stream(IMeleeWeaponID.values()).forEach(IMeleeWeaponID::getMeleeStats); + Arrays.stream(IRangedWeaponID.values()).forEach(IRangedWeaponID::getRangedStats); + Arrays.stream(IShieldID.values()).forEach(IShieldID::getShieldStats); } - private static String materialToString(ToolMaterial toolMaterial) { - if (toolMaterial == ToolMaterials.WOOD) - return "wood"; - else if (toolMaterial == ToolMaterials.STONE) - return "stone"; - else if (toolMaterial == ToolMaterials.GOLD) - return "gold"; - else if (toolMaterial == ToolMaterials.IRON) - return "iron"; - else if (toolMaterial == ToolMaterials.DIAMOND) - return "diamond"; - else if (toolMaterial == ToolMaterials.NETHERITE) - return "netherite"; - else - return "none"; - } + } diff --git a/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java b/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java index 6d241de7..50b77d1c 100644 --- a/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java +++ b/src/main/java/chronosacaria/mcdw/effects/EnchantmentEffects.java @@ -92,7 +92,7 @@ public static int animaConduitExperience(PlayerEntity playerEntity, int amount, /* LivingEntityMixin */ //mcdw$damageModifiers public static float huntersPromiseDamage(PlayerEntity owner, ServerWorld serverWorld) { - if (CONFIG.mcdwEnableItemsConfig.BOWS_ENABLED.get(BowsID.BOW_HUNTERS_PROMISE)) { + if (CONFIG.mcdwNewStatsConfig.bowStats.get(BowsID.BOW_HUNTERS_PROMISE).isEnabled) { if (owner.getMainHandStack().isOf(BowsID.BOW_HUNTERS_PROMISE.getItem())) { UUID petOwnerUUID = owner.getUuid(); diff --git a/src/main/java/chronosacaria/mcdw/enums/AxesID.java b/src/main/java/chronosacaria/mcdw/enums/AxesID.java index f3b36387..aff6b079 100644 --- a/src/main/java/chronosacaria/mcdw/enums/AxesID.java +++ b/src/main/java/chronosacaria/mcdw/enums/AxesID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwAxe; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantments; @@ -13,7 +13,6 @@ import net.minecraft.item.ToolMaterial; import net.minecraft.item.ToolMaterials; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.EnumMap; import java.util.HashMap; @@ -22,28 +21,26 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum AxesID implements IMeleeWeaponID, IInnateEnchantment { - AXE_ANCHOR(ToolMaterials.IRON, 8, -3.4f, "minecraft:iron_ingot"), - AXE_AXE(ToolMaterials.IRON, 6, -3.1f, "minecraft:iron_ingot"), - AXE_ENCRUSTED_ANCHOR(ToolMaterials.DIAMOND, 8, -3.4f, "minecraft:diamond"), - AXE_FIREBRAND(ToolMaterials.DIAMOND, 4, -2.9f, "minecraft:diamond"), - AXE_HIGHLAND(ToolMaterials.IRON, 4, -2.9f, "minecraft:iron_ingot"); + AXE_ANCHOR(true, ToolMaterials.IRON, 8, -3.4f, "minecraft:iron_ingot"), + AXE_AXE(true, ToolMaterials.IRON, 6, -3.1f, "minecraft:iron_ingot"), + AXE_ENCRUSTED_ANCHOR(true, ToolMaterials.DIAMOND, 8, -3.4f, "minecraft:diamond"), + AXE_FIREBRAND(true, ToolMaterials.DIAMOND, 4, -2.9f, "minecraft:diamond"), + AXE_HIGHLAND(true, ToolMaterials.IRON, 4, -2.9f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - AxesID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + AxesID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.AXES_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.AXE_ITEMS; @@ -58,8 +55,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.axeStats.get(this).isEnabled; } @Override @@ -108,13 +105,18 @@ public String[] getRepairIngredient() { } @Override - public @Nullable Map getInnateEnchantments() { + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + + @Override + public Map getInnateEnchantments() { return switch (this) { - case AXE_ANCHOR -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1); - case AXE_AXE -> null; - case AXE_ENCRUSTED_ANCHOR -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.JUNGLE_POISON), 1); - case AXE_FIREBRAND -> Map.of(Enchantments.FIRE_ASPECT, 1); - case AXE_HIGHLAND -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.STUNNING), 1); + case AXE_ANCHOR -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GRAVITY); + case AXE_AXE -> Map.of(); + case AXE_ENCRUSTED_ANCHOR -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GRAVITY, EnchantmentsID.JUNGLE_POISON); + case AXE_FIREBRAND -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.FIRE_ASPECT); + case AXE_HIGHLAND -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.STUNNING); }; } @@ -125,7 +127,7 @@ public String[] getRepairIngredient() { @Override public McdwAxe makeWeapon() { - McdwAxe mcdwAxe = new McdwAxe(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwAxe mcdwAxe = new McdwAxe(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwAxe); diff --git a/src/main/java/chronosacaria/mcdw/enums/BowsID.java b/src/main/java/chronosacaria/mcdw/enums/BowsID.java index e6b819d9..9af0ff84 100644 --- a/src/main/java/chronosacaria/mcdw/enums/BowsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/BowsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwBow; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.enchantment.Enchantment; @@ -23,44 +23,46 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum BowsID implements IRangedWeaponID, IInnateEnchantment { - BOW_ANCIENT_BOW( ToolMaterials.NETHERITE, 7, 14, 18f, "minecraft:netherite_scrap"), - BOW_BONEBOW( ToolMaterials.STONE, 5, 16, 12f, "minecraft:bone"), - BOW_BUBBLE_BOW( ToolMaterials.IRON, 5, 15, 12f, "minecraft:iron_ingot"), - BOW_BUBBLE_BURSTER( ToolMaterials.DIAMOND, 5, 15, 13f, "minecraft:diamond"), - BOW_BURST_GALE_BOW( ToolMaterials.DIAMOND, 6, 12, 16f, "minecraft:diamond"), - BOW_CALL_OF_THE_VOID( ToolMaterials.NETHERITE, 6, 15, 16f, "minecraft:netherite_scrap"), - BOW_ECHO_OF_THE_VALLEY(ToolMaterials.DIAMOND, 6, 11, 16f, "minecraft:diamond"), - BOW_ELITE_POWER_BOW( ToolMaterials.IRON, 6, 20, 15f, "minecraft:iron_ingot"), - BOW_GREEN_MENACE( ToolMaterials.DIAMOND, 5, 17, 13f, "minecraft:diamond"), - BOW_HAUNTED_BOW( ToolMaterials.NETHERITE, 6, 18, 16f, "minecraft:netherite_scrap"), - BOW_HUNTERS_PROMISE( ToolMaterials.IRON, 6, 15, 16f, "minecraft:iron_ingot"), - BOW_HUNTING_BOW( ToolMaterials.IRON, 6, 16, 15f, "minecraft:iron_ingot"), - BOW_LOST_SOULS( ToolMaterials.NETHERITE, 6, 12, 17f, "minecraft:netherite_scrap"), - BOW_MASTERS_BOW( ToolMaterials.IRON, 6, 17, 16f, "minecraft:iron_ingot"), - BOW_NOCTURNAL_BOW( ToolMaterials.DIAMOND, 6, 17, 14f, "minecraft:diamond"), - BOW_PHANTOM_BOW( ToolMaterials.DIAMOND, 6, 20, 14f, "minecraft:diamond"), - BOW_PINK_SCOUNDREL( ToolMaterials.DIAMOND, 5, 17, 13f, "minecraft:diamond"), - BOW_POWER_BOW( ToolMaterials.IRON, 6, 20, 14f, "minecraft:iron_ingot"), - BOW_SABREWING( ToolMaterials.DIAMOND, 5, 10, 13f, "minecraft:diamond"), - BOW_SHIVERING_BOW( ToolMaterials.DIAMOND, 6, 14, 15f, "minecraft:diamond"), - BOW_SNOW_BOW( ToolMaterials.IRON, 5, 16, 13f, "minecraft:iron_ingot"), - BOW_SOUL_BOW( ToolMaterials.IRON, 6, 14, 15f, "minecraft:iron_ingot"), - BOW_TRICKBOW( ToolMaterials.DIAMOND, 5, 12, 12f, "minecraft:diamond"), - BOW_TWIN_BOW( ToolMaterials.DIAMOND, 5, 12, 12f, "minecraft:diamond"), - BOW_TWISTING_VINE_BOW( ToolMaterials.IRON, 5, 15, 13f, "minecraft:iron_ingot"), - BOW_VOID_BOW( ToolMaterials.DIAMOND, 6, 15, 16f, "minecraft:diamond"), - BOW_WEB_BOW( ToolMaterials.DIAMOND, 5, 15, 12f, "minecraft:diamond"), - BOW_WEEPING_VINE_BOW( ToolMaterials.IRON, 5, 15, 13f, "minecraft:iron_ingot"), - BOW_WIND_BOW( ToolMaterials.DIAMOND, 6, 11, 15f, "minecraft:diamond"), - BOW_WINTERS_TOUCH( ToolMaterials.DIAMOND, 6, 15, 14f, "minecraft:diamond"); - - public final ToolMaterial material; - public final double projectileDamage; - public final int drawSpeed; - public final float range; + BOW_ANCIENT_BOW( true, ToolMaterials.NETHERITE, 7, 14, 18f, "minecraft:netherite_scrap"), + BOW_BONEBOW( true, ToolMaterials.STONE, 5, 16, 12f, "minecraft:bone"), + BOW_BUBBLE_BOW( true, ToolMaterials.IRON, 5, 15, 12f, "minecraft:iron_ingot"), + BOW_BUBBLE_BURSTER( true, ToolMaterials.DIAMOND, 5, 15, 13f, "minecraft:diamond"), + BOW_BURST_GALE_BOW( true, ToolMaterials.DIAMOND, 6, 12, 16f, "minecraft:diamond"), + BOW_CALL_OF_THE_VOID( true, ToolMaterials.NETHERITE, 6, 15, 16f, "minecraft:netherite_scrap"), + BOW_ECHO_OF_THE_VALLEY(true, ToolMaterials.DIAMOND, 6, 11, 16f, "minecraft:diamond"), + BOW_ELITE_POWER_BOW( true, ToolMaterials.IRON, 6, 20, 15f, "minecraft:iron_ingot"), + BOW_GREEN_MENACE( true, ToolMaterials.DIAMOND, 5, 17, 13f, "minecraft:diamond"), + BOW_HAUNTED_BOW( true, ToolMaterials.NETHERITE, 6, 18, 16f, "minecraft:netherite_scrap"), + BOW_HUNTERS_PROMISE( true, ToolMaterials.IRON, 6, 15, 16f, "minecraft:iron_ingot"), + BOW_HUNTING_BOW( true, ToolMaterials.IRON, 6, 16, 15f, "minecraft:iron_ingot"), + BOW_LOST_SOULS( true, ToolMaterials.NETHERITE, 6, 12, 17f, "minecraft:netherite_scrap"), + BOW_MASTERS_BOW( true, ToolMaterials.IRON, 6, 17, 16f, "minecraft:iron_ingot"), + BOW_NOCTURNAL_BOW( true, ToolMaterials.DIAMOND, 6, 17, 14f, "minecraft:diamond"), + BOW_PHANTOM_BOW( true, ToolMaterials.DIAMOND, 6, 20, 14f, "minecraft:diamond"), + BOW_PINK_SCOUNDREL( true, ToolMaterials.DIAMOND, 5, 17, 13f, "minecraft:diamond"), + BOW_POWER_BOW( true, ToolMaterials.IRON, 6, 20, 14f, "minecraft:iron_ingot"), + BOW_SABREWING( true, ToolMaterials.DIAMOND, 5, 10, 13f, "minecraft:diamond"), + BOW_SHIVERING_BOW( true, ToolMaterials.DIAMOND, 6, 14, 15f, "minecraft:diamond"), + BOW_SNOW_BOW( true, ToolMaterials.IRON, 5, 16, 13f, "minecraft:iron_ingot"), + BOW_SOUL_BOW( true, ToolMaterials.IRON, 6, 14, 15f, "minecraft:iron_ingot"), + BOW_TRICKBOW( true, ToolMaterials.DIAMOND, 5, 12, 12f, "minecraft:diamond"), + BOW_TWIN_BOW( true, ToolMaterials.DIAMOND, 5, 12, 12f, "minecraft:diamond"), + BOW_TWISTING_VINE_BOW( true, ToolMaterials.IRON, 5, 15, 13f, "minecraft:iron_ingot"), + BOW_VOID_BOW( true, ToolMaterials.DIAMOND, 6, 15, 16f, "minecraft:diamond"), + BOW_WEB_BOW( true, ToolMaterials.DIAMOND, 5, 15, 12f, "minecraft:diamond"), + BOW_WEEPING_VINE_BOW( true, ToolMaterials.IRON, 5, 15, 13f, "minecraft:iron_ingot"), + BOW_WIND_BOW( true, ToolMaterials.DIAMOND, 6, 11, 15f, "minecraft:diamond"), + BOW_WINTERS_TOUCH( true, ToolMaterials.DIAMOND, 6, 15, 14f, "minecraft:diamond"); + + private final boolean isEnabled; + private final ToolMaterial material; + private final double projectileDamage; + private final int drawSpeed; + private final float range; private final String[] repairIngredient; - BowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + BowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { this.projectileDamage = projectileDamage; @@ -72,10 +74,6 @@ public enum BowsID implements IRangedWeaponID, IInnateEnchantment { this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.BOWS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.BOW_ITEMS; @@ -90,8 +88,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.bowStats.get(this).isEnabled; } @Override @@ -149,29 +147,34 @@ public String[] getRepairIngredient() { } @Override + public RangedStats getRangedStats() { + return new IRangedWeaponID.RangedStats().rangedStats(isEnabled, CleanlinessHelper.materialToString(material), projectileDamage, drawSpeed, range, repairIngredient); + } + + public Map getInnateEnchantments() { return switch (this) { - case BOW_ANCIENT_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.DYNAMO), 1); - case BOW_BONEBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GROWING), 1); - case BOW_BUBBLE_BOW, BOW_SOUL_BOW, BOW_TWISTING_VINE_BOW, BOW_WEEPING_VINE_BOW, BOW_HUNTING_BOW -> null; - case BOW_SNOW_BOW, BOW_WINTERS_TOUCH -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FREEZING), 1); - case BOW_BUBBLE_BURSTER, BOW_TRICKBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RICOCHET), 1); - case BOW_ECHO_OF_THE_VALLEY -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.RICOCHET), 1); - case BOW_BURST_GALE_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.CHARGE), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1); - case BOW_CALL_OF_THE_VOID -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FUSE_SHOT), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.VOID_SHOT), 1); - case BOW_ELITE_POWER_BOW -> Map.of(Enchantments.POWER, 2); - case BOW_GREEN_MENACE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RICOCHET), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.POISON_CLOUD), 1); - case BOW_HAUNTED_BOW, BOW_TWIN_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.BONUS_SHOT), 1); - case BOW_HUNTERS_PROMISE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.REPLENISH), 1); - case BOW_LOST_SOULS -> Map.of(Enchantments.MULTISHOT, 1); - case BOW_NOCTURNAL_BOW, BOW_SHIVERING_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.TEMPO_THEFT), 1); - case BOW_PHANTOM_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.PHANTOMS_MARK), 1, Enchantments.POWER, 1); - case BOW_PINK_SCOUNDREL -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RICOCHET), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.WILD_RAGE), 1); - case BOW_POWER_BOW, BOW_MASTERS_BOW -> Map.of(Enchantments.POWER, 1); - case BOW_SABREWING -> Map.of(Enchantments.POWER, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.RADIANCE), 1); - case BOW_VOID_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.VOID_SHOT), 1); - case BOW_WEB_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.COBWEB_SHOT), 1); - case BOW_WIND_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1); + case BOW_ANCIENT_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.DYNAMO); + case BOW_BONEBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GROWING); + case BOW_BUBBLE_BOW, BOW_SOUL_BOW, BOW_TWISTING_VINE_BOW, BOW_WEEPING_VINE_BOW, BOW_HUNTING_BOW -> Map.of(); + case BOW_SNOW_BOW, BOW_WINTERS_TOUCH -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FREEZING); + case BOW_BUBBLE_BURSTER, BOW_TRICKBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RICOCHET); + case BOW_ECHO_OF_THE_VALLEY -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GRAVITY, EnchantmentsID.RICOCHET); + case BOW_BURST_GALE_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.CHARGE, EnchantmentsID.GRAVITY); + case BOW_CALL_OF_THE_VOID -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FUSE_SHOT, EnchantmentsID.VOID_SHOT); + case BOW_ELITE_POWER_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(2, Enchantments.POWER); + case BOW_GREEN_MENACE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RICOCHET, EnchantmentsID.POISON_CLOUD); + case BOW_HAUNTED_BOW, BOW_TWIN_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.BONUS_SHOT); + case BOW_HUNTERS_PROMISE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.REPLENISH); + case BOW_LOST_SOULS -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.MULTI_SHOT); + case BOW_NOCTURNAL_BOW, BOW_SHIVERING_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.TEMPO_THEFT); + case BOW_PHANTOM_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.MULTI_SHOT, Enchantments.POWER); + case BOW_PINK_SCOUNDREL -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RICOCHET, EnchantmentsID.WILD_RAGE); + case BOW_POWER_BOW, BOW_MASTERS_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.POWER); + case BOW_SABREWING -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.POWER, EnchantmentsID.RADIANCE); + case BOW_VOID_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.VOID_SHOT); + case BOW_WEB_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.COBWEB_SHOT); + case BOW_WIND_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GRAVITY); }; } @@ -183,7 +186,7 @@ public Map getInnateEnchantments() { @SuppressWarnings("DataFlowIssue") @Override public McdwBow makeWeapon() { - McdwBow mcdwBow = new McdwBow(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwBow mcdwBow = new McdwBow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient); if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { ((IProjectileWeapon) mcdwBow).setProjectileDamage(this.getWeaponItemStats().projectileDamage); diff --git a/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java b/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java index 27ebfd8b..8992cc26 100644 --- a/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/CrossbowsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwCrossbow; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.enchantment.Enchantment; @@ -23,43 +23,45 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum CrossbowsID implements IRangedWeaponID, IInnateEnchantment { - CROSSBOW_AUTO_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_AZURE_SEEKER( ToolMaterials.IRON, 10, 28, 8.4f, "minecraft:iron_ingot"), - CROSSBOW_BABY_CROSSBOW( ToolMaterials.IRON, 8, 23, 7.2f, "minecraft:iron_ingot"), - CROSSBOW_BURST_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_BUTTERFLY_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.9f, "minecraft:iron_ingot"), - CROSSBOW_COG_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.4f, "minecraft:iron_ingot"), - CROSSBOW_CORRUPTED_CROSSBOW( ToolMaterials.NETHERITE, 16, 22, 14.0f, "minecraft:netherite_scrap"), - CROSSBOW_DOOM_CROSSBOW( ToolMaterials.NETHERITE, 9, 26, 8.0f, "minecraft:netherite_scrap"), - CROSSBOW_DUAL_CROSSBOW( ToolMaterials.IRON, 8, 24, 7.0f, "minecraft:iron_ingot"), - CROSSBOW_EXPLODING_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_FERAL_SOUL_CROSSBOW( ToolMaterials.IRON, 10, 28, 9.2f, "minecraft:iron_ingot"), - CROSSBOW_FIREBOLT_THROWER( ToolMaterials.IRON, 9, 28, 7.9f, "minecraft:iron_ingot"), - CROSSBOW_HARPOON_CROSSBOW( ToolMaterials.IRON, 12, 28, 11.0f, "minecraft:iron_ingot"), - CROSSBOW_HARP_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.6f, "minecraft:iron_ingot"), - CROSSBOW_HEAVY_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_IMPLODING_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_LIGHTNING_HARP_CROSSBOW(ToolMaterials.DIAMOND, 16, 28, 14.2f, "minecraft:diamond"), - CROSSBOW_NAUTICAL_CROSSBOW( ToolMaterials.DIAMOND, 16, 24, 14.0f, "minecraft:diamond"), - CROSSBOW_PRIDE_OF_THE_PIGLINS( ToolMaterials.NETHERITE, 15, 20, 13.0f, "minecraft:netherite_scrap"), - CROSSBOW_RAPID_CROSSBOW( ToolMaterials.IRON, 9, 20, 8.2f, "minecraft:iron_ingot"), - CROSSBOW_SCATTER_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_SHADOW_CROSSBOW( ToolMaterials.DIAMOND, 14, 25, 12.0f, "minecraft:diamond"), - CROSSBOW_SLAYER_CROSSBOW( ToolMaterials.DIAMOND, 10, 26, 8.8f, "minecraft:diamond"), - CROSSBOW_SOUL_CROSSBOW( ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), - CROSSBOW_SOUL_HUNTER_CROSSBOW( ToolMaterials.DIAMOND, 12, 28, 11.0f, "minecraft:diamond"), - CROSSBOW_SPELLBOUND_CROSSBOW( ToolMaterials.IRON, 10, 28, 8.9f, "minecraft:iron_ingot"), - CROSSBOW_THE_SLICER( ToolMaterials.IRON, 12, 28, 10.2f, "minecraft:iron_ingot"), - CROSSBOW_VEILED_CROSSBOW( ToolMaterials.DIAMOND, 16, 22, 14.5f, "minecraft:diamond"), - CROSSBOW_VOIDCALLER_CROSSBOW( ToolMaterials.DIAMOND, 14, 26, 12.5f, "minecraft:diamond"); - - public final ToolMaterial material; - public final double projectileDamage; - public final int drawSpeed; - public final float range; + CROSSBOW_AUTO_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_AZURE_SEEKER( true, ToolMaterials.IRON, 10, 28, 8.4f, "minecraft:iron_ingot"), + CROSSBOW_BABY_CROSSBOW( true, ToolMaterials.IRON, 8, 23, 7.2f, "minecraft:iron_ingot"), + CROSSBOW_BURST_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_BUTTERFLY_CROSSBOW( true, ToolMaterials.IRON, 10, 28, 8.9f, "minecraft:iron_ingot"), + CROSSBOW_COG_CROSSBOW( true, ToolMaterials.IRON, 10, 28, 8.4f, "minecraft:iron_ingot"), + CROSSBOW_CORRUPTED_CROSSBOW( true, ToolMaterials.NETHERITE, 16, 22, 14.0f, "minecraft:netherite_scrap"), + CROSSBOW_DOOM_CROSSBOW( true, ToolMaterials.NETHERITE, 9, 26, 8.0f, "minecraft:netherite_scrap"), + CROSSBOW_DUAL_CROSSBOW( true, ToolMaterials.IRON, 8, 24, 7.0f, "minecraft:iron_ingot"), + CROSSBOW_EXPLODING_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_FERAL_SOUL_CROSSBOW( true, ToolMaterials.IRON, 10, 28, 9.2f, "minecraft:iron_ingot"), + CROSSBOW_FIREBOLT_THROWER( true, ToolMaterials.IRON, 9, 28, 7.9f, "minecraft:iron_ingot"), + CROSSBOW_HARPOON_CROSSBOW( true, ToolMaterials.IRON, 12, 28, 11.0f, "minecraft:iron_ingot"), + CROSSBOW_HARP_CROSSBOW( true, ToolMaterials.IRON, 10, 28, 8.6f, "minecraft:iron_ingot"), + CROSSBOW_HEAVY_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_IMPLODING_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_LIGHTNING_HARP_CROSSBOW(true, ToolMaterials.DIAMOND, 16, 28, 14.2f, "minecraft:diamond"), + CROSSBOW_NAUTICAL_CROSSBOW( true, ToolMaterials.DIAMOND, 16, 24, 14.0f, "minecraft:diamond"), + CROSSBOW_PRIDE_OF_THE_PIGLINS( true, ToolMaterials.NETHERITE, 15, 20, 13.0f, "minecraft:netherite_scrap"), + CROSSBOW_RAPID_CROSSBOW( true, ToolMaterials.IRON, 9, 20, 8.2f, "minecraft:iron_ingot"), + CROSSBOW_SCATTER_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_SHADOW_CROSSBOW( true, ToolMaterials.DIAMOND, 14, 25, 12.0f, "minecraft:diamond"), + CROSSBOW_SLAYER_CROSSBOW( true, ToolMaterials.DIAMOND, 10, 26, 8.8f, "minecraft:diamond"), + CROSSBOW_SOUL_CROSSBOW( true, ToolMaterials.IRON, 9, 28, 8.0f, "minecraft:iron_ingot"), + CROSSBOW_SOUL_HUNTER_CROSSBOW( true, ToolMaterials.DIAMOND, 12, 28, 11.0f, "minecraft:diamond"), + CROSSBOW_SPELLBOUND_CROSSBOW( true, ToolMaterials.IRON, 10, 28, 8.9f, "minecraft:iron_ingot"), + CROSSBOW_THE_SLICER( true, ToolMaterials.IRON, 12, 28, 10.2f, "minecraft:iron_ingot"), + CROSSBOW_VEILED_CROSSBOW( true, ToolMaterials.DIAMOND, 16, 22, 14.5f, "minecraft:diamond"), + CROSSBOW_VOIDCALLER_CROSSBOW( true, ToolMaterials.DIAMOND, 14, 26, 12.5f, "minecraft:diamond"); + + private final boolean isEnabled; + private final ToolMaterial material; + private final double projectileDamage; + private final int drawSpeed; + private final float range; private final String[] repairIngredient; - CrossbowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + CrossbowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { this.projectileDamage = projectileDamage; @@ -71,10 +73,6 @@ public enum CrossbowsID implements IRangedWeaponID, IInnateEnchantment { this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.CROSSBOWS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.CROSSBOW_ITEMS; @@ -89,8 +87,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.crossbowStats.get(this).isEnabled; } @Override @@ -147,29 +145,34 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public RangedStats getRangedStats() { + return new IRangedWeaponID.RangedStats().rangedStats(isEnabled, CleanlinessHelper.materialToString(material), projectileDamage, drawSpeed, range, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case CROSSBOW_AUTO_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ACCELERATE), 1); - case CROSSBOW_AZURE_SEEKER, CROSSBOW_BURST_CROSSBOW, CROSSBOW_COG_CROSSBOW, CROSSBOW_DUAL_CROSSBOW, CROSSBOW_RAPID_CROSSBOW, CROSSBOW_SPELLBOUND_CROSSBOW -> null; - case CROSSBOW_BABY_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GROWING), 1); - case CROSSBOW_BUTTERFLY_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.BONUS_SHOT), 1); - case CROSSBOW_CORRUPTED_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.DYNAMO), 1); - case CROSSBOW_DOOM_CROSSBOW -> Map.of(Enchantments.PUNCH, 1, Enchantments.POWER, 1); - case CROSSBOW_HARP_CROSSBOW -> Map.of(Enchantments.MULTISHOT, 2); - case CROSSBOW_HEAVY_CROSSBOW, CROSSBOW_HARPOON_CROSSBOW -> Map.of(Enchantments.PUNCH, 1); - case CROSSBOW_EXPLODING_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FUSE_SHOT), 1); - case CROSSBOW_FERAL_SOUL_CROSSBOW, CROSSBOW_SOUL_CROSSBOW, CROSSBOW_SOUL_HUNTER_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ENIGMA_RESONATOR), 1); - case CROSSBOW_FIREBOLT_THROWER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FUSE_SHOT), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.CHAIN_REACTION), 1); - case CROSSBOW_SCATTER_CROSSBOW -> Map.of(Enchantments.MULTISHOT, 1); - case CROSSBOW_IMPLODING_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FUSE_SHOT), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1); - case CROSSBOW_VOIDCALLER_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1); - case CROSSBOW_LIGHTNING_HARP_CROSSBOW -> Map.of(Enchantments.MULTISHOT, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.RICOCHET), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.THUNDERING), 1); - case CROSSBOW_NAUTICAL_CROSSBOW -> Map.of(Enchantments.PIERCING, 1, Enchantments.PUNCH, 1); - case CROSSBOW_PRIDE_OF_THE_PIGLINS, CROSSBOW_THE_SLICER -> Map.of(Enchantments.PIERCING, 1); - case CROSSBOW_SHADOW_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SHADOW_SHOT), 1); - case CROSSBOW_SLAYER_CROSSBOW -> Map.of(Enchantments.POWER, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.RICOCHET), 1); - case CROSSBOW_VEILED_CROSSBOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SHADOW_SHOT), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.SHADOW_BARB), 1); + case CROSSBOW_AUTO_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ACCELERATE); + case CROSSBOW_AZURE_SEEKER, CROSSBOW_BURST_CROSSBOW, CROSSBOW_COG_CROSSBOW, CROSSBOW_DUAL_CROSSBOW, CROSSBOW_RAPID_CROSSBOW, CROSSBOW_SPELLBOUND_CROSSBOW -> Map.of(); + case CROSSBOW_BABY_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GROWING); + case CROSSBOW_BUTTERFLY_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.BONUS_SHOT); + case CROSSBOW_CORRUPTED_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.DYNAMO); + case CROSSBOW_DOOM_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.PUNCH, 1, Enchantments.POWER); + case CROSSBOW_HARP_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(2, Enchantments.MULTISHOT); + case CROSSBOW_HEAVY_CROSSBOW, CROSSBOW_HARPOON_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.PUNCH); + case CROSSBOW_EXPLODING_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FUSE_SHOT); + case CROSSBOW_FERAL_SOUL_CROSSBOW, CROSSBOW_SOUL_CROSSBOW, CROSSBOW_SOUL_HUNTER_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ENIGMA_RESONATOR); + case CROSSBOW_FIREBOLT_THROWER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FUSE_SHOT, EnchantmentsID.CHAIN_REACTION); + case CROSSBOW_SCATTER_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.MULTISHOT); + case CROSSBOW_IMPLODING_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FUSE_SHOT, EnchantmentsID.GRAVITY); + case CROSSBOW_VOIDCALLER_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GRAVITY); + case CROSSBOW_LIGHTNING_HARP_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.MULTISHOT, EnchantmentsID.RICOCHET, EnchantmentsID.THUNDERING); + case CROSSBOW_NAUTICAL_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.PIERCING, Enchantments.PUNCH); + case CROSSBOW_PRIDE_OF_THE_PIGLINS, CROSSBOW_THE_SLICER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.PIERCING); + case CROSSBOW_SHADOW_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SHADOW_SHOT); + case CROSSBOW_SLAYER_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.POWER, EnchantmentsID.RICOCHET); + case CROSSBOW_VEILED_CROSSBOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SHADOW_SHOT, EnchantmentsID.SHADOW_BARB); }; } @@ -181,7 +184,7 @@ public Map getInnateEnchantments() { @SuppressWarnings("DataFlowIssue") @Override public McdwCrossbow makeWeapon() { - McdwCrossbow mcdwCrossbow = new McdwCrossbow(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwCrossbow mcdwCrossbow = new McdwCrossbow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient); if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { ((IProjectileWeapon) mcdwCrossbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage); diff --git a/src/main/java/chronosacaria/mcdw/enums/DaggersID.java b/src/main/java/chronosacaria/mcdw/enums/DaggersID.java index a71022f3..826f0be7 100644 --- a/src/main/java/chronosacaria/mcdw/enums/DaggersID.java +++ b/src/main/java/chronosacaria/mcdw/enums/DaggersID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwDagger; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -12,7 +12,6 @@ import net.minecraft.item.ToolMaterial; import net.minecraft.item.ToolMaterials; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.util.EnumMap; import java.util.HashMap; @@ -21,36 +20,34 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum DaggersID implements IMeleeWeaponID, IInnateEnchantment { - DAGGER_BACKSTABBER(ToolMaterials.DIAMOND,1, -1.7f, "minecraft:diamond"), - DAGGER_CHILL_GALE_KNIFE(ToolMaterials.DIAMOND,2, -2.2f, "minecraft:diamond"), - DAGGER_DAGGER(ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"), - DAGGER_FANGS_OF_FROST(ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"), - DAGGER_MOON(ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"), - DAGGER_RESOLUTE_TEMPEST_KNIFE(ToolMaterials.IRON,2, -2.2f, "minecraft:iron_ingot"), - DAGGER_SHEAR_DAGGER(ToolMaterials.IRON,0, -1.5f, "minecraft:iron_ingot"), - DAGGER_SWIFT_STRIKER(ToolMaterials.NETHERITE,1, -1.7f, "minecraft:netherite_scrap"), - DAGGER_TEMPEST_KNIFE(ToolMaterials.IRON,2, -2.2f, "minecraft:iron_ingot"), - DAGGER_THE_BEGINNING(ToolMaterials.NETHERITE,1, -1.8f, "minecraft:netherite_scrap"), - DAGGER_THE_END(ToolMaterials.NETHERITE,1, -1.8f, "minecraft:netherite_scrap"), - DAGGER_VOID_TOUCHED_BLADE(ToolMaterials.DIAMOND,1, -1.8f, "minecraft:diamond"); - + DAGGER_BACKSTABBER(true, ToolMaterials.DIAMOND,1, -1.7f, "minecraft:diamond"), + DAGGER_CHILL_GALE_KNIFE(true, ToolMaterials.DIAMOND,2, -2.2f, "minecraft:diamond"), + DAGGER_DAGGER(true, ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"), + DAGGER_FANGS_OF_FROST(true, ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"), + DAGGER_MOON(true, ToolMaterials.IRON,1, -1.5f, "minecraft:iron_ingot"), + DAGGER_RESOLUTE_TEMPEST_KNIFE(true, ToolMaterials.IRON,2, -2.2f, "minecraft:iron_ingot"), + DAGGER_SHEAR_DAGGER(true, ToolMaterials.IRON,0, -1.5f, "minecraft:iron_ingot"), + DAGGER_SWIFT_STRIKER(true, ToolMaterials.NETHERITE,1, -1.7f, "minecraft:netherite_scrap"), + DAGGER_TEMPEST_KNIFE(true, ToolMaterials.IRON,2, -2.2f, "minecraft:iron_ingot"), + DAGGER_THE_BEGINNING(true, ToolMaterials.NETHERITE,1, -1.8f, "minecraft:netherite_scrap"), + DAGGER_THE_END(true, ToolMaterials.NETHERITE,1, -1.8f, "minecraft:netherite_scrap"), + DAGGER_VOID_TOUCHED_BLADE(true, ToolMaterials.DIAMOND,1, -1.8f, "minecraft:diamond"); + + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - DaggersID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + DaggersID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.DAGGERS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.DAGGER_ITEMS; @@ -65,8 +62,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.daggerStats.get(this).isEnabled; } @Override @@ -115,19 +112,24 @@ public String[] getRepairIngredient() { } @Override - public @Nullable Map getInnateEnchantments() { + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + + @Override + public Map getInnateEnchantments() { return switch (this) { - case DAGGER_BACKSTABBER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.AMBUSH), 1); - case DAGGER_CHILL_GALE_KNIFE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RUSHDOWN), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.FREEZING), 1); - case DAGGER_FANGS_OF_FROST -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FREEZING), 1); - case DAGGER_DAGGER -> null; - case DAGGER_TEMPEST_KNIFE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RUSHDOWN), 1); - case DAGGER_MOON -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ENIGMA_RESONATOR), 1); - case DAGGER_RESOLUTE_TEMPEST_KNIFE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.COMMITTED), 1 , EnchantsRegistry.enchantments.get(EnchantmentsID.RUSHDOWN), 1); - case DAGGER_SHEAR_DAGGER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SWIRLING), 1); - case DAGGER_SWIFT_STRIKER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.AMBUSH), 1, EnchantsRegistry.enchantments.get(EnchantmentsID.ECHO), 1); - case DAGGER_THE_BEGINNING -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.LEECHING), 1); - case DAGGER_THE_END, DAGGER_VOID_TOUCHED_BLADE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.VOID_STRIKE), 1); + case DAGGER_BACKSTABBER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.AMBUSH); + case DAGGER_CHILL_GALE_KNIFE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RUSHDOWN, EnchantmentsID.FREEZING); + case DAGGER_FANGS_OF_FROST -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FREEZING); + case DAGGER_DAGGER -> Map.of(); + case DAGGER_TEMPEST_KNIFE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RUSHDOWN); + case DAGGER_MOON -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ENIGMA_RESONATOR); + case DAGGER_RESOLUTE_TEMPEST_KNIFE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.COMMITTED, EnchantmentsID.RUSHDOWN); + case DAGGER_SHEAR_DAGGER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SWIRLING); + case DAGGER_SWIFT_STRIKER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.AMBUSH, EnchantmentsID.RUSHDOWN); + case DAGGER_THE_BEGINNING -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.LEECHING); + case DAGGER_THE_END, DAGGER_VOID_TOUCHED_BLADE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.VOID_STRIKE); }; } @@ -138,7 +140,7 @@ public String[] getRepairIngredient() { @Override public McdwDagger makeWeapon() { - McdwDagger mcdwDagger = new McdwDagger(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwDagger mcdwDagger = new McdwDagger(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwDagger); diff --git a/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java b/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java index e0d09cb2..ba8b6425 100644 --- a/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java +++ b/src/main/java/chronosacaria/mcdw/enums/DoubleAxesID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwDoubleAxe; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,26 +20,24 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum DoubleAxesID implements IMeleeWeaponID, IInnateEnchantment { - DOUBLE_AXE_CURSED(ToolMaterials.IRON,7, -2.9f, "minecraft:iron_ingot"), - DOUBLE_AXE_DOUBLE(ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"), - DOUBLE_AXE_WHIRLWIND(ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"); + DOUBLE_AXE_CURSED(true, ToolMaterials.IRON,7, -2.9f, "minecraft:iron_ingot"), + DOUBLE_AXE_DOUBLE(true, ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"), + DOUBLE_AXE_WHIRLWIND(true, ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - DoubleAxesID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + DoubleAxesID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.DOUBLE_AXES_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.DOUBLE_AXE_ITEMS; @@ -54,8 +52,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.doubleAxeStats.get(this).isEnabled; } @Override @@ -103,12 +101,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case DOUBLE_AXE_CURSED -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.EXPLODING), 1); - case DOUBLE_AXE_DOUBLE -> null; - case DOUBLE_AXE_WHIRLWIND -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SHOCKWAVE), 1); + case DOUBLE_AXE_CURSED -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.EXPLODING); + case DOUBLE_AXE_DOUBLE -> Map.of(); + case DOUBLE_AXE_WHIRLWIND -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SHOCKWAVE); }; } @@ -119,7 +122,7 @@ public Map getInnateEnchantments() { @Override public McdwDoubleAxe makeWeapon() { - McdwDoubleAxe mcdwDoubleAxe = new McdwDoubleAxe(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwDoubleAxe mcdwDoubleAxe = new McdwDoubleAxe(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwDoubleAxe); diff --git a/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java b/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java index 3e2ce5cf..938e86cc 100644 --- a/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/GauntletsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwGauntlet; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,27 +20,25 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum GauntletsID implements IMeleeWeaponID, IInnateEnchantment { - GAUNTLET_GAUNTLET(ToolMaterials.IRON,0, -1.5f, "minecraft:iron_ingot"), - GAUNTLET_MAULERS(ToolMaterials.DIAMOND,1, -1.5f, "minecraft:diamond"), - GAUNTLET_SOUL_FISTS(ToolMaterials.NETHERITE,0, -1.5f, "minecraft:netherite_scrap"); + GAUNTLET_GAUNTLET(true, ToolMaterials.IRON,0, -1.5f, "minecraft:iron_ingot"), + GAUNTLET_MAULERS(true, ToolMaterials.DIAMOND,1, -1.5f, "minecraft:diamond"), + GAUNTLET_SOUL_FISTS(true, ToolMaterials.NETHERITE,0, -1.5f, "minecraft:netherite_scrap"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - GauntletsID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + GauntletsID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.GAUNTLETS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.GAUNTLET_ITEMS; @@ -55,8 +53,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.gauntletStats.get(this).isEnabled; } @Override @@ -103,13 +101,17 @@ public float getAttackSpeed(){ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } @Override public Map getInnateEnchantments() { return switch (this) { - case GAUNTLET_GAUNTLET -> null; - case GAUNTLET_MAULERS -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RAMPAGING), 1); - case GAUNTLET_SOUL_FISTS -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ENIGMA_RESONATOR), 1); + case GAUNTLET_GAUNTLET -> Map.of(); + case GAUNTLET_MAULERS -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RAMPAGING); + case GAUNTLET_SOUL_FISTS -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ENIGMA_RESONATOR); }; } @@ -120,7 +122,7 @@ public Map getInnateEnchantments() { @Override public McdwGauntlet makeWeapon() { - McdwGauntlet mcdwGauntlet = new McdwGauntlet(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwGauntlet mcdwGauntlet = new McdwGauntlet(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwGauntlet); diff --git a/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java b/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java index 6dc8af84..8b57824b 100644 --- a/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java +++ b/src/main/java/chronosacaria/mcdw/enums/GlaivesID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwGlaive; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,27 +20,25 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum GlaivesID implements IMeleeWeaponID, IInnateEnchantment { - GLAIVE_CACKLING_BROOM(ToolMaterials.IRON,5, -3f, "minecraft:iron_ingot"), - GLAIVE_GLAIVE(ToolMaterials.IRON,5, -3f, "minecraft:iron_ingot"), - GLAIVE_GRAVE_BANE(ToolMaterials.IRON,6, -3f, "minecraft:iron_ingot"), - GLAIVE_VENOM_GLAIVE(ToolMaterials.IRON,6, -3f, "minecraft:iron_ingot"); + GLAIVE_CACKLING_BROOM(true, ToolMaterials.IRON,5, -3f, "minecraft:iron_ingot"), + GLAIVE_GLAIVE(true, ToolMaterials.IRON,5, -3f, "minecraft:iron_ingot"), + GLAIVE_GRAVE_BANE(true, ToolMaterials.IRON,6, -3f, "minecraft:iron_ingot"), + GLAIVE_VENOM_GLAIVE(true, ToolMaterials.IRON,6, -3f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - GlaivesID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + GlaivesID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.GLAIVES_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.GLAIVE_ITEMS; @@ -55,8 +53,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.glaiveStats.get(this).isEnabled; } @Override @@ -103,13 +101,17 @@ public float getAttackSpeed(){ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } @Override public Map getInnateEnchantments() { return switch (this) { - case GLAIVE_CACKLING_BROOM, GLAIVE_GRAVE_BANE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SMITING), 1); - case GLAIVE_GLAIVE -> null; - case GLAIVE_VENOM_GLAIVE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.POISON_CLOUD), 1); + case GLAIVE_CACKLING_BROOM, GLAIVE_GRAVE_BANE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SMITING); + case GLAIVE_GLAIVE -> Map.of(); + case GLAIVE_VENOM_GLAIVE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.POISON_CLOUD); }; } @@ -120,7 +122,7 @@ public Map getInnateEnchantments() { @Override public McdwGlaive makeWeapon() { - McdwGlaive mcdwGlaive = new McdwGlaive(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwGlaive mcdwGlaive = new McdwGlaive(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwGlaive); diff --git a/src/main/java/chronosacaria/mcdw/enums/HammersID.java b/src/main/java/chronosacaria/mcdw/enums/HammersID.java index af1e24cf..8e02505f 100644 --- a/src/main/java/chronosacaria/mcdw/enums/HammersID.java +++ b/src/main/java/chronosacaria/mcdw/enums/HammersID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwHammer; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantments; @@ -21,31 +21,29 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum HammersID implements IMeleeWeaponID, IInnateEnchantment { - HAMMER_BONECLUB(ToolMaterials.IRON,7, -3.2f, "minecraft:bone_block"), - HAMMER_BONE_CUDGEL(ToolMaterials.NETHERITE,7, -3.2f, "minecraft:netherite_scrap"), - HAMMER_FLAIL(ToolMaterials.IRON,5, -2.8f, "minecraft:iron_ingot"), - HAMMER_GRAVITY(ToolMaterials.DIAMOND,6, -3.2f, "minecraft:diamond"), - HAMMER_GREAT_HAMMER(ToolMaterials.IRON,6, -3.2f, "minecraft:iron_ingot"), - HAMMER_MACE(ToolMaterials.IRON,5, -2.8f, "minecraft:iron_ingot"), - HAMMER_STORMLANDER(ToolMaterials.DIAMOND,7, -3.2f, "minecraft:diamond"), - HAMMER_SUNS_GRACE(ToolMaterials.DIAMOND,4, -2.8f, "minecraft:diamond"); - + HAMMER_BONECLUB(true, ToolMaterials.IRON,7, -3.2f, "minecraft:bone_block"), + HAMMER_BONE_CUDGEL(true, ToolMaterials.NETHERITE,7, -3.2f, "minecraft:netherite_scrap"), + HAMMER_FLAIL(true, ToolMaterials.IRON,5, -2.8f, "minecraft:iron_ingot"), + HAMMER_GRAVITY(true, ToolMaterials.DIAMOND,6, -3.2f, "minecraft:diamond"), + HAMMER_GREAT_HAMMER(true, ToolMaterials.IRON,6, -3.2f, "minecraft:iron_ingot"), + HAMMER_MACE(true, ToolMaterials.IRON,5, -2.8f, "minecraft:iron_ingot"), + HAMMER_STORMLANDER(true, ToolMaterials.DIAMOND,7, -3.2f, "minecraft:diamond"), + HAMMER_SUNS_GRACE(true, ToolMaterials.DIAMOND,4, -2.8f, "minecraft:diamond"); + + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - HammersID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + HammersID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.HAMMERS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.HAMMER_ITEMS; @@ -60,8 +58,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.hammerStats.get(this).isEnabled; } @Override @@ -109,16 +107,21 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case HAMMER_BONECLUB -> Map.of(Enchantments.KNOCKBACK, 1); - case HAMMER_GREAT_HAMMER, HAMMER_MACE -> null; - case HAMMER_FLAIL -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.CHAINS), 1); - case HAMMER_BONE_CUDGEL -> Map.of(Enchantments.KNOCKBACK, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.ILLAGERS_BANE), 1); - case HAMMER_GRAVITY -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.GRAVITY), 1); - case HAMMER_STORMLANDER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.THUNDERING), 1); - case HAMMER_SUNS_GRACE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RADIANCE), 1); + case HAMMER_BONECLUB -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK); + case HAMMER_GREAT_HAMMER, HAMMER_MACE -> Map.of(); + case HAMMER_FLAIL -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.CHAINS); + case HAMMER_BONE_CUDGEL -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK, EnchantmentsID.ILLAGERS_BANE); + case HAMMER_GRAVITY -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.GRAVITY); + case HAMMER_STORMLANDER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.THUNDERING); + case HAMMER_SUNS_GRACE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RADIANCE); }; } @@ -129,7 +132,7 @@ public Map getInnateEnchantments() { @Override public McdwHammer makeWeapon() { - McdwHammer mcdwHammer = new McdwHammer(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwHammer mcdwHammer = new McdwHammer(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwHammer); diff --git a/src/main/java/chronosacaria/mcdw/enums/IMcdwWeaponID.java b/src/main/java/chronosacaria/mcdw/enums/IMcdwWeaponID.java index 8a7cdc09..34a5bd5d 100644 --- a/src/main/java/chronosacaria/mcdw/enums/IMcdwWeaponID.java +++ b/src/main/java/chronosacaria/mcdw/enums/IMcdwWeaponID.java @@ -2,6 +2,7 @@ import net.minecraft.item.Item; +import java.util.Arrays; import java.util.List; import java.util.stream.Stream; @@ -29,7 +30,11 @@ static IRangedWeaponID[] rangedValues() { return arrayFather.stream().flatMap(Stream::of).toArray(IRangedWeaponID[]::new); } - Boolean isEnabled(); + static IShieldID[] shieldValues() { + return Arrays.stream(ShieldsID.values()).toArray(IShieldID[]::new); + } + + boolean getIsEnabled(); Item getItem(); diff --git a/src/main/java/chronosacaria/mcdw/enums/IMeleeWeaponID.java b/src/main/java/chronosacaria/mcdw/enums/IMeleeWeaponID.java index ef3bc8bc..ee024471 100644 --- a/src/main/java/chronosacaria/mcdw/enums/IMeleeWeaponID.java +++ b/src/main/java/chronosacaria/mcdw/enums/IMeleeWeaponID.java @@ -17,18 +17,22 @@ static IMeleeWeaponID[] values() { MeleeStats getWeaponItemStats(McdwNewStatsConfig mcdwNewStatsConfig); + boolean getIsEnabled(); ToolMaterial getMaterial(); int getDamage(); float getAttackSpeed(); String[] getRepairIngredient(); + MeleeStats getMeleeStats(); class MeleeStats { + boolean isEnabled; String material; int damage; float attackSpeed; String[] repairIngredient; - public MeleeStats meleeStats(String material, int damage, float attackSpeed, String[] repairIngredient) { + public MeleeStats meleeStats(boolean isEnabled, String material, int damage, float attackSpeed, String[] repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; diff --git a/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java b/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java index 881e4aba..6aae7616 100644 --- a/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java +++ b/src/main/java/chronosacaria/mcdw/enums/IRangedWeaponID.java @@ -18,20 +18,26 @@ static IRangedWeaponID[] values() { IRangedWeaponID.RangedStats getWeaponItemStats(McdwNewStatsConfig mcdwNewStatsConfig); + boolean getIsEnabled(); ToolMaterial getMaterial(); + @SuppressWarnings("unused") double getProjectileDamage(); int getDrawSpeed(); float getRange(); String[] getRepairIngredient(); + RangedStats getRangedStats(); + class RangedStats { + public boolean isEnabled; public String material; public double projectileDamage; public int drawSpeed; public float range; String[] repairIngredient; - public RangedStats rangedStats(String material, double projectileDamage, int drawSpeed, float range, String[] repairIngredient) { + public RangedStats rangedStats(boolean isEnabled, String material, double projectileDamage, int drawSpeed, float range, String[] repairIngredient) { + this.isEnabled = isEnabled; this.material = material; if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { this.projectileDamage = projectileDamage; diff --git a/src/main/java/chronosacaria/mcdw/enums/IShieldID.java b/src/main/java/chronosacaria/mcdw/enums/IShieldID.java index cfeb9f97..c14437df 100644 --- a/src/main/java/chronosacaria/mcdw/enums/IShieldID.java +++ b/src/main/java/chronosacaria/mcdw/enums/IShieldID.java @@ -7,21 +7,32 @@ public interface IShieldID extends IMcdwWeaponID { + static IShieldID[] values() { + return IMcdwWeaponID.shieldValues(); + } + + HashMap getWeaponStats(McdwNewStatsConfig mcdwNewStatsConfig); ShieldStats getWeaponItemStats(); ShieldStats getWeaponItemStats(McdwNewStatsConfig mcdwNewStatsConfig); + boolean getIsEnabled(); + ToolMaterial getMaterial(); String[] getRepairIngredient(); + ShieldStats getShieldStats(); + class ShieldStats { + boolean isEnabled; String material; String[] repairIngredient; - public ShieldStats shieldStats(String material, String[] repairIngredient) { + public ShieldStats shieldStats(boolean isEnabled, String material, String[] repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.repairIngredient = repairIngredient; return this; diff --git a/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java b/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java index db9fb02f..66d4f819 100644 --- a/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/LongbowsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwLongbow; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.enchantment.Enchantment; @@ -23,17 +23,19 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum LongbowsID implements IRangedWeaponID, IInnateEnchantment { - BOW_GUARDIAN_BOW(ToolMaterials.DIAMOND, 8, 30, 19f, "minecraft:diamond"), - BOW_LONGBOW( ToolMaterials.IRON, 7, 25, 17f, "minecraft:planks"), - BOW_RED_SNAKE( ToolMaterials.DIAMOND, 7, 30, 18f, "minecraft:diamond"); + BOW_GUARDIAN_BOW(true, ToolMaterials.DIAMOND, 8, 30, 19f, "minecraft:diamond"), + BOW_LONGBOW( true, ToolMaterials.IRON, 7, 25, 17f, "minecraft:planks"), + BOW_RED_SNAKE( true, ToolMaterials.DIAMOND, 7, 30, 18f, "minecraft:diamond"); + public final boolean isEnabled; public final ToolMaterial material; public final double projectileDamage; public final int drawSpeed; public final float range; private final String[] repairIngredient; - LongbowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + LongbowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { this.projectileDamage = projectileDamage; @@ -45,10 +47,6 @@ public enum LongbowsID implements IRangedWeaponID, IInnateEnchantment { this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.LONGBOWS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.LONGBOW_ITEMS; @@ -63,8 +61,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.longbowStats.get(this).isEnabled; } @Override @@ -121,12 +119,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public RangedStats getRangedStats() { + return new IRangedWeaponID.RangedStats().rangedStats(isEnabled, CleanlinessHelper.materialToString(material), projectileDamage, drawSpeed, range, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case BOW_LONGBOW -> null; - case BOW_GUARDIAN_BOW -> Map.of(Enchantments.POWER, 2); - case BOW_RED_SNAKE -> Map.of(Enchantments.POWER, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.FUSE_SHOT), 1); + case BOW_LONGBOW -> Map.of(); + case BOW_GUARDIAN_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(2, Enchantments.POWER); + case BOW_RED_SNAKE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.POWER, EnchantmentsID.FUSE_SHOT); }; } @@ -138,7 +141,7 @@ public Map getInnateEnchantments() { @SuppressWarnings("DataFlowIssue") @Override public McdwLongbow makeWeapon() { - McdwLongbow mcdwLongbow = new McdwLongbow(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwLongbow mcdwLongbow = new McdwLongbow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient); if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { ((IProjectileWeapon) mcdwLongbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage); diff --git a/src/main/java/chronosacaria/mcdw/enums/PicksID.java b/src/main/java/chronosacaria/mcdw/enums/PicksID.java index 4bf83917..56d39438 100644 --- a/src/main/java/chronosacaria/mcdw/enums/PicksID.java +++ b/src/main/java/chronosacaria/mcdw/enums/PicksID.java @@ -1,6 +1,7 @@ package chronosacaria.mcdw.enums; import chronosacaria.mcdw.Mcdw; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwPick; import chronosacaria.mcdw.configs.McdwNewStatsConfig; import chronosacaria.mcdw.registries.ItemsRegistry; @@ -13,28 +14,26 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum PicksID implements IMeleeWeaponID { - PICK_DIAMOND_PICKAXE_VAR(ToolMaterials.DIAMOND,1, -2.8f, "minecraft:diamond"), - PICK_HAILING_PINNACLE(ToolMaterials.DIAMOND,1, -2.8f, "minecraft:diamond"), - PICK_HOWLING_PICK(ToolMaterials.IRON,1, -2.8f, "minecraft:iron_ingot"), - PICK_MOUNTAINEER_PICK(ToolMaterials.IRON,1, -2.8f, "minecraft:iron_ingot"); + PICK_DIAMOND_PICKAXE_VAR(true, ToolMaterials.DIAMOND,1, -2.8f, "minecraft:diamond"), + PICK_HAILING_PINNACLE(true, ToolMaterials.DIAMOND,1, -2.8f, "minecraft:diamond"), + PICK_HOWLING_PICK(true, ToolMaterials.IRON,1, -2.8f, "minecraft:iron_ingot"), + PICK_MOUNTAINEER_PICK(true, ToolMaterials.IRON,1, -2.8f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - PicksID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + PicksID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.PICKS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.PICK_ITEMS; @@ -49,8 +48,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.pickStats.get(this).isEnabled; } @Override @@ -98,9 +97,14 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public McdwPick makeWeapon() { - McdwPick mcdwPick = new McdwPick(ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwPick mcdwPick = new McdwPick(CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwPick); diff --git a/src/main/java/chronosacaria/mcdw/enums/ScythesID.java b/src/main/java/chronosacaria/mcdw/enums/ScythesID.java index 24d17000..76ebf113 100644 --- a/src/main/java/chronosacaria/mcdw/enums/ScythesID.java +++ b/src/main/java/chronosacaria/mcdw/enums/ScythesID.java @@ -2,6 +2,7 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwScythe; import chronosacaria.mcdw.configs.McdwNewStatsConfig; import chronosacaria.mcdw.registries.EnchantsRegistry; @@ -20,28 +21,26 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum ScythesID implements IMeleeWeaponID, IInnateEnchantment { - SCYTHE_FROST_SCYTHE(ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"), - SCYTHE_JAILORS_SCYTHE(ToolMaterials.IRON,4, -2.9f, "minecraft:iron_ingot"), - SCYTHE_SKULL_SCYTHE(ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"), - SCYTHE_SOUL_SCYTHE(ToolMaterials.DIAMOND,3, -2.9f, "minecraft:diamond"); + SCYTHE_FROST_SCYTHE(true, ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"), + SCYTHE_JAILORS_SCYTHE(true, ToolMaterials.IRON,4, -2.9f, "minecraft:iron_ingot"), + SCYTHE_SKULL_SCYTHE(true, ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"), + SCYTHE_SOUL_SCYTHE(true, ToolMaterials.DIAMOND,3, -2.9f, "minecraft:diamond"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - ScythesID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + ScythesID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SCYTHES_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SCYTHE_ITEMS; @@ -56,8 +55,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.scytheStats.get(this).isEnabled; } @Override @@ -105,6 +104,11 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { @@ -121,7 +125,7 @@ public Map getInnateEnchantments() { @Override public McdwScythe makeWeapon() { - McdwScythe mcdwScythe = new McdwScythe(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwScythe mcdwScythe = new McdwScythe(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwScythe); diff --git a/src/main/java/chronosacaria/mcdw/enums/SettingsID.java b/src/main/java/chronosacaria/mcdw/enums/SettingsID.java index e1815ca4..c3a13ce1 100644 --- a/src/main/java/chronosacaria/mcdw/enums/SettingsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/SettingsID.java @@ -7,7 +7,7 @@ public enum SettingsID { SHARED_PAIN_CAN_DAMAGE_USER, AREA_OF_EFFECT_ENCHANTS_DONT_AFFECT_PLAYERS, ENABLE_INNATE_ENCHANTMENTS, - ENABLE_WEAPONS_IN_LOOTTABLES, + ENABLE_WEAPONS_IN_LOOT_TABLES, COMMON_LOOT_TABLES, UNCOMMON_LOOT_TABLES, RARE_LOOT_TABLES, diff --git a/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java b/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java index 4aa9aec1..1660360c 100644 --- a/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/ShieldsID.java @@ -1,6 +1,7 @@ package chronosacaria.mcdw.enums; import chronosacaria.mcdw.Mcdw; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwShield; import chronosacaria.mcdw.configs.McdwNewStatsConfig; import chronosacaria.mcdw.registries.ItemsRegistry; @@ -13,23 +14,21 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum ShieldsID implements IShieldID { - SHIELD_ROYAL_GUARD(ToolMaterials.DIAMOND, "minecraft:iron_ingot", "minecraft:gold_ingot"), - SHIELD_TOWER_GUARD(ToolMaterials.DIAMOND, "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:copper_ingot"), - SHIELD_VANGUARD(ToolMaterials.DIAMOND, "minecraft:planks", "minecraft:iron_ingot"); + SHIELD_ROYAL_GUARD(true, ToolMaterials.DIAMOND, "minecraft:iron_ingot", "minecraft:gold_ingot"), + SHIELD_TOWER_GUARD(true, ToolMaterials.DIAMOND, "minecraft:iron_ingot", "minecraft:gold_ingot", "minecraft:copper_ingot"), + SHIELD_VANGUARD(true, ToolMaterials.DIAMOND, "minecraft:planks", "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - ShieldsID(ToolMaterial material, String... repairIngredient) { + ShieldsID(boolean isEnabled, ToolMaterial material, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SHIELDS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SHIELD_ITEMS; @@ -43,9 +42,9 @@ public static HashMap getWeaponStats() { return CONFIG.mcdwNewStatsConfig.shieldStats; } - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + @Override + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.shieldStats.get(this).isEnabled; } @Override public McdwShield getItem() { @@ -81,9 +80,14 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public ShieldStats getShieldStats() { + return new IShieldID.ShieldStats().shieldStats(isEnabled, CleanlinessHelper.materialToString(material), repairIngredient); + } + @Override public McdwShield makeWeapon() { - McdwShield mcdwShield = new McdwShield(ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().repairIngredient); + McdwShield mcdwShield = new McdwShield(CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwShield); return mcdwShield; diff --git a/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java b/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java index 2db86df1..d93cfde5 100644 --- a/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/ShortbowsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwShortbow; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.enchantment.Enchantment; @@ -22,19 +22,21 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum ShortbowsID implements IRangedWeaponID, IInnateEnchantment { - BOW_LOVE_SPELL_BOW( ToolMaterials.IRON, 3, 9, 8f, "minecraft:iron_ingot"), - BOW_MECHANICAL_SHORTBOW(ToolMaterials.IRON, 4, 9, 9f, "minecraft:iron_ingot"), - BOW_PURPLE_STORM( ToolMaterials.IRON, 3, 9, 8f, "minecraft:iron_ingot"), - BOW_SHORTBOW( ToolMaterials.IRON, 3, 9, 8f, "minecraft:planks"); - - public final ToolMaterial material; - public final double projectileDamage; - public final int drawSpeed; - public final float range; + BOW_LOVE_SPELL_BOW( true, ToolMaterials.IRON, 3, 9, 8f, "minecraft:iron_ingot"), + BOW_MECHANICAL_SHORTBOW(true, ToolMaterials.IRON, 4, 9, 9f, "minecraft:iron_ingot"), + BOW_PURPLE_STORM( true, ToolMaterials.IRON, 3, 9, 8f, "minecraft:iron_ingot"), + BOW_SHORTBOW( true, ToolMaterials.IRON, 3, 9, 8f, "minecraft:planks"); + + private final boolean isEnabled; + private final ToolMaterial material; + private final double projectileDamage; + private final int drawSpeed; + private final float range; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - ShortbowsID(ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + ShortbowsID(boolean isEnabled, ToolMaterial material, double projectileDamage, int drawSpeed, float range, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { this.projectileDamage = projectileDamage; @@ -46,10 +48,6 @@ public enum ShortbowsID implements IRangedWeaponID, IInnateEnchantment { this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SHORTBOWS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SHORTBOW_ITEMS; @@ -64,9 +62,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.shortbowStats.get(this).isEnabled; } @Override public McdwShortbow getItem() { @@ -122,12 +119,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public RangedStats getRangedStats() { + return new IRangedWeaponID.RangedStats().rangedStats(isEnabled, CleanlinessHelper.materialToString(material), projectileDamage, drawSpeed, range, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case BOW_LOVE_SPELL_BOW -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.WILD_RAGE), 1); - case BOW_MECHANICAL_SHORTBOW, BOW_PURPLE_STORM -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ACCELERATE), 1); - case BOW_SHORTBOW -> null; + case BOW_LOVE_SPELL_BOW -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.WILD_RAGE); + case BOW_MECHANICAL_SHORTBOW, BOW_PURPLE_STORM -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ACCELERATE); + case BOW_SHORTBOW -> Map.of(); }; } @@ -139,7 +141,7 @@ public Map getInnateEnchantments() { @SuppressWarnings("DataFlowIssue") @Override public McdwShortbow makeWeapon() { - McdwShortbow mcdwShortbow = new McdwShortbow(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwShortbow mcdwShortbow = new McdwShortbow(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().drawSpeed, this.getWeaponItemStats().range, this.getWeaponItemStats().repairIngredient); if (FabricLoader.getInstance().isModLoaded("projectile_damage")) { ((IProjectileWeapon) mcdwShortbow).setProjectileDamage(this.getWeaponItemStats().projectileDamage); diff --git a/src/main/java/chronosacaria/mcdw/enums/SicklesID.java b/src/main/java/chronosacaria/mcdw/enums/SicklesID.java index 1bf84319..5acb4f49 100644 --- a/src/main/java/chronosacaria/mcdw/enums/SicklesID.java +++ b/src/main/java/chronosacaria/mcdw/enums/SicklesID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwSickle; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,27 +20,25 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum SicklesID implements IMeleeWeaponID, IInnateEnchantment { - SICKLE_LAST_LAUGH_GOLD(ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"), - SICKLE_LAST_LAUGH_SILVER(ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"), - SICKLE_NIGHTMARES_BITE(ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"), - SICKLE_SICKLE(ToolMaterials.IRON,1, -2.1f, "minecraft:iron_ingot"); + SICKLE_LAST_LAUGH_GOLD(true, ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"), + SICKLE_LAST_LAUGH_SILVER(true, ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"), + SICKLE_NIGHTMARES_BITE(true, ToolMaterials.IRON,2, -2.1f, "minecraft:iron_ingot"), + SICKLE_SICKLE(true, ToolMaterials.IRON,1, -2.1f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - SicklesID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + SicklesID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SICKLES_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SICKLE_ITEMS; @@ -55,9 +53,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.sickleStats.get(this).isEnabled; } @Override public McdwSickle getItem() { @@ -104,12 +101,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case SICKLE_LAST_LAUGH_GOLD, SICKLE_LAST_LAUGH_SILVER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.PROSPECTOR), 1); - case SICKLE_NIGHTMARES_BITE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.POISON_CLOUD), 1); - case SICKLE_SICKLE -> null; + case SICKLE_LAST_LAUGH_GOLD, SICKLE_LAST_LAUGH_SILVER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.PROSPECTOR); + case SICKLE_NIGHTMARES_BITE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.POISON_CLOUD); + case SICKLE_SICKLE -> Map.of(); }; } @@ -120,7 +122,7 @@ public Map getInnateEnchantments() { @Override public McdwSickle makeWeapon() { - McdwSickle mcdwSickle = new McdwSickle(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwSickle mcdwSickle = new McdwSickle(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwSickle); diff --git a/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java b/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java index c731aec2..171bbca7 100644 --- a/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java +++ b/src/main/java/chronosacaria/mcdw/enums/SoulDaggersID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwSoulDagger; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,10 +20,11 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum SoulDaggersID implements IMeleeWeaponID, IInnateEnchantment { - SOUL_DAGGER_ETERNAL_KNIFE(ToolMaterials.NETHERITE,4, -2.8f, "minecraft:netherite_scrap"), - SOUL_DAGGER_SOUL_KNIFE(ToolMaterials.IRON,4, -2.8f, "minecraft:iron_ingot"), - SOUL_DAGGER_TRUTHSEEKER(ToolMaterials.NETHERITE,3, -2.8f, "minecraft:netherite_scrap"); + SOUL_DAGGER_ETERNAL_KNIFE(true, ToolMaterials.NETHERITE,4, -2.8f, "minecraft:netherite_scrap"), + SOUL_DAGGER_SOUL_KNIFE(true, ToolMaterials.IRON,4, -2.8f, "minecraft:iron_ingot"), + SOUL_DAGGER_TRUTHSEEKER(true, ToolMaterials.NETHERITE,3, -2.8f, "minecraft:netherite_scrap"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; @@ -31,17 +32,14 @@ public enum SoulDaggersID implements IMeleeWeaponID, IInnateEnchantment { @SuppressWarnings("SameParameterValue") - SoulDaggersID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + SoulDaggersID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SOUL_DAGGERS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SOUL_DAGGER_ITEMS; @@ -56,8 +54,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.soulDaggerStats.get(this).isEnabled; } @Override @@ -105,12 +103,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case SOUL_DAGGER_ETERNAL_KNIFE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SOUL_SIPHON), 1); - case SOUL_DAGGER_SOUL_KNIFE -> null; - case SOUL_DAGGER_TRUTHSEEKER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.COMMITTED), 1); + case SOUL_DAGGER_ETERNAL_KNIFE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SOUL_SIPHON); + case SOUL_DAGGER_SOUL_KNIFE -> Map.of(); + case SOUL_DAGGER_TRUTHSEEKER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.COMMITTED); }; } @@ -121,7 +124,7 @@ public Map getInnateEnchantments() { @Override public McdwSoulDagger makeWeapon() { - McdwSoulDagger mcdwSoulDagger = new McdwSoulDagger(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwSoulDagger mcdwSoulDagger = new McdwSoulDagger(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwSoulDagger); diff --git a/src/main/java/chronosacaria/mcdw/enums/SpearsID.java b/src/main/java/chronosacaria/mcdw/enums/SpearsID.java index 47a955cd..99b734af 100644 --- a/src/main/java/chronosacaria/mcdw/enums/SpearsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/SpearsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwSpear; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantments; @@ -21,26 +21,24 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum SpearsID implements IMeleeWeaponID, IInnateEnchantment { - SPEAR_SPEAR(ToolMaterials.IRON,4, -2.5f, "minecraft:iron_ingot"), - SPEAR_WHISPERING_SPEAR(ToolMaterials.IRON,5, -2.5f, "minecraft:iron_ingot"), - SPEAR_FORTUNE(ToolMaterials.IRON,5, -2.5f, "minecraft:iron_ingot"); + SPEAR_SPEAR(true, ToolMaterials.IRON,4, -2.5f, "minecraft:iron_ingot"), + SPEAR_WHISPERING_SPEAR(true, ToolMaterials.IRON,5, -2.5f, "minecraft:iron_ingot"), + SPEAR_FORTUNE(true, ToolMaterials.IRON,5, -2.5f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - SpearsID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + SpearsID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SPEARS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SPEAR_ITEMS; @@ -55,9 +53,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.spearStats.get(this).isEnabled; } @Override public McdwSpear getItem() { @@ -104,12 +101,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case SPEAR_SPEAR -> null; - case SPEAR_WHISPERING_SPEAR -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ECHO), 1); - case SPEAR_FORTUNE -> Map.of(Enchantments.LOOTING, 1); + case SPEAR_SPEAR -> Map.of(); + case SPEAR_WHISPERING_SPEAR -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ECHO); + case SPEAR_FORTUNE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.LOOTING); }; } @@ -120,7 +122,7 @@ public Map getInnateEnchantments() { @Override public McdwSpear makeWeapon() { - McdwSpear mcdwSpear = new McdwSpear(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwSpear mcdwSpear = new McdwSpear(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwSpear); diff --git a/src/main/java/chronosacaria/mcdw/enums/StavesID.java b/src/main/java/chronosacaria/mcdw/enums/StavesID.java index 44c3a482..5de028c2 100644 --- a/src/main/java/chronosacaria/mcdw/enums/StavesID.java +++ b/src/main/java/chronosacaria/mcdw/enums/StavesID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwStaff; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,27 +20,25 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum StavesID implements IMeleeWeaponID, IInnateEnchantment { - STAFF_BATTLESTAFF(ToolMaterials.WOOD,2, -2.6f, "minecraft:planks"), - STAFF_BATTLESTAFF_OF_TERROR(ToolMaterials.IRON,5, -2.6f, "minecraft:iron_ingot"), - STAFF_GROWING_STAFF(ToolMaterials.IRON,5, -2.6f, "minecraft:iron_ingot"); + STAFF_BATTLESTAFF(true, ToolMaterials.WOOD,2, -2.6f, "minecraft:planks"), + STAFF_BATTLESTAFF_OF_TERROR(true, ToolMaterials.IRON,5, -2.6f, "minecraft:iron_ingot"), + STAFF_GROWING_STAFF(true, ToolMaterials.IRON,5, -2.6f, "minecraft:iron_ingot"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - StavesID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + StavesID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.STAVES_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.STAFF_ITEMS; @@ -55,9 +53,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.staffStats.get(this).isEnabled; } @Override public McdwStaff getItem() { @@ -104,12 +101,17 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case STAFF_BATTLESTAFF -> null; - case STAFF_BATTLESTAFF_OF_TERROR -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.EXPLODING), 1); - case STAFF_GROWING_STAFF -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.COMMITTED), 1); + case STAFF_BATTLESTAFF -> Map.of(); + case STAFF_BATTLESTAFF_OF_TERROR -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.EXPLODING); + case STAFF_GROWING_STAFF -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.COMMITTED); }; } @@ -120,7 +122,7 @@ public Map getInnateEnchantments() { @Override public McdwStaff makeWeapon() { - McdwStaff mcdwStaff = new McdwStaff(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwStaff mcdwStaff = new McdwStaff(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwStaff); diff --git a/src/main/java/chronosacaria/mcdw/enums/SwordsID.java b/src/main/java/chronosacaria/mcdw/enums/SwordsID.java index 4e7b1aae..c7094a2c 100644 --- a/src/main/java/chronosacaria/mcdw/enums/SwordsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/SwordsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwSword; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantments; @@ -21,47 +21,45 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum SwordsID implements IMeleeWeaponID, IInnateEnchantment { - SWORD_BEESTINGER(ToolMaterials.IRON, 0, -1.1f, "minecraft:iron_ingot"), - SWORD_BROADSWORD(ToolMaterials.IRON, 5, -3.0f, "minecraft:iron_ingot"), - SWORD_BROKEN_SAWBLADE(ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"), - SWORD_CLAYMORE(ToolMaterials.IRON, 7, -3.2f, "minecraft:iron_ingot"), - SWORD_CORAL_BLADE(ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"), - SWORD_CUTLASS(ToolMaterials.IRON,2, -2.3f, "minecraft:iron_ingot"), - SWORD_DANCERS_SWORD(ToolMaterials.IRON,3, -2.0f, "minecraft:iron_ingot"), - SWORD_DARK_KATANA(ToolMaterials.NETHERITE,4, -2.9f, "minecraft:netherite_scrap"), - SWORD_DIAMOND_SWORD_VAR(ToolMaterials.DIAMOND,3, -2.4f, "minecraft:diamond"), - SWORD_FREEZING_FOIL(ToolMaterials.IRON,1, -1.1f, "minecraft:iron_ingot"), - SWORD_FROST_SLAYER(ToolMaterials.DIAMOND, 6, -3.2f, "minecraft:diamond"), - SWORD_GREAT_AXEBLADE(ToolMaterials.IRON, 7, -3.2f, "minecraft:iron_ingot"), - SWORD_HAWKBRAND(ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"), - SWORD_HEARTSTEALER(ToolMaterials.DIAMOND, 6, -3.2f, "minecraft:diamond"), - SWORD_IRON_SWORD_VAR(ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"), - SWORD_KATANA(ToolMaterials.IRON,4, -2.9f, "minecraft:iron_ingot"), - SWORD_MASTERS_KATANA(ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"), - SWORD_MECHANIZED_SAWBLADE(ToolMaterials.DIAMOND,3, -2.4f, "minecraft:blaze_rod"), - SWORD_NAMELESS_BLADE(ToolMaterials.IRON,4, -2.3f, "minecraft:iron_ingot"), - SWORD_OBSIDIAN_CLAYMORE(ToolMaterials.NETHERITE, 6, -3.3f, "minecraft:netherite_scrap"), - SWORD_RAPIER(ToolMaterials.IRON,0, -1.14f, "minecraft:iron_ingot"), - SWORD_SINISTER(ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"), - SWORD_SPONGE_STRIKER(ToolMaterials.DIAMOND,3, -2.4f, "minecraft:diamond"), - SWORD_THE_STARLESS_NIGHT(ToolMaterials.NETHERITE, 6, -3.3f, "minecraft:netherite_scrap"); - + SWORD_BEESTINGER(true, ToolMaterials.IRON, 0, -1.1f, "minecraft:iron_ingot"), + SWORD_BROADSWORD(true, ToolMaterials.IRON, 5, -3.0f, "minecraft:iron_ingot"), + SWORD_BROKEN_SAWBLADE(true, ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"), + SWORD_CLAYMORE(true, ToolMaterials.IRON, 7, -3.2f, "minecraft:iron_ingot"), + SWORD_CORAL_BLADE(true, ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"), + SWORD_CUTLASS(true, ToolMaterials.IRON,2, -2.3f, "minecraft:iron_ingot"), + SWORD_DANCERS_SWORD(true, ToolMaterials.IRON,3, -2.0f, "minecraft:iron_ingot"), + SWORD_DARK_KATANA(true, ToolMaterials.NETHERITE,4, -2.9f, "minecraft:netherite_scrap"), + SWORD_DIAMOND_SWORD_VAR(true, ToolMaterials.DIAMOND,3, -2.4f, "minecraft:diamond"), + SWORD_FREEZING_FOIL(true, ToolMaterials.IRON,1, -1.1f, "minecraft:iron_ingot"), + SWORD_FROST_SLAYER(true, ToolMaterials.DIAMOND, 6, -3.2f, "minecraft:diamond"), + SWORD_GREAT_AXEBLADE(true, ToolMaterials.IRON, 7, -3.2f, "minecraft:iron_ingot"), + SWORD_HAWKBRAND(true, ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"), + SWORD_HEARTSTEALER(true, ToolMaterials.DIAMOND, 6, -3.2f, "minecraft:diamond"), + SWORD_IRON_SWORD_VAR(true, ToolMaterials.IRON,3, -2.4f, "minecraft:iron_ingot"), + SWORD_KATANA(true, ToolMaterials.IRON,4, -2.9f, "minecraft:iron_ingot"), + SWORD_MASTERS_KATANA(true, ToolMaterials.DIAMOND,4, -2.9f, "minecraft:diamond"), + SWORD_MECHANIZED_SAWBLADE(true, ToolMaterials.DIAMOND,3, -2.4f, "minecraft:blaze_rod"), + SWORD_NAMELESS_BLADE(true, ToolMaterials.IRON,4, -2.3f, "minecraft:iron_ingot"), + SWORD_OBSIDIAN_CLAYMORE(true, ToolMaterials.NETHERITE, 6, -3.3f, "minecraft:netherite_scrap"), + SWORD_RAPIER(true, ToolMaterials.IRON,0, -1.14f, "minecraft:iron_ingot"), + SWORD_SINISTER(true, ToolMaterials.IRON,6, -2.9f, "minecraft:iron_ingot"), + SWORD_SPONGE_STRIKER(true, ToolMaterials.DIAMOND,3, -2.4f, "minecraft:diamond"), + SWORD_THE_STARLESS_NIGHT(true, ToolMaterials.NETHERITE, 6, -3.3f, "minecraft:netherite_scrap"); + + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; - SwordsID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + SwordsID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.SWORDS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.SWORD_ITEMS; @@ -76,9 +74,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.swordStats.get(this).isEnabled; } @Override public McdwSword getItem() { @@ -124,25 +121,29 @@ public float getAttackSpeed(){ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } @Override public Map getInnateEnchantments() { return switch (this) { - case SWORD_BEESTINGER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.BUSY_BEE), 1); - case SWORD_BROKEN_SAWBLADE, SWORD_CORAL_BLADE, SWORD_CUTLASS, SWORD_DIAMOND_SWORD_VAR, SWORD_IRON_SWORD_VAR, SWORD_KATANA, SWORD_OBSIDIAN_CLAYMORE, SWORD_RAPIER -> null; - case SWORD_CLAYMORE -> Map.of(Enchantments.KNOCKBACK, 1); - case SWORD_BROADSWORD -> Map.of(Enchantments.KNOCKBACK, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.SWIRLING), 1); - case SWORD_DANCERS_SWORD -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.RAMPAGING), 1); - case SWORD_DARK_KATANA -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SMITING), 1); - case SWORD_FREEZING_FOIL -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.FREEZING), 1); - case SWORD_FROST_SLAYER -> Map.of(Enchantments.KNOCKBACK, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.FREEZING), 1); - case SWORD_GREAT_AXEBLADE -> Map.of(Enchantments.KNOCKBACK, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.DYNAMO), 1); - case SWORD_HAWKBRAND, SWORD_MASTERS_KATANA, SWORD_SINISTER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.CRITICAL_HIT), 1); - case SWORD_HEARTSTEALER -> Map.of(Enchantments.KNOCKBACK, 1, EnchantsRegistry.enchantments.get(EnchantmentsID.LEECHING), 1); - case SWORD_MECHANIZED_SAWBLADE -> Map.of(Enchantments.FIRE_ASPECT, 1); - case SWORD_NAMELESS_BLADE -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.WEAKENING), 1); - case SWORD_SPONGE_STRIKER -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.ENIGMA_RESONATOR), 1); - case SWORD_THE_STARLESS_NIGHT -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.SHARED_PAIN), 1); + case SWORD_BEESTINGER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.BUSY_BEE); + case SWORD_BROKEN_SAWBLADE, SWORD_CORAL_BLADE, SWORD_CUTLASS, SWORD_DIAMOND_SWORD_VAR, SWORD_IRON_SWORD_VAR, SWORD_KATANA, SWORD_OBSIDIAN_CLAYMORE, SWORD_RAPIER -> Map.of(); + case SWORD_CLAYMORE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK); + case SWORD_BROADSWORD -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK, EnchantmentsID.SWIRLING); + case SWORD_DANCERS_SWORD -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.RAMPAGING); + case SWORD_DARK_KATANA -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SMITING); + case SWORD_FREEZING_FOIL -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.FREEZING); + case SWORD_FROST_SLAYER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK, EnchantmentsID.FREEZING); + case SWORD_GREAT_AXEBLADE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK, EnchantmentsID.DYNAMO); + case SWORD_HAWKBRAND, SWORD_MASTERS_KATANA, SWORD_SINISTER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.CRITICAL_HIT); + case SWORD_HEARTSTEALER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.KNOCKBACK, EnchantmentsID.LEECHING); + case SWORD_MECHANIZED_SAWBLADE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, Enchantments.FIRE_ASPECT); + case SWORD_NAMELESS_BLADE -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.WEAKENING); + case SWORD_SPONGE_STRIKER -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.ENIGMA_RESONATOR); + case SWORD_THE_STARLESS_NIGHT -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.SHARED_PAIN); }; } @@ -153,7 +154,7 @@ public Map getInnateEnchantments() { @Override public McdwSword makeWeapon() { - McdwSword mcdwSword = new McdwSword(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwSword mcdwSword = new McdwSword(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwSword); diff --git a/src/main/java/chronosacaria/mcdw/enums/WhipsID.java b/src/main/java/chronosacaria/mcdw/enums/WhipsID.java index 62dfebd4..8b5d0a9e 100644 --- a/src/main/java/chronosacaria/mcdw/enums/WhipsID.java +++ b/src/main/java/chronosacaria/mcdw/enums/WhipsID.java @@ -2,9 +2,9 @@ import chronosacaria.mcdw.Mcdw; import chronosacaria.mcdw.api.interfaces.IInnateEnchantment; +import chronosacaria.mcdw.api.util.CleanlinessHelper; import chronosacaria.mcdw.bases.McdwWhip; import chronosacaria.mcdw.configs.McdwNewStatsConfig; -import chronosacaria.mcdw.registries.EnchantsRegistry; import chronosacaria.mcdw.registries.ItemsRegistry; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; @@ -20,25 +20,23 @@ import static chronosacaria.mcdw.Mcdw.CONFIG; public enum WhipsID implements IMeleeWeaponID, IInnateEnchantment { - WHIP_VINE_WHIP(ToolMaterials.IRON, 5, -3.1f, "minecraft:vine"), - WHIP_WHIP(ToolMaterials.IRON, 3, -3.1f, "minecraft:string"); + WHIP_VINE_WHIP(true, ToolMaterials.IRON, 5, -3.1f, "minecraft:vine"), + WHIP_WHIP(true, ToolMaterials.IRON, 3, -3.1f, "minecraft:string"); + private final boolean isEnabled; private final ToolMaterial material; private final int damage; private final float attackSpeed; private final String[] repairIngredient; @SuppressWarnings("SameParameterValue") - WhipsID(ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + WhipsID(boolean isEnabled, ToolMaterial material, int damage, float attackSpeed, String... repairIngredient) { + this.isEnabled = isEnabled; this.material = material; this.damage = damage; this.attackSpeed = attackSpeed; this.repairIngredient = repairIngredient; } - public static HashMap getEnabledItems(){ - return Mcdw.CONFIG.mcdwEnableItemsConfig.WHIPS_ENABLED; - } - @SuppressWarnings("SameReturnValue") public static EnumMap getItemsEnum() { return ItemsRegistry.WHIP_ITEMS; @@ -53,9 +51,8 @@ public static HashMap getWeaponStats() { } @Override - public Boolean isEnabled(){ - return getEnabledItems().get(this); - } + public boolean getIsEnabled(){ + return CONFIG.mcdwNewStatsConfig.whipStats.get(this).isEnabled; } @Override public McdwWhip getItem() { @@ -102,11 +99,16 @@ public String[] getRepairIngredient() { return repairIngredient; } + @Override + public MeleeStats getMeleeStats() { + return new IMeleeWeaponID.MeleeStats().meleeStats(isEnabled, CleanlinessHelper.materialToString(material), damage, attackSpeed, repairIngredient); + } + @Override public Map getInnateEnchantments() { return switch (this) { - case WHIP_WHIP -> null; - case WHIP_VINE_WHIP -> Map.of(EnchantsRegistry.enchantments.get(EnchantmentsID.JUNGLE_POISON), 1); + case WHIP_WHIP -> Map.of(); + case WHIP_VINE_WHIP -> CleanlinessHelper.mcdw$checkInnateEnchantmentEnabled(1, EnchantmentsID.JUNGLE_POISON); }; } @@ -117,7 +119,7 @@ public Map getInnateEnchantments() { @Override public McdwWhip makeWeapon() { - McdwWhip mcdwWhip = new McdwWhip(this, ItemsRegistry.stringToMaterial(this.getWeaponItemStats().material), + McdwWhip mcdwWhip = new McdwWhip(this, CleanlinessHelper.stringToMaterial(this.getWeaponItemStats().material), this.getWeaponItemStats().damage, this.getWeaponItemStats().attackSpeed, this.getWeaponItemStats().repairIngredient); getItemsEnum().put(this, mcdwWhip); diff --git a/src/main/java/chronosacaria/mcdw/registries/ItemsRegistry.java b/src/main/java/chronosacaria/mcdw/registries/ItemsRegistry.java index 1252b39b..6e38c84b 100644 --- a/src/main/java/chronosacaria/mcdw/registries/ItemsRegistry.java +++ b/src/main/java/chronosacaria/mcdw/registries/ItemsRegistry.java @@ -5,8 +5,6 @@ import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.item.Item; import net.minecraft.item.ItemGroups; -import net.minecraft.item.ToolMaterial; -import net.minecraft.item.ToolMaterials; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; @@ -41,7 +39,7 @@ public class ItemsRegistry { public static void register() { for (IMcdwWeaponID weaponID : IMcdwWeaponID.values()) { - if (weaponID.isEnabled()) { + if (weaponID.getIsEnabled()) { Item weapon = weaponID.makeWeapon(); registerItem(weaponID.toString().toLowerCase(Locale.ROOT), weapon); } @@ -60,14 +58,4 @@ protected static void registerItem(String id, Item item) { Registry.register(Registries.ITEM, ID(id), item); } - public static ToolMaterial stringToMaterial(String material) { - return switch (material) { - case "wood" -> ToolMaterials.WOOD; - case "stone" -> ToolMaterials.STONE; - case "gold" -> ToolMaterials.GOLD; - case "diamond" -> ToolMaterials.DIAMOND; - case "netherite" -> ToolMaterials.NETHERITE; - default -> ToolMaterials.IRON; - }; - } } diff --git a/src/main/java/chronosacaria/mcdw/registries/LootTablesRegistry.java b/src/main/java/chronosacaria/mcdw/registries/LootTablesRegistry.java index 77bfe4bf..cc6252a3 100644 --- a/src/main/java/chronosacaria/mcdw/registries/LootTablesRegistry.java +++ b/src/main/java/chronosacaria/mcdw/registries/LootTablesRegistry.java @@ -75,7 +75,7 @@ public static void register() { } if (id.equals(EntityType.WITCH.getLootTableId()) && source.isBuiltin()) { - if (GlaivesID.GLAIVE_CACKLING_BROOM.isEnabled()) { + if (GlaivesID.GLAIVE_CACKLING_BROOM.getIsEnabled()) { LootPool.Builder lootPoolBuilder = LootPool.builder(); addItemDrop(lootPoolBuilder, GlaivesID.GLAIVE_CACKLING_BROOM.getItem(), 1, 0.2F); tableBuilder.pool(lootPoolBuilder.build()); @@ -83,14 +83,14 @@ public static void register() { } if (id.equals(EntityType.WITHER.getLootTableId()) && source.isBuiltin()) { - if (BowsID.BOW_ANCIENT_BOW.isEnabled()) { + if (BowsID.BOW_ANCIENT_BOW.getIsEnabled()) { LootPool.Builder lootPoolBuilder = LootPool.builder(); addItemDrop(lootPoolBuilder, BowsID.BOW_ANCIENT_BOW.getItem(), 1, 0.1F); tableBuilder.pool(lootPoolBuilder.build()); } } - if (CONFIG.mcdwNewlootConfig.WEAPONS_ENABLED_IN_LOOTTABLES.get(SettingsID.ENABLE_WEAPONS_IN_LOOTTABLES)) { + if (CONFIG.mcdwNewlootConfig.WEAPONS_ENABLED_IN_LOOTTABLES.get(SettingsID.ENABLE_WEAPONS_IN_LOOT_TABLES)) { LootPool.Builder lootPoolBuilder = LootPool.builder(); lootPoolBuilder.rolls(ConstantLootNumberProvider.create(1)); lootPoolBuilder.conditionally(RandomChanceLootCondition.builder(CONFIG.mcdwNewlootConfig.findWeaponChance)); @@ -122,7 +122,7 @@ public static void addWeapon(LootPool.Builder lootPoolBuilder, Item weapon, int } public static void addWeaponById(LootPool.Builder lootPoolBuilder, IMcdwWeaponID weaponID) { - if (weaponID.isEnabled()) + if (weaponID.getIsEnabled()) addWeapon(lootPoolBuilder, weaponID.getItem(), weaponID.getItemSpawnRate()); }