Modding - XiaoGeNintendo/SoundGuessGame GitHub Wiki

This game supports modding. You can add your custom creatures into the game!

Preparing

You need:

  • JDK 1.8+
  • the game jar file

Modding

First, create a project and add the game jar file into the build path(or classpath or library etc..).

Then create a class names after your mod. For example MyMod.java . Let this mod extends com.hhs.xgn.soundguess.game.Mod. And writes an annotation before the class @com.hhs.xiaomao.modloader.Mod(modid = "", name = "", version = "") .So it looks like:

import com.hhs.xgn.soundguess.game.*;

import java.net.URL;
import java.util.Map;

@com.hhs.xiaomao.modloader.Mod(modid = "", name = "", version = "")
public class EmptyMod extends Mod{

	@Override
	public int getBuildVersion() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String getModName() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void init() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public URL getMusic(SoundGuess self, int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public URL getPicture(SoundGuess self, int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isIdOk(SoundGuess self, int id) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int getLimit(SoundGuess self) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public Map<String, URL> onAcquired(SoundGuess self, int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String isCorrect(SoundGuess self, int id, String name) {
		// TODO Auto-generated method stub
		return null;
	}

}

All these functions should be implemented.

Notes on function

  • getModName() should returns a String that represents your mod name for displaying. In theorm, any mod name is acceptable.
  • init() this function is called when the mod loader is loading your mod. Note that during this period, some mods are loaded and some are not.
  • getMusic(int) this function should return a piece of sound denotes the creature #id in your mod.
  • isIdOk(int) should return if #id is a valid id in your mod
  • getLimit() should return the maximum possible id. This function is used to generate random ids by the system. See code examples and source for details.
  • onAcquired(int) should return what will be given to the player after one correctly guessed the #id creature in your mod. For each entry, String is its name and URL is its position. Note: plz start your name with a identifier: "M" for a music resource, "P" for an image resource, "o" for other resource case sensetive! For example, a link to an image resources named "photo" should be named "Pphoto". See mod samples for details.
  • isCorrect(int,String) should return whether the string is a possible name for #id creature. Note, after build 2, you need to return a string. The first letter of the string is the status or verdict. It should be a letter "C" for correct, "W" for incorrect, "U" for checker internal error. Then the last part of the string will be used as a comment and will be displayed to the user. If you are building a mod for games before build2, just return a boolean value.
  • getBuildVersion() should returns the game version this mod is built for. If game version != getBuildVersion() then a warning message will be given to the user and your mod won't be loaded into game. Note: this function is called after init() is called

Note:After Build 5, a game instance SoundGuess is given to you for each method to check game resource!

Other Optional functions

  • supportVoice() should return whether this mod supports voice guessing feature
  • supportPicture() should return whether this mod supports picture guessing feature
  • openCustomMenu() is called when the user pressed "show detail" of a mod. You can create a new JFrame and put your credits here and stuff.

You can see the version of build by SoundGuess.build

Reading/Saving data from save file

You can access the save data by self.save. A special HashMap<String,String> extraData is designed for you to store extra information here. Just store anything your mod needed when the game is closed here.

Map<String,Map<String,URL>> acquired is all the resources the user get. The key string is <mod name>:<creature id> and the value map's key is resource name and the value map's value is resource location.

Map<String,HashSet<String>> named is all the names user guessed. The key string is <mod name>:<creature id> and the value set is all the names which are considered correct and the user guessed.

int correctGuess.... is the times user correctly guessed in voice/picture

String username is the username

You can change them as you like and at any time. But after you are done, use self.saveData() to save it from being lost!

Export

Finally, export your mod into a jar file and release and enjoy! Hooray!

⚠️ **GitHub.com Fallback** ⚠️