Is it possible to use MCreator to make a bookkeeping/general ledger mod?

Started by RepoMeister on Sun, 09/02/2018 - 10:06

Topic category: Help with modding (Java Edition)

Last seen on 12:35, 4. Oct 2019
Joined Jun 2018
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Is it possible to use MCreator to make a bookkeeping/general ledger mod?
Sun, 09/02/2018 - 10:06

I have spent hours poring over examples, documentation and forum posts looking for someone who created something similar to this and have had no luck. I do not know if this is because it is not doable in MCreator or maybe just because it is such a stupid idea!  

Anyways, what I want to write is a mod that allows the player to keep track of all the resources they have been selling so they can use this mod to say "Wow! I have made over 200 diamonds this week off of my slime farm" or "I need to raise the prices of my Sea Lanterns because I am almost out of them and only made 40 emeralds" etc. etc.

The mod would have the following features:

1. Ability to assign prices for various units of items

2. Ability to record every sale made by item and purchaser

3. Ability to access remote hosted MySQL database for reporting and transaction storage

I am seeing that the place to hook all this in would be in GUI object and I have done event-driven development in Windows Visual C++ since the 90's so once I know the proper high-level strategy I will be able to implement this but I am just at sea as far as where to direct my initial efforts and this can only be a part-time effort on my part because of other real-world development projects.

I learn best with working example code so any pointers would be extremely helpful and appreciated. I have seen a lot of the followups on these forums just telling the person to use feature XYZ in MCreator. I am pretty sure we all know XYZ exists already. It is the nuts and bolts of how others were able to successfully implement the features in question while using XYZ that would be helpful. Maybe this is because a lot of the MCreator users are gamers who started modding rather than coders who started using MCreator? I don't know. But working code examples are best because otherwise you are just saying "keep Googling" when it comes right down to it :) 

 

My high-level plan for this mod is:

1. Assign a hot key to open the main GUI for the mod with an alternative of an added inventory GUI button

2. Once in my GUI, let user select from LOG A SALE, SET PRICES and REPORTS buttons

3. Based on actions within those screens read from/write to a remote database

 

I apologize if this is too vague - this environment is still 100% new to me and I hope to come up to speed quickly. I am hoping for some working code examples of remote SQL connections or if that is not possible, remote HTTP connections through which I can just pass the query parameters as POST data.

Thank you!

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Is it possible in MCreator?…
Mon, 09/03/2018 - 07:45

Is it possible in MCreator? Of course, it is.
Is it easy? Well, I do not really know. Creating the GUI itself and keybind is fairly easy, so I will not write about that....especially because it depends on the way you want it to look/work.

For adding the button to already existing GUI you will have to subscribe to several events, like GuiScreenEvent.InitGuiEvent.Post and GuiScreenEvent.ActionPerformedEvent.Post, here is an example from my mod:
 

@SubscribeEvent
@SideOnly(Side.CLIENT)
	public void onInitGUI(GuiScreenEvent.InitGuiEvent.Post e) {
		
	if(e.gui instanceof GuiCreateWorld){
		GuiButton button = new GuiButton(11, e.gui.width / 2 - 75, 165, 150, 20, I18n.format("selectWorld.story", new Object[0]));
		boolean vis = ReflectionHelper.getPrivateValue(GuiCreateWorld.class, (GuiCreateWorld)e.gui,"field_146344_y");
	     button.enabled = false;
	     button.visible = !vis;
		e.buttonList.add(button);
		
	}
	}

@SubscribeEvent
@SideOnly(Side.CLIENT)
	public void onActionPerformedGUI(GuiScreenEvent.ActionPerformedEvent.Post e) {
		
	if(e.gui instanceof GuiCreateWorld){
		for(GuiButton button : e.buttonList){
			if(button.id == 11){
				boolean vis = ReflectionHelper.getPrivateValue(GuiCreateWorld.class, (GuiCreateWorld)e.gui,"field_146344_y");
				button.visible = !vis;
			}
		}
	}
	}

 

For the actual reading & writing to the database, I can not tell you much as I had not any reason do to so in Java so far, though most likely I will most likely use it in the future. However, there is a package java.sql that should contain all you need. The most important classes in here are java.sql.Connection and java.sql.DriverManager.