diff --git a/gradle.properties b/gradle.properties index b2456861..b68bed0b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=reliquary mod_group_id=reliquary -mod_version=2.0.44 +mod_version=2.0.45 sonar_project_key=xreliquary:Reliquary github_package_url=https://maven.pkg.github.com/P3pp3rF1y/Reliquary diff --git a/src/main/java/reliquary/blocks/tile/ApothecaryCauldronBlockEntity.java b/src/main/java/reliquary/blocks/tile/ApothecaryCauldronBlockEntity.java index 474c56bb..c4df5505 100644 --- a/src/main/java/reliquary/blocks/tile/ApothecaryCauldronBlockEntity.java +++ b/src/main/java/reliquary/blocks/tile/ApothecaryCauldronBlockEntity.java @@ -302,9 +302,8 @@ private int getRedstoneAmpLimit() { private Set getHeatSources() { Set heatSources = new HashSet<>(); - List heatSourceBlockNames = Settings.COMMON.blocks.apothecaryCauldron.heatSources.get(); - - heatSourceBlockNames.forEach(blockName -> heatSources.add(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockName)))); + Settings.COMMON.blocks.apothecaryCauldron.heatSources.get() + .forEach(blockName -> heatSources.add(ForgeRegistries.BLOCKS.getValue(new ResourceLocation(blockName)))); //defaults that can't be removed. heatSources.add(Blocks.LAVA); heatSources.add(Blocks.FIRE); diff --git a/src/main/java/reliquary/entities/shot/ShotEntityBase.java b/src/main/java/reliquary/entities/shot/ShotEntityBase.java index 2565c664..9d80f300 100644 --- a/src/main/java/reliquary/entities/shot/ShotEntityBase.java +++ b/src/main/java/reliquary/entities/shot/ShotEntityBase.java @@ -37,10 +37,7 @@ import reliquary.util.potions.XRPotionHelper; import javax.annotation.Nullable; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; +import java.util.*; @SuppressWarnings("squid:S2160") public abstract class ShotEntityBase extends Projectile { @@ -393,7 +390,7 @@ private void ricochet(Direction sideHit) { */ void seekTarget() { Entity closestTarget = null; - List huntableEntitiesBlacklist = Settings.COMMON.items.seekerShot.huntableEntitiesBlacklist.get(); + Set huntableEntitiesBlacklist = new HashSet<>(Settings.COMMON.items.seekerShot.huntableEntitiesBlacklist.get()); List targetsList = level().getEntities(this, new AABB(getX() - 5, getY() - 5, getZ() - 5, getX() + 5, getY() + 5, getZ() + 5), Mob.class::isInstance); diff --git a/src/main/java/reliquary/items/MidasTouchstoneItem.java b/src/main/java/reliquary/items/MidasTouchstoneItem.java index c378ec49..5949f9fe 100644 --- a/src/main/java/reliquary/items/MidasTouchstoneItem.java +++ b/src/main/java/reliquary/items/MidasTouchstoneItem.java @@ -3,16 +3,7 @@ import com.google.common.collect.ImmutableMap; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ArmorItem; -import net.minecraft.world.item.ArmorMaterial; -import net.minecraft.world.item.ArmorMaterials; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.item.Rarity; -import net.minecraft.world.item.Tier; -import net.minecraft.world.item.TieredItem; -import net.minecraft.world.item.Tiers; +import net.minecraft.world.item.*; import net.minecraft.world.level.Level; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -81,8 +72,6 @@ public void inventoryTick(ItemStack stack, Level world, Entity e, int i, boolean } private void doRepairAndDamageTouchstone(ItemStack touchstone, Player player) { - List goldItems = Settings.COMMON.items.midasTouchstone.goldItems.get(); - InventoryHelper.getItemHandlerFrom(player, null).ifPresent(itemHandler -> { for (int slot = 0; slot < itemHandler.getSlots(); slot++) { ItemStack stack = itemHandler.getStackInSlot(slot); @@ -92,7 +81,7 @@ private void doRepairAndDamageTouchstone(ItemStack touchstone, Player player) { continue; } - tryRepairingItem(touchstone, player, goldItems, stack, item); + tryRepairingItem(touchstone, player, Settings.COMMON.items.midasTouchstone.getGoldItems(), stack, item); } }); } diff --git a/src/main/java/reliquary/reference/Settings.java b/src/main/java/reliquary/reference/Settings.java index c645babb..8f291af3 100644 --- a/src/main/java/reliquary/reference/Settings.java +++ b/src/main/java/reliquary/reference/Settings.java @@ -6,32 +6,26 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Items; import net.minecraftforge.common.ForgeConfigSpec; -import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; -import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; -import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; -import net.minecraftforge.common.ForgeConfigSpec.EnumValue; -import net.minecraftforge.common.ForgeConfigSpec.IntValue; +import net.minecraftforge.common.ForgeConfigSpec.*; import net.minecraftforge.fml.event.config.ModConfigEvent; import net.minecraftforge.registries.ForgeRegistries; import org.apache.commons.lang3.tuple.Pair; import reliquary.client.gui.hud.HUDPosition; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; +import java.util.*; +import java.util.function.Predicate; +import java.util.regex.Pattern; import static reliquary.util.RegistryHelper.getItemRegistryName; -@SuppressWarnings("squid:S1192") //no issue repeating the same string literal as they are independent +@SuppressWarnings({"java:S4968", "squid:S1192"}) // ? extends String is the type parameter returned from defineList so it can't be just String here | no issue repeating the same string literal as they are independent public class Settings { private Settings() {} private static final int ITEM_CAP = 9999; + private static final Pattern REGISTRY_NAME_PATTERN = Pattern.compile("([a-z0-9_.-]+:[a-z0-9_/.-]+)"); + private static final Predicate REGISTRY_NAME_MATCHER = o -> o instanceof String s && REGISTRY_NAME_PATTERN.matcher(s).matches(); @SuppressWarnings("unused") // parameter needs to stay for addListener logic to recognize what this method is listening to public static void onFileChange(ModConfigEvent.Reloading configEvent) { @@ -354,7 +348,7 @@ public static class AngelHeartVialSettings { public final DestructionCatalystSettings destructionCatalyst; public static class DestructionCatalystSettings { - public final ConfigValue> mundaneBlocks; + public final ConfigValue> mundaneBlocks; public final IntValue gunpowderCost; public final IntValue gunpowderWorth; public final IntValue gunpowderLimit; @@ -367,7 +361,7 @@ public static class DestructionCatalystSettings { mundaneBlocks = builder .comment("List of mundane blocks the catalyst will break") - .define("mundaneBlocks", Lists.newArrayList( + .defineList("mundaneBlocks", Lists.newArrayList( "minecraft:dirt", "minecraft:coarse_dirt", "minecraft:podzol", @@ -384,7 +378,7 @@ public static class DestructionCatalystSettings { "minecraft:snow", "minecraft:soul_sand", "minecraft:netherrack", - "minecraft:end_stone")); + "minecraft:end_stone"), REGISTRY_NAME_MATCHER); gunpowderCost = builder .comment("Number of gunpowder it costs per catalyst use") @@ -714,7 +708,6 @@ public static class InfernalClawsSettings { public static class InfernalTearSettings { private static final String ITEM_EXPERIENCE_MATCHER = "([a-z1-9_.-]+:[a-z1-9_/.-]+)\\|\\d+"; public final BooleanValue absorbWhenCreated; - @SuppressWarnings("java:S4968") // ? extends String is the type parameter returned from defineList so it can't be just String here public final ForgeConfigSpec.ConfigValue> itemExperienceList; @Nullable private Map itemExperience = null; @@ -794,7 +787,7 @@ public static class KrakenShellSettings { public final LanternOfParanoiaSettings lanternOfParanoia; public static class LanternOfParanoiaSettings { - public final ConfigValue> torches; + public final ConfigValue> torches; public final IntValue minLightLevel; public final IntValue placementScanRadius; @@ -803,7 +796,7 @@ public static class LanternOfParanoiaSettings { torches = builder .comment("List of torches that are supported by the lantern") - .define("torches", Lists.newArrayList(getItemRegistryName(Items.TORCH))); + .defineList("torches", Lists.newArrayList(getItemRegistryName(Items.TORCH)), REGISTRY_NAME_MATCHER); minLightLevel = builder .comment("Minimum light level below which the lantern will place torches") .defineInRange("minLightLevel", 1, 0, 15); @@ -819,7 +812,7 @@ public static class LanternOfParanoiaSettings { public final MidasTouchstoneSettings midasTouchstone; public static class MidasTouchstoneSettings { - public final ConfigValue> goldItems; + public final ConfigValue> goldItems; public final IntValue glowstoneCost; public final IntValue glowstoneWorth; public final IntValue glowstoneLimit; @@ -829,7 +822,7 @@ public static class MidasTouchstoneSettings { goldItems = builder .comment("Gold items that can be repaired by the touchstone") - .define("goldItems", new ArrayList<>()); + .defineListAllowEmpty("goldItems", new ArrayList<>(), REGISTRY_NAME_MATCHER); glowstoneCost = builder .comment("Number of glowstone that the repair costs") @@ -845,6 +838,10 @@ public static class MidasTouchstoneSettings { builder.pop(); } + + public List getGoldItems() { + return getStringList(goldItems.get()); + } } public final MobCharmSettings mobCharm; @@ -1015,8 +1012,8 @@ public static class RendingGaleSettings { public final BooleanValue canPushProjectiles; public final IntValue pedestalFlightRange; public final IntValue pedestalCostPerSecond; - public final ConfigValue> pushableEntitiesBlacklist; - public final ConfigValue> pushableProjectilesBlacklist; + public final ConfigValue> pushableEntitiesBlacklist; + public final ConfigValue> pushableProjectilesBlacklist; RendingGaleSettings(ForgeConfigSpec.Builder builder) { builder.comment("Rending Gale settings").push("rendingGale"); @@ -1059,11 +1056,11 @@ public static class RendingGaleSettings { pushableEntitiesBlacklist = builder .comment("List of entities that are banned from being pushed by the Rending Gale") - .define("pushableEntitiesBlacklist", new ArrayList<>()); + .defineListAllowEmpty("pushableEntitiesBlacklist", new ArrayList<>(), REGISTRY_NAME_MATCHER); pushableProjectilesBlacklist = builder .comment("List of projectiles that are banned from being pushed by the Rending Gale") - .define("pushableProjectilesBlacklist", new ArrayList<>()); + .defineListAllowEmpty("pushableProjectilesBlacklist", new ArrayList<>(), REGISTRY_NAME_MATCHER); builder.pop(); } @@ -1079,7 +1076,6 @@ public static class RodOfLyssaSettings { public final BooleanValue failStealFromVacantSlots; public final BooleanValue angerOnStealFailure; public final BooleanValue stealFromPlayers; - private static final String ENTITY_NAME_MATCHER = "[a-z1-9_.-]+:[a-z1-9_/.-]+"; @SuppressWarnings("java:S4968") // ? extends String is the type parameter returned from defineList so it can't be just String here public final ForgeConfigSpec.ConfigValue> entityBlockList; @Nullable @@ -1117,7 +1113,7 @@ public static class RodOfLyssaSettings { .define("stealFromPlayers", true); entityBlockList = builder.comment("List of entities on which lyssa rod doesn't work - full registry name is required here") - .defineList("entityBlockList", new ArrayList<>(), mapping -> ((String) mapping).matches(ENTITY_NAME_MATCHER)); + .defineListAllowEmpty("entityBlockList", new ArrayList<>(), REGISTRY_NAME_MATCHER); builder.pop(); } @@ -1142,14 +1138,14 @@ private void initBlockedEntityTypes() { public final SeekerShotSettings seekerShot; public static class SeekerShotSettings { - public final ConfigValue> huntableEntitiesBlacklist; + public final ConfigValue> huntableEntitiesBlacklist; SeekerShotSettings(ForgeConfigSpec.Builder builder) { builder.comment("Seeker Shot settings").push("seekerShot"); huntableEntitiesBlacklist = builder .comment("Entities that are banned from being tracked by seeker shot") - .define("huntableEntitiesBlacklist", new ArrayList<>()); + .defineListAllowEmpty("huntableEntitiesBlacklist", new ArrayList<>(), REGISTRY_NAME_MATCHER); builder.pop(); } @@ -1158,7 +1154,7 @@ public static class SeekerShotSettings { public final SojournerStaffSettings sojournerStaff; public static class SojournerStaffSettings { - public final ConfigValue> torches; + public final ConfigValue> torches; public final IntValue maxCapacityPerItemType; public final IntValue maxRange; public final IntValue tilePerCostMultiplier; @@ -1168,7 +1164,7 @@ public static class SojournerStaffSettings { torches = builder .comment("List of torches that are supported by the staff") - .define("torches", getDefaultTorches()); + .defineList("torches", getDefaultTorches(), REGISTRY_NAME_MATCHER); maxCapacityPerItemType = builder .comment("Number of items the staff can store per item type") @@ -1286,7 +1282,7 @@ public static class AltarSettings { public static class ApothecaryCauldronSettings { public final IntValue redstoneLimit; public final IntValue cookTime; - public final ConfigValue> heatSources; + public final ConfigValue> heatSources; public final IntValue glowstoneLimit; ApothecaryCauldronSettings(ForgeConfigSpec.Builder builder) { @@ -1302,7 +1298,7 @@ public static class ApothecaryCauldronSettings { heatSources = builder .comment("List of acceptable heat sources") - .define("heatSources", new ArrayList<>()); + .defineListAllowEmpty("heatSources", new ArrayList<>(), REGISTRY_NAME_MATCHER); glowstoneLimit = builder .comment("Limit of glowstone that can be used in cauldron to make POTION more potent") @@ -1343,8 +1339,8 @@ public static class FertileLilypadSettings { public static class InterdictionTorchSettings { public final IntValue pushRadius; public final BooleanValue canPushProjectiles; - public final ConfigValue> pushableEntitiesBlacklist; - public final ConfigValue> pushableProjectilesBlacklist; + public final ConfigValue> pushableEntitiesBlacklist; + public final ConfigValue> pushableProjectilesBlacklist; InterdictionTorchSettings(ForgeConfigSpec.Builder builder) { builder.comment("Interdiction Torch settings").push("interdictionTorch"); @@ -1359,11 +1355,11 @@ public static class InterdictionTorchSettings { pushableEntitiesBlacklist = builder .comment("List of entities that are banned from being pushed by the torch") - .define("pushableEntitiesBlacklist", new ArrayList<>()); + .defineListAllowEmpty("pushableEntitiesBlacklist", new ArrayList<>(), REGISTRY_NAME_MATCHER); pushableProjectilesBlacklist = builder .comment("List of projectiles that are banned from being pushed by the torch") - .define("pushableProjectilesBlacklist", new ArrayList<>()); + .defineListAllowEmpty("pushableProjectilesBlacklist", new ArrayList<>(), REGISTRY_NAME_MATCHER); builder.pop(); } @@ -1435,4 +1431,9 @@ public static class PedestalSettings { COMMON_SPEC = specPair.getRight(); COMMON = specPair.getLeft(); } + + @SuppressWarnings("unchecked") + private static List getStringList(List list) { + return (List) list; + } } diff --git a/src/main/resources/assets/reliquary/textures/item/fortune_coin - Copy.png b/src/main/resources/assets/reliquary/textures/item/fortune_coin - Copy.png deleted file mode 100644 index 55a94573..00000000 Binary files a/src/main/resources/assets/reliquary/textures/item/fortune_coin - Copy.png and /dev/null differ