|
1 | 1 | package gregtech.api.block.coil; |
2 | 2 |
|
| 3 | +import gregtech.api.GTValues; |
| 4 | +import gregtech.api.recipes.properties.impl.TemperatureProperty; |
3 | 5 | import gregtech.api.unification.material.Material; |
| 6 | +import gregtech.api.unification.material.Materials; |
4 | 7 | import gregtech.api.util.GTUtility; |
5 | 8 | import gregtech.api.util.function.QuadConsumer; |
6 | 9 |
|
|
13 | 16 |
|
14 | 17 | public class CoilStatBuilder { |
15 | 18 |
|
16 | | - private final CustomCoilStats stats; |
17 | | - private ResourceLocation textureLocation; |
18 | 19 | private final String modid; |
19 | 20 |
|
| 21 | + private String name; |
| 22 | + |
| 23 | + // electric blast furnace properties |
| 24 | + private int coilTemperature = -1; |
| 25 | + |
| 26 | + // multi smelter properties |
| 27 | + private int level = -1; |
| 28 | + private int energyDiscount = 0; |
| 29 | + |
| 30 | + // voltage tier |
| 31 | + private int tier = GTValues.ULV; |
| 32 | + |
| 33 | + private Material material = Materials.Iron; |
| 34 | + private ResourceLocation textureLocation; |
| 35 | + private boolean isGeneric; |
| 36 | + private QuadConsumer<ItemStack, World, List<String>, Boolean> additionalTooltips; |
| 37 | + |
20 | 38 | CoilStatBuilder(String modid) { |
21 | 39 | this.modid = modid; |
22 | | - this.stats = new CustomCoilStats(); |
23 | 40 | } |
24 | 41 |
|
| 42 | + /** |
| 43 | + * @param material Material that this coil should be based off of. Used for |
| 44 | + * {@link TemperatureProperty#registerCoilType(int, Material, String)}. |
| 45 | + * @return this |
| 46 | + */ |
25 | 47 | public CoilStatBuilder material(Material material) { |
26 | | - stats.material = material; |
27 | | - stats.name = material.getResourceLocation().getPath(); |
| 48 | + return material(material, material.getName()); |
| 49 | + } |
| 50 | + |
| 51 | + /** |
| 52 | + * @param material Material that this coil should be based off of. Used for |
| 53 | + * {@link TemperatureProperty#registerCoilType(int, Material, String)}. |
| 54 | + * @param name Name of the variant to look for in the model json (typically the name of the material). |
| 55 | + * @return this |
| 56 | + */ |
| 57 | + public CoilStatBuilder material(Material material, String name) { |
| 58 | + this.material = material; |
| 59 | + this.name = name; |
28 | 60 | return this; |
29 | 61 | } |
30 | 62 |
|
31 | 63 | public CoilStatBuilder coilTemp(int coilTemperature) { |
32 | | - stats.coilTemperature = coilTemperature; |
| 64 | + this.coilTemperature = coilTemperature; |
33 | 65 | return this; |
34 | 66 | } |
35 | 67 |
|
| 68 | + /** |
| 69 | + * @param tier The voltage tier of this coil variant, used for the energy discount in the cracking unit and pyrolyse |
| 70 | + * oven |
| 71 | + * @return this |
| 72 | + */ |
36 | 73 | public CoilStatBuilder tier(int tier) { |
37 | | - stats.tier = Math.max(0, tier); |
| 74 | + this.tier = Math.max(0, tier); |
38 | 75 | return this; |
39 | 76 | } |
40 | 77 |
|
| 78 | + /** |
| 79 | + * @param level This is used for the amount of parallel recipes in the multi smelter. Multiplied by 32. |
| 80 | + * @param energyDiscount This is used for the energy discount in the multi smelter |
| 81 | + * @return this |
| 82 | + */ |
41 | 83 | public CoilStatBuilder multiSmelter(int level, int energyDiscount) { |
42 | | - stats.level = level; |
43 | | - stats.energyDiscount = energyDiscount; |
| 84 | + this.level = level; |
| 85 | + this.energyDiscount = energyDiscount; |
44 | 86 | return this; |
45 | 87 | } |
46 | 88 |
|
| 89 | + /** |
| 90 | + * @param location Location of the block model json |
| 91 | + * @return this |
| 92 | + */ |
47 | 93 | public CoilStatBuilder texture(String location) { |
48 | 94 | this.textureLocation = new ResourceLocation(this.modid, location); |
49 | 95 | return this; |
50 | 96 | } |
51 | 97 |
|
| 98 | + /** |
| 99 | + * @param location Location of the block model json |
| 100 | + * @param generic If true, the coil will use a grayscale texture to tint based off of the materials color. |
| 101 | + * Otherwise, it will look for a texture specifically for this variant. |
| 102 | + * @return this |
| 103 | + */ |
52 | 104 | public CoilStatBuilder texture(String location, boolean generic) { |
53 | 105 | return texture(location).generic(generic); |
54 | 106 | } |
55 | 107 |
|
| 108 | + /** |
| 109 | + * @param generic If true, the coil will use a grayscale texture to tint based off of the materials color. |
| 110 | + * Otherwise, it will look for a texture specifically for this variant. |
| 111 | + * @return this |
| 112 | + */ |
56 | 113 | public CoilStatBuilder generic(boolean generic) { |
57 | | - this.stats.isGeneric = generic; |
| 114 | + this.isGeneric = generic; |
58 | 115 | return this; |
59 | 116 | } |
60 | 117 |
|
| 118 | + /** |
| 119 | + * Marks this variant as generic, it will look for a grayscale texture and tint based on material color. |
| 120 | + * |
| 121 | + * @return this |
| 122 | + */ |
61 | 123 | public CoilStatBuilder generic() { |
62 | 124 | return generic(true); |
63 | 125 | } |
64 | 126 |
|
| 127 | + /** |
| 128 | + * @param additionalTooltips Used for adding additional tooltips for this variant |
| 129 | + * @return this |
| 130 | + */ |
65 | 131 | public CoilStatBuilder tooltip(QuadConsumer<ItemStack, World, List<String>, Boolean> additionalTooltips) { |
66 | | - this.stats.additionalTooltips = additionalTooltips; |
| 132 | + this.additionalTooltips = additionalTooltips; |
67 | 133 | return this; |
68 | 134 | } |
69 | 135 |
|
70 | 136 | CustomCoilStats build() { |
71 | 137 | if (this.textureLocation == null) { |
72 | 138 | this.textureLocation = GTUtility.gregtechId("wire_coil"); |
73 | 139 | } |
| 140 | + |
74 | 141 | String variant; |
75 | | - if (this.stats.isGeneric) { |
| 142 | + ModelResourceLocation inactive; |
| 143 | + ModelResourceLocation active; |
| 144 | + if (this.isGeneric) { |
76 | 145 | variant = "%s"; |
77 | | - this.stats.inactive = new ModelResourceLocation(this.textureLocation, String.format(variant, "normal")); |
78 | | - this.stats.active = new ModelResourceLocation(this.textureLocation, String.format(variant, "active")); |
| 146 | + inactive = new ModelResourceLocation(this.textureLocation, String.format(variant, "normal")); |
| 147 | + active = new ModelResourceLocation(this.textureLocation, String.format(variant, "active")); |
79 | 148 | } else { |
80 | 149 | variant = "active=%s,variant=%s"; |
81 | | - this.stats.inactive = new ModelResourceLocation(this.textureLocation, |
82 | | - String.format(variant, false, stats.name)); |
83 | | - this.stats.active = new ModelResourceLocation(this.textureLocation, |
84 | | - String.format(variant, true, stats.name)); |
| 150 | + inactive = new ModelResourceLocation(this.textureLocation, |
| 151 | + String.format(variant, false, this.name)); |
| 152 | + active = new ModelResourceLocation(this.textureLocation, |
| 153 | + String.format(variant, true, this.name)); |
85 | 154 | } |
86 | | - return this.stats; |
| 155 | + return new CustomCoilStats( |
| 156 | + this.name, |
| 157 | + this.coilTemperature, |
| 158 | + this.level, |
| 159 | + this.energyDiscount, |
| 160 | + this.tier, |
| 161 | + this.material, |
| 162 | + active, |
| 163 | + inactive, |
| 164 | + this.isGeneric, |
| 165 | + this.additionalTooltips); |
87 | 166 | } |
88 | 167 | } |
0 commit comments