mirror of
https://github.com/AlmostReliable/almostunified.git
synced 2024-11-14 19:25:13 -05:00
port 1.19.2 changes
This commit is contained in:
parent
d0e5e01f37
commit
bb47c08c2b
14 changed files with 108 additions and 323 deletions
262
.editorconfig
262
.editorconfig
|
@ -249,18 +249,6 @@ ij_java_wrap_comments = false
|
|||
ij_java_wrap_first_method_in_call_chain = true
|
||||
ij_java_wrap_long_lines = false
|
||||
|
||||
[*.nbtt]
|
||||
max_line_length = 150
|
||||
ij_continuation_indent_size = 4
|
||||
ij_visual_guides = none
|
||||
ij_nbtt_keep_indents_on_empty_lines = false
|
||||
ij_nbtt_space_after_colon = true
|
||||
ij_nbtt_space_after_comma = true
|
||||
ij_nbtt_space_before_colon = true
|
||||
ij_nbtt_space_before_comma = false
|
||||
ij_nbtt_spaces_within_brackets = false
|
||||
ij_nbtt_spaces_within_parentheses = false
|
||||
|
||||
[*.properties]
|
||||
ij_visual_guides = none
|
||||
ij_properties_align_group_field_declarations = false
|
||||
|
@ -272,222 +260,11 @@ ij_properties_spaces_around_key_value_delimiter = true
|
|||
ij_visual_guides = none
|
||||
ij_editorconfig_align_group_field_declarations = false
|
||||
ij_editorconfig_space_after_colon = false
|
||||
ij_editorconfig_space_after_comma = true
|
||||
ij_editorconfig_space_after_comma = false
|
||||
ij_editorconfig_space_before_colon = false
|
||||
ij_editorconfig_space_before_comma = false
|
||||
ij_editorconfig_spaces_around_assignment_operators = true
|
||||
|
||||
[{*.ant, *.fxml, *.jhm, *.jnlp, *.jrxml, *.jspx, *.pom, *.rng, *.tagx, *.tld, *.wsdl, *.xml, *.xsd, *.xsl, *.xslt, *.xul}]
|
||||
ij_visual_guides = none
|
||||
ij_xml_align_attributes = true
|
||||
ij_xml_align_text = false
|
||||
ij_xml_attribute_wrap = normal
|
||||
ij_xml_block_comment_at_first_column = true
|
||||
ij_xml_keep_blank_lines = 2
|
||||
ij_xml_keep_indents_on_empty_lines = false
|
||||
ij_xml_keep_line_breaks = true
|
||||
ij_xml_keep_line_breaks_in_text = true
|
||||
ij_xml_keep_whitespaces = false
|
||||
ij_xml_keep_whitespaces_around_cdata = preserve
|
||||
ij_xml_keep_whitespaces_inside_cdata = false
|
||||
ij_xml_line_comment_at_first_column = true
|
||||
ij_xml_space_after_tag_name = false
|
||||
ij_xml_space_around_equals_in_attribute = false
|
||||
ij_xml_space_inside_empty_tag = false
|
||||
ij_xml_text_wrap = normal
|
||||
ij_xml_use_custom_settings = false
|
||||
|
||||
[{*.bash, *.sh, *.zsh}]
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
ij_visual_guides = none
|
||||
ij_shell_binary_ops_start_line = false
|
||||
ij_shell_keep_column_alignment_padding = false
|
||||
ij_shell_minify_program = false
|
||||
ij_shell_redirect_followed_by_space = false
|
||||
ij_shell_switch_cases_indented = false
|
||||
ij_shell_use_unix_line_separator = true
|
||||
|
||||
[{*.gant, *.gradle, *.groovy, *.gy}]
|
||||
ij_visual_guides = none
|
||||
ij_groovy_align_group_field_declarations = false
|
||||
ij_groovy_align_multiline_array_initializer_expression = false
|
||||
ij_groovy_align_multiline_assignment = false
|
||||
ij_groovy_align_multiline_binary_operation = false
|
||||
ij_groovy_align_multiline_chained_methods = false
|
||||
ij_groovy_align_multiline_extends_list = false
|
||||
ij_groovy_align_multiline_for = true
|
||||
ij_groovy_align_multiline_list_or_map = true
|
||||
ij_groovy_align_multiline_method_parentheses = false
|
||||
ij_groovy_align_multiline_parameters = true
|
||||
ij_groovy_align_multiline_parameters_in_calls = false
|
||||
ij_groovy_align_multiline_resources = true
|
||||
ij_groovy_align_multiline_ternary_operation = false
|
||||
ij_groovy_align_multiline_throws_list = false
|
||||
ij_groovy_align_named_args_in_map = true
|
||||
ij_groovy_align_throws_keyword = false
|
||||
ij_groovy_array_initializer_new_line_after_left_brace = false
|
||||
ij_groovy_array_initializer_right_brace_on_new_line = false
|
||||
ij_groovy_array_initializer_wrap = off
|
||||
ij_groovy_assert_statement_wrap = off
|
||||
ij_groovy_assignment_wrap = off
|
||||
ij_groovy_binary_operation_wrap = off
|
||||
ij_groovy_blank_lines_after_class_header = 0
|
||||
ij_groovy_blank_lines_after_imports = 1
|
||||
ij_groovy_blank_lines_after_package = 1
|
||||
ij_groovy_blank_lines_around_class = 1
|
||||
ij_groovy_blank_lines_around_field = 0
|
||||
ij_groovy_blank_lines_around_field_in_interface = 0
|
||||
ij_groovy_blank_lines_around_method = 1
|
||||
ij_groovy_blank_lines_around_method_in_interface = 1
|
||||
ij_groovy_blank_lines_before_imports = 1
|
||||
ij_groovy_blank_lines_before_method_body = 0
|
||||
ij_groovy_blank_lines_before_package = 0
|
||||
ij_groovy_block_brace_style = end_of_line
|
||||
ij_groovy_block_comment_at_first_column = true
|
||||
ij_groovy_call_parameters_new_line_after_left_paren = false
|
||||
ij_groovy_call_parameters_right_paren_on_new_line = false
|
||||
ij_groovy_call_parameters_wrap = off
|
||||
ij_groovy_catch_on_new_line = false
|
||||
ij_groovy_class_annotation_wrap = split_into_lines
|
||||
ij_groovy_class_brace_style = end_of_line
|
||||
ij_groovy_class_count_to_use_import_on_demand = 5
|
||||
ij_groovy_do_while_brace_force = never
|
||||
ij_groovy_else_on_new_line = false
|
||||
ij_groovy_enum_constants_wrap = off
|
||||
ij_groovy_extends_keyword_wrap = off
|
||||
ij_groovy_extends_list_wrap = off
|
||||
ij_groovy_field_annotation_wrap = split_into_lines
|
||||
ij_groovy_finally_on_new_line = false
|
||||
ij_groovy_for_brace_force = never
|
||||
ij_groovy_for_statement_new_line_after_left_paren = false
|
||||
ij_groovy_for_statement_right_paren_on_new_line = false
|
||||
ij_groovy_for_statement_wrap = off
|
||||
ij_groovy_if_brace_force = never
|
||||
ij_groovy_import_annotation_wrap = 2
|
||||
ij_groovy_imports_layout = *, |, javax.**, java.**, |, $*
|
||||
ij_groovy_indent_case_from_switch = true
|
||||
ij_groovy_indent_label_blocks = true
|
||||
ij_groovy_insert_inner_class_imports = false
|
||||
ij_groovy_keep_blank_lines_before_right_brace = 2
|
||||
ij_groovy_keep_blank_lines_in_code = 2
|
||||
ij_groovy_keep_blank_lines_in_declarations = 2
|
||||
ij_groovy_keep_control_statement_in_one_line = true
|
||||
ij_groovy_keep_first_column_comment = true
|
||||
ij_groovy_keep_indents_on_empty_lines = false
|
||||
ij_groovy_keep_line_breaks = true
|
||||
ij_groovy_keep_multiple_expressions_in_one_line = false
|
||||
ij_groovy_keep_simple_blocks_in_one_line = false
|
||||
ij_groovy_keep_simple_classes_in_one_line = true
|
||||
ij_groovy_keep_simple_lambdas_in_one_line = true
|
||||
ij_groovy_keep_simple_methods_in_one_line = true
|
||||
ij_groovy_label_indent_absolute = false
|
||||
ij_groovy_label_indent_size = 0
|
||||
ij_groovy_lambda_brace_style = end_of_line
|
||||
ij_groovy_layout_static_imports_separately = true
|
||||
ij_groovy_line_comment_add_space = false
|
||||
ij_groovy_line_comment_at_first_column = true
|
||||
ij_groovy_method_annotation_wrap = split_into_lines
|
||||
ij_groovy_method_brace_style = end_of_line
|
||||
ij_groovy_method_call_chain_wrap = off
|
||||
ij_groovy_method_parameters_new_line_after_left_paren = false
|
||||
ij_groovy_method_parameters_right_paren_on_new_line = false
|
||||
ij_groovy_method_parameters_wrap = off
|
||||
ij_groovy_modifier_list_wrap = false
|
||||
ij_groovy_names_count_to_use_import_on_demand = 3
|
||||
ij_groovy_parameter_annotation_wrap = off
|
||||
ij_groovy_parentheses_expression_new_line_after_left_paren = false
|
||||
ij_groovy_parentheses_expression_right_paren_on_new_line = false
|
||||
ij_groovy_prefer_parameters_wrap = false
|
||||
ij_groovy_resource_list_new_line_after_left_paren = false
|
||||
ij_groovy_resource_list_right_paren_on_new_line = false
|
||||
ij_groovy_resource_list_wrap = off
|
||||
ij_groovy_space_after_assert_separator = true
|
||||
ij_groovy_space_after_colon = true
|
||||
ij_groovy_space_after_comma = true
|
||||
ij_groovy_space_after_comma_in_type_arguments = true
|
||||
ij_groovy_space_after_for_semicolon = true
|
||||
ij_groovy_space_after_quest = true
|
||||
ij_groovy_space_after_type_cast = true
|
||||
ij_groovy_space_before_annotation_parameter_list = false
|
||||
ij_groovy_space_before_array_initializer_left_brace = false
|
||||
ij_groovy_space_before_assert_separator = false
|
||||
ij_groovy_space_before_catch_keyword = true
|
||||
ij_groovy_space_before_catch_left_brace = true
|
||||
ij_groovy_space_before_catch_parentheses = true
|
||||
ij_groovy_space_before_class_left_brace = true
|
||||
ij_groovy_space_before_closure_left_brace = true
|
||||
ij_groovy_space_before_colon = true
|
||||
ij_groovy_space_before_comma = false
|
||||
ij_groovy_space_before_do_left_brace = true
|
||||
ij_groovy_space_before_else_keyword = true
|
||||
ij_groovy_space_before_else_left_brace = true
|
||||
ij_groovy_space_before_finally_keyword = true
|
||||
ij_groovy_space_before_finally_left_brace = true
|
||||
ij_groovy_space_before_for_left_brace = true
|
||||
ij_groovy_space_before_for_parentheses = true
|
||||
ij_groovy_space_before_for_semicolon = false
|
||||
ij_groovy_space_before_if_left_brace = true
|
||||
ij_groovy_space_before_if_parentheses = true
|
||||
ij_groovy_space_before_method_call_parentheses = false
|
||||
ij_groovy_space_before_method_left_brace = true
|
||||
ij_groovy_space_before_method_parentheses = false
|
||||
ij_groovy_space_before_quest = true
|
||||
ij_groovy_space_before_switch_left_brace = true
|
||||
ij_groovy_space_before_switch_parentheses = true
|
||||
ij_groovy_space_before_synchronized_left_brace = true
|
||||
ij_groovy_space_before_synchronized_parentheses = true
|
||||
ij_groovy_space_before_try_left_brace = true
|
||||
ij_groovy_space_before_try_parentheses = true
|
||||
ij_groovy_space_before_while_keyword = true
|
||||
ij_groovy_space_before_while_left_brace = true
|
||||
ij_groovy_space_before_while_parentheses = true
|
||||
ij_groovy_space_in_named_argument = true
|
||||
ij_groovy_space_in_named_argument_before_colon = false
|
||||
ij_groovy_space_within_empty_array_initializer_braces = false
|
||||
ij_groovy_space_within_empty_method_call_parentheses = false
|
||||
ij_groovy_spaces_around_additive_operators = true
|
||||
ij_groovy_spaces_around_assignment_operators = true
|
||||
ij_groovy_spaces_around_bitwise_operators = true
|
||||
ij_groovy_spaces_around_equality_operators = true
|
||||
ij_groovy_spaces_around_lambda_arrow = true
|
||||
ij_groovy_spaces_around_logical_operators = true
|
||||
ij_groovy_spaces_around_multiplicative_operators = true
|
||||
ij_groovy_spaces_around_regex_operators = true
|
||||
ij_groovy_spaces_around_relational_operators = true
|
||||
ij_groovy_spaces_around_shift_operators = true
|
||||
ij_groovy_spaces_within_annotation_parentheses = false
|
||||
ij_groovy_spaces_within_array_initializer_braces = false
|
||||
ij_groovy_spaces_within_braces = true
|
||||
ij_groovy_spaces_within_brackets = false
|
||||
ij_groovy_spaces_within_cast_parentheses = false
|
||||
ij_groovy_spaces_within_catch_parentheses = false
|
||||
ij_groovy_spaces_within_for_parentheses = false
|
||||
ij_groovy_spaces_within_gstring_injection_braces = false
|
||||
ij_groovy_spaces_within_if_parentheses = false
|
||||
ij_groovy_spaces_within_list_or_map = false
|
||||
ij_groovy_spaces_within_method_call_parentheses = false
|
||||
ij_groovy_spaces_within_method_parentheses = false
|
||||
ij_groovy_spaces_within_parentheses = false
|
||||
ij_groovy_spaces_within_switch_parentheses = false
|
||||
ij_groovy_spaces_within_synchronized_parentheses = false
|
||||
ij_groovy_spaces_within_try_parentheses = false
|
||||
ij_groovy_spaces_within_tuple_expression = false
|
||||
ij_groovy_spaces_within_while_parentheses = false
|
||||
ij_groovy_special_else_if_treatment = true
|
||||
ij_groovy_ternary_operation_wrap = off
|
||||
ij_groovy_throws_keyword_wrap = off
|
||||
ij_groovy_throws_list_wrap = off
|
||||
ij_groovy_use_flying_geese_braces = false
|
||||
ij_groovy_use_fq_class_names = false
|
||||
ij_groovy_use_fq_class_names_in_javadoc = true
|
||||
ij_groovy_use_relative_indents = false
|
||||
ij_groovy_use_single_class_imports = true
|
||||
ij_groovy_variable_annotation_wrap = off
|
||||
ij_groovy_while_brace_force = never
|
||||
ij_groovy_while_on_new_line = false
|
||||
ij_groovy_wrap_long_lines = false
|
||||
|
||||
[{*.kt,*.kts}]
|
||||
ij_kotlin_align_in_columns_case_branch = false
|
||||
ij_kotlin_align_multiline_binary_operation = false
|
||||
|
@ -571,7 +348,7 @@ ij_kotlin_wrap_elvis_expressions = 1
|
|||
ij_kotlin_wrap_expression_body_functions = 1
|
||||
ij_kotlin_wrap_first_method_in_call_chain = false
|
||||
|
||||
[{*.har, *.json, mcmod.info, pack.mcmeta}]
|
||||
[{**.json,mcmod.info,pack.mcmeta}]
|
||||
indent_size = 2
|
||||
max_line_length = 150
|
||||
tab_width = 2
|
||||
|
@ -588,36 +365,7 @@ ij_json_spaces_within_braces = false
|
|||
ij_json_spaces_within_brackets = false
|
||||
ij_json_wrap_long_lines = false
|
||||
|
||||
[{*.htm, *.html, *.sht, *.shtm, *.shtml}]
|
||||
ij_visual_guides = none
|
||||
ij_html_add_new_line_before_tags = body, div, p, form, h1, h2, h3
|
||||
ij_html_align_attributes = true
|
||||
ij_html_align_text = false
|
||||
ij_html_attribute_wrap = normal
|
||||
ij_html_block_comment_at_first_column = true
|
||||
ij_html_do_not_align_children_of_min_lines = 0
|
||||
ij_html_do_not_break_if_inline_tags = title, h1, h2, h3, h4, h5, h6, p
|
||||
ij_html_do_not_indent_children_of_tags = html, body, thead, tbody, tfoot
|
||||
ij_html_enforce_quotes = false
|
||||
ij_html_inline_tags = a, abbr, acronym, b, basefont, bdo, big, br, cite, cite, code, dfn, em, font, i, img, input, kbd, label, q, s, samp, select, small, span, strike, strong, sub, sup, textarea, tt, u, var
|
||||
ij_html_keep_blank_lines = 2
|
||||
ij_html_keep_indents_on_empty_lines = false
|
||||
ij_html_keep_line_breaks = true
|
||||
ij_html_keep_line_breaks_in_text = true
|
||||
ij_html_keep_whitespaces = false
|
||||
ij_html_keep_whitespaces_inside = span, pre, textarea
|
||||
ij_html_line_comment_at_first_column = true
|
||||
ij_html_new_line_after_last_attribute = never
|
||||
ij_html_new_line_before_first_attribute = never
|
||||
ij_html_quote_style = double
|
||||
ij_html_remove_new_line_before_tags = br
|
||||
ij_html_space_after_tag_name = false
|
||||
ij_html_space_around_equality_in_attribute = false
|
||||
ij_html_space_inside_empty_tag = false
|
||||
ij_html_text_wrap = normal
|
||||
ij_html_uniform_ident = false
|
||||
|
||||
[{*.markdown, *.md}]
|
||||
[**.md]
|
||||
ij_visual_guides = none
|
||||
ij_markdown_force_one_space_after_blockquote_symbol = true
|
||||
ij_markdown_force_one_space_after_header_symbol = true
|
||||
|
@ -631,11 +379,11 @@ ij_markdown_min_lines_around_block_elements = 1
|
|||
ij_markdown_min_lines_around_header = 1
|
||||
ij_markdown_min_lines_between_paragraphs = 1
|
||||
|
||||
[{*.toml, Cargo.lock, Cargo.toml.orig, Gopkg.lock, Pipfile, poetry.lock}]
|
||||
[**.toml]
|
||||
ij_visual_guides = none
|
||||
ij_toml_keep_indents_on_empty_lines = false
|
||||
|
||||
[{*.yaml, *.yml}]
|
||||
[{**.yml,**.yaml}]
|
||||
indent_size = 2
|
||||
ij_visual_guides = none
|
||||
ij_yaml_align_values_properties = do_not_align
|
||||
|
|
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
|
@ -104,11 +104,9 @@ jobs:
|
|||
version-resolver: exact
|
||||
java: ${{ env.JAVA_VERSION }}
|
||||
|
||||
curseforge-dependencies: |
|
||||
dependencies: |
|
||||
jei | suggests | *
|
||||
roughly-enough-items | suggests | *
|
||||
modrinth-dependencies: |
|
||||
roughly-enough-items | suggests | *
|
||||
|
||||
retry-attempts: 2
|
||||
retry-delay: 10000
|
||||
|
@ -132,11 +130,9 @@ jobs:
|
|||
version-resolver: exact
|
||||
java: ${{ env.JAVA_VERSION }}
|
||||
|
||||
curseforge-dependencies: |
|
||||
dependencies: |
|
||||
jei | suggests | *
|
||||
roughly-enough-items | suggests | *
|
||||
modrinth-dependencies: |
|
||||
roughly-enough-items | suggests | *
|
||||
|
||||
retry-attempts: 2
|
||||
retry-delay: 10000
|
||||
|
|
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog],
|
||||
and this project adheres to [Semantic Versioning].
|
||||
|
||||
## [0.3.7] - 2023-04-02
|
||||
|
||||
### Changed
|
||||
- removal and cleanup of old and unused code
|
||||
- mods providing stone stratas no longer have to be listed in the priority list
|
||||
- more performance improvements
|
||||
- depending on the amount of recipes, this can improve the load times by another 10-20%
|
||||
|
||||
### Fixed
|
||||
- stone strata detection on Fabric
|
||||
- prevent stone strata sub-matching
|
||||
|
||||
## [0.3.6] - 2023-03-10
|
||||
|
||||
### Changed
|
||||
|
@ -28,6 +40,7 @@ Initial 1.19.3 release!
|
|||
[semantic versioning]: https://semver.org/spec/v2.0.0.html
|
||||
|
||||
<!-- Versions -->
|
||||
[0.3.7]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.3-0.3.7-beta
|
||||
[0.3.6]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.3-0.3.6-beta
|
||||
[0.3.5]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.3-0.3.5-beta
|
||||
[0.3.4]: https://github.com/AlmostReliable/almostunified/releases/tag/v1.19.3-0.3.4-beta
|
||||
|
|
|
@ -6,8 +6,7 @@ import com.almostreliable.unified.utils.UnifyTag;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class StoneStrataHandler {
|
||||
|
@ -15,19 +14,34 @@ public class StoneStrataHandler {
|
|||
private final List<String> stoneStrata;
|
||||
private final Pattern tagMatcher;
|
||||
private final TagMap stoneStrataTagMap;
|
||||
private final Map<UnifyTag<?>, Boolean> stoneStrataTagCache;
|
||||
|
||||
private StoneStrataHandler(List<String> stoneStrata, Pattern tagMatcher, TagMap stoneStrataTagMap) {
|
||||
this.stoneStrata = stoneStrata;
|
||||
this.stoneStrata = createSortedStoneStrata(stoneStrata);
|
||||
this.tagMatcher = tagMatcher;
|
||||
this.stoneStrataTagMap = stoneStrataTagMap;
|
||||
this.stoneStrataTagCache = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stone strata list sorted from longest to shortest.
|
||||
* <p>
|
||||
* This is required to ensure that the longest strata is returned and no sub-matches happen.<br>
|
||||
* Example: "nether" and "blue_nether" would both match "nether" if the list is not sorted.
|
||||
*
|
||||
* @param stoneStrata The stone strata list to sort.
|
||||
* @return The sorted stone strata list.
|
||||
*/
|
||||
private static List<String> createSortedStoneStrata(List<String> stoneStrata) {
|
||||
return stoneStrata.stream().sorted(Comparator.comparingInt(String::length).reversed()).toList();
|
||||
}
|
||||
|
||||
public static StoneStrataHandler create(List<String> stoneStrataIds, Set<UnifyTag<Item>> stoneStrataTags, TagMap tagMap) {
|
||||
TagMap stoneStrataTagMap = tagMap.filtered(stoneStrataTags::contains, item -> true);
|
||||
Pattern tagMatcher = switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) {
|
||||
case FORGE -> Pattern.compile("forge:ores/.+");
|
||||
case FABRIC -> Pattern.compile("(c:ores/.+|c:.+_ore)");
|
||||
};
|
||||
Pattern tagMatcher = Pattern.compile(switch (AlmostUnifiedPlatform.INSTANCE.getPlatform()) {
|
||||
case FORGE -> "forge:ores/.+";
|
||||
case FABRIC -> "(c:ores/.+|c:.+_ores)";
|
||||
});
|
||||
return new StoneStrataHandler(stoneStrataIds, tagMatcher, stoneStrataTagMap);
|
||||
}
|
||||
|
||||
|
@ -64,6 +78,10 @@ public class StoneStrataHandler {
|
|||
}
|
||||
|
||||
public boolean isStoneStrataTag(UnifyTag<Item> tag) {
|
||||
return tagMatcher.matcher(tag.location().toString()).matches();
|
||||
return stoneStrataTagCache.computeIfAbsent(tag, t -> tagMatcher.matcher(t.location().toString()).matches());
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
stoneStrataTagCache.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.almostreliable.unified.api.recipe;
|
||||
|
||||
import com.almostreliable.unified.utils.TagMap;
|
||||
import com.almostreliable.unified.utils.UnifyTag;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ReplacementFallbackStrategy {
|
||||
/**
|
||||
* Determine a fallback for the given item.
|
||||
*
|
||||
* @param tag the tag to replace the item with
|
||||
* @param potentialItems the potential items to replace with
|
||||
* @param tags the tag map to use for lookup
|
||||
* @return the fallback item, or null if no fallback is available
|
||||
* @throws IllegalStateException if returning the lookupItem
|
||||
*/
|
||||
@Nullable
|
||||
ResourceLocation getFallback(UnifyTag<Item> tag, Collection<ResourceLocation> potentialItems, TagMap tags);
|
||||
}
|
|
@ -1,19 +1,17 @@
|
|||
package com.almostreliable.unified.compat;
|
||||
|
||||
import com.almostreliable.unified.AlmostUnified;
|
||||
import com.almostreliable.unified.AlmostUnifiedPlatform;
|
||||
import com.almostreliable.unified.AlmostUnifiedRuntime;
|
||||
import com.almostreliable.unified.api.StoneStrataHandler;
|
||||
import com.almostreliable.unified.config.UnifyConfig;
|
||||
import com.almostreliable.unified.utils.ReplacementMap;
|
||||
import com.almostreliable.unified.utils.TagMap;
|
||||
import com.almostreliable.unified.utils.UnifyTag;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class HideHelper {
|
||||
|
@ -33,8 +31,7 @@ public class HideHelper {
|
|||
|
||||
Set<ResourceLocation> replacements = itemsByTag
|
||||
.stream()
|
||||
.map(repMap::getReplacementForItem)
|
||||
.filter(Objects::nonNull)
|
||||
.map(item -> getReplacementForItem(repMap, item))
|
||||
.collect(Collectors.toSet());
|
||||
List<ResourceLocation> toHide = itemsByTag.stream().filter(rl -> !replacements.contains(rl)).toList();
|
||||
|
||||
|
@ -50,9 +47,18 @@ public class HideHelper {
|
|||
}).flatMap(Collection::stream).toList();
|
||||
}
|
||||
|
||||
private static StoneStrataHandler getStoneStrataHandler(UnifyConfig config) {
|
||||
Set<UnifyTag<Item>> stoneStrataTags = AlmostUnifiedPlatform.INSTANCE.getStoneStrataTags(config.getStoneStrata());
|
||||
TagMap stoneStrataTagMap = TagMap.create(stoneStrataTags);
|
||||
return StoneStrataHandler.create(config.getStoneStrata(), stoneStrataTags, stoneStrataTagMap);
|
||||
/**
|
||||
* Returns the replacement for the given item, or the item itself if no replacement is found.
|
||||
* <p>
|
||||
* Returning the item itself is important for stone strata detection.
|
||||
*
|
||||
* @param repMap The replacement map.
|
||||
* @param item The item to get the replacement for.
|
||||
* @return The replacement for the given item, or the item itself if no replacement is found.
|
||||
*/
|
||||
private static ResourceLocation getReplacementForItem(ReplacementMap repMap, ResourceLocation item) {
|
||||
var replacement = repMap.getReplacementForItem(item);
|
||||
if (replacement == null) return item;
|
||||
return replacement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,7 @@ import com.almostreliable.unified.utils.JsonCompare;
|
|||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -21,7 +18,7 @@ public class DuplicationConfig extends Config {
|
|||
private final Set<Pattern> ignoreRecipeTypes;
|
||||
private final Set<Pattern> ignoreRecipes;
|
||||
private final boolean strictMode;
|
||||
private final HashMap<ResourceLocation, Boolean> ignoredRecipeTypesCache;
|
||||
private final Map<ResourceLocation, Boolean> ignoredRecipeTypesCache;
|
||||
|
||||
public DuplicationConfig(JsonCompare.CompareSettings defaultRules, LinkedHashMap<ResourceLocation, JsonCompare.CompareSettings> overrideRules, Set<Pattern> ignoreRecipeTypes, Set<Pattern> ignoreRecipes, boolean strictMode) {
|
||||
this.defaultRules = defaultRules;
|
||||
|
|
|
@ -26,6 +26,7 @@ public class UnifyConfig extends Config {
|
|||
private final Set<Pattern> ignoredRecipeTypes;
|
||||
private final Set<Pattern> ignoredRecipes;
|
||||
private final boolean hideJeiRei;
|
||||
private final Map<ResourceLocation, Boolean> ignoredRecipeTypesCache;
|
||||
|
||||
public UnifyConfig(List<String> modPriorities, List<String> stoneStrata, List<String> unbakedTags, List<String> materials, Map<ResourceLocation, String> priorityOverrides, Set<UnifyTag<Item>> ignoredTags, Set<Pattern> ignoredItems, Set<Pattern> ignoredRecipeTypes, Set<Pattern> ignoredRecipes, boolean hideJeiRei) {
|
||||
this.modPriorities = modPriorities;
|
||||
|
@ -38,6 +39,7 @@ public class UnifyConfig extends Config {
|
|||
this.ignoredRecipeTypes = ignoredRecipeTypes;
|
||||
this.ignoredRecipes = ignoredRecipes;
|
||||
this.hideJeiRei = hideJeiRei;
|
||||
this.ignoredRecipeTypesCache = new HashMap<>();
|
||||
}
|
||||
|
||||
public List<String> getModPriorities() {
|
||||
|
@ -80,21 +82,42 @@ public class UnifyConfig extends Config {
|
|||
}
|
||||
|
||||
public boolean includeItem(ResourceLocation item) {
|
||||
return ignoredItems.stream().noneMatch(pattern -> pattern.matcher(item.toString()).matches());
|
||||
for (Pattern pattern : ignoredItems) {
|
||||
if (pattern.matcher(item.toString()).matches()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean includeRecipe(ResourceLocation recipe) {
|
||||
return ignoredRecipes.stream().noneMatch(pattern -> pattern.matcher(recipe.toString()).matches());
|
||||
for (Pattern pattern : ignoredRecipes) {
|
||||
if (pattern.matcher(recipe.toString()).matches()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean includeRecipeType(ResourceLocation type) {
|
||||
return ignoredRecipeTypes.stream().noneMatch(pattern -> pattern.matcher(type.toString()).matches());
|
||||
return ignoredRecipeTypesCache.computeIfAbsent(type, t -> {
|
||||
for (Pattern pattern : ignoredRecipeTypes) {
|
||||
if (pattern.matcher(t.toString()).matches()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public boolean reiOrJeiDisabled() {
|
||||
return !hideJeiRei;
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
ignoredRecipeTypesCache.clear();
|
||||
}
|
||||
|
||||
public static class Serializer extends Config.Serializer<UnifyConfig> {
|
||||
|
||||
public static final String MOD_PRIORITIES = "modPriorities";
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AlmostMixinPlugin implements IMixinConfigPlugin {
|
|||
@Override
|
||||
public void onLoad(String mixinPackage) {}
|
||||
|
||||
@SuppressWarnings("ReturnOfNull")
|
||||
@SuppressWarnings({ "ReturnOfNull", "DataFlowIssue" })
|
||||
@Override
|
||||
public String getRefMapperConfig() {
|
||||
return null;
|
||||
|
@ -41,7 +41,7 @@ public class AlmostMixinPlugin implements IMixinConfigPlugin {
|
|||
@Override
|
||||
public void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {}
|
||||
|
||||
@SuppressWarnings("ReturnOfNull")
|
||||
@SuppressWarnings({ "ReturnOfNull", "DataFlowIssue" })
|
||||
@Override
|
||||
public List<String> getMixins() {
|
||||
return null;
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.Map;
|
|||
public class RecipeManagerMixin {
|
||||
|
||||
@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V", at = @At("HEAD"))
|
||||
public void runTransformation(Map<ResourceLocation, JsonElement> recipes, ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfo ci) {
|
||||
private void runTransformation(Map<ResourceLocation, JsonElement> recipes, ResourceManager resourceManager, ProfilerFiller profiler, CallbackInfo ci) {
|
||||
try {
|
||||
AlmostUnified.reloadRuntime();
|
||||
AlmostUnified.getRuntime().run(recipes, AlmostUnified.getStartupConfig().isServerOnly());
|
||||
|
|
|
@ -5,7 +5,6 @@ import com.almostreliable.unified.utils.FileUtils;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
|
@ -139,7 +138,7 @@ public class RecipeDumper {
|
|||
getSortedUnifiedRecipes(type).forEach(recipe -> {
|
||||
stringBuilder
|
||||
.append("\t- ")
|
||||
.append(recipe.getId().toString())
|
||||
.append(recipe.getId())
|
||||
.append("\n")
|
||||
.append("\t\t Original: ")
|
||||
.append(recipe.getOriginal().toString())
|
||||
|
|
|
@ -75,7 +75,11 @@ public class RecipeTransformer {
|
|||
});
|
||||
|
||||
AlmostUnified.LOG.warn("Recipe count afterwards: " + recipes.size() + " (done in " + transformationTimer.stop() + ")");
|
||||
|
||||
unifyConfig.clearCache();
|
||||
duplicationConfig.clearCache();
|
||||
replacementMap.getStoneStrataHandler().clearCache();
|
||||
|
||||
if (tracker != null) recipes.putAll(tracker.compute());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -103,4 +103,8 @@ public class ReplacementMap {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public StoneStrataHandler getStoneStrataHandler() {
|
||||
return stoneStrataHandler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ junitVersion = 5.9.0
|
|||
minecraftVersion = 1.19.4
|
||||
|
||||
# Mod
|
||||
modVersion = 0.3.6
|
||||
modVersion = 0.3.7
|
||||
modPackage = com.almostreliable.unified
|
||||
modId = almostunified
|
||||
modName = AlmostUnified
|
||||
|
|
Loading…
Reference in a new issue