finish terrain generation

This commit is contained in:
2021-05-06 17:15:07 +08:00
parent d8d90c3cb4
commit b68cb9114b
28 changed files with 715 additions and 59 deletions

View File

@ -0,0 +1,239 @@
import sys
import os
import shutil
def ReadListFromFile(filename, listInstance):
f = open(filename, 'r', encoding='utf-8')
while True:
cache = f.readline()
if cache == '':
break;
cache = cache.strip()
if cache == '':
listInstance.append('')
continue
if cache.startswith('//'):
continue
listInstance.append(cache)
f.close()
def GenerateSweetBerryBushStageModel(name, stage):
f = open('assets/teyvatcraft/models/block/{}_stage{}.json'.format(name, stage), 'w', encoding='utf-8')
f.write('''{{
"parent": "minecraft:block/cross",
"textures": {{
"cross": "teyvatcraft:block/{}_stage{}"
}}
}}'''.format(name, stage))
f.close()
# folder creation
if not os.path.isdir('data/teyvatcraft/loot_tables/blocks'):
os.makedirs('data/teyvatcraft/loot_tables/blocks')
if not os.path.isdir('assets/teyvatcraft/models/block'):
os.makedirs('assets/teyvatcraft/models/block')
if not os.path.isdir('assets/teyvatcraft/blockstates'):
os.makedirs('assets/teyvatcraft/blockstates')
if not os.path.isdir('assets/teyvatcraft/textures/block'):
os.makedirs('assets/teyvatcraft/textures/block')
# read file
enList = []
zhList = []
propList = []
ReadListFromFile('zh.txt', zhList)
ReadListFromFile('en.txt', enList)
ReadListFromFile('prop.txt', propList)
if len(zhList) != len(enList) or len(propList) != len(enList):
print('3 files item is not matched')
sys.exit(0)
javaDeclareFile = open('declare.block.java', 'w', encoding='utf-8')
javaRegisterFile = open('register.block.java', 'w', encoding='utf-8')
langZhFile = open('zh_cn.block.json', 'w', encoding='utf-8')
langEnFile = open('en_us.block.json', 'w', encoding='utf-8')
for index in range(len(enList)):
underlineName = enList[index].lower().replace(',', '').replace('& ', '').replace('é', 'e').replace('-', '_').replace("'", '').replace('"', '').replace(' ', '_')
upperName = underlineName.upper()
if propList[index] == '':
# keep blank line in register & declare
javaDeclareFile.write('\n')
javaRegisterFile.write('\n')
langZhFile.write('\n')
langEnFile.write('\n')
continue
flootTables = open('data/teyvatcraft/loot_tables/blocks/' + underlineName + '.json', 'w', encoding='utf-8')
fblockstates = open('assets/teyvatcraft/blockstates/' + underlineName + '.json', 'w', encoding='utf-8')
if propList[index] == 'sweet_berry_bush':
javaDeclareFile.write('public static final Block {} = new TeyvatSweetBerryBushLikePlantBlock(ItemsManager.{});\n'.format(upperName, upperName))
flootTables.write('''{{
"type": "minecraft:block",
"pools": [
{{
"rolls": 1.0,
"entries": [
{{
"type": "minecraft:item",
"name": "teyvatcraft:{}"
}}
],
"conditions": [
{{
"condition": "minecraft:block_state_property",
"block": "teyvatcraft:{}",
"properties": {{
"age": "3"
}}
}}
],
"functions": [
{{
"function": "minecraft:set_count",
"count": {{
"min": 2.0,
"max": 3.0,
"type": "minecraft:uniform"
}}
}},
{{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {{
"bonusMultiplier": 1
}}
}}
]
}},
{{
"rolls": 1.0,
"entries": [
{{
"type": "minecraft:item",
"name": "teyvatcraft:{}"
}}
],
"conditions": [
{{
"condition": "minecraft:block_state_property",
"block": "teyvatcraft:{}",
"properties": {{
"age": "2"
}}
}}
],
"functions": [
{{
"function": "minecraft:set_count",
"count": {{
"min": 1.0,
"max": 2.0,
"type": "minecraft:uniform"
}}
}},
{{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {{
"bonusMultiplier": 1
}}
}}
]
}}
],
"functions": [
{{
"function": "minecraft:explosion_decay"
}}
]
}}'''.format(*([underlineName, ]*4)))
fblockstates.write('''{{
"variants": {{
"age=0": {{
"model": "teyvatcraft:block/{}_stage0"
}},
"age=1": {{
"model": "teyvatcraft:block/{}_stage1"
}},
"age=2": {{
"model": "teyvatcraft:block/{}_stage2"
}},
"age=3": {{
"model": "teyvatcraft:block/{}_stage3"
}}
}}
}}'''.format(*([underlineName, ]*4)))
GenerateSweetBerryBushStageModel(underlineName, 0)
GenerateSweetBerryBushStageModel(underlineName, 1)
GenerateSweetBerryBushStageModel(underlineName, 2)
GenerateSweetBerryBushStageModel(underlineName, 3)
#shutil.copyfile('sweet_berry_bush_stage0.png', 'assets/teyvatcraft/textures/block/{}_stage0.png'.format(underlineName))
#shutil.copyfile('sweet_berry_bush_stage1.png', 'assets/teyvatcraft/textures/block/{}_stage1.png'.format(underlineName))
#shutil.copyfile('sweet_berry_bush_stage2.png', 'assets/teyvatcraft/textures/block/{}_stage2.png'.format(underlineName))
#shutil.copyfile('sweet_berry_bush_stage3.png', 'assets/teyvatcraft/textures/block/{}_stage3.png'.format(underlineName))
elif propList[index] == 'flower':
fmodel = open('assets/teyvatcraft/models/block/{}.json'.format(underlineName), 'w', encoding='utf-8')
javaDeclareFile.write('public static final Block {} = new TeyvatFlowerLikePlantBlock();\n'.format(upperName))
flootTables.write('''{{
"type": "minecraft:block",
"pools": [
{{
"rolls": 1,
"entries": [
{{
"type": "minecraft:item",
"name": "teyvatcraft:{}"
}}
],
"conditions": [
{{
"condition": "minecraft:survives_explosion"
}}
]
}}
]
}}'''.format(underlineName))
fblockstates.write('''{{
"variants": {{
"": {{
"model": "teyvatcraft:block/{}"
}}
}}
}}'''.format(underlineName))
fmodel.write('''{{
"parent": "minecraft:block/cross",
"textures": {{
"cross": "teyvatcraft:block/{}"
}}
}}'''.format(underlineName))
fmodel.close()
#shutil.copyfile('flower.png', 'assets/teyvatcraft/textures/block/{}.png'.format(underlineName))
flootTables.close()
fblockstates.close()
javaRegisterFile.write('registerTeyvatPlant({}, "{}");\n'.format(upperName, underlineName))
langZhFile.write('"block.teyvatcraft.{}": "{}",\n'.format(underlineName, zhList[index]))
langEnFile.write('"block.teyvatcraft.{}": "{}",\n'.format(underlineName, enList[index].replace('"', '')))
javaDeclareFile.close()
javaRegisterFile.close()
langZhFile.close()
langEnFile.close()

View File

@ -0,0 +1,18 @@
Calla Lily
Dandelion Seed
Jueyun Chili
Small Lamp Grass
Mint
Sweet Flower
Berry
Snapdragon
Matsutake
Horsetail
Cecilia
Glaze Lily
Philanemo Mushroom
Silk Flower
Valberry
Windwheel Aster
Wolfhook
Qingxin

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

View File

@ -0,0 +1,18 @@
flower
flower
sweet_berry_bush
flower
flower
flower
sweet_berry_bush
flower
flower
flower
flower
flower
flower
sweet_berry_bush
sweet_berry_bush
flower
sweet_berry_bush
flower

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

View File

@ -0,0 +1,18 @@
嘟嘟莲
蒲公英籽
绝云椒椒
小灯草
薄荷
甜甜花
树莓
金鱼草
松茸
马尾
塞西莉亚花
琉璃百合
慕风蘑菇
霓裳花
落落莓
风车菊
钩钩果
清心