From 195fb342ba6f55b7d22a89ec6479ad1ecc4a56e4 Mon Sep 17 00:00:00 2001 From: Gabriel Harris-Rouquette Date: Thu, 24 Oct 2024 22:21:29 -0700 Subject: [PATCH] feat: add armor trim key --- .../java/org/spongepowered/api/data/Keys.java | 7 ++ .../api/item/recipe/smithing/ArmorTrim.java | 58 +++++++++++++ .../item/recipe/smithing/TrimMaterial.java | 33 +++++++ .../item/recipe/smithing/TrimMaterials.java | 70 +++++++++++++++ .../api/item/recipe/smithing/TrimPattern.java | 32 +++++++ .../item/recipe/smithing/TrimPatterns.java | 86 +++++++++++++++++++ .../api/registry/RegistryTypes.java | 6 ++ 7 files changed, 292 insertions(+) create mode 100644 src/main/java/org/spongepowered/api/item/recipe/smithing/ArmorTrim.java create mode 100644 src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterial.java create mode 100644 src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterials.java create mode 100644 src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPattern.java create mode 100644 src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPatterns.java diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index cc9a70bc0a..d11e4c3ec0 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -220,6 +220,7 @@ import org.spongepowered.api.item.enchantment.EnchantmentTypes; import org.spongepowered.api.item.inventory.Inventory; import org.spongepowered.api.item.inventory.ItemStack; +import org.spongepowered.api.item.inventory.ItemStackLike; import org.spongepowered.api.item.inventory.ItemStackSnapshot; import org.spongepowered.api.item.inventory.Slot; import org.spongepowered.api.item.inventory.equipment.EquipmentType; @@ -228,6 +229,7 @@ import org.spongepowered.api.item.merchant.Merchant; import org.spongepowered.api.item.merchant.TradeOffer; import org.spongepowered.api.item.potion.PotionType; +import org.spongepowered.api.item.recipe.smithing.ArmorTrim; import org.spongepowered.api.map.MapCanvas; import org.spongepowered.api.map.MapInfo; import org.spongepowered.api.map.decoration.MapDecoration; @@ -403,6 +405,11 @@ public final class Keys { */ public static final Key> ARMOR_MATERIAL = Keys.key(ResourceKey.sponge("armor_material"), ArmorMaterial.class); + /** + * The {@link ArmorTrim} of an armor {@link ItemStackLike ItemStack}. Can be modified. + */ + public static final Key> ARMOR_TRIM = Keys.key(ResourceKey.sponge("armor_trim"), ArmorTrim.class); + /** * The type of {@link ArtType} shown by {@link Painting}s. */ diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/ArmorTrim.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/ArmorTrim.java new file mode 100644 index 0000000000..a22867facd --- /dev/null +++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/ArmorTrim.java @@ -0,0 +1,58 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.item.recipe.smithing; + +import org.spongepowered.api.Sponge; + +import java.util.function.Supplier; + +public interface ArmorTrim { + + static ArmorTrim of(TrimMaterial material, TrimPattern pattern) { + return Sponge.game().factoryProvider().provide(Factory.class).create(material, pattern); + } + + TrimMaterial material(); + + TrimPattern pattern(); + + interface Factory { + + ArmorTrim create(TrimMaterial material, TrimPattern pattern); + + default ArmorTrim create(Supplier material, Supplier pattern) { + return create(material.get(), pattern.get()); + } + + default ArmorTrim create(Supplier material, TrimPattern pattern) { + return create(material.get(), pattern); + } + + default ArmorTrim create(TrimMaterial material, Supplier pattern) { + return create(material, pattern.get()); + } + + } +} diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterial.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterial.java new file mode 100644 index 0000000000..88585747ec --- /dev/null +++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterial.java @@ -0,0 +1,33 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.item.recipe.smithing; + +import org.spongepowered.api.registry.DefaultedRegistryValue; +import org.spongepowered.api.util.annotation.CatalogedBy; + +@CatalogedBy(TrimMaterials.class) +public interface TrimMaterial extends DefaultedRegistryValue { + +} diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterials.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterials.java new file mode 100644 index 0000000000..c536f03443 --- /dev/null +++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterials.java @@ -0,0 +1,70 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.item.recipe.smithing; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryScope; +import org.spongepowered.api.registry.RegistryScopes; +import org.spongepowered.api.registry.RegistryTypes; + +@SuppressWarnings("unused") +@RegistryScopes(scopes = RegistryScope.ENGINE) +public final class TrimMaterials { + + public static final DefaultedRegistryReference AMETHYST = TrimMaterials.key(ResourceKey.minecraft("amethyst")); + + public static final DefaultedRegistryReference COPPER = TrimMaterials.key(ResourceKey.minecraft("copper")); + + public static final DefaultedRegistryReference DIAMOND = TrimMaterials.key(ResourceKey.minecraft("diamond")); + + public static final DefaultedRegistryReference EMERALD = TrimMaterials.key(ResourceKey.minecraft("emerald")); + + public static final DefaultedRegistryReference GOLD = TrimMaterials.key(ResourceKey.minecraft("gold")); + + public static final DefaultedRegistryReference IRON = TrimMaterials.key(ResourceKey.minecraft("iron")); + + public static final DefaultedRegistryReference LAPIS = TrimMaterials.key(ResourceKey.minecraft("lapis")); + + public static final DefaultedRegistryReference NETHERITE = TrimMaterials.key(ResourceKey.minecraft("netherite")); + + public static final DefaultedRegistryReference QUARTZ = TrimMaterials.key(ResourceKey.minecraft("quartz")); + + public static final DefaultedRegistryReference REDSTONE = TrimMaterials.key(ResourceKey.minecraft("redstone")); + + private TrimMaterials() { + } + + public static Registry registry() { + return Sponge.server().registry(RegistryTypes.TRIM_MATERIAL); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.TRIM_MATERIAL, location).asDefaultedReference(Sponge::server); + } +} diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPattern.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPattern.java new file mode 100644 index 0000000000..5846c44fb9 --- /dev/null +++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPattern.java @@ -0,0 +1,32 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.item.recipe.smithing; + +import org.spongepowered.api.registry.DefaultedRegistryValue; +import org.spongepowered.api.util.annotation.CatalogedBy; + +@CatalogedBy(TrimPatterns.class) +public interface TrimPattern extends DefaultedRegistryValue { +} diff --git a/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPatterns.java b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPatterns.java new file mode 100644 index 0000000000..228aa00632 --- /dev/null +++ b/src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPatterns.java @@ -0,0 +1,86 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.item.recipe.smithing; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryScope; +import org.spongepowered.api.registry.RegistryScopes; +import org.spongepowered.api.registry.RegistryTypes; + +@SuppressWarnings("unused") +@RegistryScopes(scopes = RegistryScope.ENGINE) +public final class TrimPatterns { + + public static final DefaultedRegistryReference BOLT = TrimPatterns.key(ResourceKey.minecraft("bolt")); + + public static final DefaultedRegistryReference COAST = TrimPatterns.key(ResourceKey.minecraft("coast")); + + public static final DefaultedRegistryReference DUNE = TrimPatterns.key(ResourceKey.minecraft("dune")); + + public static final DefaultedRegistryReference EYE = TrimPatterns.key(ResourceKey.minecraft("eye")); + + public static final DefaultedRegistryReference FLOW = TrimPatterns.key(ResourceKey.minecraft("flow")); + + public static final DefaultedRegistryReference HOST = TrimPatterns.key(ResourceKey.minecraft("host")); + + public static final DefaultedRegistryReference RAISER = TrimPatterns.key(ResourceKey.minecraft("raiser")); + + public static final DefaultedRegistryReference RIB = TrimPatterns.key(ResourceKey.minecraft("rib")); + + public static final DefaultedRegistryReference SENTRY = TrimPatterns.key(ResourceKey.minecraft("sentry")); + + public static final DefaultedRegistryReference SHAPER = TrimPatterns.key(ResourceKey.minecraft("shaper")); + + public static final DefaultedRegistryReference SILENCE = TrimPatterns.key(ResourceKey.minecraft("silence")); + + public static final DefaultedRegistryReference SNOUT = TrimPatterns.key(ResourceKey.minecraft("snout")); + + public static final DefaultedRegistryReference SPIRE = TrimPatterns.key(ResourceKey.minecraft("spire")); + + public static final DefaultedRegistryReference TIDE = TrimPatterns.key(ResourceKey.minecraft("tide")); + + public static final DefaultedRegistryReference VEX = TrimPatterns.key(ResourceKey.minecraft("vex")); + + public static final DefaultedRegistryReference WARD = TrimPatterns.key(ResourceKey.minecraft("ward")); + + public static final DefaultedRegistryReference WAYFINDER = TrimPatterns.key(ResourceKey.minecraft("wayfinder")); + + public static final DefaultedRegistryReference WILD = TrimPatterns.key(ResourceKey.minecraft("wild")); + + private TrimPatterns() { + } + + public static Registry registry() { + return Sponge.server().registry(RegistryTypes.TRIM_PATTERN); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.TRIM_PATTERN, location).asDefaultedReference(Sponge::server); + } +} diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index 4b1c9a8767..b621ca11f5 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -132,6 +132,8 @@ import org.spongepowered.api.item.potion.PotionType; import org.spongepowered.api.item.recipe.Recipe; import org.spongepowered.api.item.recipe.RecipeType; +import org.spongepowered.api.item.recipe.smithing.TrimMaterial; +import org.spongepowered.api.item.recipe.smithing.TrimPattern; import org.spongepowered.api.map.color.MapColorType; import org.spongepowered.api.map.color.MapShade; import org.spongepowered.api.map.decoration.MapDecorationType; @@ -275,6 +277,10 @@ public final class RegistryTypes { public static final DefaultedRegistryType> TRIGGER = RegistryTypes.minecraftKeyInGame("trigger_type"); + public static final DefaultedRegistryType TRIM_MATERIAL = RegistryTypes.minecraftKeyInServer("trim_material"); + + public static final DefaultedRegistryType TRIM_PATTERN = RegistryTypes.minecraftKeyInServer("trim_pattern"); + public static final DefaultedRegistryType VILLAGER_TYPE = RegistryTypes.minecraftKeyInGame("villager_type"); public static final DefaultedRegistryType WORLD_TYPE = RegistryTypes.minecraftKeyInServer("dimension_type");