Skip to content

Commit 4d869f0

Browse files
committed
feat: merge armor trim api
merges #2568 Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
2 parents faefbd5 + 195fb34 commit 4d869f0

File tree

7 files changed

+292
-0
lines changed

7 files changed

+292
-0
lines changed

src/main/java/org/spongepowered/api/data/Keys.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
import org.spongepowered.api.item.enchantment.EnchantmentTypes;
223223
import org.spongepowered.api.item.inventory.Inventory;
224224
import org.spongepowered.api.item.inventory.ItemStack;
225+
import org.spongepowered.api.item.inventory.ItemStackLike;
225226
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
226227
import org.spongepowered.api.item.inventory.Slot;
227228
import org.spongepowered.api.item.inventory.equipment.EquipmentType;
@@ -230,6 +231,7 @@
230231
import org.spongepowered.api.item.merchant.Merchant;
231232
import org.spongepowered.api.item.merchant.TradeOffer;
232233
import org.spongepowered.api.item.potion.PotionType;
234+
import org.spongepowered.api.item.recipe.smithing.ArmorTrim;
233235
import org.spongepowered.api.map.MapCanvas;
234236
import org.spongepowered.api.map.MapInfo;
235237
import org.spongepowered.api.map.decoration.MapDecoration;
@@ -405,6 +407,11 @@ public final class Keys {
405407
*/
406408
public static final Key<Value<ArmorMaterial>> ARMOR_MATERIAL = Keys.key(ResourceKey.sponge("armor_material"), ArmorMaterial.class);
407409

410+
/**
411+
* The {@link ArmorTrim} of an armor {@link ItemStackLike ItemStack}. Can be modified.
412+
*/
413+
public static final Key<Value<ArmorTrim>> ARMOR_TRIM = Keys.key(ResourceKey.sponge("armor_trim"), ArmorTrim.class);
414+
408415
/**
409416
* The type of {@link ArtType} shown by {@link Painting}s.
410417
*/
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.item.recipe.smithing;
26+
27+
import org.spongepowered.api.Sponge;
28+
29+
import java.util.function.Supplier;
30+
31+
public interface ArmorTrim {
32+
33+
static ArmorTrim of(TrimMaterial material, TrimPattern pattern) {
34+
return Sponge.game().factoryProvider().provide(Factory.class).create(material, pattern);
35+
}
36+
37+
TrimMaterial material();
38+
39+
TrimPattern pattern();
40+
41+
interface Factory {
42+
43+
ArmorTrim create(TrimMaterial material, TrimPattern pattern);
44+
45+
default ArmorTrim create(Supplier<? extends TrimMaterial> material, Supplier<? extends TrimPattern> pattern) {
46+
return create(material.get(), pattern.get());
47+
}
48+
49+
default ArmorTrim create(Supplier<? extends TrimMaterial> material, TrimPattern pattern) {
50+
return create(material.get(), pattern);
51+
}
52+
53+
default ArmorTrim create(TrimMaterial material, Supplier<? extends TrimPattern> pattern) {
54+
return create(material, pattern.get());
55+
}
56+
57+
}
58+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.item.recipe.smithing;
26+
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
29+
30+
@CatalogedBy(TrimMaterials.class)
31+
public interface TrimMaterial extends DefaultedRegistryValue {
32+
33+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.item.recipe.smithing;
26+
27+
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
29+
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
31+
import org.spongepowered.api.registry.RegistryKey;
32+
import org.spongepowered.api.registry.RegistryScope;
33+
import org.spongepowered.api.registry.RegistryScopes;
34+
import org.spongepowered.api.registry.RegistryTypes;
35+
36+
@SuppressWarnings("unused")
37+
@RegistryScopes(scopes = RegistryScope.ENGINE)
38+
public final class TrimMaterials {
39+
40+
public static final DefaultedRegistryReference<TrimMaterial> AMETHYST = TrimMaterials.key(ResourceKey.minecraft("amethyst"));
41+
42+
public static final DefaultedRegistryReference<TrimMaterial> COPPER = TrimMaterials.key(ResourceKey.minecraft("copper"));
43+
44+
public static final DefaultedRegistryReference<TrimMaterial> DIAMOND = TrimMaterials.key(ResourceKey.minecraft("diamond"));
45+
46+
public static final DefaultedRegistryReference<TrimMaterial> EMERALD = TrimMaterials.key(ResourceKey.minecraft("emerald"));
47+
48+
public static final DefaultedRegistryReference<TrimMaterial> GOLD = TrimMaterials.key(ResourceKey.minecraft("gold"));
49+
50+
public static final DefaultedRegistryReference<TrimMaterial> IRON = TrimMaterials.key(ResourceKey.minecraft("iron"));
51+
52+
public static final DefaultedRegistryReference<TrimMaterial> LAPIS = TrimMaterials.key(ResourceKey.minecraft("lapis"));
53+
54+
public static final DefaultedRegistryReference<TrimMaterial> NETHERITE = TrimMaterials.key(ResourceKey.minecraft("netherite"));
55+
56+
public static final DefaultedRegistryReference<TrimMaterial> QUARTZ = TrimMaterials.key(ResourceKey.minecraft("quartz"));
57+
58+
public static final DefaultedRegistryReference<TrimMaterial> REDSTONE = TrimMaterials.key(ResourceKey.minecraft("redstone"));
59+
60+
private TrimMaterials() {
61+
}
62+
63+
public static Registry<TrimMaterial> registry() {
64+
return Sponge.server().registry(RegistryTypes.TRIM_MATERIAL);
65+
}
66+
67+
private static DefaultedRegistryReference<TrimMaterial> key(final ResourceKey location) {
68+
return RegistryKey.of(RegistryTypes.TRIM_MATERIAL, location).asDefaultedReference(Sponge::server);
69+
}
70+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.item.recipe.smithing;
26+
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
29+
30+
@CatalogedBy(TrimPatterns.class)
31+
public interface TrimPattern extends DefaultedRegistryValue {
32+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.item.recipe.smithing;
26+
27+
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
29+
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
31+
import org.spongepowered.api.registry.RegistryKey;
32+
import org.spongepowered.api.registry.RegistryScope;
33+
import org.spongepowered.api.registry.RegistryScopes;
34+
import org.spongepowered.api.registry.RegistryTypes;
35+
36+
@SuppressWarnings("unused")
37+
@RegistryScopes(scopes = RegistryScope.ENGINE)
38+
public final class TrimPatterns {
39+
40+
public static final DefaultedRegistryReference<TrimPattern> BOLT = TrimPatterns.key(ResourceKey.minecraft("bolt"));
41+
42+
public static final DefaultedRegistryReference<TrimPattern> COAST = TrimPatterns.key(ResourceKey.minecraft("coast"));
43+
44+
public static final DefaultedRegistryReference<TrimPattern> DUNE = TrimPatterns.key(ResourceKey.minecraft("dune"));
45+
46+
public static final DefaultedRegistryReference<TrimPattern> EYE = TrimPatterns.key(ResourceKey.minecraft("eye"));
47+
48+
public static final DefaultedRegistryReference<TrimPattern> FLOW = TrimPatterns.key(ResourceKey.minecraft("flow"));
49+
50+
public static final DefaultedRegistryReference<TrimPattern> HOST = TrimPatterns.key(ResourceKey.minecraft("host"));
51+
52+
public static final DefaultedRegistryReference<TrimPattern> RAISER = TrimPatterns.key(ResourceKey.minecraft("raiser"));
53+
54+
public static final DefaultedRegistryReference<TrimPattern> RIB = TrimPatterns.key(ResourceKey.minecraft("rib"));
55+
56+
public static final DefaultedRegistryReference<TrimPattern> SENTRY = TrimPatterns.key(ResourceKey.minecraft("sentry"));
57+
58+
public static final DefaultedRegistryReference<TrimPattern> SHAPER = TrimPatterns.key(ResourceKey.minecraft("shaper"));
59+
60+
public static final DefaultedRegistryReference<TrimPattern> SILENCE = TrimPatterns.key(ResourceKey.minecraft("silence"));
61+
62+
public static final DefaultedRegistryReference<TrimPattern> SNOUT = TrimPatterns.key(ResourceKey.minecraft("snout"));
63+
64+
public static final DefaultedRegistryReference<TrimPattern> SPIRE = TrimPatterns.key(ResourceKey.minecraft("spire"));
65+
66+
public static final DefaultedRegistryReference<TrimPattern> TIDE = TrimPatterns.key(ResourceKey.minecraft("tide"));
67+
68+
public static final DefaultedRegistryReference<TrimPattern> VEX = TrimPatterns.key(ResourceKey.minecraft("vex"));
69+
70+
public static final DefaultedRegistryReference<TrimPattern> WARD = TrimPatterns.key(ResourceKey.minecraft("ward"));
71+
72+
public static final DefaultedRegistryReference<TrimPattern> WAYFINDER = TrimPatterns.key(ResourceKey.minecraft("wayfinder"));
73+
74+
public static final DefaultedRegistryReference<TrimPattern> WILD = TrimPatterns.key(ResourceKey.minecraft("wild"));
75+
76+
private TrimPatterns() {
77+
}
78+
79+
public static Registry<TrimPattern> registry() {
80+
return Sponge.server().registry(RegistryTypes.TRIM_PATTERN);
81+
}
82+
83+
private static DefaultedRegistryReference<TrimPattern> key(final ResourceKey location) {
84+
return RegistryKey.of(RegistryTypes.TRIM_PATTERN, location).asDefaultedReference(Sponge::server);
85+
}
86+
}

src/main/java/org/spongepowered/api/registry/RegistryTypes.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@
132132
import org.spongepowered.api.item.potion.PotionType;
133133
import org.spongepowered.api.item.recipe.Recipe;
134134
import org.spongepowered.api.item.recipe.RecipeType;
135+
import org.spongepowered.api.item.recipe.smithing.TrimMaterial;
136+
import org.spongepowered.api.item.recipe.smithing.TrimPattern;
135137
import org.spongepowered.api.map.color.MapColorType;
136138
import org.spongepowered.api.map.color.MapShade;
137139
import org.spongepowered.api.map.decoration.MapDecorationType;
@@ -275,6 +277,10 @@ public final class RegistryTypes {
275277

276278
public static final DefaultedRegistryType<Trigger<? extends @NonNull Object>> TRIGGER = RegistryTypes.minecraftKeyInGame("trigger_type");
277279

280+
public static final DefaultedRegistryType<TrimMaterial> TRIM_MATERIAL = RegistryTypes.minecraftKeyInServer("trim_material");
281+
282+
public static final DefaultedRegistryType<TrimPattern> TRIM_PATTERN = RegistryTypes.minecraftKeyInServer("trim_pattern");
283+
278284
public static final DefaultedRegistryType<VillagerType> VILLAGER_TYPE = RegistryTypes.minecraftKeyInGame("villager_type");
279285

280286
public static final DefaultedRegistryType<WorldType> WORLD_TYPE = RegistryTypes.minecraftKeyInServer("dimension_type");

0 commit comments

Comments
 (0)