From 50f31c4ad03556dfc5d8d484ba6dfc1d0ab15c76 Mon Sep 17 00:00:00 2001 From: chronosacaria Date: Mon, 22 Jan 2024 20:40:38 -0500 Subject: [PATCH] Config Rewrite, Stats Config II, Tags, Licence Update, Version Constraints, Optimised Imports - Added `buzzy_nest_bee` to `beehive_inhabitors` tag (Fixed #31) - Added configurable `loottables` and values for artifacts (Fixed #37) - Confirmed Golem Crash no longer happening (Fixed #38) - Will be uploading to Modrinth (Fixed #39) - Constrained Minecraft Dependency to crash on 1.20.2+ - Updated Licence to TDL 1.2 - Refactored LootRegistry --- LICENSE | 9 +- .../mcdar/api/CleanlinessHelper.java | 84 -------- .../mcdar/api/GroupedObjectsHelper.java | 92 +++++++++ .../config/ArtifactStatsConfigHelper.java | 38 ++-- .../config/McdarArtifactsStatsConfig.java | 189 ++++++++++++------ .../mcdar/enums/AgilityArtifactID.java | 31 ++- .../mcdar/enums/DamagingArtifactID.java | 30 ++- .../mcdar/enums/DefensiveArtifactID.java | 32 ++- .../mcdar/enums/IArtifactItem.java | 11 +- .../mcdar/enums/QuiverArtifactID.java | 32 ++- .../enums/StatusInflictingArtifactID.java | 31 ++- .../mcdar/enums/SummoningArtifactID.java | 31 ++- .../mcdar/registries/LootRegistry.java | 186 +++-------------- .../tags/entity_types/beehive_inhabitors.json | 5 + src/main/resources/fabric.mod.json | 6 +- 15 files changed, 458 insertions(+), 349 deletions(-) create mode 100644 src/main/java/chronosacaria/mcdar/api/GroupedObjectsHelper.java create mode 100644 src/main/resources/data/minecraft/tags/entity_types/beehive_inhabitors.json diff --git a/LICENSE b/LICENSE index aaead62..9530229 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -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: @@ -12,6 +12,9 @@ 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. @@ -29,4 +32,4 @@ Content Creator, in this license, means anyone who creates content on YouTube or 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/src/main/java/chronosacaria/mcdar/api/CleanlinessHelper.java b/src/main/java/chronosacaria/mcdar/api/CleanlinessHelper.java index c7598fb..2269724 100644 --- a/src/main/java/chronosacaria/mcdar/api/CleanlinessHelper.java +++ b/src/main/java/chronosacaria/mcdar/api/CleanlinessHelper.java @@ -136,90 +136,6 @@ public static boolean isCoolingDown(PlayerEntity player, Item item) { return ActionResult.SUCCESS; } - public static float mcdar$artifactIDToGeneralSpawnChance(Item artifactItem) { - if (artifactItem instanceof IArtifactItem) { - for (AgilityArtifactID agilityArtifactID : AgilityArtifactID.values()) - if (artifactItem.asItem() == agilityArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(agilityArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(agilityArtifactID) - .mcdar$getGeneralArtifactSpawnRate(); - for (DamagingArtifactID damagingArtifactID : DamagingArtifactID.values()) - if (artifactItem.asItem() == damagingArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(damagingArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(damagingArtifactID) - .mcdar$getGeneralArtifactSpawnRate(); - for (DefensiveArtifactID defensiveArtifactID : DefensiveArtifactID.values()) - if (artifactItem.asItem() == defensiveArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(defensiveArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(defensiveArtifactID) - .mcdar$getGeneralArtifactSpawnRate(); - for (QuiverArtifactID quiverArtifactID : QuiverArtifactID.values()) - if (artifactItem.asItem() == quiverArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(quiverArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(quiverArtifactID) - .mcdar$getGeneralArtifactSpawnRate(); - for (StatusInflictingArtifactID statusInflictingArtifactID : StatusInflictingArtifactID.values()) - if (artifactItem.asItem() == statusInflictingArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(statusInflictingArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(statusInflictingArtifactID) - .mcdar$getGeneralArtifactSpawnRate(); - for (SummoningArtifactID summoningArtifactID : SummoningArtifactID.values()) - if (artifactItem.asItem() == summoningArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(summoningArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(summoningArtifactID) - .mcdar$getGeneralArtifactSpawnRate(); - } - return 0.0f; - } - public static float mcdar$artifactIDToDungeonSpawnChance(Item artifactItem) { - if (artifactItem instanceof IArtifactItem) { - for (AgilityArtifactID agilityArtifactID : AgilityArtifactID.values()) - if (artifactItem.asItem() == agilityArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(agilityArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(agilityArtifactID) - .mcdar$getDungeonArtifactSpawnRate(); - for (DamagingArtifactID damagingArtifactID : DamagingArtifactID.values()) - if (artifactItem.asItem() == damagingArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(damagingArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(damagingArtifactID) - .mcdar$getDungeonArtifactSpawnRate(); - for (DefensiveArtifactID defensiveArtifactID : DefensiveArtifactID.values()) - if (artifactItem.asItem() == defensiveArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(defensiveArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(defensiveArtifactID) - .mcdar$getDungeonArtifactSpawnRate(); - for (QuiverArtifactID quiverArtifactID : QuiverArtifactID.values()) - if (artifactItem.asItem() == quiverArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(quiverArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(quiverArtifactID) - .mcdar$getDungeonArtifactSpawnRate(); - for (StatusInflictingArtifactID statusInflictingArtifactID : StatusInflictingArtifactID.values()) - if (artifactItem.asItem() == statusInflictingArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(statusInflictingArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(statusInflictingArtifactID) - .mcdar$getDungeonArtifactSpawnRate(); - for (SummoningArtifactID summoningArtifactID : SummoningArtifactID.values()) - if (artifactItem.asItem() == summoningArtifactID.mcdar$getItem() - && Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(summoningArtifactID) - .mcdar$getIsEnabled()) - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(summoningArtifactID) - .mcdar$getDungeonArtifactSpawnRate(); - } - return 0.0f; - } - - private static int mcdar$artifactIDToItemCooldownTime(Item artifactItem) { int cooldownLevel = net.minecraft.enchantment.EnchantmentHelper.getLevel(EnchantsRegistry.COOLDOWN, artifactItem.getDefaultStack()); if (artifactItem instanceof IArtifactItem) { diff --git a/src/main/java/chronosacaria/mcdar/api/GroupedObjectsHelper.java b/src/main/java/chronosacaria/mcdar/api/GroupedObjectsHelper.java new file mode 100644 index 0000000..4d810fa --- /dev/null +++ b/src/main/java/chronosacaria/mcdar/api/GroupedObjectsHelper.java @@ -0,0 +1,92 @@ +package chronosacaria.mcdar.api; + +import chronosacaria.mcdar.enums.*; +import net.minecraft.loot.LootTables; +import net.minecraft.util.Identifier; + +import java.util.List; +import java.util.Set; + +public class GroupedObjectsHelper { + public static final Set ILLAGER_ARTIFACT_GENERAL_LOOT_TABLES = + Set.of(LootTables.WOODLAND_MANSION_CHEST, LootTables.PILLAGER_OUTPOST_CHEST); + + public static final Set VILLAGER_ARTIFACT_GENERAL_LOOT_TABLES = + Set.of(LootTables.VILLAGE_ARMORER_CHEST, LootTables.VILLAGE_BUTCHER_CHEST, + LootTables.VILLAGE_CARTOGRAPHER_CHEST, LootTables.VILLAGE_FISHER_CHEST, + LootTables.VILLAGE_FLETCHER_CHEST, LootTables.VILLAGE_DESERT_HOUSE_CHEST, + LootTables.VILLAGE_MASON_CHEST, LootTables.VILLAGE_PLAINS_CHEST, + LootTables.VILLAGE_SAVANNA_HOUSE_CHEST, LootTables.VILLAGE_SHEPARD_CHEST, + LootTables.VILLAGE_SNOWY_HOUSE_CHEST, LootTables.VILLAGE_TAIGA_HOUSE_CHEST, + LootTables.VILLAGE_TANNERY_CHEST, LootTables.VILLAGE_TEMPLE_CHEST, + LootTables.VILLAGE_TOOLSMITH_CHEST); + public static final Set ALL_ARTIFACTS_DUNGEON_LOOT_TABLES = + Set.of(LootTables.ABANDONED_MINESHAFT_CHEST, LootTables.SIMPLE_DUNGEON_CHEST, LootTables.SHIPWRECK_TREASURE_CHEST); + + public static final List illagerArtifacts = List.of( + AgilityArtifactID.DEATH_CAP_MUSHROOM, + DamagingArtifactID.BLAST_FUNGUS, + DamagingArtifactID.HARVESTER, + DamagingArtifactID.LIGHTNING_ROD, + DamagingArtifactID.POWERSHAKER, + DefensiveArtifactID.ENCHANTERS_TOME, + DefensiveArtifactID.SOUL_HEALER, + DefensiveArtifactID.TOTEM_OF_REGENERATION, + DefensiveArtifactID.TOTEM_OF_SHIELDING, + DefensiveArtifactID.TOTEM_OF_SOUL_PROTECTION, + QuiverArtifactID.HARPOON_QUIVER, + QuiverArtifactID.THUNDERING_QUIVER, + QuiverArtifactID.TORMENT_QUIVER, + StatusInflictingArtifactID.CORRUPTED_SEEDS, + StatusInflictingArtifactID.GONG_OF_WEAKENING, + StatusInflictingArtifactID.LOVE_MEDALLION, + StatusInflictingArtifactID.SATCHEL_OF_ELEMENTS, + StatusInflictingArtifactID.SHOCK_POWDER + ); + + public static final List villagerArtifacts = List.of( + AgilityArtifactID.BOOTS_OF_SWIFTNESS, + AgilityArtifactID.GHOST_CLOAK, + AgilityArtifactID.LIGHT_FEATHER, + DamagingArtifactID.UPDRAFT_TOME, + DefensiveArtifactID.IRON_HIDE_AMULET, + DefensiveArtifactID.WIND_HORN, + QuiverArtifactID.FLAMING_QUIVER, + SummoningArtifactID.BUZZY_NEST, + SummoningArtifactID.ENCHANTED_GRASS, + SummoningArtifactID.GOLEM_KIT, + SummoningArtifactID.TASTY_BONE, + SummoningArtifactID.WONDERFUL_WHEAT + ); + + public static final List allArtifacts = List.of( + AgilityArtifactID.BOOTS_OF_SWIFTNESS, + AgilityArtifactID.DEATH_CAP_MUSHROOM, + AgilityArtifactID.GHOST_CLOAK, + AgilityArtifactID.LIGHT_FEATHER, + DamagingArtifactID.BLAST_FUNGUS, + DamagingArtifactID.HARVESTER, + DamagingArtifactID.LIGHTNING_ROD, + DamagingArtifactID.POWERSHAKER, + DamagingArtifactID.UPDRAFT_TOME, + DefensiveArtifactID.ENCHANTERS_TOME, + DefensiveArtifactID.IRON_HIDE_AMULET, + DefensiveArtifactID.SOUL_HEALER, + DefensiveArtifactID.TOTEM_OF_REGENERATION, + DefensiveArtifactID.TOTEM_OF_SHIELDING, + DefensiveArtifactID.TOTEM_OF_SOUL_PROTECTION, + DefensiveArtifactID.WIND_HORN, + QuiverArtifactID.FLAMING_QUIVER, + QuiverArtifactID.HARPOON_QUIVER, + QuiverArtifactID.THUNDERING_QUIVER, + QuiverArtifactID.TORMENT_QUIVER, + StatusInflictingArtifactID.CORRUPTED_SEEDS, + StatusInflictingArtifactID.GONG_OF_WEAKENING, + StatusInflictingArtifactID.SATCHEL_OF_ELEMENTS, + StatusInflictingArtifactID.SHOCK_POWDER, + SummoningArtifactID.BUZZY_NEST, + SummoningArtifactID.ENCHANTED_GRASS, + SummoningArtifactID.GOLEM_KIT, + SummoningArtifactID.TASTY_BONE, + SummoningArtifactID.WONDERFUL_WHEAT); +} diff --git a/src/main/java/chronosacaria/mcdar/config/ArtifactStatsConfigHelper.java b/src/main/java/chronosacaria/mcdar/config/ArtifactStatsConfigHelper.java index 4318c82..8de9702 100644 --- a/src/main/java/chronosacaria/mcdar/config/ArtifactStatsConfigHelper.java +++ b/src/main/java/chronosacaria/mcdar/config/ArtifactStatsConfigHelper.java @@ -1,6 +1,7 @@ package chronosacaria.mcdar.config; import java.util.List; +import java.util.Set; public class ArtifactStatsConfigHelper { @@ -8,8 +9,10 @@ public class ArtifactStatsConfigHelper { boolean isEnabled = true; int durability; int maxCooldownEnchantmentTime; - float generalSpawnRate; - float dungeonSpawnRate; + int generalSpawnWeight; + int dungeonSpawnWeight; + Set generalLootTables; + Set dungeonLootTables; public boolean mcdar$getIsEnabled() { return isEnabled; @@ -23,31 +26,42 @@ public class ArtifactStatsConfigHelper { return maxCooldownEnchantmentTime; } - public float mcdar$getGeneralArtifactSpawnRate() { - return generalSpawnRate; + public int mcdar$getGeneralArtifactSpawnWeight() { + return generalSpawnWeight; } - public float mcdar$getDungeonArtifactSpawnRate() { - return dungeonSpawnRate; + public int mcdar$getDungeonArtifactSpawnWeight() { + return dungeonSpawnWeight; + } + public Set mcdar$getGeneralLootTables() { + return generalLootTables; + } + + public Set mcdar$getDungeonLootTables() { + return dungeonLootTables; } @SuppressWarnings("unused") public ArtifactStatsConfigHelper() { } - public ArtifactStatsConfigHelper(boolean isEnabled, int durability, int maxCooldownEnchantmentTime, float generalSpawnRate, float dungeonSpawnRate) { + public ArtifactStatsConfigHelper(boolean isEnabled, int durability, int maxCooldownEnchantmentTime, int generalSpawnWeight, int dungeonSpawnWeight, Set generalLootTables, Set dungeonLootTables) { this.isEnabled = isEnabled; this.durability = durability; this.maxCooldownEnchantmentTime = maxCooldownEnchantmentTime; - this.generalSpawnRate = generalSpawnRate; - this.dungeonSpawnRate = dungeonSpawnRate; + this.generalSpawnWeight = generalSpawnWeight; + this.dungeonSpawnWeight = dungeonSpawnWeight; + this.generalLootTables = generalLootTables; + this.dungeonLootTables = dungeonLootTables; } - public ArtifactStatsConfigHelper(List comment, boolean isEnabled, int durability, int maxCooldownEnchantmentTime, float generalSpawnRate, float dungeonSpawnRate) { + public ArtifactStatsConfigHelper(List comment, boolean isEnabled, int durability, int maxCooldownEnchantmentTime, int generalSpawnWeight, int dungeonSpawnWeight, Set generalLootTables, Set dungeonLootTables) { this.comment = comment; this.isEnabled = isEnabled; this.durability = durability; this.maxCooldownEnchantmentTime = maxCooldownEnchantmentTime; - this.generalSpawnRate = generalSpawnRate; - this.dungeonSpawnRate = dungeonSpawnRate; + this.generalSpawnWeight = generalSpawnWeight; + this.dungeonSpawnWeight = dungeonSpawnWeight; + this.generalLootTables = generalLootTables; + this.dungeonLootTables = dungeonLootTables; } } diff --git a/src/main/java/chronosacaria/mcdar/config/McdarArtifactsStatsConfig.java b/src/main/java/chronosacaria/mcdar/config/McdarArtifactsStatsConfig.java index 676b273..194d0f9 100644 --- a/src/main/java/chronosacaria/mcdar/config/McdarArtifactsStatsConfig.java +++ b/src/main/java/chronosacaria/mcdar/config/McdarArtifactsStatsConfig.java @@ -1,14 +1,20 @@ package chronosacaria.mcdar.config; +import chronosacaria.mcdar.api.GroupedObjectsHelper; import chronosacaria.mcdar.enums.*; import me.shedaniel.autoconfig.ConfigData; import me.shedaniel.autoconfig.annotation.Config; +import net.minecraft.util.Identifier; import java.util.LinkedHashMap; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; @Config(name = "mcdar_artifacts_stats_config") public class McdarArtifactsStatsConfig implements ConfigData { + public final float ARTIFACT_GENERAL_SPAWN_CHANCE = 0.25f; + public final float ARTIFACT_DUNGEON_SPAWN_CHANCE = 0.1f; public final LinkedHashMap AGILITY_ARTIFACT_STATS = new LinkedHashMap<>(); public final LinkedHashMap DAMAGING_ARTIFACT_STATS = new LinkedHashMap<>(); public final LinkedHashMap DEFENSIVE_ARTIFACT_STATS = new LinkedHashMap<>(); @@ -17,14 +23,19 @@ public class McdarArtifactsStatsConfig implements ConfigData { public final LinkedHashMap SUMMONING_ARTIFACT_STATS = new LinkedHashMap<>(); public McdarArtifactsStatsConfig() { + Set villager = GroupedObjectsHelper.VILLAGER_ARTIFACT_GENERAL_LOOT_TABLES.stream().map(Identifier::toString).collect(Collectors.toSet()); + Set illager = GroupedObjectsHelper.ILLAGER_ARTIFACT_GENERAL_LOOT_TABLES.stream().map(Identifier::toString).collect(Collectors.toSet()); + Set dungeon = GroupedObjectsHelper.ALL_ARTIFACTS_DUNGEON_LOOT_TABLES.stream().map(Identifier::toString).collect(Collectors.toSet()); AGILITY_ARTIFACT_STATS.put( AgilityArtifactID.BOOTS_OF_SWIFTNESS, new ArtifactStatsConfigHelper( true, 64, 100, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); AGILITY_ARTIFACT_STATS.put( @@ -33,8 +44,10 @@ public McdarArtifactsStatsConfig() { true, 64, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); AGILITY_ARTIFACT_STATS.put( @@ -43,8 +56,10 @@ public McdarArtifactsStatsConfig() { true, 64, 120, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); AGILITY_ARTIFACT_STATS.put( @@ -53,8 +68,10 @@ public McdarArtifactsStatsConfig() { true, 64, 120, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); @@ -64,8 +81,10 @@ public McdarArtifactsStatsConfig() { true, 64, 120, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DAMAGING_ARTIFACT_STATS.put( @@ -74,8 +93,10 @@ public McdarArtifactsStatsConfig() { true, 64, 60, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DAMAGING_ARTIFACT_STATS.put( @@ -84,8 +105,10 @@ public McdarArtifactsStatsConfig() { true, 64, 40, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DAMAGING_ARTIFACT_STATS.put( @@ -94,8 +117,10 @@ public McdarArtifactsStatsConfig() { true, 64, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DAMAGING_ARTIFACT_STATS.put( @@ -104,8 +129,10 @@ public McdarArtifactsStatsConfig() { true, 64, 300, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); @@ -115,8 +142,10 @@ public McdarArtifactsStatsConfig() { true, 64, 100, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DEFENSIVE_ARTIFACT_STATS.put( @@ -125,8 +154,10 @@ public McdarArtifactsStatsConfig() { true, 64, 500, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); DEFENSIVE_ARTIFACT_STATS.put( @@ -135,8 +166,10 @@ public McdarArtifactsStatsConfig() { true, 64, 60, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DEFENSIVE_ARTIFACT_STATS.put( @@ -145,8 +178,10 @@ public McdarArtifactsStatsConfig() { true, 64, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DEFENSIVE_ARTIFACT_STATS.put( @@ -155,8 +190,10 @@ public McdarArtifactsStatsConfig() { true, 64, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DEFENSIVE_ARTIFACT_STATS.put( @@ -165,8 +202,10 @@ public McdarArtifactsStatsConfig() { true, 64, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); DEFENSIVE_ARTIFACT_STATS.put( @@ -175,8 +214,10 @@ public McdarArtifactsStatsConfig() { true, 64, 250, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); @@ -193,8 +234,10 @@ public McdarArtifactsStatsConfig() { true, 8, 500, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); QUIVER_ARTIFACT_STATS.put( @@ -210,8 +253,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); QUIVER_ARTIFACT_STATS.put( @@ -227,8 +272,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); QUIVER_ARTIFACT_STATS.put( @@ -244,8 +291,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); @@ -255,8 +304,10 @@ public McdarArtifactsStatsConfig() { true, 64, 100, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); STATUS_INFLICTING_ARTIFACT_STATS.put( @@ -265,8 +316,10 @@ public McdarArtifactsStatsConfig() { true, 64, 100, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); STATUS_INFLICTING_ARTIFACT_STATS.put( @@ -275,8 +328,10 @@ public McdarArtifactsStatsConfig() { true, 64, 120, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); STATUS_INFLICTING_ARTIFACT_STATS.put( @@ -285,8 +340,10 @@ public McdarArtifactsStatsConfig() { true, 64, 60, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); STATUS_INFLICTING_ARTIFACT_STATS.put( @@ -295,8 +352,10 @@ public McdarArtifactsStatsConfig() { true, 64, 300, - 0.25f, - 0.1f + 2, + 1, + illager, + dungeon ) ); @@ -306,8 +365,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); SUMMONING_ARTIFACT_STATS.put( @@ -316,8 +377,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); SUMMONING_ARTIFACT_STATS.put( @@ -326,8 +389,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); SUMMONING_ARTIFACT_STATS.put( @@ -336,8 +401,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); SUMMONING_ARTIFACT_STATS.put( @@ -346,8 +413,10 @@ public McdarArtifactsStatsConfig() { true, 8, 600, - 0.25f, - 0.1f + 2, + 1, + villager, + dungeon ) ); } diff --git a/src/main/java/chronosacaria/mcdar/enums/AgilityArtifactID.java b/src/main/java/chronosacaria/mcdar/enums/AgilityArtifactID.java index 62c972c..33edd84 100644 --- a/src/main/java/chronosacaria/mcdar/enums/AgilityArtifactID.java +++ b/src/main/java/chronosacaria/mcdar/enums/AgilityArtifactID.java @@ -3,8 +3,12 @@ import chronosacaria.mcdar.Mcdar; import chronosacaria.mcdar.registries.ArtifactsRegistry; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.Identifier; import java.util.EnumMap; +import java.util.Set; public enum AgilityArtifactID implements IArtifactItem { BOOTS_OF_SWIFTNESS, @@ -27,12 +31,31 @@ public static EnumMap getItemsEnum() { } @Override - public Float mcdar$getGeneralArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(this).mcdar$getGeneralArtifactSpawnRate(); + public Set mcdar$getGeneralLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(this).mcdar$getGeneralLootTables(); + } + @Override + public Set mcdar$getDungeonLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(this).mcdar$getDungeonLootTables(); + } + + @Override + public void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getGeneralLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS + .get(this).mcdar$getGeneralArtifactSpawnWeight())); + } } @Override - public Float mcdar$getDungeonArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(this).mcdar$getDungeonArtifactSpawnRate(); + public void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getDungeonLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS + .get(this).mcdar$getDungeonArtifactSpawnWeight())); + } } } diff --git a/src/main/java/chronosacaria/mcdar/enums/DamagingArtifactID.java b/src/main/java/chronosacaria/mcdar/enums/DamagingArtifactID.java index e52f820..fe128c3 100644 --- a/src/main/java/chronosacaria/mcdar/enums/DamagingArtifactID.java +++ b/src/main/java/chronosacaria/mcdar/enums/DamagingArtifactID.java @@ -3,8 +3,12 @@ import chronosacaria.mcdar.Mcdar; import chronosacaria.mcdar.registries.ArtifactsRegistry; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.Identifier; import java.util.EnumMap; +import java.util.Set; public enum DamagingArtifactID implements IArtifactItem{ BLAST_FUNGUS, @@ -29,12 +33,30 @@ public static EnumMap getItemsEnum() { } @Override - public Float mcdar$getGeneralArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(this).mcdar$getGeneralArtifactSpawnRate(); + public Set mcdar$getGeneralLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(this).mcdar$getGeneralLootTables(); + } + @Override + public Set mcdar$getDungeonLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(this).mcdar$getDungeonLootTables(); + } + @Override + public void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getGeneralLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS + .get(this).mcdar$getGeneralArtifactSpawnWeight())); + } } @Override - public Float mcdar$getDungeonArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(this).mcdar$getDungeonArtifactSpawnRate(); + public void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getDungeonLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS + .get(this).mcdar$getDungeonArtifactSpawnWeight())); + } } } diff --git a/src/main/java/chronosacaria/mcdar/enums/DefensiveArtifactID.java b/src/main/java/chronosacaria/mcdar/enums/DefensiveArtifactID.java index 0099645..05a0c6b 100644 --- a/src/main/java/chronosacaria/mcdar/enums/DefensiveArtifactID.java +++ b/src/main/java/chronosacaria/mcdar/enums/DefensiveArtifactID.java @@ -3,8 +3,12 @@ import chronosacaria.mcdar.Mcdar; import chronosacaria.mcdar.registries.ArtifactsRegistry; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.Identifier; import java.util.EnumMap; +import java.util.Set; public enum DefensiveArtifactID implements IArtifactItem{ ENCHANTERS_TOME, @@ -17,7 +21,6 @@ public enum DefensiveArtifactID implements IArtifactItem{ TOTEM_OF_SOUL_PROTECTION, WIND_HORN; - public static EnumMap getItemsEnum() { return ArtifactsRegistry.DEFENSIVE_ARTIFACT; } @@ -33,12 +36,31 @@ public static EnumMap getItemsEnum() { } @Override - public Float mcdar$getGeneralArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(this).mcdar$getGeneralArtifactSpawnRate(); + public Set mcdar$getGeneralLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(this).mcdar$getGeneralLootTables(); + } + + @Override + public Set mcdar$getDungeonLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(this).mcdar$getDungeonLootTables(); + } + @Override + public void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getGeneralLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS + .get(this).mcdar$getGeneralArtifactSpawnWeight())); + } } @Override - public Float mcdar$getDungeonArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(this).mcdar$getDungeonArtifactSpawnRate(); + public void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getDungeonLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS + .get(this).mcdar$getDungeonArtifactSpawnWeight())); + } } } diff --git a/src/main/java/chronosacaria/mcdar/enums/IArtifactItem.java b/src/main/java/chronosacaria/mcdar/enums/IArtifactItem.java index 0fbfbf7..54352ca 100644 --- a/src/main/java/chronosacaria/mcdar/enums/IArtifactItem.java +++ b/src/main/java/chronosacaria/mcdar/enums/IArtifactItem.java @@ -1,6 +1,10 @@ package chronosacaria.mcdar.enums; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.util.Identifier; + +import java.util.Set; public interface IArtifactItem { @@ -8,6 +12,9 @@ public interface IArtifactItem { Item mcdar$getItem(); - Float mcdar$getGeneralArtifactSpawnRate(); - Float mcdar$getDungeonArtifactSpawnRate(); + Set mcdar$getGeneralLootTables(); + Set mcdar$getDungeonLootTables(); + + void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id); + void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id); } diff --git a/src/main/java/chronosacaria/mcdar/enums/QuiverArtifactID.java b/src/main/java/chronosacaria/mcdar/enums/QuiverArtifactID.java index 022987a..812f485 100644 --- a/src/main/java/chronosacaria/mcdar/enums/QuiverArtifactID.java +++ b/src/main/java/chronosacaria/mcdar/enums/QuiverArtifactID.java @@ -3,8 +3,12 @@ import chronosacaria.mcdar.Mcdar; import chronosacaria.mcdar.registries.ArtifactsRegistry; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.Identifier; import java.util.EnumMap; +import java.util.Set; public enum QuiverArtifactID implements IArtifactItem { FLAMING_QUIVER, @@ -12,7 +16,6 @@ public enum QuiverArtifactID implements IArtifactItem { THUNDERING_QUIVER, TORMENT_QUIVER; - public static EnumMap getItemsEnum() { return ArtifactsRegistry.QUIVER_ARTIFACT; } @@ -28,12 +31,31 @@ public static EnumMap getItemsEnum() { } @Override - public Float mcdar$getGeneralArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(this).mcdar$getGeneralArtifactSpawnRate(); + public Set mcdar$getGeneralLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(this).mcdar$getGeneralLootTables(); + } + + @Override + public Set mcdar$getDungeonLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(this).mcdar$getDungeonLootTables(); + } + @Override + public void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getGeneralLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS + .get(this).mcdar$getGeneralArtifactSpawnWeight())); + } } @Override - public Float mcdar$getDungeonArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(this).mcdar$getDungeonArtifactSpawnRate(); + public void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getDungeonLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS + .get(this).mcdar$getDungeonArtifactSpawnWeight())); + } } } diff --git a/src/main/java/chronosacaria/mcdar/enums/StatusInflictingArtifactID.java b/src/main/java/chronosacaria/mcdar/enums/StatusInflictingArtifactID.java index 8a3565b..bbb9a17 100644 --- a/src/main/java/chronosacaria/mcdar/enums/StatusInflictingArtifactID.java +++ b/src/main/java/chronosacaria/mcdar/enums/StatusInflictingArtifactID.java @@ -3,8 +3,12 @@ import chronosacaria.mcdar.Mcdar; import chronosacaria.mcdar.registries.ArtifactsRegistry; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.Identifier; import java.util.EnumMap; +import java.util.Set; public enum StatusInflictingArtifactID implements IArtifactItem { CORRUPTED_SEEDS, @@ -28,12 +32,31 @@ public static EnumMap getItemsEnum() { } @Override - public Float mcdar$getGeneralArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(this).mcdar$getGeneralArtifactSpawnRate(); + public Set mcdar$getGeneralLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(this).mcdar$getGeneralLootTables(); } @Override - public Float mcdar$getDungeonArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(this).mcdar$getDungeonArtifactSpawnRate(); + public Set mcdar$getDungeonLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(this).mcdar$getDungeonLootTables(); + } + @Override + public void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getGeneralLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS + .get(this).mcdar$getGeneralArtifactSpawnWeight())); + } + } + + @Override + public void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getDungeonLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS + .get(this).mcdar$getDungeonArtifactSpawnWeight())); + } } } diff --git a/src/main/java/chronosacaria/mcdar/enums/SummoningArtifactID.java b/src/main/java/chronosacaria/mcdar/enums/SummoningArtifactID.java index 1249a4e..7e075c0 100644 --- a/src/main/java/chronosacaria/mcdar/enums/SummoningArtifactID.java +++ b/src/main/java/chronosacaria/mcdar/enums/SummoningArtifactID.java @@ -3,8 +3,12 @@ import chronosacaria.mcdar.Mcdar; import chronosacaria.mcdar.registries.ArtifactsRegistry; import net.minecraft.item.Item; +import net.minecraft.loot.LootPool; +import net.minecraft.loot.entry.ItemEntry; +import net.minecraft.util.Identifier; import java.util.EnumMap; +import java.util.Set; public enum SummoningArtifactID implements IArtifactItem{ BUZZY_NEST, @@ -28,12 +32,31 @@ public static EnumMap getItemsEnum() { } @Override - public Float mcdar$getGeneralArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(this).mcdar$getGeneralArtifactSpawnRate(); + public Set mcdar$getGeneralLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(this).mcdar$getGeneralLootTables(); } @Override - public Float mcdar$getDungeonArtifactSpawnRate() { - return Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(this).mcdar$getDungeonArtifactSpawnRate(); + public Set mcdar$getDungeonLootTables() { + return Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS.get(this).mcdar$getDungeonLootTables(); + } + @Override + public void mcdar$insertIntoGeneralLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getGeneralLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS + .get(this).mcdar$getGeneralArtifactSpawnWeight())); + } + } + + @Override + public void mcdar$insertIntoDungeonLootPool(LootPool.Builder lootPoolBuilder, Identifier id) { + if (this.mcdar$getDungeonLootTables().contains(id.toString())) { + lootPoolBuilder + .with(ItemEntry.builder(this.mcdar$getItem()) + .weight(Mcdar.CONFIG.mcdarArtifactsStatsConfig.SUMMONING_ARTIFACT_STATS + .get(this).mcdar$getDungeonArtifactSpawnWeight())); + } } } diff --git a/src/main/java/chronosacaria/mcdar/registries/LootRegistry.java b/src/main/java/chronosacaria/mcdar/registries/LootRegistry.java index 3a5b2a7..62ff28b 100644 --- a/src/main/java/chronosacaria/mcdar/registries/LootRegistry.java +++ b/src/main/java/chronosacaria/mcdar/registries/LootRegistry.java @@ -1,179 +1,47 @@ package chronosacaria.mcdar.registries; import chronosacaria.mcdar.Mcdar; -import chronosacaria.mcdar.enums.*; +import chronosacaria.mcdar.api.GroupedObjectsHelper; +import chronosacaria.mcdar.enums.IArtifactItem; +import net.fabricmc.fabric.api.loot.v2.FabricLootTableBuilder; import net.fabricmc.fabric.api.loot.v2.LootTableEvents; -import net.minecraft.item.Item; import net.minecraft.loot.LootPool; -import net.minecraft.loot.LootTables; import net.minecraft.loot.condition.RandomChanceLootCondition; -import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.provider.number.ConstantLootNumberProvider; import net.minecraft.util.Identifier; -import net.minecraft.util.math.random.Random; -import java.util.Collection; import java.util.List; -import java.util.Set; public class LootRegistry { - public static final Collection ILLAGER_ARTIFACT_LOOT_TABLES = - Set.of(LootTables.WOODLAND_MANSION_CHEST, LootTables.PILLAGER_OUTPOST_CHEST); - - public static final Collection VILLAGER_ARTIFACT_LOOT_TABLES = - Set.of(LootTables.VILLAGE_ARMORER_CHEST, LootTables.VILLAGE_BUTCHER_CHEST, - LootTables.VILLAGE_CARTOGRAPHER_CHEST, LootTables.VILLAGE_FISHER_CHEST, - LootTables.VILLAGE_FLETCHER_CHEST, LootTables.VILLAGE_DESERT_HOUSE_CHEST, - LootTables.VILLAGE_MASON_CHEST, LootTables.VILLAGE_PLAINS_CHEST, - LootTables.VILLAGE_SAVANNA_HOUSE_CHEST, LootTables.VILLAGE_SHEPARD_CHEST, - LootTables.VILLAGE_SNOWY_HOUSE_CHEST, LootTables.VILLAGE_TAIGA_HOUSE_CHEST, - LootTables.VILLAGE_TANNERY_CHEST, LootTables.VILLAGE_TEMPLE_CHEST, - LootTables.VILLAGE_TOOLSMITH_CHEST); - public static final Collection WORLD_CHESTS = - Set.of(LootTables.ABANDONED_MINESHAFT_CHEST, LootTables.SIMPLE_DUNGEON_CHEST, LootTables.SHIPWRECK_TREASURE_CHEST); - - public static final List illagerArtifacts = List.of( - DamagingArtifactID.BLAST_FUNGUS, - DamagingArtifactID.HARVESTER, - DamagingArtifactID.LIGHTNING_ROD, - DamagingArtifactID.POWERSHAKER, - StatusInflictingArtifactID.CORRUPTED_SEEDS, - StatusInflictingArtifactID.GONG_OF_WEAKENING, - StatusInflictingArtifactID.SATCHEL_OF_ELEMENTS, - StatusInflictingArtifactID.SHOCK_POWDER, - AgilityArtifactID.DEATH_CAP_MUSHROOM, - DefensiveArtifactID.ENCHANTERS_TOME, - DefensiveArtifactID.SOUL_HEALER, - DefensiveArtifactID.TOTEM_OF_REGENERATION, - DefensiveArtifactID.TOTEM_OF_SHIELDING, - DefensiveArtifactID.TOTEM_OF_SOUL_PROTECTION, - QuiverArtifactID.HARPOON_QUIVER, - QuiverArtifactID.THUNDERING_QUIVER, - QuiverArtifactID.TORMENT_QUIVER - ); - public static final List illagerArtifactSpawnRates = List.of( - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(DamagingArtifactID.BLAST_FUNGUS).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(DamagingArtifactID.HARVESTER).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(DamagingArtifactID.LIGHTNING_ROD).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DAMAGING_ARTIFACT_STATS.get(DamagingArtifactID.POWERSHAKER).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(StatusInflictingArtifactID.CORRUPTED_SEEDS).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(StatusInflictingArtifactID.GONG_OF_WEAKENING).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(StatusInflictingArtifactID.SATCHEL_OF_ELEMENTS).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.STATUS_INFLICTING_ARTIFACT_STATS.get(StatusInflictingArtifactID.SHOCK_POWDER).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.AGILITY_ARTIFACT_STATS.get(AgilityArtifactID.DEATH_CAP_MUSHROOM).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(DefensiveArtifactID.ENCHANTERS_TOME).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(DefensiveArtifactID.SOUL_HEALER).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(DefensiveArtifactID.TOTEM_OF_REGENERATION).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(DefensiveArtifactID.TOTEM_OF_SHIELDING).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.DEFENSIVE_ARTIFACT_STATS.get(DefensiveArtifactID.TOTEM_OF_SOUL_PROTECTION).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(QuiverArtifactID.HARPOON_QUIVER).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(QuiverArtifactID.THUNDERING_QUIVER).mcdar$getGeneralArtifactSpawnRate(), - Mcdar.CONFIG.mcdarArtifactsStatsConfig.QUIVER_ARTIFACT_STATS.get(QuiverArtifactID.TORMENT_QUIVER).mcdar$getGeneralArtifactSpawnRate() - ); - - public static final List villagerArtifacts = List.of( - AgilityArtifactID.BOOTS_OF_SWIFTNESS, - SummoningArtifactID.BUZZY_NEST, - SummoningArtifactID.ENCHANTED_GRASS, - QuiverArtifactID.FLAMING_QUIVER, - AgilityArtifactID.GHOST_CLOAK, - SummoningArtifactID.GOLEM_KIT, - DefensiveArtifactID.IRON_HIDE_AMULET, - AgilityArtifactID.LIGHT_FEATHER, - SummoningArtifactID.TASTY_BONE, - DamagingArtifactID.UPDRAFT_TOME, - DefensiveArtifactID.WIND_HORN, - SummoningArtifactID.WONDERFUL_WHEAT - ); - - public static final List allArtifacts = List.of( - DamagingArtifactID.BLAST_FUNGUS, - StatusInflictingArtifactID.CORRUPTED_SEEDS, - AgilityArtifactID.DEATH_CAP_MUSHROOM, - DefensiveArtifactID.ENCHANTERS_TOME, - StatusInflictingArtifactID.GONG_OF_WEAKENING, - QuiverArtifactID.HARPOON_QUIVER, - DamagingArtifactID.HARVESTER, - DamagingArtifactID.LIGHTNING_ROD, - DamagingArtifactID.POWERSHAKER, - StatusInflictingArtifactID.SATCHEL_OF_ELEMENTS, - StatusInflictingArtifactID.SHOCK_POWDER, - DefensiveArtifactID.SOUL_HEALER, - QuiverArtifactID.THUNDERING_QUIVER, - QuiverArtifactID.TORMENT_QUIVER, - DefensiveArtifactID.TOTEM_OF_REGENERATION, - DefensiveArtifactID.TOTEM_OF_SHIELDING, - DefensiveArtifactID.TOTEM_OF_SOUL_PROTECTION, - AgilityArtifactID.BOOTS_OF_SWIFTNESS, - SummoningArtifactID.BUZZY_NEST, - SummoningArtifactID.ENCHANTED_GRASS, - QuiverArtifactID.FLAMING_QUIVER, - AgilityArtifactID.GHOST_CLOAK, - SummoningArtifactID.GOLEM_KIT, - DefensiveArtifactID.IRON_HIDE_AMULET, - AgilityArtifactID.LIGHT_FEATHER, - SummoningArtifactID.TASTY_BONE, - DamagingArtifactID.UPDRAFT_TOME, - DefensiveArtifactID.WIND_HORN, - SummoningArtifactID.WONDERFUL_WHEAT); - - public static void register(){ - Random randomArtifact = Random.create(); - LootTableEvents.MODIFY.register(((resourceManager, lootManager, id, tableBuilder, source) -> { - if (ILLAGER_ARTIFACT_LOOT_TABLES.contains(id)) { - LootPool.Builder lootPoolBuilder = LootPool.builder(); - int selectedArtifact = randomArtifact.nextBetween(0, 16); - lootPoolBuilder.rolls(ConstantLootNumberProvider.create(1)); - - for (IArtifactItem artifactItem : illagerArtifacts) { - lootPoolBuilder.conditionally( - RandomChanceLootCondition.builder( - illagerArtifactSpawnRates.get(selectedArtifact) - ) - ); - if (illagerArtifacts.get(selectedArtifact).mcdar$isEnabled()) { - addArtifact(lootPoolBuilder, artifactItem.mcdar$getItem()); - } - } - tableBuilder.pool(lootPoolBuilder.build()); - - } - else if (VILLAGER_ARTIFACT_LOOT_TABLES.contains(id)) { - LootPool.Builder lootPoolBuilder = LootPool.builder(); - lootPoolBuilder.rolls(ConstantLootNumberProvider.create(1)); - for (IArtifactItem artifactItem : List.of(AgilityArtifactID.BOOTS_OF_SWIFTNESS, SummoningArtifactID.BUZZY_NEST, SummoningArtifactID.ENCHANTED_GRASS, - QuiverArtifactID.FLAMING_QUIVER, AgilityArtifactID.GHOST_CLOAK, SummoningArtifactID.GOLEM_KIT, DefensiveArtifactID.IRON_HIDE_AMULET, - AgilityArtifactID.LIGHT_FEATHER, SummoningArtifactID.TASTY_BONE, DamagingArtifactID.UPDRAFT_TOME, DefensiveArtifactID.WIND_HORN, - SummoningArtifactID.WONDERFUL_WHEAT)) { - lootPoolBuilder.conditionally(RandomChanceLootCondition.builder(artifactItem.mcdar$getGeneralArtifactSpawnRate())); - if (artifactItem.mcdar$isEnabled()) - addArtifact(lootPoolBuilder, artifactItem.mcdar$getItem()); - tableBuilder.pool(lootPoolBuilder.build()); - } - } - else if (WORLD_CHESTS.contains(id)) { - LootPool.Builder lootPoolBuilder = LootPool.builder(); - lootPoolBuilder.rolls(ConstantLootNumberProvider.create(1)); - for (IArtifactItem artifactItem : List.of(DamagingArtifactID.BLAST_FUNGUS, StatusInflictingArtifactID.CORRUPTED_SEEDS, AgilityArtifactID.DEATH_CAP_MUSHROOM, - DefensiveArtifactID.ENCHANTERS_TOME, StatusInflictingArtifactID.GONG_OF_WEAKENING, QuiverArtifactID.HARPOON_QUIVER, DamagingArtifactID.HARVESTER, - DamagingArtifactID.LIGHTNING_ROD, DamagingArtifactID.POWERSHAKER, StatusInflictingArtifactID.SATCHEL_OF_ELEMENTS, StatusInflictingArtifactID.SHOCK_POWDER, - DefensiveArtifactID.SOUL_HEALER, QuiverArtifactID.THUNDERING_QUIVER, QuiverArtifactID.TORMENT_QUIVER, DefensiveArtifactID.TOTEM_OF_REGENERATION, - DefensiveArtifactID.TOTEM_OF_SHIELDING, DefensiveArtifactID.TOTEM_OF_SOUL_PROTECTION, AgilityArtifactID.BOOTS_OF_SWIFTNESS, SummoningArtifactID.BUZZY_NEST, - SummoningArtifactID.ENCHANTED_GRASS, QuiverArtifactID.FLAMING_QUIVER, AgilityArtifactID.GHOST_CLOAK, SummoningArtifactID.GOLEM_KIT, DefensiveArtifactID.IRON_HIDE_AMULET, - AgilityArtifactID.LIGHT_FEATHER, SummoningArtifactID.TASTY_BONE, DamagingArtifactID.UPDRAFT_TOME, DefensiveArtifactID.WIND_HORN, SummoningArtifactID.WONDERFUL_WHEAT)) { - lootPoolBuilder.conditionally(RandomChanceLootCondition.builder(artifactItem.mcdar$getDungeonArtifactSpawnRate())); - if (artifactItem.mcdar$isEnabled()) - addArtifact(lootPoolBuilder, artifactItem.mcdar$getItem()); - tableBuilder.pool(lootPoolBuilder.build()); - } - } + mcdar$artifactsGeneralLootBuilder(GroupedObjectsHelper.illagerArtifacts, id, tableBuilder); + mcdar$artifactsGeneralLootBuilder(GroupedObjectsHelper.villagerArtifacts, id, tableBuilder); + mcdar$artifactsDungeonLootBuilder(id, tableBuilder); })); } - public static void addArtifact(LootPool.Builder poolBuilder, Item artifact){ - poolBuilder.with(ItemEntry.builder(artifact).build()); + private static void mcdar$artifactsGeneralLootBuilder(List artifactItemList, Identifier id, FabricLootTableBuilder tableBuilder) { + LootPool.Builder lootPoolBuilder = LootPool.builder(); + lootPoolBuilder.rolls(ConstantLootNumberProvider.create(1)) + .conditionally(RandomChanceLootCondition.builder(Mcdar.CONFIG.mcdarArtifactsStatsConfig.ARTIFACT_GENERAL_SPAWN_CHANCE)); + for (IArtifactItem artifactItem : artifactItemList) { + if (!artifactItem.mcdar$isEnabled()) + continue; + artifactItem.mcdar$insertIntoGeneralLootPool(lootPoolBuilder, id); + } + tableBuilder.pool(lootPoolBuilder.build()); + } + private static void mcdar$artifactsDungeonLootBuilder(Identifier id, FabricLootTableBuilder tableBuilder) { + LootPool.Builder lootPoolBuilder = LootPool.builder(); + lootPoolBuilder.rolls(ConstantLootNumberProvider.create(1)) + .conditionally(RandomChanceLootCondition.builder(Mcdar.CONFIG.mcdarArtifactsStatsConfig.ARTIFACT_DUNGEON_SPAWN_CHANCE)); + for (IArtifactItem artifactItem : GroupedObjectsHelper.allArtifacts) { + if (!artifactItem.mcdar$isEnabled()) + continue; + artifactItem.mcdar$insertIntoDungeonLootPool(lootPoolBuilder, id); + } + tableBuilder.pool(lootPoolBuilder.build()); } } diff --git a/src/main/resources/data/minecraft/tags/entity_types/beehive_inhabitors.json b/src/main/resources/data/minecraft/tags/entity_types/beehive_inhabitors.json new file mode 100644 index 0000000..d665913 --- /dev/null +++ b/src/main/resources/data/minecraft/tags/entity_types/beehive_inhabitors.json @@ -0,0 +1,5 @@ +{ + "values": [ + "mcdar:buzzy_nest_bee" + ] +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index e519d53..fbb677d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "mcdar", "version": "${version}", "name": "MC Dungeons Artifacts", - "description": "Bringing the artefacts of Minecraft Dungeons to Minecraft", + "description": "Bringing the artifacts of Minecraft Dungeons to Minecraft", "authors": [ "Chronosacaria", "Kluzzio", @@ -12,7 +12,7 @@ "Patreons (Support)" ], "contact": {}, - "license": "Timefall Development License", + "license": "Timefall Development License 1.2", "icon": "assets/mcdar/icon.png", "environment": "*", "entrypoints": { @@ -30,6 +30,6 @@ "depends": { "fabricloader": ">=0.11.3", "fabric": "*", - "minecraft": ">=1.20.0" + "minecraft": ">=1.20.0 <=1.20.1" } }