Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add armor trim key #2568

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/main/java/org/spongepowered/api/data/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -403,6 +405,11 @@ public final class Keys {
*/
public static final Key<Value<ArmorMaterial>> 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<Value<ArmorTrim>> ARMOR_TRIM = Keys.key(ResourceKey.sponge("armor_trim"), ArmorTrim.class);

/**
* The type of {@link ArtType} shown by {@link Painting}s.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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<? extends TrimMaterial> material, Supplier<? extends TrimPattern> pattern) {
return create(material.get(), pattern.get());
}
Comment on lines +45 to +47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these defaulted methods be in ArmorTrim and not in Factory? All convience with not calling .get() is gone if you need to call factory for it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, adding the static methods to ArmorTrim as well


default ArmorTrim create(Supplier<? extends TrimMaterial> material, TrimPattern pattern) {
return create(material.get(), pattern);
}

default ArmorTrim create(TrimMaterial material, Supplier<? extends TrimPattern> pattern) {
return create(material, pattern.get());
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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 {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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<TrimMaterial> AMETHYST = TrimMaterials.key(ResourceKey.minecraft("amethyst"));

public static final DefaultedRegistryReference<TrimMaterial> COPPER = TrimMaterials.key(ResourceKey.minecraft("copper"));

public static final DefaultedRegistryReference<TrimMaterial> DIAMOND = TrimMaterials.key(ResourceKey.minecraft("diamond"));

public static final DefaultedRegistryReference<TrimMaterial> EMERALD = TrimMaterials.key(ResourceKey.minecraft("emerald"));

public static final DefaultedRegistryReference<TrimMaterial> GOLD = TrimMaterials.key(ResourceKey.minecraft("gold"));

public static final DefaultedRegistryReference<TrimMaterial> IRON = TrimMaterials.key(ResourceKey.minecraft("iron"));

public static final DefaultedRegistryReference<TrimMaterial> LAPIS = TrimMaterials.key(ResourceKey.minecraft("lapis"));

public static final DefaultedRegistryReference<TrimMaterial> NETHERITE = TrimMaterials.key(ResourceKey.minecraft("netherite"));

public static final DefaultedRegistryReference<TrimMaterial> QUARTZ = TrimMaterials.key(ResourceKey.minecraft("quartz"));

public static final DefaultedRegistryReference<TrimMaterial> REDSTONE = TrimMaterials.key(ResourceKey.minecraft("redstone"));

private TrimMaterials() {
}

public static Registry<TrimMaterial> registry() {
return Sponge.server().registry(RegistryTypes.TRIM_MATERIAL);
}

private static DefaultedRegistryReference<TrimMaterial> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.TRIM_MATERIAL, location).asDefaultedReference(Sponge::server);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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 {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* 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<TrimPattern> BOLT = TrimPatterns.key(ResourceKey.minecraft("bolt"));

public static final DefaultedRegistryReference<TrimPattern> COAST = TrimPatterns.key(ResourceKey.minecraft("coast"));

public static final DefaultedRegistryReference<TrimPattern> DUNE = TrimPatterns.key(ResourceKey.minecraft("dune"));

public static final DefaultedRegistryReference<TrimPattern> EYE = TrimPatterns.key(ResourceKey.minecraft("eye"));

public static final DefaultedRegistryReference<TrimPattern> FLOW = TrimPatterns.key(ResourceKey.minecraft("flow"));

public static final DefaultedRegistryReference<TrimPattern> HOST = TrimPatterns.key(ResourceKey.minecraft("host"));

public static final DefaultedRegistryReference<TrimPattern> RAISER = TrimPatterns.key(ResourceKey.minecraft("raiser"));

public static final DefaultedRegistryReference<TrimPattern> RIB = TrimPatterns.key(ResourceKey.minecraft("rib"));

public static final DefaultedRegistryReference<TrimPattern> SENTRY = TrimPatterns.key(ResourceKey.minecraft("sentry"));

public static final DefaultedRegistryReference<TrimPattern> SHAPER = TrimPatterns.key(ResourceKey.minecraft("shaper"));

public static final DefaultedRegistryReference<TrimPattern> SILENCE = TrimPatterns.key(ResourceKey.minecraft("silence"));

public static final DefaultedRegistryReference<TrimPattern> SNOUT = TrimPatterns.key(ResourceKey.minecraft("snout"));

public static final DefaultedRegistryReference<TrimPattern> SPIRE = TrimPatterns.key(ResourceKey.minecraft("spire"));

public static final DefaultedRegistryReference<TrimPattern> TIDE = TrimPatterns.key(ResourceKey.minecraft("tide"));

public static final DefaultedRegistryReference<TrimPattern> VEX = TrimPatterns.key(ResourceKey.minecraft("vex"));

public static final DefaultedRegistryReference<TrimPattern> WARD = TrimPatterns.key(ResourceKey.minecraft("ward"));

public static final DefaultedRegistryReference<TrimPattern> WAYFINDER = TrimPatterns.key(ResourceKey.minecraft("wayfinder"));

public static final DefaultedRegistryReference<TrimPattern> WILD = TrimPatterns.key(ResourceKey.minecraft("wild"));

private TrimPatterns() {
}

public static Registry<TrimPattern> registry() {
return Sponge.server().registry(RegistryTypes.TRIM_PATTERN);
}

private static DefaultedRegistryReference<TrimPattern> key(final ResourceKey location) {
return RegistryKey.of(RegistryTypes.TRIM_PATTERN, location).asDefaultedReference(Sponge::server);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -275,6 +277,10 @@ public final class RegistryTypes {

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

public static final DefaultedRegistryType<TrimMaterial> TRIM_MATERIAL = RegistryTypes.minecraftKeyInServer("trim_material");

public static final DefaultedRegistryType<TrimPattern> TRIM_PATTERN = RegistryTypes.minecraftKeyInServer("trim_pattern");

public static final DefaultedRegistryType<VillagerType> VILLAGER_TYPE = RegistryTypes.minecraftKeyInGame("villager_type");

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