-
-
Notifications
You must be signed in to change notification settings - Fork 343
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
feat: add armor trim key #2568
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/org/spongepowered/api/item/recipe/smithing/ArmorTrim.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
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()); | ||
} | ||
|
||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterial.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/org/spongepowered/api/item/recipe/smithing/TrimMaterials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/org/spongepowered/api/item/recipe/smithing/TrimPatterns.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 inFactory
? All convience with not calling.get()
is gone if you need to call factory for itThere was a problem hiding this comment.
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