Skip to content

Commit

Permalink
Register broken predicate for json things tinkers armor
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed May 15, 2024
1 parent f3f83e3 commit 6dae7ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class FlexItemTypes {
static final List<Item> TOOL_ITEMS = new ArrayList<>();
/** All crossbow items that need their predicate registered */
static final List<Item> CROSSBOW_ITEMS = new ArrayList<>();
/** All armor items that need the broken predicate */
static final List<Item> ARMOR_ITEMS = new ArrayList<>();

/** Adds a thing to a list so we can fetch the instances later */
private static <T> T add(List<? super T> list, T item) {
Expand Down Expand Up @@ -80,7 +82,7 @@ public static void init() {
ResourceLocation name = JsonHelper.getResourceLocation(data, "texture_name");
SoundEvent sound = Loadables.SOUND_EVENT.getOrDefault(data, "equip_sound", SoundEvents.ARMOR_EQUIP_GENERIC);
ArmorSlotType slot = JsonHelper.getAsEnum(data, "slot", ArmorSlotType.class);
return (props, builder) -> new FlexModifiableArmorItem(new DummyArmorMaterial(name, sound), slot.getEquipmentSlot(), props, ToolDefinition.create(builder.getRegistryName()));
return (props, builder) -> add(ARMOR_ITEMS, new FlexModifiableArmorItem(new DummyArmorMaterial(name, sound), slot.getEquipmentSlot(), props, ToolDefinition.create(builder.getRegistryName())));
});

/* Layered armor type, used for golden, dyeable, etc */
Expand All @@ -89,14 +91,14 @@ public static void init() {
SoundEvent sound = Loadables.SOUND_EVENT.getOrDefault(data, "equip_sound", SoundEvents.ARMOR_EQUIP_GENERIC);
ArmorSlotType slot = JsonHelper.getAsEnum(data, "slot", ArmorSlotType.class);
List<ArmorTextureSupplier> layers = ARMOR_TEXTURES.getIfPresent(data, "texture_layers");
return (props, builder) -> new FlexMultilayerArmorModel(new DummyArmorMaterial(builder.getRegistryName(), sound), slot.getEquipmentSlot(), props, ToolDefinition.create(builder.getRegistryName()), layers.toArray(new ArmorTextureSupplier[0]));
return (props, builder) -> add(ARMOR_ITEMS, new FlexMultilayerArmorModel(new DummyArmorMaterial(builder.getRegistryName(), sound), slot.getEquipmentSlot(), props, ToolDefinition.create(builder.getRegistryName()), layers.toArray(new ArmorTextureSupplier[0])));
});

/* Register a modifiable armor part that supports embellishments */
register("material_armor", data -> {
SoundEvent sound = Loadables.SOUND_EVENT.getOrDefault(data, "equip_sound", SoundEvents.ARMOR_EQUIP_GENERIC);
ArmorSlotType slot = JsonHelper.getAsEnum(data, "slot", ArmorSlotType.class);
return (props, builder) -> new FlexMaterialArmorItem(new DummyArmorMaterial(builder.getRegistryName(), sound), slot.getEquipmentSlot(), props, ToolDefinition.create(builder.getRegistryName()));
return (props, builder) -> add(ARMOR_ITEMS, new FlexMaterialArmorItem(new DummyArmorMaterial(builder.getRegistryName(), sound), slot.getEquipmentSlot(), props, ToolDefinition.create(builder.getRegistryName())));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ private static void clientSetup(FMLClientSetupEvent event) {
for (Item item : FlexItemTypes.CROSSBOW_ITEMS) {
TinkerItemProperties.registerCrossbowProperties(item);
}
for (Item item : FlexItemTypes.ARMOR_ITEMS) {
TinkerItemProperties.registerBrokenProperty(item);
}
});
}
}

0 comments on commit 6dae7ca

Please sign in to comment.