Skip to content

Instantly share code, notes, and snippets.

@LiaungYip
Created June 9, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LiaungYip/8535aeac8894ab10db9b0044ec264a94 to your computer and use it in GitHub Desktop.
Save LiaungYip/8535aeac8894ab10db9b0044ec264a94 to your computer and use it in GitHub Desktop.
twitch_launcher_configurator
import os
import shutil
def copy_file(root, src, dst):
print("Copying %s to %s" % (src, dst))
s = os.path.join(root, src)
d = os.path.join(root, dst)
shutil.copy(s, d)
def replace(root, relative_file_path, old, new):
file_path = os.path.join(root, relative_file_path)
print("%s\n Old: %s\n New: %s" % (file_path, old, new))
with open(file_path, 'r') as read_handle:
old_contents = read_handle.read()
new_contents = old_contents.replace(old, new)
with open(file_path, 'w') as write_handle:
write_handle.write(new_contents)
import os
import hjson
from common import replace, copy_file
root = r"C:\Users\lws\Curse\Minecraft\Instances\TEST\config"
# Custom Ore Generator
# ====================
# Create copies of the default files so we can customise them.
#
# Note: Need to do this, because all changes to the default files are reverted
# each time the mod starts up.
copy_file(root,
r'CustomOreGen\CustomOreGen_Config_Default.xml',
r'CustomOreGen\CustomOreGen_Config.xml')
copy_file(root,
r'CustomOreGen\modules\default\ProjectRed.xml',
r'CustomOreGen\modules\custom\ProjectRed.xml')
copy_file(root,
r'CustomOreGen\modules\default\ThermalFoundation.xml',
r'CustomOreGen\modules\custom\ThermalFoundation.xml')
# Point to new copy of file
replace(root,
relative_file_path=r'CustomOreGen\CustomOreGen_Config.xml',
old="<Import file='modules/default/ProjectRed.xml'/>",
new="<!--<Import file='modules/custom/ProjectRed.xml'/>-->")
# Point to new copy of file
replace(root,
relative_file_path=r'CustomOreGen\CustomOreGen_Config.xml',
old="<Import file='modules/default/ThermalFoundation.xml'/>",
new="<!--<Import file='modules/custom/ThermalFoundation.xml'/>-->")
replace(root,
relative_file_path=r'CustomOreGen\modules\custom\ProjectRed.xml',
old='ProjRed|Exploration',
new='projectred-exploration')
replace(root,
relative_file_path=r'CustomOreGen\modules\custom\ProjectRed.xml',
old='Ore',
new='ore')
replace(root,
relative_file_path=r'CustomOreGen\modules\custom\ThermalFoundation.xml',
old='ThermalFoundation',
new='thermalfoundation')
replace(root,
relative_file_path=r'CustomOreGen\modules\custom\ThermalFoundation.xml',
old=':Ore',
new=':ore')
# Disable silly update checks.
# ============================
replace(root,
relative_file_path=r'actuallyadditions.cfg',
old='B:"Do update check"=true',
new='B:"Do update check"=false')
replace(root,
relative_file_path=r'betterfps.json',
old='"updateChecker":true',
new='"updateChecker":false')
replace(root,
relative_file_path=r'BiblioCraft.cfg',
old='B:CheckForUpdates=true',
new='B:CheckForUpdates=false')
replace(root,
relative_file_path=r'forge.cfg',
old='B:disableVersionCheck=false',
new='B:disableVersionCheck=true')
replace(root,
relative_file_path=r'MrTJPCore.cfg',
old='B:"Version Checking"=true',
new='B:"Version Checking"=false')
replace(root,
relative_file_path=r'oreexcavation.cfg',
old='B:"Hide Updates"=false',
new='B:"Hide Updates"=true')
replace(root,
relative_file_path=r'opencomputers\settings.conf',
old='updateCheck=true',
new='updateCheck=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Version Checking"=true',
new='B:"Version Checking"=false')
replace(root,
relative_file_path=r'reborncore.cfg',
old='B:"Check for new versions"=true',
new='B:"Check for new versions"=false')
# replace(root,
# relative_file_path=r'',
# old='',
# new='')
# Actually Additions
# ==================
# # Shold Black Quartz generate in the world?
# B:"Black Quartz"=true
# replace(root,
# relative_file_path=r'actuallyadditions.cfg',
# old='B:"Black Quartz"=true',
# new='B:"Black Quartz"=false')
# Embers
# ======
#
# Disable all ore generation from embers.
replace(root,
relative_file_path=r'embers.cfg',
old='I:copperVeinsPerChunk=6',
new='I:copperVeinsPerChunk=0')
replace(root,
relative_file_path=r'embers.cfg',
old='I:leadVeinsPerChunk=6',
new='I:leadVeinsPerChunk=0')
replace(root,
relative_file_path=r'embers.cfg',
old='I:silverVeinsPerChunk=6',
new='I:silverVeinsPerChunk=0')
# Forestry
# ========
#
# Disable copper and tin generation.
# Leave apatite generation alone (???)
replace(root,
relative_file_path=r'forestry\common.cfg',
old='B:copper=true',
new='B:copper=false')
replace(root,
relative_file_path=r'forestry\common.cfg',
old='B:tin=true',
new='B:tin=false')
# Immersive Engineering
# =====================
#
# Disable all ore generation.
# Sample from immersiveengineering.cfg
#
# # Generation config for Bauxite Ore.
# # Parameters: Vein size, lowest possible Y, highest possible Y, veins per chunk, chance for vein to spawn (out of 100). Set vein size to 0 to disable the generation
# I: ore_bauxite <
# 4
# 40
# 85
# 8
# 100
# >
#
# replace(root,
# relative_file_path=r'immersiveengineering.cfg',
# old='I:ore_bauxite <\n 4',
# new='I:ore_bauxite <\n 0')
#
# replace(root,
# relative_file_path=r'immersiveengineering.cfg',
# old='I:ore_copper <\n 8',
# new='I:ore_copper <\n 0')
#
# replace(root,
# relative_file_path=r'immersiveengineering.cfg',
# old='I:ore_lead <\n 6',
# new='I:ore_lead <\n 0')
#
# replace(root,
# relative_file_path=r'immersiveengineering.cfg',
# old='I:ore_nickel <\n 6',
# new='I:ore_nickel <\n 0')
#
# replace(root,
# relative_file_path=r'immersiveengineering.cfg',
# old='I:ore_silver <\n 8',
# new='I:ore_silver <\n 0')
#
# replace(root,
# relative_file_path=r'immersiveengineering.cfg',
# old='I:ore_uranium <\n 4',
# new='I:ore_uranium <\n 0')
# Disable all ore generation, by adding the overworld (dimension 0) to the
# list of dimensions where Immersive Engineering ore will not spawn.
replace(root,
relative_file_path=r'immersiveengineering.cfg',
old=' I:oreDimBlacklist <\n -1\n 1\n >',
new=' I:oreDimBlacklist <\n -1\n 0\n 1\n >', )
# Magneticraft
# ============
replace(root,
relative_file_path=r'magneticraft.cfg',
old='# If Copper ore should be generated or not [default: true]\n B:active=true',
new='# If Copper ore should be generated or not [default: true]\n B:active=false')
replace(root,
relative_file_path=r'magneticraft.cfg',
old='# If Lead ore should be generated or not [default: true]\n B:active=true',
new='# If Lead ore should be generated or not [default: true]\n B:active=false')
# Leave Cobalt on for the moment - this is the only mod that generates it.
# replace(root,
# relative_file_path=r'magneticraft.cfg',
# old='# If Cobalt ore should be generated or not [default: true]\n B:active=true',
# new='# If Cobalt ore should be generated or not [default: true]\n B:active=false')
replace(root,
relative_file_path=r'magneticraft.cfg',
old='# If Tungsten ore should be generated or not [default: true]\n B:active=true',
new='# If Tungsten ore should be generated or not [default: true]\n B:active=false')
replace(root,
relative_file_path=r'magneticraft.cfg',
old='# If Limestone should be generated or not [default: true]\n B:active=true',
new='# If Limestone should be generated or not [default: true]\n B:active=false')
# Project Red
# ===========
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Copper Ore"=true',
new='B:"Copper Ore"=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Electrotine Ore"=true',
new='B:"Electrotine Ore"=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Peridot Ore"=true',
new='B:"Peridot Ore"=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Ruby Ore"=true',
new='B:"Ruby Ore"=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Sapphire Ore"=true',
new='B:"Sapphire Ore"=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Silver Ore"=true',
new='B:"Silver Ore"=false')
replace(root,
relative_file_path=r'ProjectRed.cfg',
old='B:"Tin Ore"=true',
new='B:"Tin Ore"=false')
# Railcraft
# =========
#
# From railcraft.cfg:
# worldgen {
#
# ##########################################################################################################
# # generate
# #--------------------------------------------------------------------------------------------------------#
# # You can control which Ores/Features generate in the world here.
# # If wish to disable world gen entirely it is recommended
# # that you disable the World Module in 'modules.cfg' instead.
# # Before disabling Railcraft metal ore gen, you should be aware
# # that is does not spawn like vanilla ore. It forms localized clouds
# # in distinct regions rather than a uniform spread.
# # It also consists of two types of ore, standard and poor.
# # Poor ore forms throughout the cloud, standard ore only forms in the core of the cloud.
# # These are referred to as Railcraft Ore Mines.
# ##########################################################################################################
#
# In our case, we want to disable metal ore generation, while keeping
# Railcraft's sulphur, saltpeter, and abyssal-stone geode generation.
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineCopper=true',
new='B:mineCopper=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineGold=true',
new='B:mineGold=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineIron=true',
new='B:mineIron=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineLead=true',
new='B:mineLead=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineNickel=true',
new='B:mineNickel=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineSilver=true',
new='B:mineSilver=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='B:mineTin=true',
new='B:mineTin=false')
replace(root,
relative_file_path=r'railcraft\railcraft.cfg',
old='I:vanillaOreGenChance=100',
new='I:vanillaOreGenChance=0')
# Tiny Progressions
replace(root,
relative_file_path=r'Tiny Progressions\Main.cfg',
old='B:"Remove Wooden Tools & Weapons"=true',
new='B:"Remove Wooden Tools & Weapons"=false')
replace(root,
relative_file_path=r'Tiny Progressions\Main.cfg',
old='B:"Bone Tools & Weapons"=true',
new='B:"Bone Tools & Weapons"=false', )
replace(root,
relative_file_path=r'Tiny Progressions\Main.cfg',
old='B:"Flint Tools & Weapons"=true',
new='B:"Flint Tools & Weapons"=false')
# Tech Reborn
# ===========
#
# Disable all overworld ore spawning.
#
# Galena (silver/lead), Iridium, Ruby, Sapphire, Bauxite, Lead, Silver, Copper, Tin,
# Garnierite (Nickel)
#
# Note this mod uses HJSON format instead of the usual forge config format -
# a refreshing change!
TR_config_path = os.path.join(root, r'techreborn\ores.hjson')
with open(TR_config_path) as TR_config_read_handle:
TR_config = hjson.load(TR_config_read_handle)
# pprint.pprint(TR_config)
overworld = TR_config['overworldOres']
for ore in overworld:
ore['shouldSpawn'] = False
# pprint.pprint(TR_config)
s = hjson.dumps(TR_config)
# print(s)
if __name__ == '__main__':
with open(TR_config_path, "w") as TR_config_write_handle:
TR_config_write_handle.write(s)
# Extreme Reactors
# ================
#
# Disable yellorite (uranium) spawning
replace(root,
relative_file_path=r'Extreme Reactors\Extreme Reactors.cfg',
old='B:yelloriteOreEnableWorldGen=true',
new='B:yelloriteOreEnableWorldGen=false')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment