forked from AztechMC/Modern-Industrialization
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_petrochem.py
153 lines (136 loc) · 4.79 KB
/
gen_petrochem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
from collections import defaultdict
from pathlib import Path
import os
import json
import shutil
path_output = "src/main/resources/data/modern_industrialization/recipes/generated/petrochem/"
shutil.rmtree(path_output, ignore_errors=True)
# Generate all the distillation recipes, TODO: and the distillation tower
def gen_distillation(eu, duration, input, outputs):
def split_fluid(x):
amount, fluid = x.split()
return int(amount), fluid
in_amount, in_fluid = split_fluid(input)
out_dir = path_output + in_fluid + "_distillation/"
Path(out_dir).mkdir(parents=True, exist_ok=True)
i = 0
for out_amount, out_fluid in map(split_fluid, outputs):
with open(out_dir + str(i) + ".json", "w") as f:
json.dump({
"type": "modern_industrialization:distillery",
"eu": eu,
"duration": duration,
"fluid_inputs": {
"fluid": "modern_industrialization:" + in_fluid,
"amount": in_amount,
},
"fluid_outputs": {
"fluid": "modern_industrialization:" + out_fluid,
"amount": out_amount,
}
}, f, indent=4)
i += 1
with open(out_dir + "full.json", "w") as f:
json.dump({
"type": "modern_industrialization:distillation_tower",
"eu": eu * len(outputs),
"duration": duration,
"fluid_inputs": {
"fluid": "modern_industrialization:" + in_fluid,
"amount": in_amount,
},
"fluid_outputs": [{
"fluid": "modern_industrialization:" + out_fluid,
"amount": out_amount
} for out_amount, out_fluid in map(split_fluid, outputs)],
}, f, indent=4)
# Generate the Sulfuric X to X recipe
def gen_sulfuric(fluid):
out_dir = path_output + "sulfuric_purification/"
Path(out_dir).mkdir(parents=True, exist_ok=True)
with open(out_dir + fluid + ".json", "w") as f:
json.dump({
"type": "modern_industrialization:chemical_reactor",
"eu": 16,
"duration": 400,
"fluid_inputs": [
{
"fluid": "modern_industrialization:sulfuric_" + fluid,
"amount": 12000,
},
{
"fluid": "modern_industrialization:hydrogen",
"amount": 2000,
},
],
"fluid_outputs": [
{
"fluid": "modern_industrialization:" + fluid,
"amount": 12000,
},
{
"fluid": "modern_industrialization:sulfuric_acid",
"amount": 2000,
},
],
}, f, indent=4)
# Generate the two polymerization recipes
def gen_polymerization(input, output):
out_dir = path_output + "polymerization/"
Path(out_dir).mkdir(parents=True, exist_ok=True)
names = ["lead", "chrome"]
in_counts = [4, 1]
out_counts = [300, 700]
probabilities = [1.0, 0.5]
for i in range(2):
with open(out_dir + input + "_" + names[i] + ".json", "w") as f:
json.dump({
"type": "modern_industrialization:chemical_reactor",
"eu": 12,
"duration": 700,
"fluid_inputs": [
{
"fluid": "modern_industrialization:" + input,
"amount": 500,
}
],
"item_inputs": {
"tag": "c:" + names[i] + "_tiny_dusts",
"amount": in_counts[i],
},
"fluid_outputs": [
{
"fluid": "modern_industrialization:" + output,
"amount": out_counts[i],
}
],
}, f, indent=4)
gen_distillation(12, 200, "1000 crude_oil", [
"500 sulfuric_light_fuel",
"200 sulfuric_heavy_fuel",
"300 sulfuric_naphtha",
])
gen_distillation(15, 200, "1000 steam_cracked_naphtha", [
"150 methane",
"50 acetylene",
"250 ethylene",
"75 propene",
"125 butadiene",
"150 benzene",
"100 toluene",
"100 ethylbenzene",
])
gen_distillation(10, 200, "1000 shale_oil", [
"50 helium",
"450 sulfuric_crude_oil",
"500 sulfuric_naphtha",
])
gen_sulfuric("crude_oil")
gen_sulfuric("heavy_fuel")
gen_sulfuric("light_fuel")
gen_sulfuric("naphtha")
gen_polymerization("ethylene", "polyethylene")
gen_polymerization("vinyl_chloride", "polyvinyl_chloride")
gen_polymerization("caprolactam", "nylon")
gen_polymerization("acrylic_acid", "acrylic_glue")
gen_polymerization("styrene_butadiene", "styrene_butadiene_rubber")