diff --git a/misc/shell_rename_files.sh b/misc/shell_rename_files.sh index 4f6bdf18b..df7a1001e 100644 --- a/misc/shell_rename_files.sh +++ b/misc/shell_rename_files.sh @@ -6,15 +6,15 @@ do echo $file -OLD="\"_block" -NEW="\"_bricks" +OLD="_adamantine" +NEW="_wood" # Modifica delle string all'interno del file # sed "s/old_string/new_string/g" $file # remove -i to preview changes sed -i "s/$OLD/$NEW/g" $file - wordToRemove="block - Copy.json" - wordToAdd="bricks.json" + wordToRemove="_custom.json" + wordToAdd="_adamantine.json" # file = test_chest.json -> test_ new=${file//$wordToRemove/} @@ -22,7 +22,9 @@ NEW="\"_bricks" # file = test_ -> test_chestplate.json # $nomevariabile1$nomevariabile2 = string contatenation # mv "vecchia string" "nuova string" -> file rename - mv "$file" "$new$wordToAdd" + if [ $file != $new ]; then + mv "$file" "$new$wordToAdd" + fi echo LASAGNE! diff --git a/src/main/java/it/hurts/metallurgy_reforged/Metallurgy.java b/src/main/java/it/hurts/metallurgy_reforged/Metallurgy.java index 9c470f130..75805f96a 100644 --- a/src/main/java/it/hurts/metallurgy_reforged/Metallurgy.java +++ b/src/main/java/it/hurts/metallurgy_reforged/Metallurgy.java @@ -61,7 +61,7 @@ public class Metallurgy { public static final String MODID = "metallurgy"; public static final String NAME = "Metallurgy 4: Reforged"; - public static final String VERSION = "1.3.9"; + public static final String VERSION = "1.4.0"; public static Logger logger; @@ -116,19 +116,19 @@ public void preInit(FMLPreInitializationEvent event) logger.info("Metallurgy Advancement Criteria Registered!"); //checks if tinker is installed - if (ModChecker.isTConLoaded && !GeneralConfig.tinkerIntegration) + if (ModChecker.isTConLoaded && GeneralConfig.tiCIntegration) { IntegrationTIC.preInit(); logger.info("Tinkers' Construct Compatibility module has been pre-initialized"); - if (ModChecker.isConarmLoaded && !GeneralConfig.armoryIntegration) + if (ModChecker.isConarmLoaded && GeneralConfig.conarmIntegration) { IntegrationCArmory.preInit(); logger.info("Construct's Armory Compatibility module has been pre-initialized"); } } - if (ModChecker.isIFLoaded && !GeneralConfig.inForegoingIntegration) + if (ModChecker.isIFLoaded && GeneralConfig.inForegoingIntegration) { IntegrationIF.preInit(); logger.info("Industrial Foregoing Compatibility module has been pre-initialized"); @@ -140,7 +140,7 @@ public void preInit(FMLPreInitializationEvent event) logger.info("CraftTweaker Compatibility module has been pre-initialized"); } - if (ModChecker.isSilentGemsLoaded) + if (ModChecker.isSilentGemsLoaded && GeneralConfig.silentGemsIntegration) { IntegrationSilentGems.init(); logger.info("CraftTweaker Compatibility module has been initialized"); @@ -167,12 +167,12 @@ public void init(FMLInitializationEvent event) ModRecipes.initFurnaceRecipes(); logger.info("Furnace Recipes loaded!"); - if (ModChecker.isTConLoaded && !GeneralConfig.tinkerIntegration) + if (ModChecker.isTConLoaded && GeneralConfig.tiCIntegration) { IntegrationTIC.init(); logger.info("Tinkers' Construct Compatibility module has been initialized"); - if (ModChecker.isConarmLoaded && !GeneralConfig.armoryIntegration) + if (ModChecker.isConarmLoaded && GeneralConfig.conarmIntegration) { IntegrationCArmory.init(); logger.info("Construct's Armory Compatibility module has been initialized"); @@ -216,7 +216,7 @@ public void postInit(FMLPostInitializationEvent event) PacketManager.init(); logger.info(NAME + "'s Network System Loaded"); - if (ModChecker.isTConLoaded && !GeneralConfig.tinkerIntegration) + if (ModChecker.isTConLoaded && GeneralConfig.tiCIntegration) IntegrationTIC.postInit(); logger.info("Tinker's alloy recipes loaded"); diff --git a/src/main/java/it/hurts/metallurgy_reforged/config/GeneralConfig.java b/src/main/java/it/hurts/metallurgy_reforged/config/GeneralConfig.java index c611f95f7..ef4ecc2aa 100644 --- a/src/main/java/it/hurts/metallurgy_reforged/config/GeneralConfig.java +++ b/src/main/java/it/hurts/metallurgy_reforged/config/GeneralConfig.java @@ -29,26 +29,26 @@ public class GeneralConfig { @Config.RangeDouble(min = 1) public static double roadSpeed = 1.50D; - @Config.Name("Disable tinker integration") - @Config.Comment("Set to true to disable Tinkers' Construct Integration") - public static boolean tinkerIntegration = false; + @Config.Name("Tinkers' Construct integration") + @Config.Comment("Set to false to disable Tinkers' Construct Integration") + public static boolean tiCIntegration = true; - @Config.Name("Tinker Materials Blacklist") + @Config.Name("Tinkers' Materials Blacklist") @Config.Comment("Add a material in this array to blacklist it during game boot - material name format is \"snake_case\" (e.g. 'osmium' or 'damascus_steel')") @Config.RequiresMcRestart public static String[] tinkerMaterialsBlacklist = new String[]{ }; - @Config.Name("Disable ConArm Integration") - @Config.Comment("Set to true to disable Construct's Armory Integration") - public static boolean armoryIntegration = false; + @Config.Name("Disable Construct's Armory integration") + @Config.Comment("Set to false to disable Construct's Armory Integration") + public static boolean conarmIntegration = true; - @Config.Name("Disable IF Integration") - @Config.Comment("Set to true to disable Industrial Foregoing Integration") - public static boolean inForegoingIntegration = false; + @Config.Name("Industrial Foregoing integration") + @Config.Comment("Set to false to disable Industrial Foregoing integration") + public static boolean inForegoingIntegration = true; - @Config.Name("Disable Automatic EMC values") - @Config.Comment("Set to true to disable default EMC values") - public static boolean projectEIntegration = false; + @Config.Name("ProjectE Integration") + @Config.Comment("Set to false to disable default EMC values (ProjectE)") + public static boolean projectEIntegration = true; @Config.Name("Enable Duplication Trait") @Config.Comment("When set to true the duplication trait from tinker integration is enabled") @@ -114,6 +114,14 @@ public class GeneralConfig { @Config.Comment("Disabling this option will prevent modification to tooltip borders for metal items (useful when the modpack has another system to modify tooltips that conflicts with Metallurgy or hinders the consistency of modpack tooltips).") public static boolean metalColoredTooltipBorders = true; + @Config.Name("Silent's Gems Integration") + @Config.Comment("Set to false to disable Silent's Gems integration") + public static boolean silentGemsIntegration = true; + + @Config.Name("Spartan Weaponry Integration") + @Config.Comment("Set to false to disable Spartan Weaponry integration (WARNING: integration items use up a lot of IDs!)") + public static boolean spartanWeaponryIntegration = true; + //Handles Config Synchronization public static class ChangeListener { diff --git a/src/main/java/it/hurts/metallurgy_reforged/handler/RegistrationHandler.java b/src/main/java/it/hurts/metallurgy_reforged/handler/RegistrationHandler.java index 196e30136..5ac7430fa 100644 --- a/src/main/java/it/hurts/metallurgy_reforged/handler/RegistrationHandler.java +++ b/src/main/java/it/hurts/metallurgy_reforged/handler/RegistrationHandler.java @@ -16,10 +16,12 @@ import it.hurts.metallurgy_reforged.capabilities.effect.EffectDataProvider; import it.hurts.metallurgy_reforged.capabilities.entity.EntityDataProvider; import it.hurts.metallurgy_reforged.capabilities.punch.PunchEffectProvider; +import it.hurts.metallurgy_reforged.config.GeneralConfig; import it.hurts.metallurgy_reforged.config.RegistrationConfig; import it.hurts.metallurgy_reforged.entity.EntityPierKnight; import it.hurts.metallurgy_reforged.entity.MetallurgyPrimedTNT; import it.hurts.metallurgy_reforged.fluid.ModFluids; +import it.hurts.metallurgy_reforged.integration.IntegrationSW; import it.hurts.metallurgy_reforged.item.ModItems; import it.hurts.metallurgy_reforged.item.tool.EnumTools; import it.hurts.metallurgy_reforged.material.ModMetals; @@ -27,6 +29,7 @@ import it.hurts.metallurgy_reforged.render.knuckles.BrassKnucklesBakedModel; import it.hurts.metallurgy_reforged.sound.ModSounds; import it.hurts.metallurgy_reforged.util.ItemUtils; +import it.hurts.metallurgy_reforged.util.ModChecker; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -112,6 +115,11 @@ public static void registerItems(RegistryEvent.Register event) //Init OreDictionary (Register keys) OreDictHandler.init(); Metallurgy.logger.info(Metallurgy.NAME + ": OreDictionary has been initialized"); + + if (ModChecker.isSpartanWeaponryLoaded && GeneralConfig.spartanWeaponryIntegration) { + IntegrationSW.registerItems(event.getRegistry()); + Metallurgy.logger.info(Metallurgy.NAME + ": Spartan Weaponry Integration items have been registered"); + } } @SubscribeEvent diff --git a/src/main/java/it/hurts/metallurgy_reforged/integration/IntegrationSW.java b/src/main/java/it/hurts/metallurgy_reforged/integration/IntegrationSW.java new file mode 100644 index 000000000..d7aa56465 --- /dev/null +++ b/src/main/java/it/hurts/metallurgy_reforged/integration/IntegrationSW.java @@ -0,0 +1,55 @@ +/*============================================================================== + = Class: IntegrationSW + = This class is part of Metallurgy 4: Reforged + = Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged + = This code is licensed under GNU GPLv3 + = Authors: Davoleo, ItHurtsLikeHell, PierKnight100 + = Copyright (c) 2018-2024. + =============================================================================*/ + +package it.hurts.metallurgy_reforged.integration; + +import com.oblivioussp.spartanweaponry.api.IWeaponCallback; +import com.oblivioussp.spartanweaponry.api.SpartanWeaponryAPI; +import it.hurts.metallurgy_reforged.Metallurgy; +import it.hurts.metallurgy_reforged.integration.spartanweaponry.SpartanMetal; +import it.hurts.metallurgy_reforged.integration.spartanweaponry.SpartanMetallurgyTab; +import it.hurts.metallurgy_reforged.integration.spartanweaponry.SpartanWeaponType; +import it.hurts.metallurgy_reforged.material.ModMetals; +import net.minecraft.item.Item; +import net.minecraftforge.registries.IForgeRegistry; + +import java.util.ArrayList; +import java.util.List; + +public class IntegrationSW { + + public static final String MODID = "spartanweaponry"; + + public static final IWeaponCallback NOOP = (material, stack, world, tooltip, flag) -> { + }; + + public static final SpartanMetallurgyTab CREATIVE_TAB = new SpartanMetallurgyTab(); + + public static final List spartanMetals = new ArrayList<>(); + + public static void registerItems(IForgeRegistry registry) { + ModMetals.metalMap.forEach((name, metal) -> { + if (metal.hasToolSet()) { + spartanMetals.add(new SpartanMetal(registry, metal.getStats())); + } + }); + + spartanMetals.forEach(spartanMetal -> { + SpartanWeaponryAPI.registerColourHandler( + spartanMetal.getMaterialEx(), + spartanMetal.getItems().values().toArray(new Item[0]) + ); + + for (SpartanWeaponType weaponType : SpartanWeaponType.values()) { + SpartanWeaponryAPI.addItemModelToRegistry(spartanMetal.getWeapon(weaponType), + Metallurgy.MODID, IntegrationSW.MODID + '/' + weaponType.name().toLowerCase()); + } + }); + } +} diff --git a/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/ISpartanWeaponInitalizer.java b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/ISpartanWeaponInitalizer.java new file mode 100644 index 000000000..dcc3a307b --- /dev/null +++ b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/ISpartanWeaponInitalizer.java @@ -0,0 +1,22 @@ +/*============================================================================== + = Class: SpartanWeaponInitalizer + = This class is part of Metallurgy 4: Reforged + = Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged + = This code is licensed under GNU GPLv3 + = Authors: Davoleo, ItHurtsLikeHell, PierKnight100 + = Copyright (c) 2018-2024. + =============================================================================*/ + +package it.hurts.metallurgy_reforged.integration.spartanweaponry; + +import com.oblivioussp.spartanweaponry.api.ToolMaterialEx; +import com.oblivioussp.spartanweaponry.api.weaponproperty.WeaponProperty; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +@FunctionalInterface +public interface ISpartanWeaponInitalizer { + + Item create(ToolMaterialEx toolMaterialEx, String modid, CreativeTabs creativeTab, WeaponProperty... properties); + +} diff --git a/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetal.java b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetal.java new file mode 100644 index 000000000..38b6bc3b8 --- /dev/null +++ b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetal.java @@ -0,0 +1,71 @@ +/*============================================================================== + = Class: SpartanMetal + = This class is part of Metallurgy 4: Reforged + = Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged + = This code is licensed under GNU GPLv3 + = Authors: Davoleo, ItHurtsLikeHell, PierKnight100 + = Copyright (c) 2018-2024. + =============================================================================*/ + +package it.hurts.metallurgy_reforged.integration.spartanweaponry; + +import com.google.common.base.CaseFormat; +import com.google.common.collect.Maps; +import com.oblivioussp.spartanweaponry.api.ToolMaterialEx; +import it.hurts.metallurgy_reforged.Metallurgy; +import it.hurts.metallurgy_reforged.integration.IntegrationSW; +import it.hurts.metallurgy_reforged.material.MetalStats; +import net.minecraft.item.Item; +import net.minecraftforge.registries.IForgeRegistry; + +import java.util.Map; + +public class SpartanMetal { + + private final MetalStats stats; + + private final ToolMaterialEx toolMaterial; + + private final Map items = Maps.newEnumMap(SpartanWeaponType.class); + + public SpartanMetal(IForgeRegistry registry, MetalStats stats) { + this.stats = stats; + + final String ingotOre = "ingot" + CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, stats.getName()); + final int metalColor = stats.getColorHex(); + this.toolMaterial = new ToolMaterialEx( + stats.getName(), ingotOre, Metallurgy.MODID, metalColor, metalColor, + stats.getToolMaterial().getHarvestLevel(), stats.getToolMaterial().getMaxUses(), stats.getToolMaterial().getEfficiency(), + stats.getToolMaterial().getAttackDamage(), stats.getToolMaterial().getEnchantability() + ); + + for (SpartanWeaponType type : SpartanWeaponType.values()) { + final Item weapon = type.initializer.create(toolMaterial, Metallurgy.MODID, IntegrationSW.CREATIVE_TAB); + items.put(type, weapon); + + if (weapon != null) { + registry.register(weapon); + } + } + } + + public MetalStats getStats() { + return stats; + } + + public ToolMaterialEx getMaterialEx() { + return toolMaterial; + } + + public Map getItems() { + return items; + } + + public Item getWeapon(SpartanWeaponType type) { + return items.get(type); + } + + public boolean isWeaponEnabled(SpartanWeaponType type) { + return items.get(type) != null; + } +} diff --git a/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetallurgyTab.java b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetallurgyTab.java new file mode 100644 index 000000000..cb5ca811a --- /dev/null +++ b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanMetallurgyTab.java @@ -0,0 +1,29 @@ +/*============================================================================== + = Class: SpartanMetallurgyTab + = This class is part of Metallurgy 4: Reforged + = Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged + = This code is licensed under GNU GPLv3 + = Authors: Davoleo, ItHurtsLikeHell, PierKnight100 + = Copyright (c) 2018-2024. + =============================================================================*/ + +package it.hurts.metallurgy_reforged.integration.spartanweaponry; + +import it.hurts.metallurgy_reforged.integration.IntegrationSW; +import it.hurts.metallurgy_reforged.util.MetallurgyTabs; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnull; + +public class SpartanMetallurgyTab extends MetallurgyTabs { + + public SpartanMetallurgyTab() { + super(9, IntegrationSW.MODID); + } + + @Nonnull + @Override + public ItemStack createIcon() { + return new ItemStack(IntegrationSW.spartanMetals.get(0).getWeapon(SpartanWeaponType.KATANA)); + } +} diff --git a/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanWeaponType.java b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanWeaponType.java new file mode 100644 index 000000000..cf3912302 --- /dev/null +++ b/src/main/java/it/hurts/metallurgy_reforged/integration/spartanweaponry/SpartanWeaponType.java @@ -0,0 +1,47 @@ +/*============================================================================== + = Class: SpartanWeaponTypes + = This class is part of Metallurgy 4: Reforged + = Complete source code is available at https://github.com/Davoleo/Metallurgy-4-Reforged + = This code is licensed under GNU GPLv3 + = Authors: Davoleo, ItHurtsLikeHell, PierKnight100 + = Copyright (c) 2018-2024. + =============================================================================*/ + +package it.hurts.metallurgy_reforged.integration.spartanweaponry; + +import com.oblivioussp.spartanweaponry.api.SpartanWeaponryAPI; +import it.hurts.metallurgy_reforged.integration.IntegrationSW; + + +public enum SpartanWeaponType { + DAGGER(SpartanWeaponryAPI::createDagger), + LONGSWORD(SpartanWeaponryAPI::createLongsword), + KATANA(SpartanWeaponryAPI::createKatana), + SABER(SpartanWeaponryAPI::createSaber), + RAPIER(SpartanWeaponryAPI::createRapier), + GREATSWORD(SpartanWeaponryAPI::createGreatsword), + HAMMER(SpartanWeaponryAPI::createHammer), + WARHAMMER(SpartanWeaponryAPI::createWarhammer), + SPEAR(SpartanWeaponryAPI::createSpear), + HALBERD(SpartanWeaponryAPI::createHalberd), + PIKE(SpartanWeaponryAPI::createPike), + LANCE(SpartanWeaponryAPI::createLance), + THROWING_KNIFE(SpartanWeaponryAPI::createThrowingKnife), + THROWING_AXE(SpartanWeaponryAPI::createThrowingAxe), + JAVELIN(SpartanWeaponryAPI::createJavelin), + BOOMERANG(SpartanWeaponryAPI::createBoomerang), + BATTLEAXE(SpartanWeaponryAPI::createBattleaxe), + MACE(SpartanWeaponryAPI::createMace), + GLAIVE(SpartanWeaponryAPI::createGlaive), + QUARTERSTAFF(SpartanWeaponryAPI::createQuarterstaff), + PARRYING_DAGGER(SpartanWeaponryAPI::createParryingDagger), + //Ranged + LONGBOW((toolMaterialEx, modid, creativeTab, properties) -> SpartanWeaponryAPI.createLongbow(toolMaterialEx, modid, creativeTab, IntegrationSW.NOOP)), + CROSSBOW((toolMaterialEx, modid, creativeTab, properties) -> SpartanWeaponryAPI.createCrossbow(toolMaterialEx, modid, creativeTab, IntegrationSW.NOOP)), + ; + final ISpartanWeaponInitalizer initializer; + + SpartanWeaponType(ISpartanWeaponInitalizer initializer) { + this.initializer = initializer; + } +} diff --git a/src/main/java/it/hurts/metallurgy_reforged/util/ModChecker.java b/src/main/java/it/hurts/metallurgy_reforged/util/ModChecker.java index a8ea3df77..38350201b 100644 --- a/src/main/java/it/hurts/metallurgy_reforged/util/ModChecker.java +++ b/src/main/java/it/hurts/metallurgy_reforged/util/ModChecker.java @@ -9,10 +9,7 @@ package it.hurts.metallurgy_reforged.util; -import it.hurts.metallurgy_reforged.integration.IntegrationChisel; -import it.hurts.metallurgy_reforged.integration.IntegrationEnderIO; -import it.hurts.metallurgy_reforged.integration.IntegrationMekanism; -import it.hurts.metallurgy_reforged.integration.IntegrationThermal; +import it.hurts.metallurgy_reforged.integration.*; import net.minecraftforge.fml.common.Loader; public class ModChecker { @@ -29,6 +26,7 @@ public class ModChecker { public static boolean isChiselLoaded; public static boolean isTELoaded; public static boolean isMekanismLoaded; + public static boolean isSpartanWeaponryLoaded; static { @@ -44,6 +42,7 @@ public class ModChecker { ModChecker.isChiselLoaded = Loader.isModLoaded(IntegrationChisel.MODID); ModChecker.isTELoaded = Loader.isModLoaded(IntegrationThermal.EXPANSION_MODID); ModChecker.isMekanismLoaded = Loader.isModLoaded(IntegrationMekanism.MODID); + ModChecker.isSpartanWeaponryLoaded = Loader.isModLoaded(IntegrationSW.MODID); } } diff --git a/src/main/java/it/hurts/metallurgy_reforged/util/SubEvent.java b/src/main/java/it/hurts/metallurgy_reforged/util/SubEvent.java index de804e45e..bde99bbed 100644 --- a/src/main/java/it/hurts/metallurgy_reforged/util/SubEvent.java +++ b/src/main/java/it/hurts/metallurgy_reforged/util/SubEvent.java @@ -42,7 +42,7 @@ public static void init() MinecraftForge.EVENT_BUS.register(effect); }); - if (ModChecker.isConarmLoaded && !GeneralConfig.armoryIntegration) + if (ModChecker.isConarmLoaded && GeneralConfig.conarmIntegration) { MinecraftForge.EVENT_BUS.register(MetallurgyArmorTraits.quickly); MinecraftForge.EVENT_BUS.register(MetallurgyArmorTraits.stronglyAmordrine); diff --git a/src/main/resources/assets/metallurgy/lang/en_us.lang b/src/main/resources/assets/metallurgy/lang/en_us.lang index 9ac7ad5f0..771092c2b 100644 --- a/src/main/resources/assets/metallurgy/lang/en_us.lang +++ b/src/main/resources/assets/metallurgy/lang/en_us.lang @@ -810,6 +810,8 @@ itemGroup.metallurgy.special=Metallurgy Special itemGroup.metallurgy.ores=Metallurgy Ores itemGroup.metallurgy.tools=Metallurgy Tools +itemGroup.metallurgy.spartanweaponry=Spartan Weaponry: Metallurgy Materials + #Dust item.metallurgy.adamantine_dust.name=Adamantine Dust item.metallurgy.alduorite_dust.name=Alduorite Dust