diff --git a/gradle.properties b/gradle.properties index 0307b97a..149393bf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,15 +12,15 @@ minecraft_version=1.21 # as they do not follow standard versioning conventions. minecraft_version_range=[1.21,1.22) # The Neo version must agree with the Minecraft version to get a valid artifact -neo_version=21.0.21-beta +neo_version=21.0.30-beta # The Neo version range can use any version of Neo as bounds -neo_version_range=[21.0.21-beta,) +neo_version_range=[21.0.30-beta,) # The loader version range can only use the major version of FML as bounds loader_version_range=[2,) # read more on this at https://github.com/neoforged/NeoGradle/blob/NG_7.0/README.md#apply-parchment-mappings # you can also find the latest versions at: https://parchmentmc.org/docs/getting-started -neogradle.subsystems.parchment.minecraftVersion=1.20.6 -neogradle.subsystems.parchment.mappingsVersion=2024.06.16 +neogradle.subsystems.parchment.minecraftVersion=1.21 +neogradle.subsystems.parchment.mappingsVersion=2024.06.23 # https://www.curseforge.com/minecraft/mc-mods/jade/files/all jade_id=5444008 jade_api=5427895 diff --git a/src/generated/resources/assets/allomancy/lang/en_us.json b/src/generated/resources/assets/allomancy/lang/en_us.json index f2d73684..01345a82 100644 --- a/src/generated/resources/assets/allomancy/lang/en_us.json +++ b/src/generated/resources/assets/allomancy/lang/en_us.json @@ -7,12 +7,12 @@ "advancements.consequences.title": "Consequences, Vin", "advancements.dna_entangled.desc": "Your DNA is too entangled with the spiritual realm to use Lerasium", "advancements.dna_entangled.title": "Spiritual DNA Entanglement", + "advancements.going_loud.desc": "Allomancy can grant great stealth, unless you do that!", + "advancements.going_loud.title": "Going Loud", "advancements.local_metallurgist.desc": "Craft a grinder to begin mixing metals", "advancements.local_metallurgist.title": "Local Metallurgist!", "advancements.metallic_collector.desc": "Collect every single metallic flake, even the useless ones", "advancements.metallic_collector.title": "Metallic Collector", - "advancements.noisey.desc": "Allomancy can grant great stealth, unless you do that!", - "advancements.noisey.title": "Going Loud", "advancements.tin_foil_hat.desc": "Protect yourself, and be a bit paranoid too", "advancements.tin_foil_hat.title": "Tin foil hat", "allomancy.aluminum.black": "Black Aluminum Symbol", @@ -175,6 +175,7 @@ "allomancy.gold.red": "Red Gold Symbol", "allomancy.gold.white": "White Gold Symbol", "allomancy.gold.yellow": "Yellow Gold Symbol", + "allomancy.gui": "Select Metal", "allomancy.iron.black": "Black Iron Symbol", "allomancy.iron.blue": "Blue Iron Symbol", "allomancy.iron.brown": "Brown Iron Symbol", diff --git a/src/generated/resources/data/allomancy/advancement/main/noisey.json b/src/generated/resources/data/allomancy/advancement/main/going_loud.json similarity index 83% rename from src/generated/resources/data/allomancy/advancement/main/noisey.json rename to src/generated/resources/data/allomancy/advancement/main/going_loud.json index c9d0e610..8fd04681 100644 --- a/src/generated/resources/data/allomancy/advancement/main/noisey.json +++ b/src/generated/resources/data/allomancy/advancement/main/going_loud.json @@ -14,9 +14,8 @@ } }, "display": { - "announce_to_chat": false, "description": { - "translate": "advancements.noisey.desc" + "translate": "advancements.going_loud.desc" }, "hidden": true, "icon": { @@ -24,7 +23,7 @@ "id": "minecraft:bell" }, "title": { - "translate": "advancements.noisey.title" + "translate": "advancements.going_loud.title" } }, "requirements": [ diff --git a/src/generated/resources/data/minecraft/advancement/recipes/redstone/inverted_from_iron_button.json b/src/generated/resources/data/allomancy/advancement/recipes/redstone/inverted_from_iron_button.json similarity index 83% rename from src/generated/resources/data/minecraft/advancement/recipes/redstone/inverted_from_iron_button.json rename to src/generated/resources/data/allomancy/advancement/recipes/redstone/inverted_from_iron_button.json index b4ae489a..80316959 100644 --- a/src/generated/resources/data/minecraft/advancement/recipes/redstone/inverted_from_iron_button.json +++ b/src/generated/resources/data/allomancy/advancement/recipes/redstone/inverted_from_iron_button.json @@ -13,7 +13,7 @@ }, "has_the_recipe": { "conditions": { - "recipe": "minecraft:inverted_from_iron_button" + "recipe": "allomancy:inverted_from_iron_button" }, "trigger": "minecraft:recipe_unlocked" } @@ -26,7 +26,7 @@ ], "rewards": { "recipes": [ - "minecraft:inverted_from_iron_button" + "allomancy:inverted_from_iron_button" ] } } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/advancement/recipes/redstone/iron_button_from_inverted.json b/src/generated/resources/data/allomancy/advancement/recipes/redstone/iron_button_from_inverted.json similarity index 84% rename from src/generated/resources/data/minecraft/advancement/recipes/redstone/iron_button_from_inverted.json rename to src/generated/resources/data/allomancy/advancement/recipes/redstone/iron_button_from_inverted.json index 8f770942..bdbdb371 100644 --- a/src/generated/resources/data/minecraft/advancement/recipes/redstone/iron_button_from_inverted.json +++ b/src/generated/resources/data/allomancy/advancement/recipes/redstone/iron_button_from_inverted.json @@ -13,7 +13,7 @@ }, "has_the_recipe": { "conditions": { - "recipe": "minecraft:iron_button_from_inverted" + "recipe": "allomancy:iron_button_from_inverted" }, "trigger": "minecraft:recipe_unlocked" } @@ -26,7 +26,7 @@ ], "rewards": { "recipes": [ - "minecraft:iron_button_from_inverted" + "allomancy:iron_button_from_inverted" ] } } \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/recipe/inverted_from_iron_button.json b/src/generated/resources/data/allomancy/recipe/inverted_from_iron_button.json similarity index 100% rename from src/generated/resources/data/minecraft/recipe/inverted_from_iron_button.json rename to src/generated/resources/data/allomancy/recipe/inverted_from_iron_button.json diff --git a/src/generated/resources/data/minecraft/recipe/iron_button_from_inverted.json b/src/generated/resources/data/allomancy/recipe/iron_button_from_inverted.json similarity index 100% rename from src/generated/resources/data/minecraft/recipe/iron_button_from_inverted.json rename to src/generated/resources/data/allomancy/recipe/iron_button_from_inverted.json diff --git a/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java b/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java index 054f432f..f2030ed3 100644 --- a/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java +++ b/src/main/java/com/legobmw99/allomancy/api/data/IAllomancerData.java @@ -95,14 +95,14 @@ public interface IAllomancerData { /** * Increase the amount of this metal being stored * - * @param metal + * @param metal the Metal to store more off */ void incrementStored(Metal metal); /** * Decrease the amount of this metal being stored * - * @param metal + * @param metal the Metal to store less of */ void decrementStored(Metal metal); diff --git a/src/main/java/com/legobmw99/allomancy/api/enums/Metal.java b/src/main/java/com/legobmw99/allomancy/api/enums/Metal.java index a10b816d..10210bd4 100644 --- a/src/main/java/com/legobmw99/allomancy/api/enums/Metal.java +++ b/src/main/java/com/legobmw99/allomancy/api/enums/Metal.java @@ -1,6 +1,8 @@ package com.legobmw99.allomancy.api.enums; +import com.mojang.serialization.Codec; import net.minecraft.util.StringRepresentable; +import org.jetbrains.annotations.NotNull; import java.util.Locale; @@ -64,10 +66,10 @@ public int getIndex() { } - public static final StringRepresentable.EnumCodec CODEC = StringRepresentable.fromEnum(Metal::values); + public static final Codec CODEC = StringRepresentable.fromEnum(Metal::values); @Override - public String getSerializedName() { + public @NotNull String getSerializedName() { return getName(); } } \ No newline at end of file diff --git a/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java b/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java index 2d759aca..e2dae856 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/Advancements.java @@ -24,7 +24,7 @@ import java.util.Optional; import java.util.function.Consumer; -public class Advancements implements AdvancementProvider.AdvancementGenerator { +class Advancements implements AdvancementProvider.AdvancementGenerator { @Override public void generate(HolderLookup.Provider registries, @@ -121,11 +121,11 @@ public void generate(HolderLookup.Provider registries, Component.translatable("advancements.tin_foil_hat.desc"), null, AdvancementType.TASK, true, false, true) .addCriterion("attempted_nicrosil_manipulation", - MetalUsedOnPlayerTrigger.TriggerInstance.instance(Optional.of(tinFoilPredicate), - Metal.NICROSIL, false)) + MetalUsedOnPlayerTrigger.TriggerInstance.instance(tinFoilPredicate, Metal.NICROSIL, + false)) .addCriterion("attempted_chromium_manipulation", - MetalUsedOnPlayerTrigger.TriggerInstance.instance(Optional.of(tinFoilPredicate), - Metal.CHROMIUM, false)) + MetalUsedOnPlayerTrigger.TriggerInstance.instance(tinFoilPredicate, Metal.CHROMIUM, + false)) .requirements(AdvancementRequirements.Strategy.OR) .save(saver, "allomancy:main/tin_foil_hat"); @@ -139,14 +139,11 @@ public void generate(HolderLookup.Provider registries, .display(Blocks.IRON_BLOCK, Component.translatable("advancements.consequences.title"), Component.translatable("advancements.consequences.desc"), null, AdvancementType.TASK, true, false, true) - .addCriterion("pushed_iron_golem", MetalUsedOnEntityTrigger.TriggerInstance.instance(Optional.empty(), - Optional.of( - ironGolemPredicate), - Metal.STEEL)) - .addCriterion("pulled_iron_golem", MetalUsedOnEntityTrigger.TriggerInstance.instance(Optional.empty(), - Optional.of( - ironGolemPredicate), - Metal.IRON)) + .addCriterion("pushed_iron_golem", + MetalUsedOnEntityTrigger.TriggerInstance.instance(null, ironGolemPredicate, + Metal.STEEL)) + .addCriterion("pulled_iron_golem", + MetalUsedOnEntityTrigger.TriggerInstance.instance(null, ironGolemPredicate, Metal.IRON)) .requirements(AdvancementRequirements.Strategy.OR) .save(saver, "allomancy:main/consequences"); @@ -156,11 +153,11 @@ public void generate(HolderLookup.Provider registries, .parent(Advancement.Builder .advancement() .build(ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "main/coinshot"))) - .display(Blocks.BELL, Component.translatable("advancements.noisey.title"), - Component.translatable("advancements.noisey.desc"), null, AdvancementType.TASK, true, true, - true) + .display(Blocks.BELL, Component.translatable("advancements.going_loud.title"), + Component.translatable("advancements.going_loud.desc"), null, AdvancementType.TASK, true, + true, true) .addCriterion("allomantically_activate_bell", AllomanticallyActivatedBlockTrigger.TriggerInstance.activatedBlock(Blocks.BELL)) - .save(saver, "allomancy:main/noisey"); + .save(saver, "allomancy:main/going_loud"); } } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/BannerTags.java b/src/main/java/com/legobmw99/allomancy/datagen/BannerTags.java index d36973f0..a2b5d73f 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/BannerTags.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/BannerTags.java @@ -9,18 +9,18 @@ import java.util.concurrent.CompletableFuture; -public class BannerTags extends BannerPatternTagsProvider { +class BannerTags extends BannerPatternTagsProvider { - public BannerTags(PackOutput pGenerator, - CompletableFuture registries, - net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) { + BannerTags(PackOutput pGenerator, + CompletableFuture registries, + net.neoforged.neoforge.common.data.ExistingFileHelper existingFileHelper) { super(pGenerator, registries, Allomancy.MODID, existingFileHelper); } @Override protected void addTags(HolderLookup.Provider pProvider) { for (Metal mt : Metal.values()) { - Allomancy.LOGGER.debug("Creating banner tag for " + mt.getName()); + Allomancy.LOGGER.debug("Creating banner tag for {}", mt.getName()); this.tag(ExtrasSetup.PATTERN_KEYS.get(mt.getIndex())).add(ExtrasSetup.PATTERNS.get(mt.getIndex())); } } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/BlockLootTables.java b/src/main/java/com/legobmw99/allomancy/datagen/BlockLootTables.java index 81729b15..21585dd3 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/BlockLootTables.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/BlockLootTables.java @@ -13,8 +13,8 @@ import java.util.function.Supplier; import java.util.stream.Stream; -public class BlockLootTables extends BlockLootSubProvider { - public BlockLootTables(HolderLookup.Provider provider) { +class BlockLootTables extends BlockLootSubProvider { + BlockLootTables(HolderLookup.Provider provider) { super(Set.of(), FeatureFlags.REGISTRY.allFlags(), provider); } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/BlockStates.java b/src/main/java/com/legobmw99/allomancy/datagen/BlockStates.java index 5afa84f8..37ab15a6 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/BlockStates.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/BlockStates.java @@ -15,9 +15,9 @@ import java.util.function.BiConsumer; -public class BlockStates extends BlockStateProvider { +class BlockStates extends BlockStateProvider { - public BlockStates(PackOutput gen, ExistingFileHelper exFileHelper) { + BlockStates(PackOutput gen, ExistingFileHelper exFileHelper) { super(gen, Allomancy.MODID, exFileHelper); } @@ -26,26 +26,26 @@ protected void registerStatesAndModels() { for (var rblock : MaterialsSetup.ORE_BLOCKS) { Block block = rblock.get(); String path = rblock.getId().getPath(); - singleTextureBlock(block, path, "block/" + path); + singleTextureBlock(block); } for (var rblock : MaterialsSetup.DEEPSLATE_ORE_BLOCKS) { Block block = rblock.get(); String path = rblock.getId().getPath(); - singleTextureBlock(block, path, "block/" + path); + singleTextureBlock(block); } for (var rblock : MaterialsSetup.RAW_ORE_BLOCKS) { Block block = rblock.get(); String path = rblock.getId().getPath(); - singleTextureBlock(block, path, "block/" + path); + singleTextureBlock(block); } for (var rblock : MaterialsSetup.STORAGE_BLOCKS) { if (rblock != null) { Block block = rblock.get(); String path = rblock.getId().getPath(); - singleTextureBlock(block, path, "block/" + path); + singleTextureBlock(block); } } @@ -56,15 +56,15 @@ protected void registerStatesAndModels() { } - private void singleTextureBlock(Block block, String model, String texture) { - Allomancy.LOGGER.debug("Creating Block Data for " + BuiltInRegistries.BLOCK.getKey(block)); + private void singleTextureBlock(Block block) { + Allomancy.LOGGER.debug("Creating Block Data for {}", BuiltInRegistries.BLOCK.getKey(block)); simpleBlock(block); } private void createIronButtonBlock(IronButtonBlock block) { Allomancy.LOGGER.debug("Creating Block Data for allomancy:iron_button"); - ModelFile inventory = models() + models() .withExistingParent("allomancy:iron_button_inventory", mcLoc("block/button_inventory")) .texture("texture", mcLoc("block/iron_block")); ModelFile button = models() @@ -139,7 +139,7 @@ private void createIronLeverBlock() { .rotation() .origin(8, 1, 8) .axis(Direction.Axis.X) - .angle(-45F) + .angle(-45.0F) .end() .allFaces(lever_generator) .end(); diff --git a/src/main/java/com/legobmw99/allomancy/datagen/BlockTags.java b/src/main/java/com/legobmw99/allomancy/datagen/BlockTags.java index 1274eaf4..c317b710 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/BlockTags.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/BlockTags.java @@ -14,11 +14,11 @@ import java.util.concurrent.CompletableFuture; -public class BlockTags extends BlockTagsProvider { +class BlockTags extends BlockTagsProvider { - public BlockTags(PackOutput gen, - CompletableFuture lookupProvider, - ExistingFileHelper exFileHelper) { + BlockTags(PackOutput gen, + CompletableFuture lookupProvider, + ExistingFileHelper exFileHelper) { super(gen, lookupProvider, Allomancy.MODID, exFileHelper); } @@ -68,7 +68,7 @@ protected void addTags(HolderLookup.Provider pProvider) { @SafeVarargs private void addCommonTag(String name, ResourceKey... items) { - Allomancy.LOGGER.debug("Creating block tag for c:" + name); + Allomancy.LOGGER.debug("Creating block tag for c:{}", name); tag(net.minecraft.tags.BlockTags.create(ResourceLocation.fromNamespaceAndPath("c", name))) .replace(false) .add(items); diff --git a/src/main/java/com/legobmw99/allomancy/datagen/DamageTags.java b/src/main/java/com/legobmw99/allomancy/datagen/DamageTags.java index b88fb68b..a95f8c9c 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/DamageTags.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/DamageTags.java @@ -12,10 +12,10 @@ import java.util.concurrent.CompletableFuture; -public class DamageTags extends DamageTypeTagsProvider { - public DamageTags(PackOutput out, - CompletableFuture lookup, - @Nullable ExistingFileHelper existingFileHelper) { +class DamageTags extends DamageTypeTagsProvider { + DamageTags(PackOutput out, + CompletableFuture lookup, + @Nullable ExistingFileHelper existingFileHelper) { super(out, lookup, Allomancy.MODID, existingFileHelper); } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/DataGenerators.java b/src/main/java/com/legobmw99/allomancy/datagen/DataGenerators.java index 5fab32f3..9e14603d 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/DataGenerators.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/DataGenerators.java @@ -18,7 +18,7 @@ public class DataGenerators { @SubscribeEvent - public static void gatherData(GatherDataEvent event) { + public static void gatherData(final GatherDataEvent event) { var generator = event.getGenerator(); var packOutput = generator.getPackOutput(); var lookup = event.getLookupProvider(); diff --git a/src/main/java/com/legobmw99/allomancy/datagen/DatapackEntries.java b/src/main/java/com/legobmw99/allomancy/datagen/DatapackEntries.java index 02f455b2..b903f3df 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/DatapackEntries.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/DatapackEntries.java @@ -15,18 +15,17 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; -public class DatapackEntries extends DatapackBuiltinEntriesProvider { +class DatapackEntries extends DatapackBuiltinEntriesProvider { - public static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() - .add(Registries.DAMAGE_TYPE, context -> { - context.register(CombatSetup.COIN_DAMAGE, new DamageType("allomancy.coin", 0.0f)); - }) + private static final RegistrySetBuilder BUILDER = new RegistrySetBuilder() + .add(Registries.DAMAGE_TYPE, + context -> context.register(CombatSetup.COIN_DAMAGE, new DamageType("allomancy.coin", 0.0f))) .add(Registries.CONFIGURED_FEATURE, MaterialsSetup::bootstrapConfigured) .add(Registries.PLACED_FEATURE, MaterialsSetup::bootstrapPlaced) .add(Registries.BANNER_PATTERN, ExtrasSetup::bootstrapBanners) .add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, MaterialsSetup::bootstrapBiomeModifier); - public DatapackEntries(PackOutput output, CompletableFuture provider) { + DatapackEntries(PackOutput output, CompletableFuture provider) { super(output, provider, BUILDER, Set.of("minecraft", Allomancy.MODID)); } } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/ItemModels.java b/src/main/java/com/legobmw99/allomancy/datagen/ItemModels.java index e238f6fe..a037578a 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/ItemModels.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/ItemModels.java @@ -15,8 +15,8 @@ import net.neoforged.neoforge.common.data.ExistingFileHelper; -public class ItemModels extends ItemModelProvider { - public ItemModels(PackOutput generator, ExistingFileHelper existingFileHelper) { +class ItemModels extends ItemModelProvider { + ItemModels(PackOutput generator, ExistingFileHelper existingFileHelper) { super(generator, Allomancy.MODID, existingFileHelper); } @@ -89,36 +89,36 @@ protected void registerModels() { } - public void parentedBlock(Block block) { + private void parentedBlock(Block block) { parentedBlock(block, "block/" + BuiltInRegistries.BLOCK.getKey(block).getPath()); } - public void parentedBlock(Block block, String model) { - Allomancy.LOGGER.debug("Creating Item Model for " + BuiltInRegistries.BLOCK.getKey(block)); + private void parentedBlock(Block block, String model) { + Allomancy.LOGGER.debug("Creating block Item Model for {}", BuiltInRegistries.BLOCK.getKey(block)); getBuilder(BuiltInRegistries.BLOCK.getKey(block).getPath()).parent( new ModelFile.UncheckedModelFile(modLoc(model))); } - public void itemGenerated(Item item) { + private void itemGenerated(Item item) { itemGenerated(item, "item/" + BuiltInRegistries.ITEM.getKey(item).getPath()); } - public void itemGenerated(Item item, String model) { - Allomancy.LOGGER.debug("Creating Item Model for " + BuiltInRegistries.ITEM.getKey(item)); + private void itemGenerated(Item item, String model) { + Allomancy.LOGGER.debug("Creating Item Model for {}", BuiltInRegistries.ITEM.getKey(item)); getBuilder(BuiltInRegistries.ITEM.getKey(item).getPath()) .parent(getExistingFile(mcLoc("item/generated"))) .texture("layer0", modLoc(model)); } - public void itemHandheld(Item item) { - Allomancy.LOGGER.debug("Creating Item Model for " + BuiltInRegistries.ITEM.getKey(item)); + private void itemHandheld(Item item) { + Allomancy.LOGGER.debug("Creating handheld Item Model for {}", BuiltInRegistries.ITEM.getKey(item)); getBuilder(BuiltInRegistries.ITEM.getKey(item).getPath()) .parent(getExistingFile(mcLoc("item/handheld"))) .texture("layer0", modLoc("item/" + BuiltInRegistries.ITEM.getKey(item).getPath())); } - public void largeItemHandheld(Item item) { - Allomancy.LOGGER.debug("Creating Large Item Model for " + BuiltInRegistries.ITEM.getKey(item)); + private void largeItemHandheld(Item item) { + Allomancy.LOGGER.debug("Creating Large Item Model for {}", BuiltInRegistries.ITEM.getKey(item)); getBuilder(BuiltInRegistries.ITEM.getKey(item).getPath()) .parent(getExistingFile(modLoc("item/handheld_large"))) .texture("layer0", modLoc("item/" + BuiltInRegistries.ITEM.getKey(item).getPath())); diff --git a/src/main/java/com/legobmw99/allomancy/datagen/ItemTags.java b/src/main/java/com/legobmw99/allomancy/datagen/ItemTags.java index aae432dd..ead67687 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/ItemTags.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/ItemTags.java @@ -16,13 +16,13 @@ import java.util.concurrent.CompletableFuture; -public class ItemTags extends ItemTagsProvider { +class ItemTags extends ItemTagsProvider { - public ItemTags(PackOutput gen, - CompletableFuture lookupProvider, - CompletableFuture> blockTagProvider, - ExistingFileHelper exFileHelper) { + ItemTags(PackOutput gen, + CompletableFuture lookupProvider, + CompletableFuture> blockTagProvider, + ExistingFileHelper exFileHelper) { super(gen, lookupProvider, blockTagProvider, Allomancy.MODID, exFileHelper); } @@ -86,7 +86,7 @@ protected void addTags(HolderLookup.Provider pProvider) { @SafeVarargs private void addCommonTag(String name, ResourceKey... items) { - Allomancy.LOGGER.debug("Creating item tag for c:" + name); + Allomancy.LOGGER.debug("Creating item tag for c:{}", name); tag(net.minecraft.tags.ItemTags.create(ResourceLocation.fromNamespaceAndPath("c", name))) .replace(false) .add(items); diff --git a/src/main/java/com/legobmw99/allomancy/datagen/Languages.java b/src/main/java/com/legobmw99/allomancy/datagen/Languages.java index 1dfb62ef..1fe34b14 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/Languages.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/Languages.java @@ -14,10 +14,10 @@ import java.util.Locale; import java.util.stream.Collectors; -public class Languages extends LanguageProvider { +class Languages extends LanguageProvider { - public Languages(PackOutput gen) { + Languages(PackOutput gen) { super(gen, Allomancy.MODID, "en_us"); } @@ -116,12 +116,13 @@ protected void addTranslations() { add("advancements.tin_foil_hat.desc", "Protect yourself, and be a bit paranoid too"); add("advancements.consequences.title", "Consequences, Vin"); add("advancements.consequences.desc", "Learn what happens when you push on a much heavier target."); - add("advancements.noisey.title", "Going Loud"); - add("advancements.noisey.desc", "Allomancy can grant great stealth, unless you do that!"); + add("advancements.going_loud.title", "Going Loud"); + add("advancements.going_loud.desc", "Allomancy can grant great stealth, unless you do that!"); add("key.categories.allomancy", "Allomancy"); add("key.burn", "Burn Metals"); add("key.hud", "Show HUD"); + add("allomancy.gui", "Select Metal"); add("commands.allomancy.getpowers", "%s currently has Allomantic powers: %s"); add("commands.allomancy.addpower", "%s added Allomantic power %s"); diff --git a/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java b/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java index 19526e50..c30c84fb 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/LootModifiers.java @@ -13,9 +13,9 @@ import java.util.concurrent.CompletableFuture; -public class LootModifiers extends GlobalLootModifierProvider { +class LootModifiers extends GlobalLootModifierProvider { - public LootModifiers(PackOutput output, CompletableFuture regisrties) { + LootModifiers(PackOutput output, CompletableFuture regisrties) { super(output, regisrties, Allomancy.MODID); } diff --git a/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java b/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java index fdd38e5a..b39700ea 100644 --- a/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java +++ b/src/main/java/com/legobmw99/allomancy/datagen/Recipes.java @@ -27,11 +27,11 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; -public class Recipes extends RecipeProvider { +class Recipes extends RecipeProvider { private final Map defaultIngredients = new HashMap<>(); - public Recipes(PackOutput packOutput, CompletableFuture lookupProvider) { + Recipes(PackOutput packOutput, CompletableFuture lookupProvider) { super(packOutput, lookupProvider); add('i', Tags.Items.INGOTS_IRON); add('g', Tags.Items.INGOTS_GOLD); @@ -47,24 +47,24 @@ public Recipes(PackOutput packOutput, CompletableFuture l } - protected static void buildShapeless(RecipeOutput consumer, - RecipeCategory cat, - ItemLike result, - int count, - Item criterion, - Ingredient... ingredients) { + private static void buildShapeless(RecipeOutput consumer, + RecipeCategory cat, + ItemLike result, + int count, + Item criterion, + Ingredient... ingredients) { buildShapeless(consumer, cat, result, count, criterion, "", ingredients); } - protected static void buildShapeless(RecipeOutput consumer, - RecipeCategory cat, - ItemLike result, - int count, - Item criterion, - String save, - Ingredient... ingredients) { - Allomancy.LOGGER.debug( - "Creating Shapeless Recipe for " + BuiltInRegistries.ITEM.getKey(result.asItem()) + " " + save); + private static void buildShapeless(RecipeOutput consumer, + RecipeCategory cat, + ItemLike result, + int count, + Item criterion, + String save, + Ingredient... ingredients) { + Allomancy.LOGGER.debug("Creating Shapeless Recipe for {}", + BuiltInRegistries.ITEM.getKey(result.asItem()) + " " + save); ShapelessRecipeBuilder builder = ShapelessRecipeBuilder.shapeless(cat, result, count); @@ -78,16 +78,16 @@ protected static void buildShapeless(RecipeOutput consumer, if (save.isEmpty()) { builder.save(consumer); } else { - builder.save(consumer, save); + builder.save(consumer, Allomancy.MODID + ":" + save); } } - protected static void buildSmeltingAndBlasting(RecipeOutput consumer, - ItemLike result, - ItemLike ingredient, - float xp) { - Allomancy.LOGGER.debug( - "Creating Smelting and Blasting Recipe for " + BuiltInRegistries.ITEM.getKey(result.asItem())); + private static void buildSmeltingAndBlasting(RecipeOutput consumer, + ItemLike result, + ItemLike ingredient, + float xp) { + Allomancy.LOGGER.debug("Creating Smelting and Blasting Recipe for {}", + BuiltInRegistries.ITEM.getKey(result.asItem())); SimpleCookingRecipeBuilder smelt = SimpleCookingRecipeBuilder.smelting(ing(ingredient), RecipeCategory.MISC, result, xp, 200); @@ -108,34 +108,30 @@ protected static void buildSmeltingAndBlasting(RecipeOutput consumer, } private static String mixing_save(String metal) { - return "allomancy:" + metal + "_flakes_from_mixing"; + return metal + "_flakes_from_mixing"; } private static String alloy_save(String metal) { - return "allomancy:" + metal + "_ingot_from_alloying"; + return metal + "_ingot_from_alloying"; } - protected static Ingredient ing(String tag) { + private static Ingredient ing(String tag) { return Ingredient.of(ItemTags.create(ResourceLocation.parse(tag))); } - protected static Ingredient ing(TagKey tag) { + private static Ingredient ing(TagKey tag) { return Ingredient.of(tag); } - protected static Ingredient ing(ItemLike itemProvider) { + private static Ingredient ing(ItemLike itemProvider) { return Ingredient.of(itemProvider); } - protected static Ingredient ing(Ingredient ingredient) { - return ingredient; - } - - protected static Ingredient[] repeat(Ingredient ing, int n) { + private static Ingredient[] repeat(Ingredient ing, int n) { return repeatWith(ing, n); } - protected static Ingredient[] repeatWith(Ingredient ing, int n, Ingredient... extras) { + private static Ingredient[] repeatWith(Ingredient ing, int n, Ingredient... extras) { int size = n + extras.length; Ingredient[] out = new Ingredient[size]; for (int i = 0; i < n; i++) { @@ -220,12 +216,11 @@ protected void buildRecipes(RecipeOutput consumer) { // building up buildShapeless(consumer, RecipeCategory.BUILDING_BLOCKS, block, 1, ingot, repeat(ing(ingot), 9)); buildShapeless(consumer, RecipeCategory.MISC, ingot, 1, nugget, - "allomancy:" + BuiltInRegistries.ITEM.getKey(ingot).getPath() + "_from_nuggets", - repeat(ing(nugget), 9)); + BuiltInRegistries.ITEM.getKey(ingot).getPath() + "_from_nuggets", repeat(ing(nugget), 9)); // breaking down buildShapeless(consumer, RecipeCategory.MISC, ingot, 9, block, - "allomancy:" + BuiltInRegistries.ITEM.getKey(ingot).getPath() + "_from_block", ing(block)); + BuiltInRegistries.ITEM.getKey(ingot).getPath() + "_from_block", ing(block)); buildShapeless(consumer, RecipeCategory.MISC, nugget, 9, ingot, ing(ingot)); } @@ -329,13 +324,13 @@ protected void buildRecipes(RecipeOutput consumer) { } - protected void buildShaped(RecipeOutput consumer, - RecipeCategory cat, - ItemLike result, - int count, - Item criterion, - String... lines) { - Allomancy.LOGGER.debug("Creating Shaped Recipe for " + BuiltInRegistries.ITEM.getKey(result.asItem())); + private void buildShaped(RecipeOutput consumer, + RecipeCategory cat, + ItemLike result, + int count, + Item criterion, + String... lines) { + Allomancy.LOGGER.debug("Creating Shaped Recipe for {}", BuiltInRegistries.ITEM.getKey(result.asItem())); ShapedRecipeBuilder builder = ShapedRecipeBuilder.shaped(cat, result, count); @@ -358,23 +353,23 @@ protected void buildShaped(RecipeOutput consumer, builder.save(consumer); } - protected void buildShaped(RecipeOutput consumer, - RecipeCategory cat, - ItemLike result, - Item criterion, - String... lines) { + private void buildShaped(RecipeOutput consumer, + RecipeCategory cat, + ItemLike result, + Item criterion, + String... lines) { buildShaped(consumer, cat, result, 1, criterion, lines); } - protected void add(char c, TagKey itemTag) { + private void add(char c, TagKey itemTag) { this.defaultIngredients.put(c, Ingredient.of(itemTag)); } - protected void add(char c, ItemLike itemProvider) { + private void add(char c, ItemLike itemProvider) { this.defaultIngredients.put(c, Ingredient.of(itemProvider)); } - protected void add(char c, Ingredient ingredient) { + private void add(char c, Ingredient ingredient) { this.defaultIngredients.put(c, ingredient); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java b/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java index 587f491c..63456620 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/CombatSetup.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.function.Supplier; -public class CombatSetup { +public final class CombatSetup { private static final DeferredRegister> ENTITIES = DeferredRegister.create(Registries.ENTITY_TYPE, Allomancy.MODID); @@ -51,10 +51,10 @@ public class CombatSetup { ITEMS.register("obsidian_dagger", ObsidianDaggerItem::new); public static final DeferredItem KOLOSS_BLADE = ITEMS.register("koloss_blade", KolossBladeItem::new); - public static final DeferredRegister ARMOR_MATERIALS = + private static final DeferredRegister ARMOR_MATERIALS = DeferredRegister.create(Registries.ARMOR_MATERIAL, Allomancy.MODID); - public static final DeferredHolder WOOL_ARMOR = + private static final DeferredHolder WOOL_ARMOR = ARMOR_MATERIALS.register("wool", () -> new ArmorMaterial(Util.make(new EnumMap<>(ArmorItem.Type.class), map -> { @@ -68,7 +68,7 @@ public class CombatSetup { ResourceLocation.fromNamespaceAndPath( Allomancy.MODID, "wool"))), 0, 0)); - public static final DeferredHolder ALUMINUM_ARMOR = + private static final DeferredHolder ALUMINUM_ARMOR = ARMOR_MATERIALS.register("aluminum", () -> new ArmorMaterial(Util.make(new EnumMap<>(ArmorItem.Type.class), map -> { map.put(ArmorItem.Type.BOOTS, 0); @@ -90,7 +90,7 @@ public class CombatSetup { .add(Attributes.MOVEMENT_SPEED, new AttributeModifier( ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "mistcloak_speed"), - .25, + 0.25, AttributeModifier.Operation.ADD_MULTIPLIED_TOTAL), EquipmentSlotGroup.CHEST) .build()); @@ -112,6 +112,8 @@ public class CombatSetup { .sized(0.25F, 0.25F) .build("nugget_projectile")); + private CombatSetup() {} + public static void register(IEventBus bus) { ARMOR_MATERIALS.register(bus); ENTITIES.register(bus); diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/client/CombatClientSetup.java b/src/main/java/com/legobmw99/allomancy/modules/combat/client/CombatClientSetup.java index 5152822b..9b4a03b6 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/client/CombatClientSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/client/CombatClientSetup.java @@ -4,7 +4,9 @@ import net.minecraft.client.renderer.entity.ThrownItemRenderer; import net.neoforged.neoforge.client.event.EntityRenderersEvent; -public class CombatClientSetup { +public final class CombatClientSetup { + private CombatClientSetup() {} + public static void registerEntityRenders(final EntityRenderersEvent.RegisterRenderers e) { e.registerEntityRenderer(CombatSetup.NUGGET_PROJECTILE.get(), ThrownItemRenderer::new); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/entity/ProjectileNuggetEntity.java b/src/main/java/com/legobmw99/allomancy/modules/combat/entity/ProjectileNuggetEntity.java index a849d80e..0acb81b7 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/entity/ProjectileNuggetEntity.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/entity/ProjectileNuggetEntity.java @@ -6,7 +6,6 @@ import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; @@ -20,25 +19,14 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -@OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class) public class ProjectileNuggetEntity extends ThrowableItemProjectile implements ItemSupplier { private static final EntityDataAccessor ITEM = SynchedEntityData.defineId(ProjectileNuggetEntity.class, EntityDataSerializers.ITEM_STACK); - private float damage; + private final float damage; private boolean dropItem = true; - public ProjectileNuggetEntity(double x, double y, double z, Level worldIn, ItemStack itemIn, float damageIn) { - super(CombatSetup.NUGGET_PROJECTILE.get(), x, y, z, worldIn); - this.damage = damageIn; - - if (!itemIn.isEmpty()) { - this.entityData.set(ITEM, itemIn.copy()); - } - } public ProjectileNuggetEntity(LivingEntity livingEntityIn, Level worldIn, ItemStack itemIn, float damageIn) { super(CombatSetup.NUGGET_PROJECTILE.get(), livingEntityIn, worldIn); @@ -54,17 +42,10 @@ public ProjectileNuggetEntity(LivingEntity livingEntityIn, Level worldIn, ItemSt } public ProjectileNuggetEntity(EntityType entityEntityType, Level world) { - super(CombatSetup.NUGGET_PROJECTILE.get(), world); + super(entityEntityType, world); this.damage = 0; } - public ProjectileNuggetEntity(Level world, Entity other) { - this(CombatSetup.NUGGET_PROJECTILE.get(), world); - if (other instanceof ProjectileNuggetEntity nugget) { - this.entityData.set(ITEM, nugget.getItem().copy()); - this.damage = nugget.getDamage(); - } - } @Override protected void defineSynchedData(SynchedEntityData.Builder builder) { @@ -110,9 +91,6 @@ public ItemStack getItem() { return this.entityData.get(ITEM).isEmpty() ? new ItemStack(this.getDefaultItem()) : this.entityData.get(ITEM); } - public float getDamage() { - return this.damage; - } @Override protected Item getDefaultItem() { diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/item/CoinBagItem.java b/src/main/java/com/legobmw99/allomancy/modules/combat/item/CoinBagItem.java index 0389ba2e..81ce2a74 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/item/CoinBagItem.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/item/CoinBagItem.java @@ -21,9 +21,7 @@ import java.util.function.Predicate; public class CoinBagItem extends ProjectileWeaponItem { - - - public static final Predicate NUGGETS = (stack) -> { + private static final Predicate NUGGETS = (stack) -> { Item item = stack.getItem(); return Physical.doesResourceContainMetal(BuiltInRegistries.ITEM.getKey(item)) && BuiltInRegistries.ITEM.getKey(item).getPath().contains("nugget"); diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/item/KolossBladeItem.java b/src/main/java/com/legobmw99/allomancy/modules/combat/item/KolossBladeItem.java index f38a2fb5..16a4e09e 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/item/KolossBladeItem.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/item/KolossBladeItem.java @@ -24,42 +24,11 @@ public class KolossBladeItem extends SwordItem { private static final int ATTACK_DAMAGE = 9; private static final float ATTACK_SPEED = -2.6F; - private static final Tier SLOW_STONE = new Tier() { - @Override - public int getUses() { - return Tiers.STONE.getUses(); - } - - @Override - public float getSpeed() { - return ATTACK_SPEED; - } - - @Override - public float getAttackDamageBonus() { - return ATTACK_DAMAGE; - } - - @Override - public TagKey getIncorrectBlocksForDrops() { - return Tiers.STONE.getIncorrectBlocksForDrops(); - } - - @Override - public int getEnchantmentValue() { - return Tiers.STONE.getEnchantmentValue(); - } - - @Override - public Ingredient getRepairIngredient() { - return Tiers.STONE.getRepairIngredient(); - } - - }; + private static final Tier SLOW_STONE = new SlowStoneTier(); public KolossBladeItem() { super(SLOW_STONE, - new Item.Properties().attributes(SwordItem.createAttributes(SLOW_STONE, ATTACK_DAMAGE, ATTACK_SPEED))); + new Item.Properties().attributes(createAttributes(SLOW_STONE, ATTACK_DAMAGE, ATTACK_SPEED))); } @Override @@ -98,4 +67,37 @@ public void appendHoverText(ItemStack stack, public boolean isCorrectToolForDrops(ItemStack pStack, BlockState pState) { return false; } + + private static class SlowStoneTier implements Tier { + @Override + public int getUses() { + return Tiers.STONE.getUses(); + } + + @Override + public float getSpeed() { + return ATTACK_SPEED; + } + + @Override + public float getAttackDamageBonus() { + return ATTACK_DAMAGE; + } + + @Override + public TagKey getIncorrectBlocksForDrops() { + return Tiers.STONE.getIncorrectBlocksForDrops(); + } + + @Override + public int getEnchantmentValue() { + return Tiers.STONE.getEnchantmentValue(); + } + + @Override + public Ingredient getRepairIngredient() { + return Tiers.STONE.getRepairIngredient(); + } + + } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java b/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java index 1fa80df9..61ebe1c5 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java +++ b/src/main/java/com/legobmw99/allomancy/modules/combat/item/ObsidianDaggerItem.java @@ -18,42 +18,11 @@ public class ObsidianDaggerItem extends SwordItem { private static final int ATTACK_DAMAGE = 12; private static final float ATTACK_SPEED = 9.2F; - private static final Tier tier = new Tier() { - @Override - public int getUses() { - return 2; - } - - @Override - public float getSpeed() { - return ATTACK_SPEED; - } - - @Override - public float getAttackDamageBonus() { - return ATTACK_DAMAGE; - } - - @Override - public TagKey getIncorrectBlocksForDrops() { - return BlockTags.INCORRECT_FOR_WOODEN_TOOL; - } - - @Override - public int getEnchantmentValue() { - return 1; - } - - @Override - public Ingredient getRepairIngredient() { - return Ingredient.of(Blocks.OBSIDIAN); - } - - }; + private static final Tier tier = new ObsidianTier(); public ObsidianDaggerItem() { super(tier, new Item.Properties() - .attributes(SwordItem.createAttributes(tier, ATTACK_DAMAGE, ATTACK_SPEED)) + .attributes(createAttributes(tier, ATTACK_DAMAGE, ATTACK_SPEED)) .rarity(Rarity.UNCOMMON)); } @@ -90,4 +59,36 @@ public float getXpRepairRatio(ItemStack stack) { return 0; } + private static class ObsidianTier implements Tier { + @Override + public int getUses() { + return 2; + } + + @Override + public float getSpeed() { + return ATTACK_SPEED; + } + + @Override + public float getAttackDamageBonus() { + return ATTACK_DAMAGE; + } + + @Override + public TagKey getIncorrectBlocksForDrops() { + return BlockTags.INCORRECT_FOR_WOODEN_TOOL; + } + + @Override + public int getEnchantmentValue() { + return 1; + } + + @Override + public Ingredient getRepairIngredient() { + return Ingredient.of(Blocks.OBSIDIAN); + } + + } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/consumables/ConsumeSetup.java b/src/main/java/com/legobmw99/allomancy/modules/consumables/ConsumeSetup.java index c1db0c0f..c77fa802 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/consumables/ConsumeSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/consumables/ConsumeSetup.java @@ -15,7 +15,7 @@ import java.util.function.Supplier; -public class ConsumeSetup { +public final class ConsumeSetup { private static final DeferredRegister.DataComponents DATA_COMPONENTS = DeferredRegister.createDataComponents(Allomancy.MODID); @@ -37,6 +37,8 @@ public class ConsumeSetup { public static final Supplier VIAL_RECIPE_SERIALIZER = RECIPES.register("vial_filling", VialItemRecipe.Serializer::new); + private ConsumeSetup() {} + public static void register(IEventBus bus) { DATA_COMPONENTS.register(bus); ITEMS.register(bus); diff --git a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java index 9fc77d90..451dfa46 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java +++ b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/VialItem.java @@ -23,8 +23,6 @@ import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.component.CustomModelData; import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import java.util.List; @@ -32,7 +30,7 @@ public class VialItem extends Item { - public static final CustomModelData FILLED_MODEL_DATA = new CustomModelData(1); + private static final CustomModelData FILLED_MODEL_DATA = new CustomModelData(1); public VialItem() { super(new Item.Properties().stacksTo(32).rarity(Rarity.COMMON)); @@ -107,7 +105,6 @@ public InteractionResultHolder use(Level worldIn, Player playerIn, In return new InteractionResultHolder<>(InteractionResult.FAIL, itemStackIn); } - @OnlyIn(Dist.CLIENT) @Override public void appendHoverText(ItemStack stack, Item.TooltipContext ctx, diff --git a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java index 67726ffc..fd013ea7 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java +++ b/src/main/java/com/legobmw99/allomancy/modules/consumables/item/component/FlakeStorage.java @@ -7,18 +7,14 @@ import java.util.EnumSet; -public class FlakeStorage { +public final class FlakeStorage { private final EnumSet flakes; - FlakeStorage(EnumSet flakes) { + private FlakeStorage(EnumSet flakes) { this.flakes = flakes; } - public FlakeStorage() { - this(EnumSet.noneOf(Metal.class)); - } - public boolean contains(Metal mt) { return this.flakes.contains(mt); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java b/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java index 6c593be0..f63afd4b 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/ExtrasSetup.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.function.Supplier; -public class ExtrasSetup { +public final class ExtrasSetup { public static final DeferredRegister.Blocks BLOCKS = DeferredRegister.createBlocks(Allomancy.MODID); private static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(Allomancy.MODID); @@ -108,6 +108,8 @@ public class ExtrasSetup { public static final Supplier ALLOMANTICALLY_ACTIVATED_BLOCK_TRIGGER = CT.register("activated_allomancy_block", AllomanticallyActivatedBlockTrigger::new); + private ExtrasSetup() {} + public static void register(IEventBus bus) { BLOCKS.register(bus); ITEMS.register(bus); @@ -122,7 +124,7 @@ public static void bootstrapBanners(BootstrapContext bootstrapCon } } - public static void registerCapabilities(RegisterCapabilitiesEvent event) { + public static void registerCapabilities(final RegisterCapabilitiesEvent event) { event.registerBlock(ALLOMANTICALLY_USABLE_BLOCK, new IronLeverBlock.AllomanticUseCapabilityProvider(), IRON_LEVER.get()); event.registerBlock(ALLOMANTICALLY_USABLE_BLOCK, new IronButtonBlock.AllomanticUseCapabilityProvider(), @@ -131,7 +133,7 @@ public static void registerCapabilities(RegisterCapabilitiesEvent event) { event.registerBlock(ALLOMANTICALLY_USABLE_BLOCK, ((level, pos, state, blockEntity, context) -> ((player, isPush) -> { if (player instanceof ServerPlayer sp) { - ExtrasSetup.ALLOMANTICALLY_ACTIVATED_BLOCK_TRIGGER.get().trigger(sp, pos, isPush); + ALLOMANTICALLY_ACTIVATED_BLOCK_TRIGGER.get().trigger(sp, pos, isPush); } if (level.isClientSide()) { return true; diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/AllomanticallyActivatedBlockTrigger.java b/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/AllomanticallyActivatedBlockTrigger.java index 74c0f8fc..f447b7ec 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/AllomanticallyActivatedBlockTrigger.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/AllomanticallyActivatedBlockTrigger.java @@ -45,7 +45,7 @@ public Codec codec() { public record TriggerInstance(Optional player, Optional location, Optional isPush) implements SimpleInstance { - public static final Codec CODEC = RecordCodecBuilder.create(builder -> builder + static final Codec CODEC = RecordCodecBuilder.create(builder -> builder .group(EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), EntityPredicate.ADVANCEMENT_CODEC .optionalFieldOf("entity") @@ -107,7 +107,7 @@ public static Criterion pullBlock(LootItemCondition.Builder... Optional.of(false))); } - public boolean matches(LootContext ctx, boolean is_push) { + boolean matches(LootContext ctx, boolean is_push) { return (this.isPush.isEmpty() || this.isPush.get() == is_push) && (this.location.isEmpty() || this.location.get().matches(ctx)); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnEntityTrigger.java b/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnEntityTrigger.java index 08e42e1d..f76f018e 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnEntityTrigger.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnEntityTrigger.java @@ -11,6 +11,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.storage.loot.LootContext; +import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -32,7 +33,7 @@ public void trigger(ServerPlayer player, Entity entity, Metal mt, boolean enhanc public record TriggerInstance(Optional player, Optional entityPredicate, Metal mt, Optional enhanced) implements SimpleCriterionTrigger.SimpleInstance { - public static final Codec CODEC = RecordCodecBuilder.create(builder -> builder + private static final Codec CODEC = RecordCodecBuilder.create(builder -> builder .group(EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), EntityPredicate.ADVANCEMENT_CODEC .optionalFieldOf("entity") @@ -41,21 +42,26 @@ public record TriggerInstance(Optional player, Codec.BOOL.optionalFieldOf("enhanced").forGetter(TriggerInstance::enhanced)) .apply(builder, TriggerInstance::new)); - public static Criterion instance(Optional player, - Optional entityPredicate, + public static Criterion instance(@Nullable ContextAwarePredicate player, + @Nullable ContextAwarePredicate entityPredicate, Metal mt) { + return ExtrasSetup.METAL_USED_ON_ENTITY_TRIGGER .get() - .createCriterion(new TriggerInstance(player, entityPredicate, mt, Optional.empty())); + .createCriterion( + new TriggerInstance(Optional.ofNullable(player), Optional.ofNullable(entityPredicate), mt, + Optional.empty())); } - public static Criterion instance(Optional player, - Optional entityPredicate, + public static Criterion instance(@Nullable ContextAwarePredicate player, + @Nullable ContextAwarePredicate entityPredicate, Metal mt, boolean enhanced) { return ExtrasSetup.METAL_USED_ON_ENTITY_TRIGGER .get() - .createCriterion(new TriggerInstance(player, entityPredicate, mt, Optional.of(enhanced))); + .createCriterion( + new TriggerInstance(Optional.ofNullable(player), Optional.ofNullable(entityPredicate), mt, + Optional.of(enhanced))); } boolean matches(LootContext entity, Metal mt, boolean enhanced) { diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnPlayerTrigger.java b/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnPlayerTrigger.java index df8be7fc..2083a911 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnPlayerTrigger.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/advancement/MetalUsedOnPlayerTrigger.java @@ -28,25 +28,23 @@ public void trigger(ServerPlayer player, Metal mt, boolean enhanced) { public record TriggerInstance(Optional player, Metal mt, Optional enhanced) implements SimpleInstance { - public static final Codec CODEC = RecordCodecBuilder.create(builder -> builder + private static final Codec CODEC = RecordCodecBuilder.create(builder -> builder .group(EntityPredicate.ADVANCEMENT_CODEC.optionalFieldOf("player").forGetter(TriggerInstance::player), Metal.CODEC.fieldOf("metal").forGetter(TriggerInstance::mt), Codec.BOOL.optionalFieldOf("enhanced").forGetter(TriggerInstance::enhanced)) .apply(builder, TriggerInstance::new)); - public static Criterion instance(Optional player, Metal mt) { + public static Criterion instance(ContextAwarePredicate player, Metal mt) { return ExtrasSetup.METAL_USED_ON_PLAYER_TRIGGER .get() - .createCriterion(new TriggerInstance(player, mt, Optional.empty())); + .createCriterion(new TriggerInstance(Optional.ofNullable(player), mt, Optional.empty())); } - public static Criterion instance(Optional player, - Metal mt, - boolean enhanced) { + public static Criterion instance(ContextAwarePredicate player, Metal mt, boolean enhanced) { return ExtrasSetup.METAL_USED_ON_PLAYER_TRIGGER .get() - .createCriterion(new TriggerInstance(player, mt, Optional.of(enhanced))); + .createCriterion(new TriggerInstance(Optional.ofNullable(player), mt, Optional.of(enhanced))); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/block/IronLeverBlock.java b/src/main/java/com/legobmw99/allomancy/modules/extras/block/IronLeverBlock.java index f8180814..468a2606 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/block/IronLeverBlock.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/block/IronLeverBlock.java @@ -61,11 +61,6 @@ public void appendHoverText(ItemStack stack, tooltip.add(lore); } - private void updateNeighbors(BlockState state, Level world, BlockPos pos) { - world.updateNeighborsAt(pos, this); - world.updateNeighborsAt(pos.relative(getConnectedDirection(state).getOpposite()), this); - } - public static class AllomanticUseCapabilityProvider implements IBlockCapabilityProvider { diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java b/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java index 3baf5f45..4a4f1bb2 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerCommand.java @@ -25,13 +25,16 @@ import java.util.function.Function; import java.util.function.Predicate; -public class AllomancyPowerCommand { +public final class AllomancyPowerCommand { private static final DynamicCommandExceptionType ERROR_CANT_ADD = new DynamicCommandExceptionType(s -> Component.translatable("commands.allomancy.err_add", s)); private static final DynamicCommandExceptionType ERROR_CANT_REMOVE = new DynamicCommandExceptionType(s -> Component.translatable("commands.allomancy.err_remove", s)); + + private AllomancyPowerCommand() {} + private static Predicate permissions(int level) { return (player) -> player.hasPermission(level); } @@ -95,10 +98,10 @@ public static void register(CommandDispatcher dispatcher) { * @param players Collection of players * @param toApply Function to apply to all players or sender * @return The number of players successfully applied to - * @throws CommandSyntaxException + * @throws CommandSyntaxException if invalid */ private static int handleMultiPlayer(CommandContext ctx, - Collection players, + Iterable players, CheckedBiCon, ServerPlayer> toApply) throws CommandSyntaxException { int i = 0; @@ -158,7 +161,7 @@ private static void removePower(CommandContext ctx, * @param single Either metal -> data.addPower or its inverse * @param exception Function to create an exception * @param success String used when successful - * @throws CommandSyntaxException + * @throws CommandSyntaxException if invalid */ private static void handlePowerChange(CommandContext ctx, ServerPlayer player, @@ -171,12 +174,12 @@ private static void handlePowerChange(CommandContext ctx, String type = ctx.getArgument("type", String.class); var data = player.getData(AllomancerAttachment.ALLOMANCY_DATA); - if (type.equalsIgnoreCase("all")) { + if ("all".equalsIgnoreCase(type)) { all.accept(data); } else { Predicate filter = filterFunction.apply(data); - if (type.equalsIgnoreCase("random")) { + if ("random".equalsIgnoreCase(type)) { List metalList = Arrays.asList(Metal.values()); Collections.shuffle(metalList); Metal mt = metalList.stream().filter(filter).findFirst().orElseThrow(() -> exception.apply(type)); diff --git a/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerType.java b/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerType.java index 56591d94..0d8cab81 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerType.java +++ b/src/main/java/com/legobmw99/allomancy/modules/extras/command/AllomancyPowerType.java @@ -17,9 +17,9 @@ import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; -public class AllomancyPowerType implements ArgumentType { +public final class AllomancyPowerType implements ArgumentType { - public static final AllomancyPowerType INSTANCE = new AllomancyPowerType(); + static final AllomancyPowerType INSTANCE = new AllomancyPowerType(); private static final Set types = Arrays.stream(Metal.values()).map(Metal::getName).collect(Collectors.toSet()); private static final DynamicCommandExceptionType unknown_power = diff --git a/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java b/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java index 22577c0f..f6528e19 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/materials/MaterialsSetup.java @@ -42,8 +42,9 @@ import java.util.List; import java.util.function.Supplier; -public class MaterialsSetup { +public final class MaterialsSetup { + private MaterialsSetup() {} public record OreConfig(String name, int size, int placementCount, int minHeight, int maxHeight) { @@ -93,7 +94,7 @@ public String toString() { static { for (Metal mt : Metal.values()) { String name = mt.getName(); - FLAKES.add(MaterialsSetup.ITEMS.register(name + "_flakes", MaterialsSetup::createStandardItem)); + FLAKES.add(ITEMS.register(name + "_flakes", MaterialsSetup::createStandardItem)); if (mt.isVanilla()) { NUGGETS.add(null); @@ -109,14 +110,14 @@ public String toString() { new Item.Properties()))); } } - FLAKES.add(MaterialsSetup.ITEMS.register("lead_flakes", MaterialsSetup::createStandardItem)); + FLAKES.add(ITEMS.register("lead_flakes", MaterialsSetup::createStandardItem)); NUGGETS.add(ITEMS.register("lead_nugget", MaterialsSetup::createStandardItem)); INGOTS.add(ITEMS.register("lead_ingot", MaterialsSetup::createStandardItem)); STORAGE_BLOCKS.add(BLOCKS.register("lead_block", MaterialsSetup::createStandardBlock)); STORAGE_BLOCK_ITEMS.add(ITEMS.register("lead_block", () -> new BlockItem(STORAGE_BLOCKS.get(LEAD).get(), new Item.Properties()))); - FLAKES.add(MaterialsSetup.ITEMS.register("silver_flakes", MaterialsSetup::createStandardItem)); + FLAKES.add(ITEMS.register("silver_flakes", MaterialsSetup::createStandardItem)); NUGGETS.add(ITEMS.register("silver_nugget", MaterialsSetup::createStandardItem)); INGOTS.add(ITEMS.register("silver_ingot", MaterialsSetup::createStandardItem)); STORAGE_BLOCKS.add(BLOCKS.register("silver_block", MaterialsSetup::createStandardBlock)); @@ -158,20 +159,20 @@ public static void register(IEventBus bus) { GLM.register(bus); } - public static Block createStandardBlock() { + private static Block createStandardBlock() { return new Block(Blocks.STONE.properties().strength(2.1F).requiresCorrectToolForDrops()); } - public static Block createStandardOre() { + private static Block createStandardOre() { return new DropExperienceBlock(UniformInt.of(2, 5), Blocks.IRON_ORE.properties()); } - public static Block createDeepslateBlock() { + private static Block createDeepslateBlock() { return new DropExperienceBlock(UniformInt.of(2, 5), Blocks.DEEPSLATE_IRON_ORE.properties().strength(4.5F, 3.0F)); } - public static Item createStandardItem() { + private static Item createStandardItem() { return new Item(new Item.Properties()); } @@ -194,11 +195,7 @@ public static void bootstrapConfigured(BootstrapContext> public static void bootstrapPlaced(BootstrapContext bootstrap) { - for (int i = 0; i < ORE_METALS.length; i++) { - OreConfig ore = ORE_METALS[i]; - var ore_block = ORE_BLOCKS.get(i); - var deepslate_ore_block = DEEPSLATE_ORE_BLOCKS.get(i); - + for (OreConfig ore : ORE_METALS) { // Get configured feature registry HolderGetter> configured = bootstrap.lookup(Registries.CONFIGURED_FEATURE); diff --git a/src/main/java/com/legobmw99/allomancy/modules/materials/world/DaggerLootModifier.java b/src/main/java/com/legobmw99/allomancy/modules/materials/world/DaggerLootModifier.java index 799b84eb..0917e1bd 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/materials/world/DaggerLootModifier.java +++ b/src/main/java/com/legobmw99/allomancy/modules/materials/world/DaggerLootModifier.java @@ -19,7 +19,7 @@ public class DaggerLootModifier extends LootModifier { - public final int chance_one_in; + private final int chance_one_in; public static final Supplier> CODEC = Suppliers.memoize( () -> RecordCodecBuilder.mapCodec(inst -> codecStart(inst) .and(Codec.INT.fieldOf("chance_one_in").forGetter(t -> t.chance_one_in)) diff --git a/src/main/java/com/legobmw99/allomancy/modules/materials/world/LerasiumLootModifier.java b/src/main/java/com/legobmw99/allomancy/modules/materials/world/LerasiumLootModifier.java index 13680e8a..285bc814 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/materials/world/LerasiumLootModifier.java +++ b/src/main/java/com/legobmw99/allomancy/modules/materials/world/LerasiumLootModifier.java @@ -17,7 +17,7 @@ public class LerasiumLootModifier extends LootModifier { - public final int chance_one_in; + private final int chance_one_in; public static final Supplier> CODEC = Suppliers.memoize( () -> RecordCodecBuilder.mapCodec(inst -> codecStart(inst) .and(Codec.INT.fieldOf("chance_one_in").forGetter(t -> t.chance_one_in)) diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/CommonEventHandler.java b/src/main/java/com/legobmw99/allomancy/modules/powers/CommonEventHandler.java index 2334711a..1987cbf8 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/CommonEventHandler.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/CommonEventHandler.java @@ -38,9 +38,11 @@ import java.io.File; import java.util.Arrays; -public class CommonEventHandler { +public final class CommonEventHandler { + private CommonEventHandler() {} + /** * TEMPORARY: Used to port Forge worlds to Neoforged. * Loads the player's data file and sees if they have an old forge Capability stored. diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/PowersConfig.java b/src/main/java/com/legobmw99/allomancy/modules/powers/PowersConfig.java index 5f8faa8f..a7fa4863 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/PowersConfig.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/PowersConfig.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.Set; -public class PowersConfig { +public final class PowersConfig { public static final Set whitelist = new HashSet<>(); public static ModConfigSpec.IntValue max_metal_detection; @@ -20,7 +20,9 @@ public class PowersConfig { public static ModConfigSpec.EnumValue overlay_position; public static ModConfigSpec.BooleanValue random_mistings; public static ModConfigSpec.BooleanValue respect_player_UUID; - public static ModConfigSpec.ConfigValue> cfg_whitelist; + private static ModConfigSpec.ConfigValue> cfg_whitelist; + + private PowersConfig() {} public static void init(ModConfigSpec.Builder server_builder, ModConfigSpec.Builder common_builder, @@ -41,7 +43,7 @@ public static void init(ModConfigSpec.Builder server_builder, client_builder.push("graphics"); max_metal_detection = client_builder - .comment("Maximum iron/steelsight distance. Can have a HUGE impact on performance") + .comment("Maximum iron/steel sight distance. Can have an impact on performance") .defineInRange("max_metal_distance", 15, 3, 30); animate_selection = client_builder.comment("Animate the selection wheel").define("animate_selection", true); enable_overlay = client_builder.comment("Enable the screen overlay").define("overlay_enabled", true); @@ -52,7 +54,7 @@ public static void init(ModConfigSpec.Builder server_builder, } - public static void refresh(final ModConfigEvent e) { + public static void refresh(ModConfigEvent e) { ModConfig cfg = e.getConfig(); if (cfg.getSpec() == AllomancyConfig.SERVER_CONFIG) { whitelist.clear(); diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/PowersSetup.java b/src/main/java/com/legobmw99/allomancy/modules/powers/PowersSetup.java index 2bcc1341..65abd61e 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/PowersSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/PowersSetup.java @@ -3,11 +3,11 @@ import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.neoforged.neoforge.common.NeoForge; -public class PowersSetup { +public final class PowersSetup { + private PowersSetup() {} + public static void init(final FMLCommonSetupEvent e) { - e.enqueueWork(() -> { - NeoForge.EVENT_BUS.register(CommonEventHandler.class); - }); + e.enqueueWork(() -> NeoForge.EVENT_BUS.register(CommonEventHandler.class)); } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/ClientEventHandler.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/ClientEventHandler.java index 55bed21b..fc9b8bd1 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/ClientEventHandler.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/ClientEventHandler.java @@ -16,17 +16,16 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.neoforge.client.event.*; import net.neoforged.neoforge.client.event.sound.PlaySoundEvent; import org.lwjgl.glfw.GLFW; -public class ClientEventHandler { +public final class ClientEventHandler { private static final Tracking tracking = new Tracking(); - @OnlyIn(Dist.CLIENT) + private ClientEventHandler() {} + @SubscribeEvent public static void onClientTick(final ClientTickEvent.Post event) { Minecraft mc = Minecraft.getInstance(); @@ -46,14 +45,14 @@ public static void onClientTick(final ClientTickEvent.Post event) { // Handle our input-based powers if (mc.options.keyAttack.isDown()) { // Ray trace 20 blocks (or 40 if enhanced) - var trace = Inputs.getMouseOverExtended(20F * dist_modifier); + var trace = Inputs.getMouseOverExtended(20.0F * dist_modifier); PowerRequests.metallicPushPull(data, trace, Metal.IRON); PowerRequests.emotionPushPull(data, trace, Metal.ZINC); } if (mc.options.keyUse.isDown()) { // Ray trace 20 blocks (or 40 if enhanced) - var trace = Inputs.getMouseOverExtended(20F * dist_modifier); + var trace = Inputs.getMouseOverExtended(20.0F * dist_modifier); PowerRequests.metallicPushPull(data, trace, Metal.STEEL); PowerRequests.emotionPushPull(data, trace, Metal.BRASS); PowerRequests.nicrosilEnhance(data, trace); @@ -63,7 +62,6 @@ public static void onClientTick(final ClientTickEvent.Post event) { } - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onKeyInput(final InputEvent.Key event) { if (event.getAction() == GLFW.GLFW_PRESS) { @@ -71,7 +69,6 @@ public static void onKeyInput(final InputEvent.Key event) { } } - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onMouseInput(final InputEvent.MouseButton.Pre event) { if (event.getAction() == GLFW.GLFW_PRESS) { @@ -80,7 +77,6 @@ public static void onMouseInput(final InputEvent.MouseButton.Pre event) { } - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onRenderLevelStage(final RenderLevelStageEvent event) { if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_PARTICLES) { @@ -118,11 +114,11 @@ public static void onRenderLevelStage(final RenderLevelStageEvent event) { if ((data.isBurning(Metal.IRON) || data.isBurning(Metal.STEEL))) { tracking.forEachMetallicEntity( - entity -> Rendering.drawMetalLine(stack, playervec, entity.position(), 1.5F, 0F, 0.6F, 1F)); + entity -> Rendering.drawMetalLine(stack, playervec, entity.position(), 1.5F, 0.0F, 0.6F, 1.0F)); tracking.forEachMetalBlob(blob -> Rendering.drawMetalLine(stack, playervec, blob.getCenter(), Mth.clamp(0.3F + blob.size() * 0.4F, 0.5F, - 7.5F), 0F, 0.6F, 1F)); + 7.5F), 0.0F, 0.6F, 1.0F)); } /********************************************* @@ -161,7 +157,6 @@ public static void onRenderLevelStage(final RenderLevelStageEvent event) { } - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onFovCompute(final ComputeFovModifierEvent event) { var data = event.getPlayer().getData(AllomancerAttachment.ALLOMANCY_DATA); @@ -171,7 +166,6 @@ public static void onFovCompute(final ComputeFovModifierEvent event) { } } - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void onSound(final PlaySoundEvent event) { @@ -190,7 +184,6 @@ public static void onSound(final PlaySoundEvent event) { /** * Used to enable movement while the MetalSelectScreen is open */ - @OnlyIn(Dist.CLIENT) @SubscribeEvent public static void updateInputEvent(final MovementInputUpdateEvent event) { if (Minecraft.getInstance().screen instanceof MetalSelectScreen) { diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/PowersClientSetup.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/PowersClientSetup.java index fa4657af..b7abcb57 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/PowersClientSetup.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/PowersClientSetup.java @@ -16,8 +16,8 @@ import java.util.function.Supplier; -public class PowersClientSetup { - public static final DeferredRegister> PARTICLES = +public final class PowersClientSetup { + private static final DeferredRegister> PARTICLES = DeferredRegister.create(Registries.PARTICLE_TYPE, Allomancy.MODID); public static final Supplier> SOUND_PARTICLE_TYPE = PARTICLES.register("sound_particle", () -> new ParticleType<>(true) { @@ -34,13 +34,15 @@ public StreamCodec streamCod } }); + private PowersClientSetup() {} + public static void register(IEventBus bus) { PARTICLES.register(bus); } public static void registerParticle(final RegisterParticleProvidersEvent event) { Allomancy.LOGGER.info("Allomancy: Registering custom particles"); - event.registerSprite(PowersClientSetup.SOUND_PARTICLE_TYPE.get(), new SoundParticle.Factory()); + event.registerSprite(SOUND_PARTICLE_TYPE.get(), new SoundParticle.Factory()); } public static void clientInit(final FMLClientSetupEvent e) { diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java index 35bfbd0f..2a0de19b 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalOverlay.java @@ -9,7 +9,6 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.LayeredDraw; -import net.minecraft.client.gui.screens.ChatScreen; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.resources.ResourceLocation; @@ -17,12 +16,12 @@ import java.awt.*; -public class MetalOverlay implements LayeredDraw.Layer { +public final class MetalOverlay implements LayeredDraw.Layer { private static final Point[] Frames = new Point[4]; private static final ResourceLocation meterLoc = ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, "textures/gui/overlay/meter.png"); - private static int currentFrame = 0; + private int currentFrame = 0; static { int x = 0; @@ -115,14 +114,14 @@ public enum SCREEN_LOC { TOP_LEFT, BOTTOM_LEFT; - public int getX(int screenWidth) { + private int getX(int screenWidth) { return switch (this) { case TOP_RIGHT, BOTTOM_RIGHT -> screenWidth - 145; default -> 5; }; } - public int getY(int screenHeight) { + private int getY(int screenHeight) { return switch (this) { case BOTTOM_RIGHT, BOTTOM_LEFT -> screenHeight - 50; default -> 10; diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java index 711dfd05..bb11ddd3 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/gui/MetalSelectScreen.java @@ -26,13 +26,10 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import org.lwjgl.opengl.GL11; import java.util.Arrays; -@OnlyIn(Dist.CLIENT) public class MetalSelectScreen extends Screen { private static final String[] METAL_NAMES = @@ -44,13 +41,13 @@ public class MetalSelectScreen extends Screen { .stream(METAL_NAMES) .map(s -> ResourceLocation.fromNamespaceAndPath(Allomancy.MODID, String.format(GUI_METAL, s))) .toArray(ResourceLocation[]::new); - final Minecraft mc; - int timeIn = PowersConfig.animate_selection.get() ? 0 : 16; + private final Minecraft mc; + private int timeIn = PowersConfig.animate_selection.get() ? 0 : 16; // Config setting for whether the wheel animates open or instantly appears - int slotSelected = -1; + private int slotSelected = -1; public MetalSelectScreen() { - super(Component.translatable("allomancy_gui")); + super(Component.translatable("allomancy.gui")); this.mc = Minecraft.getInstance(); } @@ -93,7 +90,7 @@ public void render(GuiGraphics guiGraphics, int mx, int my, float partialTicks) Metal mt = Metal.getMetal(toMetalIndex(seg)); boolean mouseInSector = data.hasPower(mt) && (degPer * seg < angle && angle < degPer * (seg + 1)); float radius = - Math.max(0F, Math.min((this.timeIn + partialTicks - seg * 6F / segments) * 40F, maxRadius)); + Math.max(0.0F, Math.min((this.timeIn + partialTicks - seg * 6.0F / segments) * 40.0F, maxRadius)); if (mouseInSector) { this.slotSelected = seg; radius *= 1.025f; @@ -132,7 +129,7 @@ public void render(GuiGraphics guiGraphics, int mx, int my, float partialTicks) Metal mt = Metal.getMetal(toMetalIndex(seg)); boolean mouseInSector = data.hasPower(mt) && (degPer * seg < angle && angle < degPer * (seg + 1)); float radius = - Math.max(0F, Math.min((this.timeIn + partialTicks - seg * 6F / segments) * 40F, maxRadius)); + Math.max(0.0F, Math.min((this.timeIn + partialTicks - seg * 6.0F / segments) * 40.0F, maxRadius)); if (mouseInSector) { radius *= 1.025f; } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/ClientPayloadHandler.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/ClientPayloadHandler.java index 96a485f1..670cb9de 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/ClientPayloadHandler.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/ClientPayloadHandler.java @@ -14,9 +14,11 @@ import java.util.Arrays; -public class ClientPayloadHandler { +public final class ClientPayloadHandler { - public static void updateAllomancer(final AllomancerDataPayload payload, final IPayloadContext ctx) { + private ClientPayloadHandler() {} + + public static void updateAllomancer(AllomancerDataPayload payload, IPayloadContext ctx) { ctx.enqueueWork(() -> { Player player = Minecraft.getInstance().level.getPlayerByUUID(payload.player()); if (player == Minecraft.getInstance().player) { @@ -39,7 +41,7 @@ public static void updateAllomancer(final AllomancerDataPayload payload, final I }); } - public static void updateEnhanced(final EnhanceTimePayload payload, final IPayloadContext ctx) { + public static void updateEnhanced(EnhanceTimePayload payload, IPayloadContext ctx) { ctx.enqueueWork(() -> { Entity e = Minecraft.getInstance().level.getEntity(payload.entityID()); if (e instanceof Player player) { diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/PowerRequests.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/PowerRequests.java index 6fb5d3e9..1f73ec70 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/PowerRequests.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/network/PowerRequests.java @@ -4,7 +4,6 @@ import com.legobmw99.allomancy.api.enums.Metal; import com.legobmw99.allomancy.modules.combat.CombatSetup; import com.legobmw99.allomancy.modules.powers.client.util.Sounds; -import com.legobmw99.allomancy.modules.powers.data.AllomancerData; import com.legobmw99.allomancy.modules.powers.network.*; import com.legobmw99.allomancy.modules.powers.util.Physical; import net.minecraft.client.Minecraft; @@ -18,7 +17,9 @@ import net.minecraft.world.phys.HitResult; import net.neoforged.neoforge.network.PacketDistributor; -public class PowerRequests { +public final class PowerRequests { + private PowerRequests() {} + /** * Used to toggle a metal's burn state and play a sound effect * @@ -61,22 +62,30 @@ public static void metallicPushPull(IAllomancerData data, HitResult trace, Metal int force = (data.isEnhanced() ? 4 : 1) * (metal == Metal.STEEL ? 1 : -1); - if (trace.getType() == HitResult.Type.ENTITY && - Physical.isEntityMetallic(((EntityHitResult) trace).getEntity())) { - sendToServer(new EntityPushPullPayload(((EntityHitResult) trace).getEntity().getId(), force)); - } else if (trace.getType() == HitResult.Type.BLOCK) { - BlockPos bp = ((BlockHitResult) trace).getBlockPos(); - Player player = Minecraft.getInstance().player; - if (Physical.isBlockStateMetallic(player.level().getBlockState(bp)) || - (player.isCrouching() && metal == Metal.STEEL && - player.getMainHandItem().getItem() == CombatSetup.COIN_BAG.get() && - (!player.getProjectile(player.getMainHandItem()).isEmpty()))) { - sendToServer(new BlockPushPullPayload(bp, force)); + switch (trace) { + case EntityHitResult e: { + if (Physical.isEntityMetallic((e).getEntity())) { + sendToServer(new EntityPushPullPayload((e).getEntity().getId(), force)); + + } + break; + } + case BlockHitResult b: { + BlockPos bp = b.getBlockPos(); + Player player = Minecraft.getInstance().player; + if (Physical.isBlockStateMetallic(player.level().getBlockState(bp)) || + (player.isCrouching() && metal == Metal.STEEL && + player.getMainHandItem().getItem() == CombatSetup.COIN_BAG.get() && + (!player.getProjectile(player.getMainHandItem()).isEmpty()))) { + sendToServer(new BlockPushPullPayload(bp, force)); + } } + break; + default: } } - public static void nicrosilEnhance(AllomancerData data, HitResult trace) { + public static void nicrosilEnhance(IAllomancerData data, HitResult trace) { if (data.isBurning(Metal.NICROSIL)) { if ((trace != null) && (trace.getType() == HitResult.Type.ENTITY)) { Entity entity = ((EntityHitResult) trace).getEntity(); diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/particle/SoundParticle.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/particle/SoundParticle.java index af45fa4e..4e839d43 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/particle/SoundParticle.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/particle/SoundParticle.java @@ -6,19 +6,16 @@ import net.minecraft.client.particle.TextureSheetParticle; import net.minecraft.sounds.SoundSource; import net.minecraft.world.level.Level; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -@OnlyIn(Dist.CLIENT) -public class SoundParticle extends TextureSheetParticle { - public SoundParticle(Level world, - double x, - double y, - double z, - double motionX, - double motionY, - double motionZ, - SoundSource typeIn) { +public final class SoundParticle extends TextureSheetParticle { + private SoundParticle(Level world, + double x, + double y, + double z, + double motionX, + double motionY, + double motionZ, + SoundSource typeIn) { super((ClientLevel) world, x, y, z, motionX, motionY, motionZ); this.xd = motionX; @@ -31,13 +28,13 @@ public SoundParticle(Level world, switch (typeIn) { case HOSTILE -> // red - setColor(1F, 0.15F, 0.15F); + setColor(1.0F, 0.15F, 0.15F); case PLAYERS -> // yellow - setColor(1F, 1F, 0F); + setColor(1.0F, 1.0F, 0.0F); case NEUTRAL -> // green - setColor(0F, 1F, 0F); + setColor(0.0F, 1.0F, 0.0F); default -> // neutral/blue - setColor(0F, 0F, 1F); + setColor(0.0F, 0.0F, 1.0F); } } @@ -48,11 +45,12 @@ public void tick() { this.xo = this.x; this.yo = this.y; this.zo = this.z; - if (this.age++ >= this.lifetime) { + if (this.age >= this.lifetime) { this.remove(); } else { this.move(this.xd, this.yd, this.zd); } + this.age++; } @@ -62,7 +60,6 @@ public ParticleRenderType getRenderType() { } - @OnlyIn(Dist.CLIENT) public static class Factory implements ParticleProvider.Sprite { public TextureSheetParticle createParticle(SoundParticleData data, ClientLevel worldIn, diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Inputs.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Inputs.java index 4a1898a6..3c5fb6f5 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Inputs.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Inputs.java @@ -20,22 +20,18 @@ import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; import org.lwjgl.glfw.GLFW; import javax.annotation.Nullable; -@OnlyIn(Dist.CLIENT) -public class Inputs { +public final class Inputs { - @OnlyIn(Dist.CLIENT) - public static KeyMapping hud; - @OnlyIn(Dist.CLIENT) + private static KeyMapping hud; public static KeyMapping burn; - @OnlyIn(Dist.CLIENT) - public static KeyMapping[] powers; + private static KeyMapping[] powers; + + private Inputs() {} /** * Adapted from vanilla, allows getting mouseover at given distances @@ -53,21 +49,17 @@ public static HitResult getMouseOverExtended(float dist) { if (mc.level != null) { objectMouseOver = entity.pick(dist, partialTicks, false); Vec3 vec3d = entity.getEyePosition(partialTicks); - boolean flag = false; - int i = 3; double d1; d1 = objectMouseOver.getLocation().distanceToSqr(vec3d); Vec3 vec3d1 = entity.getViewVector(1.0F); Vec3 vec3d2 = vec3d.add(vec3d1.x * dist, vec3d1.y * dist, vec3d1.z * dist); - float f = 1.0F; AABB axisalignedbb = entity.getBoundingBox().expandTowards(vec3d1.scale(dist)).inflate(1.0D, 1.0D, 1.0D); EntityHitResult entityraytraceresult = ProjectileUtil.getEntityHitResult(entity, vec3d, vec3d2, axisalignedbb, (e) -> true, d1); if (entityraytraceresult != null) { - Entity entity1 = entityraytraceresult.getEntity(); Vec3 vec3d3 = entityraytraceresult.getLocation(); double d2 = vec3d.distanceToSqr(vec3d3); if (d2 < d1) { diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Rendering.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Rendering.java index 99403982..1febeb70 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Rendering.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Rendering.java @@ -7,13 +7,15 @@ import net.minecraft.world.phys.Vec3; import org.joml.Matrix4f; -public class Rendering { +public final class Rendering { + private Rendering() {} + /** * Draws a line from the player (denoted pX,Y,Z) to the given set of * coordinates (oX,Y,Z) in a certain color (r,g,b) * - * @param player - * @param dest + * @param player location of the player + * @param dest location to draw toward * @param width the width of the line */ public static void drawMetalLine(PoseStack stack, diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Sounds.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Sounds.java index f56d12b0..622d1d02 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Sounds.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Sounds.java @@ -7,20 +7,19 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.Vec3; -import net.neoforged.api.distmarker.Dist; -import net.neoforged.api.distmarker.OnlyIn; -@OnlyIn(Dist.CLIENT) -public class Sounds { +public final class Sounds { + private Sounds() {} + public static void soundForBurnChange(boolean burning) { if (burning) { Minecraft.getInstance().player.playSound( SoundEvent.createFixedRangeEvent(ResourceLocation.withDefaultNamespace("item.flintandsteel.use"), - 1f), 1, 5); + 1.0f), 1, 5); } else { Minecraft.getInstance().player.playSound( SoundEvent.createFixedRangeEvent(ResourceLocation.withDefaultNamespace("block.fire.extinguish"), - 1f), 1, 4); + 1.0f), 1, 4); } } @@ -35,15 +34,15 @@ public static void spawnParticleForSound(Player player, SoundInstance sound) { // Spawn sound particles String soundName = sound.getLocation().toString(); if (soundName.contains("entity") || soundName.contains("step")) { - double motionX = ((posX - (sound.getX() + .5)) * -0.7) / magnitude; - double motionY = ((posY - (sound.getY() + .2)) * -0.7) / magnitude; - double motionZ = ((posZ - (sound.getZ() + .5)) * -0.7) / magnitude; + double motionX = ((posX - (sound.getX() + 0.5)) * -0.7) / magnitude; + double motionY = ((posY - (sound.getY() + 0.2)) * -0.7) / magnitude; + double motionZ = ((posZ - (sound.getZ() + 0.5)) * -0.7) / magnitude; Minecraft.getInstance() .particleEngine.createParticle(new SoundParticleData(sound.getSource()), - posX + (Math.sin(Math.toRadians(player.getYHeadRot())) * -.7d), - posY + .2, - posZ + (Math.cos(Math.toRadians(player.getYHeadRot())) * .7d), + posX + (Math.sin(Math.toRadians(player.getYHeadRot())) * -0.7d), + posY + 0.2, + posZ + (Math.cos(Math.toRadians(player.getYHeadRot())) * 0.7d), motionX, motionY, motionZ); } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Tracking.java b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Tracking.java index bf2454c6..df0f5e5b 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Tracking.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/client/util/Tracking.java @@ -149,7 +149,7 @@ private boolean seek(IAllomancerData data, Player otherPlayer) { return true; } - public static class MetalBlockBlob { + public static final class MetalBlockBlob { private static final Level level = Minecraft.getInstance().level; private int blocks; diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerAttachment.java b/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerAttachment.java index 74c1f130..f88117cc 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerAttachment.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerAttachment.java @@ -8,7 +8,7 @@ import java.util.function.Supplier; -public class AllomancerAttachment { +public final class AllomancerAttachment { private static final DeferredRegister> ATTACHMENT_TYPES = DeferredRegister.create(NeoForgeRegistries.ATTACHMENT_TYPES, Allomancy.MODID); @@ -17,6 +17,8 @@ public class AllomancerAttachment { ATTACHMENT_TYPES.register("allomancy_data", () -> AttachmentType.serializable(AllomancerData::new).copyOnDeath().build()); + private AllomancerAttachment() {} + public static void register(IEventBus bus) { ATTACHMENT_TYPES.register(bus); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java b/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java index 0ad236a4..ee5fb919 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/data/AllomancerData.java @@ -269,14 +269,14 @@ public CompoundTag serializeNBT(HolderLookup.Provider provider) { allomancy_data.put("metal_burning", metal_burning); CompoundTag position = new CompoundTag(); - BlockPos death_block = this.getDeathLoc(); + BlockPos death_block = this.death_pos; if (death_block != null) { position.putString("death_dimension", this.getDeathDim().location().toString()); position.putInt("death_x", death_block.getX()); position.putInt("death_y", death_block.getY()); position.putInt("death_z", death_block.getZ()); } - BlockPos spawn_block = this.getSpawnLoc(); + BlockPos spawn_block = this.spawn_pos; if (spawn_block != null) { position.putString("spawn_dimension", this.getSpawnDim().location().toString()); position.putInt("spawn_x", spawn_block.getX()); diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/entity/ai/AIAttackOnCollideExtended.java b/src/main/java/com/legobmw99/allomancy/modules/powers/entity/ai/AIAttackOnCollideExtended.java index f7bf5b4c..2214a7b4 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/entity/ai/AIAttackOnCollideExtended.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/entity/ai/AIAttackOnCollideExtended.java @@ -5,46 +5,37 @@ import net.minecraft.world.entity.PathfinderMob; import net.minecraft.world.entity.ai.goal.Goal; import net.minecraft.world.entity.monster.Monster; -import net.minecraft.world.level.Level; import net.minecraft.world.level.pathfinder.Node; import net.minecraft.world.level.pathfinder.Path; import java.util.EnumSet; public class AIAttackOnCollideExtended extends Goal { - final Level worldObj; - final PathfinderMob attacker; + private final PathfinderMob attacker; /** * The speed with which the mob will approach the target */ - final double speedTowardsTarget; + private final double speedTowardsTarget; /** * When true, the mob will continue chasing its target, even if it can't * find a path to them right now. */ - final boolean longMemory; + private final boolean longMemory; /** * An amount of decrementing ticks that allows the entity to attack once the * tick reaches 0. */ - int attackTick; + private int attackTick; /** * The PathEntity of our entity. */ - Path entityPathEntity; - Class classTarget; + private Path entityPathEntity; private int ticksUntilNextPathRecalculation; private int failedPathFindingPenalty; - public AIAttackOnCollideExtended(PathfinderMob par1EntityCreature, Class par2Class, double par3, boolean par5) { - this(par1EntityCreature, par3, par5); - this.classTarget = par2Class; - } - public AIAttackOnCollideExtended(PathfinderMob par1EntityCreature, double par2, boolean par4) { this.attacker = par1EntityCreature; - this.worldObj = par1EntityCreature.level(); this.speedTowardsTarget = par2; this.longMemory = par4; this.setFlags(EnumSet.of(Flag.TARGET)); @@ -61,10 +52,9 @@ public boolean canUse() { return false; } else if (!livingEntity.isAlive()) { return false; - } else if ((this.classTarget != null) && !this.classTarget.isAssignableFrom(livingEntity.getClass())) { - return false; } else { - if (--this.ticksUntilNextPathRecalculation <= 0) { + --this.ticksUntilNextPathRecalculation; + if (this.ticksUntilNextPathRecalculation <= 0) { this.entityPathEntity = this.attacker.getNavigation().createPath(livingEntity, 0); this.ticksUntilNextPathRecalculation = 4 + this.attacker.getRandom().nextInt(7); return this.entityPathEntity != null; @@ -117,21 +107,23 @@ public void tick() { } this.attacker.getLookControl().setLookAt(livingEntity, 30.0F, 30.0F); - if ((this.longMemory || this.attacker.getSensing().hasLineOfSight(livingEntity)) && - (--this.ticksUntilNextPathRecalculation <= 0)) { - this.ticksUntilNextPathRecalculation = - this.failedPathFindingPenalty + 4 + this.attacker.getRandom().nextInt(7); - this.attacker.getNavigation().moveTo(livingEntity, this.speedTowardsTarget); - if (this.attacker.getNavigation().getPath() != null) { - Node finalPathPoint = this.attacker.getNavigation().getPath().getEndNode(); - if ((finalPathPoint != null) && - (livingEntity.distanceToSqr(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1)) { - this.failedPathFindingPenalty = 0; + if ((this.longMemory || this.attacker.getSensing().hasLineOfSight(livingEntity))) { + --this.ticksUntilNextPathRecalculation; + if (this.ticksUntilNextPathRecalculation <= 0) { + this.ticksUntilNextPathRecalculation = + this.failedPathFindingPenalty + 4 + this.attacker.getRandom().nextInt(7); + this.attacker.getNavigation().moveTo(livingEntity, this.speedTowardsTarget); + if (this.attacker.getNavigation().getPath() != null) { + Node finalPathPoint = this.attacker.getNavigation().getPath().getEndNode(); + if ((finalPathPoint != null) && + (livingEntity.distanceToSqr(finalPathPoint.x, finalPathPoint.y, finalPathPoint.z) < 1)) { + this.failedPathFindingPenalty = 0; + } else { + this.failedPathFindingPenalty += 10; + } } else { this.failedPathFindingPenalty += 10; } - } else { - this.failedPathFindingPenalty += 10; } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/Network.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/Network.java index 4df4fdf0..2e8f1aa5 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/Network.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/Network.java @@ -10,9 +10,11 @@ import net.neoforged.neoforge.network.registration.PayloadRegistrar; -public class Network { +public final class Network { + private Network() {} + public static void registerPayloads(final RegisterPayloadHandlersEvent event) { - final PayloadRegistrar registrar = event.registrar(Allomancy.MODID).versioned("3.0"); + PayloadRegistrar registrar = event.registrar(Allomancy.MODID).versioned("3.0"); registrar.playToClient(AllomancerDataPayload.TYPE, AllomancerDataPayload.STREAM_CODEC, ClientPayloadHandler::updateAllomancer); diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/network/ServerPayloadHandler.java b/src/main/java/com/legobmw99/allomancy/modules/powers/network/ServerPayloadHandler.java index 7075b9f0..859968e9 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/network/ServerPayloadHandler.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/network/ServerPayloadHandler.java @@ -26,9 +26,11 @@ import java.util.Arrays; -public class ServerPayloadHandler { +public final class ServerPayloadHandler { - public static void changeEmotion(final EmotionPayload data, final IPayloadContext ctx) { + private ServerPayloadHandler() {} + + public static void changeEmotion(EmotionPayload data, IPayloadContext ctx) { ctx.enqueueWork(() -> { ServerPlayer allomancer = (ServerPlayer) ctx.player(); PathfinderMob target = (PathfinderMob) allomancer.level().getEntity(data.entityID()); @@ -52,7 +54,7 @@ public static void changeEmotion(final EmotionPayload data, final IPayloadContex } - public static void tryPushPullBlock(final BlockPushPullPayload data, final IPayloadContext ctx) { + public static void tryPushPullBlock(BlockPushPullPayload data, IPayloadContext ctx) { ServerPlayer player = (ServerPlayer) ctx.player(); Level level = player.level(); BlockPos pos = data.block(); @@ -77,13 +79,13 @@ public static void tryPushPullBlock(final BlockPushPullPayload data, final IPayl "Tried to push or pull against an non-metallic block!")); } } else { - Allomancy.LOGGER.warn("Illegal use of iron/steel by player: {}!", player); + Allomancy.LOGGER.warn("Illegal use of iron/steel by player: {}! Block not loaded at {}", player, pos); ctx.disconnect(Component.translatable("allomancy.networking.kicked", "Tried to push or pull against an unloaded block!")); } } - public static void tryPushPullEntity(final EntityPushPullPayload payload, final IPayloadContext ctx) { + public static void tryPushPullEntity(EntityPushPullPayload payload, IPayloadContext ctx) { ServerPlayer player = (ServerPlayer) ctx.player(); Level level = player.level(); Entity target = level.getEntity(payload.entityID()); @@ -116,7 +118,7 @@ public static void tryPushPullEntity(final EntityPushPullPayload payload, final } } - public static void toggleBurnRequest(final ToggleBurnPayload payload, final IPayloadContext ctx) { + public static void toggleBurnRequest(ToggleBurnPayload payload, IPayloadContext ctx) { assert ctx.flow().isServerbound(); ctx.enqueueWork(() -> { @@ -147,7 +149,7 @@ public static void toggleBurnRequest(final ToggleBurnPayload payload, final IPay }); } - public static void updateEnhanced(final EnhanceTimePayload payload, final IPayloadContext ctx) { + public static void updateEnhanced(EnhanceTimePayload payload, IPayloadContext ctx) { assert ctx.flow().isServerbound(); ctx.enqueueWork(() -> { diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Emotional.java b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Emotional.java index d962f51f..58123ce6 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Emotional.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Emotional.java @@ -26,13 +26,15 @@ import java.util.function.Predicate; -public class Emotional { +public final class Emotional { private static final Predicate isAggroGoal = (goal) -> goal instanceof SwellGoal || goal instanceof AIAttackOnCollideExtended || goal instanceof MeleeAttackGoal || goal instanceof TargetGoal || goal instanceof PanicGoal || goal.getClass().getName().contains("Fireball") || goal.getClass().getName().contains("Attack") || goal.getClass().getName().contains("Anger"); + private Emotional() {} + public static void riot(PathfinderMob target, Player allomancer, boolean enhanced) { try { if (!enhanced) { @@ -45,7 +47,7 @@ public static void riot(PathfinderMob target, Player allomancer, boolean enhance target.setTarget(allomancer); target.setLastHurtByMob(allomancer); // TODO: try to use PrioritizedGoal::startExecuting for already hostiles - target.targetSelector.addGoal(1, new AIAttackOnCollideExtended(target, 1d, false)); + target.targetSelector.addGoal(1, new AIAttackOnCollideExtended(target, 1.0d, false)); target.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(target, Player.class, false)); target.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(target, target.getClass(), false)); target.goalSelector.addGoal(4, new RandomLookAroundGoal(target)); @@ -79,7 +81,7 @@ public static void riot(PathfinderMob target, Player allomancer, boolean enhance target.kill(); } } catch (Exception e) { - Allomancy.LOGGER.error("Failed to riot entity " + target + "! Please report this error!", e); + Allomancy.LOGGER.error("Failed to riot entity {}! Please report this error!", target, e); } } @@ -140,7 +142,7 @@ public static void soothe(PathfinderMob target, Player allomancer, boolean enhan } } catch (Exception e) { - Allomancy.LOGGER.error("Failed to soothe entity " + target + "! Please report this error!", e); + Allomancy.LOGGER.error("Failed to soothe entity {}! Please report this error!", target, e); } } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Enhancement.java b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Enhancement.java index 3b000614..edfcb5ea 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Enhancement.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Enhancement.java @@ -1,8 +1,8 @@ package com.legobmw99.allomancy.modules.powers.util; +import com.legobmw99.allomancy.api.data.IAllomancerData; import com.legobmw99.allomancy.api.enums.Metal; import com.legobmw99.allomancy.modules.powers.data.AllomancerAttachment; -import com.legobmw99.allomancy.modules.powers.data.AllomancerData; import com.legobmw99.allomancy.modules.powers.network.Network; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceKey; @@ -17,7 +17,9 @@ import static net.minecraft.world.level.portal.DimensionTransition.DO_NOTHING; -public class Enhancement { +public final class Enhancement { + private Enhancement() {} + /** * Wipe all metals from the player and sync to tracking entities. Used by Aluminum and Nicrosil * @@ -61,7 +63,7 @@ private static void teleport(Player player, Level world, ResourceKey dime } } - public static void teleportToLastDeath(Player curPlayer, Level level, AllomancerData data) { + public static void teleportToLastDeath(Player curPlayer, Level level, IAllomancerData data) { ResourceKey deathDim = data.getDeathDim(); if (deathDim != null) { teleport(curPlayer, level, deathDim, data.getDeathLoc()); @@ -72,7 +74,7 @@ public static void teleportToLastDeath(Player curPlayer, Level level, Allomancer } } - public static void teleportToSpawn(Player curPlayer, Level level, AllomancerData data) { + public static void teleportToSpawn(Player curPlayer, Level level, IAllomancerData data) { ResourceKey spawnDim = data.getSpawnDim(); BlockPos spawnLoc; diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Physical.java b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Physical.java index ef51529e..679facde 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Physical.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Physical.java @@ -10,7 +10,6 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; -import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.animal.IronGolem; @@ -33,9 +32,11 @@ import java.util.Objects; import java.util.regex.Pattern; -public class Physical { +public final class Physical { + private Physical() {} + /** * Block state wrapper on {@link Physical#isBlockMetallic} * @@ -77,40 +78,29 @@ private static boolean isOnWhitelist(String s) { * @return Whether the entity is metallic */ public static boolean isEntityMetallic(Entity entity) { - if (entity == null) { - return false; - } - if (entity instanceof ItemEntity item) { - return isItemMetallic(item.getItem()); - } - if (entity instanceof ItemFrame itemFrame) { - return isItemMetallic(itemFrame.getItem()); - } - if (entity instanceof FallingBlockEntity fbe) { - return isBlockStateMetallic(fbe.getBlockState()); - } - if (entity instanceof ProjectileNuggetEntity) { - return true; - } - if (entity instanceof AbstractMinecart) { - return true; - } - if (entity instanceof LivingEntity ent) { - if (ent instanceof IronGolem) { - return true; - } - if (isItemMetallic(ent.getItemInHand(InteractionHand.MAIN_HAND)) || - isItemMetallic(ent.getItemInHand(InteractionHand.OFF_HAND))) { - return true; - } - for (ItemStack itemStack : ent.getArmorSlots()) { - if (isItemMetallic(itemStack)) { - return true; + return switch (entity) { + case ItemEntity item -> isItemMetallic(item.getItem()); + case ItemFrame itemFrame -> isItemMetallic(itemFrame.getItem()); + case FallingBlockEntity fbe -> isBlockStateMetallic(fbe.getBlockState()); + case ProjectileNuggetEntity ignored -> true; + case AbstractMinecart ignored -> true; + case IronGolem ignored -> true; + case LivingEntity ent -> { + for (ItemStack itemStack : ent.getHandSlots()) { + if (isItemMetallic(itemStack)) { + yield true; + } } + for (ItemStack itemStack : ent.getArmorAndBodyArmorSlots()) { + if (isItemMetallic(itemStack)) { + yield true; + } + } + yield false; } - } + default -> false; + }; - return false; } private static final Pattern ACTIVE_METAL_REGEX = Pattern.compile( @@ -275,14 +265,14 @@ public static List default_whitelist() { .forEach(Physical::add); - ArrayList list = new ArrayList<>(defaultList); + List list = new ArrayList<>(defaultList); list.sort(String::compareTo); return list; } private static void add(String s) { - Allomancy.LOGGER.info("Adding " + s + " to the default whitelist!"); + Allomancy.LOGGER.info("Adding {} to the default whitelist!", s); defaultList.add(s); } diff --git a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Temporal.java b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Temporal.java index cdd1af49..14bff309 100644 --- a/src/main/java/com/legobmw99/allomancy/modules/powers/util/Temporal.java +++ b/src/main/java/com/legobmw99/allomancy/modules/powers/util/Temporal.java @@ -1,7 +1,6 @@ package com.legobmw99.allomancy.modules.powers.util; import com.legobmw99.allomancy.api.data.IAllomancerData; -import com.legobmw99.allomancy.modules.powers.data.AllomancerData; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.effect.MobEffectInstance; @@ -17,7 +16,9 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -public class Temporal { +public final class Temporal { + private Temporal() {} + @SuppressWarnings("unchecked") public static void speedUpNearby(Player curPlayer, Level level, IAllomancerData data) { curPlayer.addEffect(new MobEffectInstance(MobEffects.DIG_SPEED, 10, 3, true, false)); @@ -56,7 +57,7 @@ public static void speedUpNearby(Player curPlayer, Level level, IAllomancerData } } - public static void slowDownNearby(Player curPlayer, Level level, AllomancerData data) { + public static void slowDownNearby(Player curPlayer, Level level, IAllomancerData data) { int max = data.isEnhanced() ? 20 : 10; Vec3 negative = curPlayer.position().add(-max, -max, -max); Vec3 positive = curPlayer.position().add(max, max, max); diff --git a/src/main/java/com/legobmw99/allomancy/util/AllomancyConfig.java b/src/main/java/com/legobmw99/allomancy/util/AllomancyConfig.java index 2fe312af..26a5ba77 100644 --- a/src/main/java/com/legobmw99/allomancy/util/AllomancyConfig.java +++ b/src/main/java/com/legobmw99/allomancy/util/AllomancyConfig.java @@ -7,7 +7,7 @@ import net.neoforged.neoforge.common.ModConfigSpec; -public class AllomancyConfig { +public final class AllomancyConfig { private static final ModConfigSpec COMMON_CONFIG; private static final ModConfigSpec CLIENT_CONFIG; @@ -27,6 +27,8 @@ public class AllomancyConfig { } + private AllomancyConfig() {} + public static void onReload(final ModConfigEvent.Reloading e) { PowersConfig.refresh(e); } @@ -37,8 +39,8 @@ public static void onLoad(final ModConfigEvent.Loading e) { } public static void register(ModContainer container) { - container.registerConfig(ModConfig.Type.COMMON, AllomancyConfig.COMMON_CONFIG); - container.registerConfig(ModConfig.Type.CLIENT, AllomancyConfig.CLIENT_CONFIG); - container.registerConfig(ModConfig.Type.SERVER, AllomancyConfig.SERVER_CONFIG); + container.registerConfig(ModConfig.Type.COMMON, COMMON_CONFIG); + container.registerConfig(ModConfig.Type.CLIENT, CLIENT_CONFIG); + container.registerConfig(ModConfig.Type.SERVER, SERVER_CONFIG); } } diff --git a/src/main/java/com/legobmw99/allomancy/util/ItemDisplay.java b/src/main/java/com/legobmw99/allomancy/util/ItemDisplay.java index ccde6507..8473e73e 100644 --- a/src/main/java/com/legobmw99/allomancy/util/ItemDisplay.java +++ b/src/main/java/com/legobmw99/allomancy/util/ItemDisplay.java @@ -23,92 +23,96 @@ import java.util.function.Supplier; -public class ItemDisplay { +public final class ItemDisplay { private static final DeferredRegister CREATIVETABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, Allomancy.MODID); - public static Supplier allomancy_group = CREATIVETABS.register("main_tab", () -> CreativeModeTab - .builder() - .icon(() -> new ItemStack(CombatSetup.MISTCLOAK.get())) - .title(Component.translatable("tabs.allomancy.main_tab")) - .displayItems((featureFlags, output) -> { - output.accept(ConsumeSetup.LERASIUM_NUGGET.get()); - output.accept(CombatSetup.ALUMINUM_HELMET.get()); - output.accept(CombatSetup.MISTCLOAK.get()); - output.accept(CombatSetup.COIN_BAG.get()); - output.accept(ConsumeSetup.ALLOMANTIC_GRINDER.get()); - output.accept(ConsumeSetup.VIAL.get()); - - ItemStack fullVial = new ItemStack(ConsumeSetup.VIAL.get(), 1); - FlakeStorage.Mutable storage = new FlakeStorage.Mutable(); - for (Metal mt : Metal.values()) { - storage.add(mt); - } - VialItem.fillVial(fullVial, storage.toImmutable()); - - output.accept(fullVial); - - output.accept(CombatSetup.KOLOSS_BLADE.get()); - output.accept(CombatSetup.OBSIDIAN_DAGGER.get()); - - output.accept(ExtrasSetup.IRON_LEVER.get()); - output.accept(ExtrasSetup.IRON_BUTTON.get()); - output.accept(ExtrasSetup.INVERTED_IRON_BUTTON.get()); - - - for (var block : MaterialsSetup.STORAGE_BLOCKS) { - if (block == null) { - continue; - } - output.accept(block.get()); - } - - for (var ingot : MaterialsSetup.INGOTS) { - if (ingot == null) { - continue; - } - output.accept(ingot.get()); - } - - for (var nug : MaterialsSetup.NUGGETS) { - if (nug == null) { - continue; - } - output.accept(nug.get()); - } - - for (var flake : MaterialsSetup.FLAKES) { - if (flake == null) { - continue; - } - output.accept(flake.get()); - } - - for (Metal mt : Metal.values()) { - output.accept(ExtrasSetup.PATTERN_ITEMS.get(mt.getIndex()).get()); - } - - for (var ore : MaterialsSetup.ORE_BLOCKS) { - output.accept(ore.get()); - } - - for (var ore : MaterialsSetup.DEEPSLATE_ORE_BLOCKS) { - output.accept(ore.get()); - } - - for (var ore : MaterialsSetup.RAW_ORE_BLOCKS) { - output.accept(ore.get()); - } - - for (var ore : MaterialsSetup.RAW_ORE_ITEMS) { - output.accept(ore.get()); - } - - }) - .build()); - - public static void addTabContents(BuildCreativeModeTabContentsEvent event) { + private static final Supplier ALLOMANCY_CREATIVE_TAB = + + CREATIVETABS.register("main_tab", () -> CreativeModeTab + .builder() + .icon(() -> new ItemStack(CombatSetup.MISTCLOAK.get())) + .title(Component.translatable("tabs" + ".allomancy.main_tab")) + .displayItems((featureFlags, output) -> { + output.accept(ConsumeSetup.LERASIUM_NUGGET.get()); + output.accept(CombatSetup.ALUMINUM_HELMET.get()); + output.accept(CombatSetup.MISTCLOAK.get()); + output.accept(CombatSetup.COIN_BAG.get()); + output.accept(ConsumeSetup.ALLOMANTIC_GRINDER.get()); + output.accept(ConsumeSetup.VIAL.get()); + + ItemStack fullVial = new ItemStack(ConsumeSetup.VIAL.get(), 1); + FlakeStorage.Mutable storage = new FlakeStorage.Mutable(); + for (Metal mt : Metal.values()) { + storage.add(mt); + } + VialItem.fillVial(fullVial, storage.toImmutable()); + + output.accept(fullVial); + + output.accept(CombatSetup.KOLOSS_BLADE.get()); + output.accept(CombatSetup.OBSIDIAN_DAGGER.get()); + + output.accept(ExtrasSetup.IRON_LEVER.get()); + output.accept(ExtrasSetup.IRON_BUTTON.get()); + output.accept(ExtrasSetup.INVERTED_IRON_BUTTON.get()); + + + for (var block : MaterialsSetup.STORAGE_BLOCKS) { + if (block == null) { + continue; + } + output.accept(block.get()); + } + + for (var ingot : MaterialsSetup.INGOTS) { + if (ingot == null) { + continue; + } + output.accept(ingot.get()); + } + + for (var nug : MaterialsSetup.NUGGETS) { + if (nug == null) { + continue; + } + output.accept(nug.get()); + } + + for (var flake : MaterialsSetup.FLAKES) { + if (flake == null) { + continue; + } + output.accept(flake.get()); + } + + for (Metal mt : Metal.values()) { + output.accept(ExtrasSetup.PATTERN_ITEMS.get(mt.getIndex()).get()); + } + + for (var ore : MaterialsSetup.ORE_BLOCKS) { + output.accept(ore.get()); + } + + for (var ore : MaterialsSetup.DEEPSLATE_ORE_BLOCKS) { + output.accept(ore.get()); + } + + for (var ore : MaterialsSetup.RAW_ORE_BLOCKS) { + output.accept(ore.get()); + } + + for (var ore : MaterialsSetup.RAW_ORE_ITEMS) { + output.accept(ore.get()); + } + + }) + .build()); + + private ItemDisplay() {} + + public static void addTabContents(final BuildCreativeModeTabContentsEvent event) { if (event.getTabKey() == CreativeModeTabs.COMBAT) { event.accept(CombatSetup.ALUMINUM_HELMET); event.accept(CombatSetup.MISTCLOAK); diff --git a/src/main/resources/META-INF/neoforge.mods.toml b/src/main/resources/META-INF/neoforge.mods.toml index c39ec4d9..37474f7f 100644 --- a/src/main/resources/META-INF/neoforge.mods.toml +++ b/src/main/resources/META-INF/neoforge.mods.toml @@ -5,7 +5,7 @@ # Find more information on toml format here: https://github.com/toml-lang/toml # The name of the mod loader type to load - for regular FML @Mod mods it should be javafml modLoader = "javafml" #mandatory -# A version range to match for said mod loader - for regular FML @Mod it will be the the FML version. This is currently 47. +# A version range to match for said mod loader - for regular FML @Mod it will be the FML version. This is currently 47. loaderVersion = "${loader_version_range}" #mandatory # The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties. # Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here. @@ -44,7 +44,7 @@ description = '''${mod_description}''' [[dependencies.${ mod_id }]] #optional # the modid of the dependency modId = "neoforge" #mandatory -# The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case insensitive). +# The type of the dependency. Can be one of "required", "optional", "incompatible" or "discouraged" (case-insensitive). # 'required' requires the mod to exist, 'optional' does not # 'incompatible' will prevent the game from loading when the mod exists, and 'discouraged' will show a warning type = "required" #mandatory