From 7e936d3ddd7b97065b1aa7d33c0157288c3da6f3 Mon Sep 17 00:00:00 2001 From: Michael Hillcox Date: Sat, 21 Nov 2020 10:55:20 +0000 Subject: [PATCH] Added class to group all tools and armors into one class --- .../common/items/ToolSet.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/main/java/de/ellpeck/actuallyadditions/common/items/ToolSet.java diff --git a/src/main/java/de/ellpeck/actuallyadditions/common/items/ToolSet.java b/src/main/java/de/ellpeck/actuallyadditions/common/items/ToolSet.java new file mode 100644 index 000000000..dfacce7df --- /dev/null +++ b/src/main/java/de/ellpeck/actuallyadditions/common/items/ToolSet.java @@ -0,0 +1,54 @@ +package de.ellpeck.actuallyadditions.common.items; + +import com.google.common.collect.ImmutableSet; +import de.ellpeck.actuallyadditions.common.materials.ToolMaterials; +import net.minecraft.inventory.EquipmentSlotType; +import net.minecraft.item.*; +import net.minecraftforge.registries.DeferredRegister; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.Set; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +public final class ToolSet { + public final Pair pickaxe; + public final Pair axe; + public final Pair shovel; + public final Pair sword; + public final Pair hoe; + public final Pair helmet; + public final Pair chest; + public final Pair leggins; + public final Pair boots; + + public final Set> items; + + public final IItemTier tier; + public final String name; + + public ToolSet(String name, IItemTier tier, IArmorMaterial armorTier, Supplier props) { + this.pickaxe = Pair.of("pickaxe", new PickaxeItem(tier, 1, -2.8f, props.get())); + this.axe = Pair.of("axe", new AxeItem(tier, 6, -3.0f, props.get())); + this.shovel = Pair.of("shovel", new ShovelItem(tier, 1, -3.0f, props.get())); + this.sword = Pair.of("sword", new SwordItem(tier, 1, ToolMaterials.RESTONIA.getAttackDamage() + 1.f, props.get())); + this.hoe = Pair.of("hoe", new HoeItem(tier, 1, ToolMaterials.RESTONIA.getAttackDamage() + 1.f, props.get())); + this.helmet = Pair.of("helmet", new ArmorItem(armorTier, EquipmentSlotType.HEAD, props.get())); + this.chest = Pair.of("chest", new ArmorItem(armorTier, EquipmentSlotType.CHEST, props.get())); + this.leggins = Pair.of("leggins", new ArmorItem(armorTier, EquipmentSlotType.LEGS, props.get())); + this.boots = Pair.of("boots", new ArmorItem(armorTier, EquipmentSlotType.FEET, props.get())); + + this.items = ImmutableSet.of(pickaxe, axe, shovel, sword, hoe, helmet, chest, leggins, boots); + + this.name = name; + this.tier = tier; + } + + public void register(DeferredRegister register) { + this.items.forEach(item -> register.register(String.format("%s_%s", this.name, item.getKey()), item::getValue)); + } + + public Set getItemGroup() { + return this.items.stream().map(Pair::getValue).collect(Collectors.toSet()); + } +}