Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Mod Config Annotations Help
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
captainmk

[1.12.2] Mod Config Annotations Help

By captainmk, October 19 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

captainmk    0

captainmk

captainmk    0

  • Tree Puncher
  • captainmk
  • Members
  • 0
  • 4 posts
Posted October 19

Hello, I'm a fairly new modder, trying to work with 1.12 config annotations for the first time.
Right now I have a working @Config class, and working mod functionality. When the game starts, it correctly loads a boolean from the .cfg, and the mod works as it should.
However, when I change the value at runtime via mod options, it does literally nothing from what I can tell.
Here's the relevant code snippets:

@Config src

@Config(modid = Reference.MODID, name = "touchofalpha", type = Type.INSTANCE)
public class TOAConfig {
    @Comment ({
        "Classic minecraft sunset where light drops in ticks (DEFAULT: true)"
    })
    public static boolean tickingSunset = true;
}


Event handler (doesn't seem to do anything)

@SubscribeEvent
    public void configChange(ConfigChangedEvent event) {
        if (event.getModID().equals(Reference.MODID)) {
            System.out.println(Reference.MODID + ": Configuration changed");
            ConfigManager.sync(Reference.MODID, Config.Type.INSTANCE);
        }
    }


In the mod I replace the WorldProvider with a custom one, and run the following line in one of the methods:

if (TOAConfig.tickingSunset) {
	// Functional Code Here
}

 

Any help would be appreciated.
Bonus question: How do you ensure that the config option is strictly loaded from the client and not the server? Will the config loading always default to the server's cfg file? The tickingSunset option only needs to happen on the client.

  • Quote

Share this post


Link to post
Share on other sites

Toma™    7

Toma™

Toma™    7

  • Stone Miner
  • Toma™
  • Members
  • 7
  • 74 posts
Posted October 19

Make sure to actually register the event handler.

Either you can annotate the class with @EventBusSubscriber and let it register itself automatically (but your event method has to be declared as static) or register to to MinecraftForge.EVENT_BUS

  • Thanks 1
  • Quote

Share this post


Link to post
Share on other sites

Toma™    7

Toma™

Toma™    7

  • Stone Miner
  • Toma™
  • Members
  • 7
  • 74 posts
Posted October 19

Also to answer your next question - Depends on the side where code is executed, if it's server side it's going to take data from config stored on server. However someone has to confirm that, because I'm not sure and that's how I believe it works

  • Quote

Share this post


Link to post
Share on other sites

captainmk    0

captainmk

captainmk    0

  • Tree Puncher
  • captainmk
  • Members
  • 0
  • 4 posts
Posted October 19

I was structuring my code poorly. The event bus that I was using was registered to terraingen because of another feature I was working on, putting it on the proper bus solved it.
Thank you, I appreciate the response 😊

  • Quote

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      [1.14.4] Modifying the containers & screens of vanilla entities

      By diesieben07 · Posted 17 minutes ago

      If only the Slot constructor had a way to tell it which inventory to use... Oh, it does. It has an IInventory parameter. Use SlotItemHandler for the IItemHandler variant.   Incorrect. The slot modifies whatever inventory you give it.   Yes.   If it's the horse inventory, then how is the slot supposed to know that it should look anywhere else?
    • Choco
      [1.14.4] Modifying the containers & screens of vanilla entities

      By Choco · Posted 20 minutes ago

      I do have an ItemStackHandler and it is attached  It's actually attached in that same class (it was something I left out because it was irrelevant at the time). @SubscribeEvent public static void attachHorseCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof AbstractHorseEntity) { event.addCapability(new ResourceLocation(MOD_ID, "capability_mycustomslots"), new ThisIsntTheClassNameButYouGetTheIdea()); } } It's implemented correctly, supplies an additional slot index, serializes and deserializes to/from NBT, sure. Here's my confusion. How am I supposed to say "Hey, when you interact with this slot, you should be modifying this capability" because adding a slot reflectively to the horse container modifies what I assume is the horse inventory, correct? Should I be passing that capability somewhere so my slot knows to interact with that capability instead of the default, vanilla inventoryContents supplied by the inventory? I see only the IInventory passed to the Slot but as far as I'm concerned, that should be the horse inventory.
    • diesieben07
      [1.14.4] Modifying the containers & screens of vanilla entities

      By diesieben07 · Posted 28 minutes ago

      Since you said this, I assumed you had already done that... You need a capability attached to horses, which stores an IItemHandler for your additional inventory space.
    • Choco
      [1.14.4] Modifying the containers & screens of vanilla entities

      By Choco · Posted 30 minutes ago

      Correct, although that was my question to begin with. How am I meant to modify the inventory of an existing entity? I was under the impression that this would be addressed as well, though that mustn't be the case. The way you had described it in your initial reply had made it seem like the slots would have allowed the user to interact with them. Perhaps I misunderstood. I understand I am interacting with the 3rd slot (index 2) and I understand why I'm getting this exception, I'm just unsure how to address it. Overriding one of the existing slot indexes surely isn't an option. I want to maintain the vanilla functionality of a horse.   So to rephrase the question in the OP, what would be the correct approach to add a slot to a horse inventory with which a player may interact and place/take items?
    • diesieben07
      [1.14.4] Add a Tab to the Player Inventory Gui in Survival Modus

      By diesieben07 · Posted 36 minutes ago

      You can use the various sub-events of GuiScreenEvent to change existing GUIs.
  • Topics

    • Choco
      9
      [1.14.4] Modifying the containers & screens of vanilla entities

      By Choco
      Started 4 hours ago

    • DragonITA
      1
      [1.14.4] Add a Tab to the Player Inventory Gui in Survival Modus

      By DragonITA
      Started 42 minutes ago

    • JetCobblestone
      3
      [1.14] layout of a modpack

      By JetCobblestone
      Started 4 hours ago

    • AdieCraft
      0
      Working Flashing Christmas Tree

      By AdieCraft
      Started 44 minutes ago

    • plugsmustard
      29
      on/off button for custom furnace

      By plugsmustard
      Started Yesterday at 03:11 PM

  • Who's Online (See full list)

    • Choco
    • Hendoor64
    • AdieCraft
    • Koyo Seduku
    • nenikitov
    • diesieben07
    • AmateurHalibut
    • plugsmustard
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] Mod Config Annotations Help
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community