-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #251
- Loading branch information
Showing
18 changed files
with
332 additions
and
112 deletions.
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
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
111 changes: 111 additions & 0 deletions
111
.../item_setting/src/main/java/org/quiltmc/qsl/item/setting/api/RecipeRemainderLocation.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,111 @@ | ||
/* | ||
* Copyright 2024 The Quilt Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.quiltmc.qsl.item.setting.api; | ||
|
||
import java.util.Objects; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.jetbrains.annotations.Contract; | ||
|
||
import net.minecraft.util.Identifier; | ||
|
||
import org.quiltmc.qsl.item.setting.impl.RecipeRemainderLogicHandlerImpl; | ||
|
||
/** | ||
* Contains the different recipe remainder locations that QSL supports. | ||
* Calling {@link #register(Identifier)} allows mods to create their own remainder locations. | ||
* | ||
* <p> This class should not be extended. | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface RecipeRemainderLocation { | ||
/** | ||
* Remainder location for Vanilla crafting. Used in Crafting Tables and the inventory crafting screen. | ||
*/ | ||
RecipeRemainderLocation CRAFTING = register(new Identifier("minecraft:crafting")); | ||
|
||
/** | ||
* Remainder location for the furnace fuel slot in the different furnace types. | ||
*/ | ||
RecipeRemainderLocation FURNACE_FUEL = register(new Identifier("minecraft:furnace_fuel")); | ||
|
||
/** | ||
* Remainder location for the furnace ingredient slot in the different furnace types. | ||
*/ | ||
RecipeRemainderLocation FURNACE_INGREDIENT = register(new Identifier("minecraft:furnace_ingredient")); | ||
|
||
/** | ||
* Remainder location for the dye slot in looms. | ||
*/ | ||
RecipeRemainderLocation LOOM_DYE = register(new Identifier("minecraft:loom_dye")); | ||
|
||
/** | ||
* Remainder location for the potion addition in brewing stands. | ||
*/ | ||
RecipeRemainderLocation POTION_ADDITION = register(new Identifier("minecraft:potion_addition")); | ||
|
||
/** | ||
* Remainder location for the input to the stone cutter. | ||
*/ | ||
RecipeRemainderLocation STONE_CUTTER_INPUT = register(new Identifier("minecraft:stone_cutter_input")); | ||
|
||
/** | ||
* Remainder location for the smithing template slot. | ||
*/ | ||
RecipeRemainderLocation SMITHING_TEMPLATE = register(new Identifier("minecraft:smithing_template")); | ||
|
||
/** | ||
* Remainder location for the smithing base slot. | ||
*/ | ||
RecipeRemainderLocation SMITHING_BASE = register(new Identifier("minecraft:smithing_base")); | ||
|
||
/** | ||
* Remainder location for the smithing ingredient slot. | ||
*/ | ||
RecipeRemainderLocation SMITHING_INGREDIENT = register(new Identifier("minecraft:smithing_ingredient")); | ||
|
||
/** | ||
* The default locations for a recipe remainder. | ||
*/ | ||
RecipeRemainderLocation[] DEFAULT_LOCATIONS = {CRAFTING, FURNACE_FUEL}; | ||
|
||
/** | ||
* Registers a new remainder location. | ||
* @param id the id for the location | ||
* @return a new remainder location | ||
*/ | ||
@Contract("null -> fail; _ -> new") | ||
static RecipeRemainderLocation register(Identifier id) { | ||
record RecipeRemainderLocationImpl(Identifier id) implements RecipeRemainderLocation { | ||
} | ||
|
||
Objects.requireNonNull(id, "`id` must not be null."); | ||
|
||
var location = new RecipeRemainderLocationImpl(id); | ||
if (!RecipeRemainderLogicHandlerImpl.LOCATIONS.add(location)) { | ||
throw new IllegalArgumentException(String.format("Cannot add `%s` as a recipe remainder location twice!", id)); | ||
} | ||
|
||
return location; | ||
} | ||
|
||
/** | ||
* | ||
* @return the id for the location. | ||
*/ | ||
Identifier id(); | ||
} |
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
Oops, something went wrong.