Skip to content

Commit 17baf9c

Browse files
authored
feat: Add support for Augment Items (#22)
1 parent f49730d commit 17baf9c

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

src/main/java/dev/latvian/mods/kubejs/thermal/KubeJSThermalPlugin.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
import cofh.thermal.core.init.registries.TCoreRecipeTypes;
66
import dev.latvian.mods.kubejs.KubeJSPlugin;
77
import dev.latvian.mods.kubejs.recipe.schema.RegisterRecipeSchemasEvent;
8+
import dev.latvian.mods.kubejs.registry.RegistryInfo;
89

910
public class KubeJSThermalPlugin extends KubeJSPlugin {
11+
@Override
12+
public void init() {
13+
RegistryInfo.ITEM.addType("thermal_augment", ThermalAugmentItemBuilder.class, ThermalAugmentItemBuilder::new);
14+
}
15+
1016
@Override
1117
public void registerRecipeSchemas(RegisterRecipeSchemasEvent event) {
1218
event.namespace(ModIds.ID_THERMAL)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package dev.latvian.mods.kubejs.thermal;
2+
3+
import cofh.core.util.helpers.AugmentDataHelper;
4+
import cofh.thermal.lib.common.item.AugmentItem;
5+
import dev.latvian.mods.kubejs.item.ItemBuilder;
6+
import dev.latvian.mods.kubejs.typings.Info;
7+
import net.minecraft.resources.ResourceLocation;
8+
import net.minecraft.world.item.Item;
9+
10+
import java.util.LinkedHashMap;
11+
import java.util.Map;
12+
13+
import static cofh.lib.util.constants.NBTTags.TAG_AUGMENT_BASE_MOD;
14+
import static cofh.lib.util.constants.NBTTags.TAG_AUGMENT_TYPE_UPGRADE;
15+
16+
public class ThermalAugmentItemBuilder extends ItemBuilder {
17+
public transient String augmentType;
18+
public transient LinkedHashMap<String, Float> thermalMods;
19+
20+
public ThermalAugmentItemBuilder(ResourceLocation i) {
21+
super(i);
22+
augmentType = TAG_AUGMENT_TYPE_UPGRADE;
23+
thermalMods = new LinkedHashMap<>();
24+
}
25+
26+
@Info("Sets Thermal augment type, default is Thermal upgrade augment type.")
27+
public ThermalAugmentItemBuilder augmentType(String type) {
28+
augmentType = type;
29+
return this;
30+
}
31+
32+
@Info("Sets a Thermal augment numeric modifier by key. Can be called multiple times for different keys.")
33+
public ThermalAugmentItemBuilder thermalMod(String key, float value) {
34+
thermalMods.put(key, value);
35+
return this;
36+
}
37+
38+
@Info("Convenience alias for setting Thermal BaseMod.")
39+
public ThermalAugmentItemBuilder baseMod(float value) {
40+
thermalMods.put(TAG_AUGMENT_BASE_MOD, value);
41+
return this;
42+
}
43+
44+
@Override
45+
public Item createObject() {
46+
var builder = AugmentDataHelper.builder().type(augmentType);
47+
for (Map.Entry<String, Float> entry : thermalMods.entrySet()) {
48+
builder.mod(entry.getKey(), entry.getValue());
49+
}
50+
51+
return new AugmentItem(createItemProperties(),
52+
builder.build());
53+
}
54+
}

0 commit comments

Comments
 (0)