Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Bailym

Members
  • Posts

    8
  • Joined

  • Last visited

Bailym's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I am looking to use the forge config to change the MaxDamageFactorIn value when creating ArmorMaterials. For example here is one entry from the ArmorMaterial enum where the ArmorMaterials are created. I am reading an IntValue from the config and passing that as an argument. This works fine. public enum CustomArmorMaterial implements ArmorMaterial { OAK_WOOD(ExtraArmor.MOD_ID + ":oak_wood", ArmorConfig.COMMON.oakWoodDurability.get(), new int[]{1, 2, 3, 1}, 9, SoundEvents.ARMOR_EQUIP_GENERIC, 0.0F, 0.0F, () -> { return Ingredient.of(Items.OAK_PLANKS); }); /* DURABILITY: HEAD = maxDamageFactorIn * 11 CHEST = maxDamageFactorIn * 16 LEGS = maxDamageFactorIn * 15 FEET = maxDamageFactorIn * 13 */ } //ENUM METHODS ETC. BELOW My issue is that the ArmorMaterials are used when I register the items, meaning the config has not yet been initialized. Here is how i am registering an item. public static RegistryObject<ArmorItem> OAK_WOOD_HELMET = ITEMS.register("oak_wood_helmet", () -> new ArmorItem(CustomArmorMaterial.OAK_WOOD, EquipmentSlot.HEAD, new Item.Properties().tab(ExtraArmor.TAB))); Ideally, I'd need to somehow register the items, then set the items ArmorMaterial later after the config has been initialized (after FMLCommonSetupEvent). Is that possible?
  2. Having followed those instructions I am getting the same results. It seems my lack of understanding of forge in general is the issue Thanks for the advice, its been really helpful. Just one final thing. If i were to disable recipes and creative tab entries as you suggested, would i do so inside the FMLCommonSetupEvent handler or some place else? Thanks
  3. I initially removed the .gitignore because i wanted to preserve the world saves, ill add it back in with the necessary exceptions. Just to clarify. If you set enableOakWood to false in extraarmor-common.toml the line System.out.println(ArmorConfig.COMMON.enableOakWood.get()); //Always True returns false as expected? As i'm not getting the same behavior
  4. https://github.com/Bailym/ExtraArmor
  5. Hmmm... i did notice that the forge docs are using: FMLModLoadingContext.get().getModEventBus().addListener(this::commonSetup); whereas i am using: FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onCommonSetup); is there a difference between the two? (FMLModloadingContext and FMLJavaModLoadingContext) as i cant seem to import the former.
  6. I'm now registering the config in the onCommonSetup method which i have been reading about here (https://mcforge.readthedocs.io/en/latest/concepts/lifecycle/) However i'm still getting true (the default value) even if the value in the config file is false private void onCommonSetup(FMLCommonSetupEvent event) { //Register the config ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ArmorConfig.COMMON_SPEC); System.out.println(ArmorConfig.COMMON.enableOakWood.get()); //Always True }
  7. Thanks for the info! I'll look into the CommonSetup stage. Yes I was intending to only register items with true values.What's the alternative? Is there some other way to make items unavailable in game other than just not registering them? Thanks for the help!
  8. I've been trying to get a config file working for my mod so that certain armor sets can be disabled. I followed a tutorial i found on youtube, however it doesnt seem to be working. It seems that i am always getting the default value for each option, rather than the one in the config file. My config class is as follows: import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; import org.apache.commons.lang3.tuple.Pair; public class ArmorConfig { public static class Common { public final BooleanValue enableOakWood; public final BooleanValue enableBirchWood; public final BooleanValue enableJungleWood; public final BooleanValue enableSpruceWood; public final BooleanValue enableDarkOakWood; public final BooleanValue enableAcaciaWood; public final BooleanValue enableCactus; public final BooleanValue enableObsidian; public final BooleanValue enableMagma; public final BooleanValue enableMelon; public final BooleanValue enableQuartz; public final BooleanValue enableBone; public final BooleanValue enableMolten; public final BooleanValue enablePumpkin; public final BooleanValue enablePhantom; public final BooleanValue enableGhost; public final BooleanValue enableCryingObsidian; public final BooleanValue enableIce; public final BooleanValue enableSnow; public final BooleanValue enableGlowstone; public final BooleanValue enablePrismarineShard; public final BooleanValue enablePrismarineCrystal; public final BooleanValue enableHoneycomb; public final BooleanValue enableEmerald; public final BooleanValue enableEnder; Common(ForgeConfigSpec.Builder builder){ builder.comment("Armor Config") .push("Armor"); enableOakWood = builder .comment("Enable or Disable Oak Wood Armor") .worldRestart() .define("enableOakWood", true); enableBirchWood = builder .comment("Enable or Disable Birch Wood Armor") .worldRestart() .define("enableBirchWood", true); enableJungleWood = builder .comment("Enable or Disable Jungle Wood Armor") .worldRestart() .define("enableJungleWood", true); enableSpruceWood = builder .comment("Enable or Disable Spruce Wood Armor") .worldRestart() .define("enableSpruceWood", true); enableDarkOakWood = builder .comment("Enable or Disable Dark Oak Wood Armor") .worldRestart() .define("enableDarkOakWood", true); enableAcaciaWood = builder .comment("Enable or Disable Acacia Wood Armor") .worldRestart() .define("enableAcaciaWood", true); enableCactus = builder .comment("Enable or Disable Cactus Armor") .worldRestart() .define("enableCactus", true); enableObsidian = builder .comment("Enable or Disable Obsidian Armor") .worldRestart() .define("enableObsidian", true); enableMagma = builder .comment("Enable or Disable Magma Armor") .worldRestart() .define("enableMagma", true); enableMelon = builder .comment("Enable or Disable Melon Armor") .worldRestart() .define("enableMelon", true); enableQuartz = builder .comment("Enable or Disable Quartz Armor") .worldRestart() .define("enableQuartz", true); enableBone = builder .comment("Enable or Disable Bone Armor") .worldRestart() .define("enableBone", true); enableMolten = builder .comment("Enable or Disable Molten Armor") .worldRestart() .define("enableMolten", true); enablePumpkin = builder .comment("Enable or Disable Pumpkin Armor") .worldRestart() .define("enablePumpkin", true); enablePhantom = builder .comment("Enable or Disable Phantom Armor") .worldRestart() .define("enablePhantom", true); enableGhost = builder .comment("Enable or Disable Ghost Armor") .worldRestart() .define("enableGhost", true); enableCryingObsidian = builder .comment("Enable or Disable Crying Obsidian Armor") .worldRestart() .define("enableCryingObsidian", true); enableIce = builder .comment("Enable or Disable Ice Armor") .worldRestart() .define("enableIce", true); enableSnow = builder .comment("Enable or Disable Snow Armor") .worldRestart() .define("enableSnow", true); enableGlowstone = builder .comment("Enable or Disable Glowstone Armor") .worldRestart() .define("enableGlowstone", true); enablePrismarineShard = builder .comment("Enable or Disable Prismarine Shard Armor") .worldRestart() .define("enablePrismarineShard", true); enablePrismarineCrystal = builder .comment("Enable or Disable Prismarine Crystal Armor") .worldRestart() .define("enablePrismarineCrystal", true); enableHoneycomb = builder .comment("Enable or Disable Honeycomb Armor") .worldRestart() .define("enableHoneycomb", true); enableEmerald = builder .comment("Enable or Disable Emerald Armor") .worldRestart() .define("enableEmerald", true); enableEnder = builder .comment("Enable or Disable Ender Armor") .worldRestart() .define("enableEnder", true); builder.pop(); } } public static final ForgeConfigSpec COMMON_SPEC; public static final Common COMMON; static{ final Pair<Common, ForgeConfigSpec> specPair = new ForgeConfigSpec.Builder().configure(Common::new); COMMON_SPEC = specPair.getRight(); COMMON = specPair.getLeft(); } } and the config file (generated): #Armor Config [Armor] #Enable or Disable Cactus Armor enableCactus = true #Enable or Disable Honeycomb Armor enableHoneycomb = true #Enable or Disable Oak Wood Armor enableOakWood = true #Enable or Disable Obsidian Armor enableObsidian = true #Enable or Disable Ice Armor enableIce = true #Enable or Disable Glowstone Armor enableGlowstone = true #Enable or Disable Acacia Wood Armor enableAcaciaWood = true #Enable or Disable Crying Obsidian Armor enableCryingObsidian = true #Enable or Disable Molten Armor enableMolten = true #Enable or Disable Melon Armor enableMelon = true #Enable or Disable Ender Armor enableEnder = true #Enable or Disable Prismarine Crystal Armor enablePrismarineCrystal = true #Enable or Disable Birch Wood Armor enableBirchWood = true #Enable or Disable Pumpkin Armor enablePumpkin = true #Enable or Disable Spruce Wood Armor enableSpruceWood = true #Enable or Disable Magma Armor enableMagma = true #Enable or Disable Dark Oak Wood Armor enableDarkOakWood = true #Enable or Disable Quartz Armor enableQuartz = true #Enable or Disable Ghost Armor enableGhost = true #Enable or Disable Emerald Armor enableEmerald = true #Enable or Disable Jungle Wood Armor enableJungleWood = true #Enable or Disable Bone Armor enableBone = true #Enable or Disable Phantom Armor enablePhantom = true #Enable or Disable Snow Armor enableSnow = true #Enable or Disable Prismarine Shard Armor enablePrismarineShard = true Here is where i'm expecting to load the config (the main class for the mod): import com.bailym.extraarmor.config.ArmorConfig; import com.bailym.extraarmor.util.RegistryHandler; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.config.ModConfig; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; // The value here should match an entry in the META-INF/mods.toml file @Mod("extraarmor") public class ExtraArmor { public static final String MOD_ID = "extraarmor"; // Directly reference a log4j logger. private static final Logger LOGGER = LogManager.getLogger(); public ExtraArmor() { // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); //HERE IS WHERE I AM REGISTERING THE CONFIG AND CHECKING ONE OF THE VALUES ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, ArmorConfig.COMMON_SPEC); //DOESNT GIVE THE VALUE IN THE CONFIG FILE. ONLY THE DEFAULT VALUE IN THE CONFIG CLASS System.out.println(ArmorConfig.COMMON.enableOakWood.get()); //Call the method to initialize the registry. (Multiple registries require multiple calls). RegistryHandler.init(); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void doClientStuff(final FMLClientSetupEvent event) { } //Creates a custom ItemGroup with the label extraArmorTab. In game Label can be set in lang files. public static final ItemGroup TAB = new ItemGroup("extraArmorTab") { //Overrides the vanilla createIcon method to chnge the icon used for this tab to a new item. @Override public ItemStack createIcon() { return new ItemStack(Items.LEATHER_CHESTPLATE); } }; } Any help is appreciated. Thanks.
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.