Config: Make obituary item configurable
parent
d3f300da85
commit
aa2ae4f20b
|
@ -58,7 +58,9 @@ public class DeathChests {
|
|||
Debug.out("Received FMLInitializationEvent");
|
||||
|
||||
GameRegistry.registerBlock(BlockDeathChest.getInstance(), "death_chest");
|
||||
if (Config.giveObituary) {
|
||||
GameRegistry.registerItem(ItemObituary.getInstance(), "obituary");
|
||||
}
|
||||
Debug.out("Registered block and item.");
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new EventHook());
|
||||
|
|
|
@ -201,8 +201,10 @@ public class EventHook {
|
|||
Debug.out("Chest location Z: " + Integer.toString(chestLocation[2]));
|
||||
Debug.out("Chest location dimension: " + Integer.toString(chestLocation[3]));
|
||||
|
||||
if (Config.giveObituary) {
|
||||
//TODO: NBT data
|
||||
event.player.inventory.addItemStackToInventory(new ItemStack(ItemObituary.getInstance()));
|
||||
}
|
||||
} else {
|
||||
Debug.out("No death chest location was stored.");
|
||||
//TODO: tell player that a death chest couldn’t be placed and that the items have been dropped
|
||||
|
|
|
@ -17,6 +17,7 @@ public class Config {
|
|||
public static int maxDistance = 50;
|
||||
public static boolean allowOtherPlayers = true;
|
||||
public static String notAllowedMessage = "§4Cannot get items from another player's death chest.";
|
||||
public static boolean giveObituary = true;
|
||||
|
||||
private static final String config_header = "# The format of this file is strictly `option=value` (no spaces).\n# Lines starting with # and empty lines are ignored.";
|
||||
|
||||
|
@ -37,6 +38,9 @@ public class Config {
|
|||
configOut += "\n\n# The message to display when trying to get items from another player's death chest and allowOtherPlayers=false";
|
||||
configOut += "notAllowedMessage=";
|
||||
configOut += notAllowedMessage;
|
||||
configOut += "\n\n# Whether to give respawning players an obituary item\n";
|
||||
configOut += "giveObituary=";
|
||||
configOut += giveObituary ? "true" : "false";
|
||||
|
||||
File configFile = new File(configDir, config_file_name);
|
||||
try {
|
||||
|
@ -78,6 +82,10 @@ public class Config {
|
|||
notAllowedMessage = configData.get(i).substring(equalsSign+1);
|
||||
break;
|
||||
}
|
||||
case ("giveObituary"): {
|
||||
giveObituary = configData.get(i).substring(equalsSign + 1).equals("true") ? true : false;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
System.err.println("Failed parsing config entry: " + configData.get(i));
|
||||
FMLCommonHandler.instance().exitJava(1, false);
|
||||
|
|
Loading…
Reference in New Issue