-
Notifications
You must be signed in to change notification settings - Fork 95
Allow for custom hatch types #1159
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4509e73
Allow for custom hatch types
Swedz ec75719
Allow the hatch types on a hatch flags instance to be accessed
Swedz 7ba7e72
Make use of the accessible hatch types on the flags
Swedz 784e1b8
Merge branch '1.21.x' into allow-custom-hatch-types
Swedz 958ff81
Use Set.copyOf for HatchFlags
Swedz f84e20c
Use Component for HatchType
Swedz cc05336
Make HatchType final
Swedz 04f9ada
Rename create to register
Swedz 594454b
Comment informing of the use of the blockId on HatchTypes
Swedz 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
88 changes: 88 additions & 0 deletions
88
src/main/java/aztech/modern_industrialization/machines/multiblocks/HatchTypes.java
This file contains hidden or 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,88 @@ | ||
| /* | ||
| * MIT License | ||
| * | ||
| * Copyright (c) 2020 Azercoco & Technici4n | ||
| * | ||
| * 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 aztech.modern_industrialization.machines.multiblocks; | ||
|
|
||
| import aztech.modern_industrialization.MI; | ||
| import aztech.modern_industrialization.MIText; | ||
| import java.util.Collection; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import net.minecraft.network.chat.MutableComponent; | ||
| import net.minecraft.resources.ResourceLocation; | ||
|
|
||
| public class HatchTypes { | ||
Technici4n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private static final Map<ResourceLocation, HatchType> registeredHatches = new HashMap<>(); | ||
|
|
||
| public static final HatchType ITEM_INPUT = register(MI.id("item_input"), MIText.ItemInputHatch); | ||
| public static final HatchType ITEM_OUTPUT = register(MI.id("item_output"), MIText.ItemOutputHatch); | ||
| public static final HatchType FLUID_INPUT = register(MI.id("fluid_input"), MIText.FluidInputHatch); | ||
| public static final HatchType FLUID_OUTPUT = register(MI.id("fluid_output"), MIText.FluidOutputHatch); | ||
| public static final HatchType ENERGY_INPUT = register(MI.id("energy_input"), MIText.EnergyInputHatch); | ||
| public static final HatchType ENERGY_OUTPUT = register(MI.id("energy_output"), MIText.EnergyOutputHatch); | ||
| public static final HatchType NUCLEAR_ITEM = register(MI.id("nuclear_item"), MI.id("nuclear_item_hatch")); | ||
| public static final HatchType NUCLEAR_FLUID = register(MI.id("nuclear_fluid"), MI.id("nuclear_fluid_hatch")); | ||
| public static final HatchType LARGE_TANK = register(MI.id("large_tank"), MI.id("large_tank_hatch")); | ||
|
|
||
| public static HatchType register(ResourceLocation id, MutableComponent description) { | ||
| if (registeredHatches.containsKey(id)) { | ||
| throw new IllegalArgumentException("Duplicate hatch type definition: " + id); | ||
| } | ||
| var type = new HatchType(id, description); | ||
| registeredHatches.put(id, type); | ||
| return type; | ||
| } | ||
|
|
||
| public static HatchType register(ResourceLocation id, MIText description) { | ||
| return register(id, description.text()); | ||
| } | ||
|
|
||
| /** | ||
| * The block id corresponds to the user-facing description of the hatch type. | ||
| */ | ||
| public static HatchType register(ResourceLocation id, ResourceLocation blockId) { | ||
| if (registeredHatches.containsKey(id)) { | ||
| throw new IllegalArgumentException("Duplicate hatch type definition: " + id); | ||
| } | ||
| var type = new HatchType(id, blockId); | ||
| registeredHatches.put(id, type); | ||
| return type; | ||
| } | ||
|
|
||
| public static HatchType get(ResourceLocation id) { | ||
| var type = registeredHatches.get(id); | ||
| if (type != null) { | ||
| return type; | ||
| } else { | ||
| throw new IllegalArgumentException("Hatch type \"" + id + "\" does not exist."); | ||
| } | ||
| } | ||
|
|
||
| public static HatchType get(String name) { | ||
| return get(ResourceLocation.isValidPath(name) ? MI.id(name) : ResourceLocation.parse(name)); | ||
| } | ||
|
|
||
| public static Collection<HatchType> values() { | ||
| return registeredHatches.values(); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.