Skip to content

Commit

Permalink
Merge pull request #15 from Wetterquarz/mc1.21.4
Browse files Browse the repository at this point in the history
Update to MC 1.21.4 based on PR #14
  • Loading branch information
keve1227 authored Feb 9, 2025
2 parents 7cd5df9 + 088b4e0 commit 4d7099f
Show file tree
Hide file tree
Showing 19 changed files with 483 additions and 449 deletions.
21 changes: 15 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ ij_smart_tabs = false
ij_visual_guides = 80, 120
ij_wrap_on_typing = false

[*.yml]
indent_size = 2
tab_width = 2
ij_yaml_keep_indents_on_empty_lines = false
ij_yaml_keep_line_breaks = true
ij_yaml_space_before_colon = false
ij_yaml_spaces_within_braces = true
ij_yaml_spaces_within_brackets = false

[*.java]
ij_java_align_consecutive_assignments = false
ij_java_align_consecutive_variable_declarations = false
Expand Down Expand Up @@ -72,12 +81,12 @@ ij_java_case_statement_on_separate_line = true
ij_java_catch_on_new_line = false
ij_java_class_annotation_wrap = split_into_lines
ij_java_class_brace_style = end_of_line
ij_java_class_count_to_use_import_on_demand = 5
ij_java_class_count_to_use_import_on_demand = 3
ij_java_class_names_in_javadoc = 1
ij_java_deconstruction_list_wrap = on_every_item
ij_java_do_not_indent_top_level_class_members = false
ij_java_do_not_wrap_after_single_annotation = false
ij_java_do_not_wrap_after_single_annotation_in_parameter = false
ij_java_do_not_wrap_after_single_annotation = true
ij_java_do_not_wrap_after_single_annotation_in_parameter = true
ij_java_do_while_brace_force = if_multiline
ij_java_doc_add_blank_line_after_description = true
ij_java_doc_add_blank_line_after_param_comments = false
Expand All @@ -102,7 +111,7 @@ ij_java_enum_constants_wrap = on_every_item
ij_java_enum_field_annotation_wrap = off
ij_java_extends_keyword_wrap = normal
ij_java_extends_list_wrap = normal
ij_java_field_annotation_wrap = split_into_lines
ij_java_field_annotation_wrap = normal
ij_java_field_name_prefix =
ij_java_field_name_suffix =
ij_java_finally_on_new_line = false
Expand Down Expand Up @@ -154,7 +163,7 @@ ij_java_new_line_after_lparen_in_deconstruction_pattern = true
ij_java_new_line_after_lparen_in_record_header = true
ij_java_new_line_when_body_is_presented = false
ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.*
ij_java_parameter_annotation_wrap = off
ij_java_parameter_annotation_wrap = normal
ij_java_parameter_name_prefix =
ij_java_parameter_name_suffix =
ij_java_parentheses_expression_new_line_after_left_paren = true
Expand Down Expand Up @@ -267,7 +276,7 @@ ij_java_use_external_annotations = false
ij_java_use_fq_class_names = false
ij_java_use_relative_indents = false
ij_java_use_single_class_imports = true
ij_java_variable_annotation_wrap = off
ij_java_variable_annotation_wrap = normal
ij_java_visibility = public
ij_java_while_brace_force = if_multiline
ij_java_while_on_new_line = false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
path: build/libs/
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20
yarn_mappings=1.20+build.1
loader_version=0.16.5
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10

# Mod Properties
mod_version=1.0.4
mod_version=1.1.0
maven_group=com.kevinsundqvistnorlen
archives_base_name=rubi

# Dependencies
fabric_version=0.83.0+1.20
minecraft_range=1.20.0
fabric_version=0.115.1+1.21.4
minecraft_range=1.21.4
14 changes: 14 additions & 0 deletions src/main/java/com/kevinsundqvistnorlen/rubi/IRubyStyle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.kevinsundqvistnorlen.rubi;

import net.minecraft.text.Style;

import java.util.Optional;

public interface IRubyStyle {
static Optional<RubyText> getRuby(Style style) {
return Optional.ofNullable(((IRubyStyle) style).rubi$getRuby());
}

Style rubi$withRuby(String word, String ruby);
RubyText rubi$getRuby();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.kevinsundqvistnorlen.rubi;

import net.minecraft.text.*;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;

import java.util.Objects;
import java.util.Optional;

/**
* A helper class that breaks down an {@link OrderedText} into sections with the same style.
*/
public final class OrderedTextStringVisitable implements StringVisitable {
private final OrderedText text;

public OrderedTextStringVisitable(OrderedText text) {
this.text = text;
}

@Override
public <T> Optional<T> visit(Visitor<T> visitor) {
return this.visit((style, string) -> visitor.accept(string), Style.EMPTY);
}

@Override
public <T> Optional<T> visit(StyledVisitor<T> styledVisitor, Style parent) {
if (Objects.equals(this.text, OrderedText.EMPTY)) {
return Optional.empty();
}

Mutable<Optional<T>> result = new MutableObject<>(Optional.empty());
StringBuilder pendingString = new StringBuilder();
Mutable<Style> pendingStyle = new MutableObject<>();

this.text.accept((index, style, codePoint) -> {
Style parentedStyle = style.withParent(parent);
if (!pendingString.isEmpty() && !pendingStyle.getValue().equals(parentedStyle)) {
var optional = styledVisitor.accept(pendingStyle.getValue(), pendingString.toString());
if (optional.isPresent()) {
result.setValue(optional);
return false;
}

pendingString.setLength(0);
}

pendingString.appendCodePoint(codePoint);
pendingStyle.setValue(parentedStyle);
return true;
});

if (result.getValue().isPresent()) {
return result.getValue();
}

if (!pendingString.isEmpty()) {
var optional = styledVisitor.accept(pendingStyle.getValue(), pendingString.toString());
if (optional.isPresent()) {
result.setValue(optional);
}
}

return result.getValue();
}
}
Loading

0 comments on commit 4d7099f

Please sign in to comment.