|
| 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