From 35e40c085d38934168b28bc3356f684040bb14bb Mon Sep 17 00:00:00 2001 From: Anton <79146501+btwonion@users.noreply.github.com> Date: Sun, 16 Jun 2024 22:08:23 +0200 Subject: [PATCH] 1.21 - v3.0.0 (#14) * way to much to explain * even more progress * progress - maybe beta tomorrow? * 1.21 works * fix workflows * update media * improve datagen * backport * wrong vcs version * fix some multiversion bugs * add more heap space * fix upstream * remove unused accesswidener * now really remove accesswidener * remove paper module * remove all parchment deps --- .editorconfig | 433 ++++++++++++++++-- .github/workflows/build-commit.yml | 18 +- .github/workflows/release.yml | 14 +- .gitignore | 4 +- README.md | 94 +--- build.gradle.kts | 198 +++++++- changelog.md | 7 +- gradle.properties | 3 +- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 19 +- .../mixins/AbstractChestedHorseMixin.java | 7 +- .../mixins/AbstractHorseMixin.java | 20 +- .../mixins/AbstractMinecartMixin.java | 29 ++ .../nyon/telekinesis/mixins/AllayMixin.java | 46 ++ .../nyon/telekinesis/mixins/BlockMixin.java | 119 +++++ .../nyon/telekinesis/mixins/BoatMixin.java | 15 +- .../telekinesis/mixins/ChestBoatMixin.java | 34 ++ .../telekinesis/mixins/EnchantmentsMixin.java | 12 +- .../telekinesis/mixins/EnderManMixin.java | 15 +- .../telekinesis/mixins/FishingHookMixin.java | 55 +++ .../telekinesis/mixins/LivingEntityMixin.java | 103 +++++ .../telekinesis/mixins/MinecartTNTMixin.java | 27 +- .../dev/nyon/telekinesis/mixins/MobMixin.java | 45 ++ .../dev/nyon/telekinesis/mixins/PigMixin.java | 7 +- .../nyon/telekinesis/mixins/PiglinMixin.java | 30 ++ .../nyon/telekinesis/mixins/PlayerMixin.java | 40 ++ .../nyon/telekinesis/mixins/SheepMixin.java | 54 +++ .../telekinesis/mixins/SnowGolemMixin.java | 52 +++ .../telekinesis/mixins/SpawnerBlockMixin.java | 48 ++ .../nyon/telekinesis/mixins/StriderMixin.java | 5 +- .../mixins/SweetBerryBushBlockMixin.java | 42 ++ .../mixins/VehicleEntityMixin.java | 55 +++ .../telekinesis/mixins/WitherBossMixin.java | 32 ++ .../nyon/telekinesis/utils/MixinHelper.java | 166 +++++++ .../kotlin/dev/nyon/telekinesis/DropEvent.kt | 35 ++ src/main/kotlin/dev/nyon/telekinesis/Main.kt | 18 + .../telekinesis/TelekinesisEnchantment.kt | 54 +++ .../TelekinesisEnchantmentGenerator.kt | 65 +++ .../dev/nyon/telekinesis/config/Config.kt | 13 + .../nyon/telekinesis/config}/ModMenuImpl.kt | 2 +- .../config/TelekinesisConfigScreen.kt | 77 ++++ .../resources/assets/telekinesis/icon.png | Bin .../assets/telekinesis/lang/de_de.json | 13 + .../assets/telekinesis/lang/en_us.json | 13 + src/main/resources/fabric.mod.json | 55 +++ src/main/resources/telekinesis.mixins.json | 34 ++ stonecutter.gradle.kts | 108 +++++ telekinesis-fabric/build.gradle.kts | 216 --------- .../mixins/AbstractMinecartMixin.java | 32 -- .../nyon/telekinesis/mixins/AllayMixin.java | 65 --- .../nyon/telekinesis/mixins/BlockMixin.java | 89 ---- .../mixins/CatalystBlockAccessor.java | 13 - .../telekinesis/mixins/ChestBoatMixin.java | 32 -- .../mixins/DropExperienceBlockAccessor.java | 13 - .../telekinesis/mixins/FishingHookMixin.java | 64 --- .../telekinesis/mixins/InventoryMixin.java | 29 -- .../telekinesis/mixins/LivingEntityMixin.java | 71 --- .../mixins/MinecraftServerMixin.java | 24 - .../dev/nyon/telekinesis/mixins/MobMixin.java | 30 -- .../nyon/telekinesis/mixins/PiglinMixin.java | 43 -- .../nyon/telekinesis/mixins/SheepMixin.java | 92 ---- .../telekinesis/mixins/SnowgolemMixin.java | 47 -- .../mixins/SweetBerryBushBlockMixin.java | 83 ---- .../mixins/VehicleEntityMixin.java | 28 -- .../telekinesis/mixins/WitherBossMixin.java | 39 -- .../betternether/BetterNetherMixinPlugin.java | 60 --- .../compat/betternether/RubyFireMixin.java | 99 ---- .../mixins/compat/levelz/BlockMixinMixin.java | 88 ---- .../levelz/EnderDragonEntityMixinMixin.java | 55 --- .../levelz/FishingBobberEntityMixinMixin.java | 36 -- .../levelz/LevelExperienceOrbAccessor.java | 9 - .../levelz/LevelExperienceOrbEntityMixin.java | 34 -- .../compat/levelz/LevelZMixinPlugin.java | 61 --- .../compat/levelz/LivingEntityMixinMixin.java | 35 -- .../compat/levelz/PlantBlockMixinMixin.java | 39 -- .../treeharvester/TreeCutEventsMixin.java | 44 -- .../TreeHarvesterMixinPlugin.java | 60 --- .../nyon/telekinesis/utils/EntityUtils.java | 65 --- .../nyon/telekinesis/utils/PlayerUtils.java | 33 -- .../telekinesis/utils/TelekinesisUtils.java | 94 ---- .../main/kotlin/dev/nyon/telekinesis/Main.kt | 12 - .../dev/nyon/telekinesis/TelekinesisConfig.kt | 76 --- .../telekinesis/TelekinesisConfigScreen.kt | 138 ------ .../telekinesis/TelekinesisEnchantment.kt | 49 -- .../dev/nyon/telekinesis/TelekinesisPolicy.kt | 20 - .../assets/telekinesis/lang/de_de.json | 24 - .../assets/telekinesis/lang/en_us.json | 24 - .../resources/compat.betternether.mixins.json | 15 - .../main/resources/compat.levelz.mixins.json | 21 - .../compat.treeharvester.mixins.json | 13 - .../src/main/resources/fabric.mod.json | 53 --- .../main/resources/telekinesis.accesswidener | 3 - .../main/resources/telekinesis.mixins.json | 36 -- telekinesis-fabric/stonecutter.gradle.kts | 16 - telekinesis-paper/build.gradle.kts | 142 ------ .../dev/nyon/telekinesis/PaperLoader.java | 22 - .../main/kotlin/dev/nyon/telekinesis/Main.kt | 82 ---- .../dev/nyon/telekinesis/TelekinesisConfig.kt | 75 --- .../telekinesis/TelekinesisEnchantment.kt | 72 --- .../dev/nyon/telekinesis/TelekinesisPolicy.kt | 19 - .../telekinesis/listeners/BlockListeners.kt | 30 -- .../telekinesis/listeners/MobListeners.kt | 34 -- .../dev/nyon/telekinesis/util/Listeners.kt | 25 - .../nyon/telekinesis/util/TelekinesisCheck.kt | 45 -- .../src/main/resources/paper-plugin.yml | 9 - .../1.20.1/gradle.properties | 2 +- .../1.20.4/gradle.properties | 2 +- .../1.20.6/gradle.properties | 4 +- versions/1.21/gradle.properties | 10 + 109 files changed, 2175 insertions(+), 3057 deletions(-) rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java (78%) rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java (53%) create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java (80%) create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java (91%) rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java (67%) create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java (50%) create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/PigMixin.java (75%) create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java rename {telekinesis-fabric/src => src}/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java (80%) create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java create mode 100644 src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java create mode 100644 src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt create mode 100644 src/main/kotlin/dev/nyon/telekinesis/Main.kt create mode 100644 src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt create mode 100644 src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt create mode 100644 src/main/kotlin/dev/nyon/telekinesis/config/Config.kt rename {telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis => src/main/kotlin/dev/nyon/telekinesis/config}/ModMenuImpl.kt (90%) create mode 100644 src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt rename {telekinesis-fabric/src => src}/main/resources/assets/telekinesis/icon.png (100%) create mode 100644 src/main/resources/assets/telekinesis/lang/de_de.json create mode 100644 src/main/resources/assets/telekinesis/lang/en_us.json create mode 100644 src/main/resources/fabric.mod.json create mode 100644 src/main/resources/telekinesis.mixins.json create mode 100644 stonecutter.gradle.kts delete mode 100644 telekinesis-fabric/build.gradle.kts delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/CatalystBlockAccessor.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/DropExperienceBlockAccessor.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/InventoryMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecraftServerMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SnowgolemMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/BetterNetherMixinPlugin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/RubyFireMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/BlockMixinMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/EnderDragonEntityMixinMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/FishingBobberEntityMixinMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbAccessor.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbEntityMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelZMixinPlugin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LivingEntityMixinMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/PlantBlockMixinMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeCutEventsMixin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeHarvesterMixinPlugin.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/EntityUtils.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/PlayerUtils.java delete mode 100644 telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/TelekinesisUtils.java delete mode 100644 telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/Main.kt delete mode 100644 telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt delete mode 100644 telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfigScreen.kt delete mode 100644 telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt delete mode 100644 telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt delete mode 100644 telekinesis-fabric/src/main/resources/assets/telekinesis/lang/de_de.json delete mode 100644 telekinesis-fabric/src/main/resources/assets/telekinesis/lang/en_us.json delete mode 100644 telekinesis-fabric/src/main/resources/compat.betternether.mixins.json delete mode 100644 telekinesis-fabric/src/main/resources/compat.levelz.mixins.json delete mode 100644 telekinesis-fabric/src/main/resources/compat.treeharvester.mixins.json delete mode 100644 telekinesis-fabric/src/main/resources/fabric.mod.json delete mode 100644 telekinesis-fabric/src/main/resources/telekinesis.accesswidener delete mode 100644 telekinesis-fabric/src/main/resources/telekinesis.mixins.json delete mode 100644 telekinesis-fabric/stonecutter.gradle.kts delete mode 100644 telekinesis-paper/build.gradle.kts delete mode 100644 telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt delete mode 100644 telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt delete mode 100644 telekinesis-paper/src/main/resources/paper-plugin.yml rename {telekinesis-fabric/versions => versions}/1.20.1/gradle.properties (83%) rename {telekinesis-fabric/versions => versions}/1.20.4/gradle.properties (83%) rename {telekinesis-fabric/versions => versions}/1.20.6/gradle.properties (72%) create mode 100644 versions/1.21/gradle.properties diff --git a/.editorconfig b/.editorconfig index 4e0d1ae..2f10bbb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,40 +1,409 @@ -# https://editorconfig.org -root = true - [*] -indent_style = space -indent_size = 2 -max_line_length = 140 - -end_of_line = lf charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.{java,kt,kts,scala,rs,xml,kt.spec,kts.spec}] +end_of_line = lf indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 120 +tab_width = 4 +ij_continuation_indent_size = 8 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_wrap_on_typing = false -[*.{kt,kts}] -ktlint_code_style = ktlint_official -ktlint_ignore_back_ticked_identifier = true -ij_kotlin_allow_trailing_comma_on_call_site = false -ij_kotlin_allow_trailing_comma = false - -ktlint_standard = enabled - -# Don't allow any wildcard imports -ij_kotlin_packages_to_use_import_on_demand = unset +[*.java] +ij_continuation_indent_size = 4 +ij_java_align_consecutive_assignments = false +ij_java_align_consecutive_variable_declarations = false +ij_java_align_group_field_declarations = false +ij_java_align_multiline_annotation_parameters = false +ij_java_align_multiline_array_initializer_expression = false +ij_java_align_multiline_assignment = false +ij_java_align_multiline_binary_operation = false +ij_java_align_multiline_chained_methods = false +ij_java_align_multiline_deconstruction_list_components = true +ij_java_align_multiline_extends_list = false +ij_java_align_multiline_for = true +ij_java_align_multiline_method_parentheses = false +ij_java_align_multiline_parameters = true +ij_java_align_multiline_parameters_in_calls = false +ij_java_align_multiline_parenthesized_expression = false +ij_java_align_multiline_records = true +ij_java_align_multiline_resources = true +ij_java_align_multiline_ternary_operation = false +ij_java_align_multiline_text_blocks = false +ij_java_align_multiline_throws_list = false +ij_java_align_subsequent_simple_methods = false +ij_java_align_throws_keyword = false +ij_java_align_types_in_multi_catch = true +ij_java_annotation_parameter_wrap = split_into_lines +ij_java_array_initializer_new_line_after_left_brace = false +ij_java_array_initializer_right_brace_on_new_line = false +ij_java_array_initializer_wrap = off +ij_java_assert_statement_colon_on_next_line = false +ij_java_assert_statement_wrap = off +ij_java_assignment_wrap = off +ij_java_binary_operation_sign_on_next_line = false +ij_java_binary_operation_wrap = normal +ij_java_blank_lines_after_anonymous_class_header = 0 +ij_java_blank_lines_after_class_header = 0 +ij_java_blank_lines_after_imports = 1 +ij_java_blank_lines_after_package = 1 +ij_java_blank_lines_around_class = 1 +ij_java_blank_lines_around_field = 0 +ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_initializer = 1 +ij_java_blank_lines_around_method = 1 +ij_java_blank_lines_around_method_in_interface = 1 +ij_java_blank_lines_before_class_end = 0 +ij_java_blank_lines_before_imports = 1 +ij_java_blank_lines_before_method_body = 0 +ij_java_blank_lines_before_package = 0 +ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false +ij_java_block_comment_at_first_column = true +ij_java_call_parameters_new_line_after_left_paren = true +ij_java_call_parameters_right_paren_on_new_line = true +ij_java_call_parameters_wrap = on_every_item +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_names_in_javadoc = 1 +ij_java_deconstruction_list_wrap = normal +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_while_brace_force = never +ij_java_doc_add_blank_line_after_description = true +ij_java_doc_add_blank_line_after_param_comments = false +ij_java_doc_add_blank_line_after_return = false +ij_java_doc_add_p_tag_on_empty_lines = true +ij_java_doc_align_exception_comments = true +ij_java_doc_align_param_comments = true +ij_java_doc_do_not_wrap_if_one_line = false +ij_java_doc_enable_formatting = true +ij_java_doc_enable_leading_asterisks = true +ij_java_doc_indent_on_continuation = false +ij_java_doc_keep_empty_lines = true +ij_java_doc_keep_empty_parameter_tag = true +ij_java_doc_keep_empty_return_tag = true +ij_java_doc_keep_empty_throws_tag = true +ij_java_doc_keep_invalid_tags = true +ij_java_doc_param_description_on_new_line = false +ij_java_doc_preserve_line_breaks = false +ij_java_doc_use_throws_not_exception_tag = true +ij_java_else_on_new_line = false +ij_java_entity_dd_suffix = EJB +ij_java_entity_eb_suffix = Bean +ij_java_entity_hi_suffix = Home +ij_java_entity_lhi_prefix = Local +ij_java_entity_lhi_suffix = Home +ij_java_entity_li_prefix = Local +ij_java_entity_pk_class = java.lang.String +ij_java_entity_vo_suffix = VO +ij_java_enum_constants_wrap = split_into_lines +ij_java_enum_field_annotation_wrap = off +ij_java_extends_keyword_wrap = off +ij_java_extends_list_wrap = off +ij_java_field_annotation_wrap = split_into_lines +ij_java_finally_on_new_line = false +ij_java_for_brace_force = never +ij_java_for_statement_new_line_after_left_paren = false +ij_java_for_statement_right_paren_on_new_line = false +ij_java_for_statement_wrap = off +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false +ij_java_if_brace_force = never +ij_java_imports_layout = *, |, javax.**, java.**, |, $* +ij_java_indent_case_from_switch = true +ij_java_insert_inner_class_imports = false +ij_java_insert_override_annotation = true +ij_java_keep_blank_lines_before_right_brace = 2 +ij_java_keep_blank_lines_between_package_declaration_and_header = 2 +ij_java_keep_blank_lines_in_code = 2 +ij_java_keep_blank_lines_in_declarations = 2 +ij_java_keep_builder_methods_indents = false +ij_java_keep_control_statement_in_one_line = true +ij_java_keep_first_column_comment = false +ij_java_keep_indents_on_empty_lines = false +ij_java_keep_line_breaks = false +ij_java_keep_multiple_expressions_in_one_line = false +ij_java_keep_simple_blocks_in_one_line = false +ij_java_keep_simple_classes_in_one_line = false +ij_java_keep_simple_lambdas_in_one_line = false +ij_java_keep_simple_methods_in_one_line = false +ij_java_label_indent_absolute = false +ij_java_label_indent_size = 0 +ij_java_lambda_brace_style = end_of_line +ij_java_layout_static_imports_separately = true +ij_java_line_comment_add_space = false +ij_java_line_comment_add_space_on_reformat = false +ij_java_line_comment_at_first_column = true +ij_java_message_dd_suffix = EJB +ij_java_message_eb_suffix = Bean +ij_java_method_annotation_wrap = split_into_lines +ij_java_method_brace_style = end_of_line +ij_java_method_call_chain_wrap = split_into_lines +ij_java_method_parameters_new_line_after_left_paren = true +ij_java_method_parameters_right_paren_on_new_line = true +ij_java_method_parameters_wrap = split_into_lines +ij_java_modifier_list_wrap = false +ij_java_multi_catch_types_wrap = normal +ij_java_names_count_to_use_import_on_demand = 3 +ij_java_new_line_after_lparen_in_annotation = true +ij_java_new_line_after_lparen_in_deconstruction_pattern = true +ij_java_new_line_after_lparen_in_record_header = false +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 = split_into_lines +ij_java_parentheses_expression_new_line_after_left_paren = false +ij_java_parentheses_expression_right_paren_on_new_line = false +ij_java_place_assignment_sign_on_next_line = false +ij_java_prefer_longer_names = true +ij_java_prefer_parameters_wrap = false +ij_java_record_components_wrap = normal +ij_java_repeat_synchronized = true +ij_java_replace_instanceof_and_cast = false +ij_java_replace_null_check = true +ij_java_replace_sum_lambda_with_method_ref = true +ij_java_resource_list_new_line_after_left_paren = false +ij_java_resource_list_right_paren_on_new_line = false +ij_java_resource_list_wrap = off +ij_java_rparen_on_new_line_in_annotation = true +ij_java_rparen_on_new_line_in_deconstruction_pattern = true +ij_java_rparen_on_new_line_in_record_header = false +ij_java_session_dd_suffix = EJB +ij_java_session_eb_suffix = Bean +ij_java_session_hi_suffix = Home +ij_java_session_lhi_prefix = Local +ij_java_session_lhi_suffix = Home +ij_java_session_li_prefix = Local +ij_java_session_si_suffix = Service +ij_java_space_after_closing_angle_bracket_in_type_argument = false +ij_java_space_after_colon = true +ij_java_space_after_comma = true +ij_java_space_after_comma_in_type_arguments = true +ij_java_space_after_for_semicolon = true +ij_java_space_after_quest = true +ij_java_space_after_type_cast = true +ij_java_space_before_annotation_array_initializer_left_brace = false +ij_java_space_before_annotation_parameter_list = false +ij_java_space_before_array_initializer_left_brace = true +ij_java_space_before_catch_keyword = true +ij_java_space_before_catch_left_brace = true +ij_java_space_before_catch_parentheses = true +ij_java_space_before_class_left_brace = true +ij_java_space_before_colon = true +ij_java_space_before_colon_in_foreach = true +ij_java_space_before_comma = false +ij_java_space_before_deconstruction_list = false +ij_java_space_before_do_left_brace = true +ij_java_space_before_else_keyword = true +ij_java_space_before_else_left_brace = true +ij_java_space_before_finally_keyword = true +ij_java_space_before_finally_left_brace = true +ij_java_space_before_for_left_brace = true +ij_java_space_before_for_parentheses = true +ij_java_space_before_for_semicolon = false +ij_java_space_before_if_left_brace = true +ij_java_space_before_if_parentheses = true +ij_java_space_before_method_call_parentheses = false +ij_java_space_before_method_left_brace = true +ij_java_space_before_method_parentheses = false +ij_java_space_before_opening_angle_bracket_in_type_parameter = false +ij_java_space_before_quest = true +ij_java_space_before_switch_left_brace = true +ij_java_space_before_switch_parentheses = true +ij_java_space_before_synchronized_left_brace = true +ij_java_space_before_synchronized_parentheses = true +ij_java_space_before_try_left_brace = true +ij_java_space_before_try_parentheses = true +ij_java_space_before_type_parameter_list = false +ij_java_space_before_while_keyword = true +ij_java_space_before_while_left_brace = true +ij_java_space_before_while_parentheses = true +ij_java_space_inside_one_line_enum_braces = false +ij_java_space_within_empty_array_initializer_braces = false +ij_java_space_within_empty_method_call_parentheses = false +ij_java_space_within_empty_method_parentheses = false +ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_annotation_eq = true +ij_java_spaces_around_assignment_operators = true +ij_java_spaces_around_bitwise_operators = true +ij_java_spaces_around_equality_operators = true +ij_java_spaces_around_lambda_arrow = true +ij_java_spaces_around_logical_operators = true +ij_java_spaces_around_method_ref_dbl_colon = false +ij_java_spaces_around_multiplicative_operators = true +ij_java_spaces_around_relational_operators = true +ij_java_spaces_around_shift_operators = true +ij_java_spaces_around_type_bounds_in_type_parameters = true +ij_java_spaces_around_unary_operator = false +ij_java_spaces_within_angle_brackets = false +ij_java_spaces_within_annotation_parentheses = false +ij_java_spaces_within_array_initializer_braces = true +ij_java_spaces_within_braces = false +ij_java_spaces_within_brackets = false +ij_java_spaces_within_cast_parentheses = false +ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_deconstruction_list = false +ij_java_spaces_within_for_parentheses = false +ij_java_spaces_within_if_parentheses = false +ij_java_spaces_within_method_call_parentheses = false +ij_java_spaces_within_method_parentheses = false +ij_java_spaces_within_parentheses = false +ij_java_spaces_within_record_header = false +ij_java_spaces_within_switch_parentheses = false +ij_java_spaces_within_synchronized_parentheses = false +ij_java_spaces_within_try_parentheses = false +ij_java_spaces_within_while_parentheses = false +ij_java_special_else_if_treatment = true +ij_java_subclass_name_suffix = Impl +ij_java_switch_expressions_wrap = normal +ij_java_ternary_operation_signs_on_next_line = false +ij_java_ternary_operation_wrap = off +ij_java_test_name_suffix = Test +ij_java_throws_keyword_wrap = off +ij_java_throws_list_wrap = off +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 = split_into_lines +ij_java_visibility = public +ij_java_while_brace_force = never +ij_java_while_on_new_line = false +ij_java_wrap_comments = false +ij_java_wrap_first_method_in_call_chain = false +ij_java_wrap_long_lines = false +ij_java_wrap_semicolon_after_call_chain = false -# Prevent wildcard imports -ij_kotlin_name_count_to_use_star_import = 99 -ij_kotlin_name_count_to_use_star_import_for_members = 99 +[.editorconfig] +ij_editorconfig_align_group_field_declarations = false +ij_editorconfig_space_after_colon = false +ij_editorconfig_space_after_comma = true +ij_editorconfig_space_before_colon = false +ij_editorconfig_space_before_comma = false +ij_editorconfig_spaces_around_assignment_operators = true -[*.md] -trim_trailing_whitespace = false -max_line_length = unset +[{*.kt,*.kts}] +ij_continuation_indent_size = 4 +ij_kotlin_align_in_columns_case_branch = false +ij_kotlin_align_multiline_binary_operation = false +ij_kotlin_align_multiline_extends_list = false +ij_kotlin_align_multiline_method_parentheses = false +ij_kotlin_align_multiline_parameters = true +ij_kotlin_align_multiline_parameters_in_calls = false +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false +ij_kotlin_assignment_wrap = normal +ij_kotlin_blank_lines_after_class_header = 0 +ij_kotlin_blank_lines_around_block_when_branches = 0 +ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 +ij_kotlin_block_comment_add_space = false +ij_kotlin_block_comment_at_first_column = true +ij_kotlin_call_parameters_new_line_after_left_paren = true +ij_kotlin_call_parameters_right_paren_on_new_line = true +ij_kotlin_call_parameters_wrap = on_every_item +ij_kotlin_catch_on_new_line = false +ij_kotlin_class_annotation_wrap = split_into_lines +ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL +ij_kotlin_continuation_indent_for_chained_calls = false +ij_kotlin_continuation_indent_for_expression_bodies = false +ij_kotlin_continuation_indent_in_argument_lists = false +ij_kotlin_continuation_indent_in_elvis = false +ij_kotlin_continuation_indent_in_if_conditions = false +ij_kotlin_continuation_indent_in_parameter_lists = false +ij_kotlin_continuation_indent_in_supertype_lists = false +ij_kotlin_else_on_new_line = false +ij_kotlin_enum_constants_wrap = split_into_lines +ij_kotlin_extends_list_wrap = normal +ij_kotlin_field_annotation_wrap = split_into_lines +ij_kotlin_finally_on_new_line = false +ij_kotlin_if_rparen_on_new_line = true +ij_kotlin_import_nested_classes = false +ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^ +ij_kotlin_insert_whitespaces_in_simple_one_line_method = true +ij_kotlin_keep_blank_lines_before_right_brace = 0 +ij_kotlin_keep_blank_lines_in_code = 1 +ij_kotlin_keep_blank_lines_in_declarations = 1 +ij_kotlin_keep_first_column_comment = false +ij_kotlin_keep_indents_on_empty_lines = false +ij_kotlin_keep_line_breaks = false +ij_kotlin_lbrace_on_next_line = false +ij_kotlin_line_break_after_multiline_when_entry = false +ij_kotlin_line_comment_add_space = false +ij_kotlin_line_comment_add_space_on_reformat = false +ij_kotlin_line_comment_at_first_column = true +ij_kotlin_method_annotation_wrap = split_into_lines +ij_kotlin_method_call_chain_wrap = normal +ij_kotlin_method_parameters_new_line_after_left_paren = true +ij_kotlin_method_parameters_right_paren_on_new_line = true +ij_kotlin_method_parameters_wrap = on_every_item +ij_kotlin_name_count_to_use_star_import = 5 +ij_kotlin_name_count_to_use_star_import_for_members = 3 +ij_kotlin_packages_to_use_import_on_demand = java.util.*, kotlinx.android.synthetic.**, io.ktor.** +ij_kotlin_parameter_annotation_wrap = split_into_lines +ij_kotlin_space_after_comma = true +ij_kotlin_space_after_extend_colon = true +ij_kotlin_space_after_type_colon = true +ij_kotlin_space_before_catch_parentheses = true +ij_kotlin_space_before_comma = false +ij_kotlin_space_before_extend_colon = true +ij_kotlin_space_before_for_parentheses = true +ij_kotlin_space_before_if_parentheses = true +ij_kotlin_space_before_lambda_arrow = true +ij_kotlin_space_before_type_colon = false +ij_kotlin_space_before_when_parentheses = true +ij_kotlin_space_before_while_parentheses = true +ij_kotlin_spaces_around_additive_operators = true +ij_kotlin_spaces_around_assignment_operators = true +ij_kotlin_spaces_around_equality_operators = true +ij_kotlin_spaces_around_function_type_arrow = true +ij_kotlin_spaces_around_logical_operators = true +ij_kotlin_spaces_around_multiplicative_operators = true +ij_kotlin_spaces_around_range = true +ij_kotlin_spaces_around_relational_operators = true +ij_kotlin_spaces_around_unary_operator = false +ij_kotlin_spaces_around_when_arrow = true +ij_kotlin_variable_annotation_wrap = split_into_lines +ij_kotlin_while_on_new_line = false +ij_kotlin_wrap_elvis_expressions = 1 +ij_kotlin_wrap_expression_body_functions = 1 +ij_kotlin_wrap_first_method_in_call_chain = false -[gradle/verification-metadata.xml] -indent_size = 3 +[{*.markdown,*.md}] +ij_continuation_indent_size = 4 +ij_markdown_force_one_space_after_blockquote_symbol = true +ij_markdown_force_one_space_after_header_symbol = true +ij_markdown_force_one_space_after_list_bullet = true +ij_markdown_force_one_space_between_words = true +ij_markdown_format_tables = true +ij_markdown_insert_quote_arrows_on_wrap = true +ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_keep_line_breaks_inside_text_blocks = true +ij_markdown_max_lines_around_block_elements = 1 +ij_markdown_max_lines_around_header = 1 +ij_markdown_max_lines_between_paragraphs = 1 +ij_markdown_min_lines_around_block_elements = 1 +ij_markdown_min_lines_around_header = 1 +ij_markdown_min_lines_between_paragraphs = 1 +ij_markdown_wrap_text_if_long = true +ij_markdown_wrap_text_inside_blockquotes = true -[*.yml] -ij_yaml_spaces_within_brackets = false \ No newline at end of file +[{*.yaml,*.yml}] +indent_size = 2 +ij_yaml_align_values_properties = do_not_align +ij_yaml_autoinsert_sequence_marker = true +ij_yaml_block_mapping_on_new_line = false +ij_yaml_indent_sequence_value = true +ij_yaml_keep_indents_on_empty_lines = false +ij_yaml_keep_line_breaks = true +ij_yaml_sequence_on_new_line = false +ij_yaml_space_before_colon = false +ij_yaml_spaces_within_braces = true +ij_yaml_spaces_within_brackets = true \ No newline at end of file diff --git a/.github/workflows/build-commit.yml b/.github/workflows/build-commit.yml index dd116f5..191d9c4 100644 --- a/.github/workflows/build-commit.yml +++ b/.github/workflows/build-commit.yml @@ -5,7 +5,7 @@ name: build-commit on: push: paths-ignore: - - "readme.md" + - "README.md" - "LICENSE" - ".gitignore" - "changelog.md" @@ -13,7 +13,7 @@ on: - "src/*/resources/lang/*" pull_request: paths-ignore: - - "readme.md" + - "README.md" - "LICENSE" - ".gitignore" - "changelog.md" @@ -38,9 +38,17 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Build with Gradle - uses: Wandalen/wretry.action@master - with: - command: ./gradlew buildAllVersions --stacktrace + run: ./gradlew buildAllVersions --stacktrace - uses: actions/upload-artifact@v4 with: path: versions/**/build/libs/*.jar + + modrinth-description: + runs-on: ubuntu-latest + name: Sync Modrinth description + steps: + - uses: actions/checkout@v4 + - uses: funnyboy-roks/modrinth-auto-desc@v1.6 + with: + auth-token: ${{ secrets.MODRINTH_API_KEY }} + slug: 'skylper' \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd58a72..022f825 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,9 +21,7 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Release with Gradle - uses: Wandalen/wretry.action@master - with: - command: ./gradlew releaseAllVersions --stacktrace + run: ./gradlew releaseAllVersions postUpdate --stacktrace env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MODRINTH_API_KEY: ${{ secrets.MODRINTH_API_KEY }} @@ -33,3 +31,13 @@ jobs: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SECRET_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SECRET_KEY_PASSWORD }} GPG_SECRET_KEY_ID: ${{ secrets.GPG_SECRET_KEY_ID }} + + modrinth-description: + runs-on: ubuntu-latest + name: Sync Modrinth description + steps: + - uses: actions/checkout@v4 + - uses: funnyboy-roks/modrinth-auto-desc@v1.6 + with: + auth-token: ${{ secrets.MODRINTH_API_KEY }} + slug: 'skylper' \ No newline at end of file diff --git a/.gitignore b/.gitignore index 073af1c..529e79a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ **/.gradle/ **/run/ !run/mods/ -**/build/ \ No newline at end of file +**/build/ +.kotlin +**/.cache \ No newline at end of file diff --git a/README.md b/README.md index 3a6747c..551a6cd 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,36 @@ # telekinesis -This mod/plugin adds the telekinesis enchantment, allowing you to instantly move drops into your inventory: - -## Supported drops -- block drops -- mob drops -- exp drops -- shearing drops (fabric only) -- vehicle drops (fabric only) -- fishing drops (fabric only) - -## Compatibility -The paper module of telekinesis is as of Minecraft version 1.20.2 discontinued cause of the lack of ability to -register the enchantment (I will figure a way out when I have time to, but it seems like this step is linked with way more reflection than before.) +This mod/plugin adds the telekinesis enchantment, allowing you to instantly move drops into your inventory. ## Configuration The configuration file can be found in the client/server directory. -The file differs cause of the supported drops between fabric and paper environments. - --> mod configuration file: `/config/telekinesis.toml` -
--> plugin configuration file: `/plugins/telekinesis.toml` +-> configuration file: `/config/telekinesis.json`
telekinesis.toml -
-paper config - -```toml -# Uncomment the following values if you want to change them: -# -# Decides whether telekinesis can be used without the enchantment. -onByDefault = false -# Uncomment this to block functionality for those who don't have the required permission. -# onByDefaultPermissionRequirement = 'permission' -# -# Decides whether players should be required to sneak to use telekinesis. -onlyOnSneak = false -# Decides whether telekinesis can be used for block drops. -blockDrops = true -# blockDropsPermissionRequirement = 'permission' -# -# Decides whether telekinesis can be used for exp drops. -expDrops = true -# expDropsPermissionRequirement = 'permission' -# -# Decides whether telekinesis can be used for entity drops. -entityDrops = true -# entityDropsPermissionRequirement = 'permission' -# -# Decides whether to add the enchantment to the game. -enchantment = true -``` -
- -
-fabric config - -```toml -# Uncomment the following values if you want to change them: -# -# Decides whether telekinesis can be used without the enchantment. -onByDefault = false -# Decides whether players should be required to sneak to use telekinesis. -onlyOnSneak = false -# Decides whether to add the enchantment to the game. -enchantment = true -# Decides whether telekinesis can be used for block drops. -blockDrops = true -# Decides whether telekinesis can be used for exp drops. -expDrops = true -# Decides whether telekinesis can be used for mob drops. -mobDrops = true -# Decides whether telekinesis can be used for vehicle drops. -vehicleDrops = true -# Decides whether telekinesis can be used for shearing drops. -shearingDrops = true -# Decides whether telekinesis can be used for fishing drops. -fishingDrops = true +```json +{ + "version": 1, // Only for migration purposes, just ignore this. + "config": { + "needEnchantment": true, // Defines, whether telekinesis should without or with the enchantment on the tool. + "needSneak": false, // Defines. whether the player should have to sneak in order to use telekinesis. + "expAllowed": true, // Enables the use of telekinesis for exp drops. + "itemsAllowed": true // Enables the use of telekinesis for item drops. + } +} ``` -
### Other -⚠️ The development version is always the latest stable release of Minecraft. -Therefore, new features will only be available for the current and following Minecraft versions. + +Currently supported versions are: 1.20.1, 1.20.4, 1.20.6 and 1.21. This can change in the future! If you need help with any of my mods, just join my [discord server](https://nyon.dev/discord) + +#### Paper Compatibility + +The paper module of telekinesis is as of Minecraft version 1.20.2 discontinued cause of the lack of ability to +register the enchantment (When Paper's registry modification api is merged I will continue.) diff --git a/build.gradle.kts b/build.gradle.kts index 4a92d56..479c7c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,17 +1,203 @@ -plugins { - kotlin("jvm") version "1.9.24" - kotlin("plugin.serialization") version "1.9.24" +@file:Suppress("SpellCheckingInspection", "SENSELESS_COMPARISON") - id("me.modmuss50.mod-publish-plugin") version "0.5.+" +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - id("fabric-loom") version "1.6-SNAPSHOT" apply (false) +plugins { + kotlin("jvm") version "2.0.0" + kotlin("plugin.serialization") version "2.0.0" + id("fabric-loom") version "1.7-SNAPSHOT" - id("io.papermc.paperweight.userdev") version "1.5.5" apply (false) + id("me.modmuss50.mod-publish-plugin") version "0.5.+" `maven-publish` signing } +val beta: Int = 1 // Pattern is '1.0.0-beta1-1.20.6-pre.2' +val featureVersion = "1.0.0${if (beta != null) "-beta$beta" else ""}" +val mcVersion = property("mcVersion")!!.toString() +val mcVersionRange = property("mcVersionRange")!!.toString() +version = "$featureVersion-$mcVersion" + +group = "dev.nyon" +val projectAuthors = listOf("btwonion") +val githubRepo = "btwonion/telekinesis" + +base { + archivesName.set(rootProject.name) +} + +loom { + if (stonecutter.current.isActive) { + runConfigs.all { + ideConfigGenerated(true) + runDir("../../run") + } + } + + mixin { useLegacyMixinAp = false } +} + +// Enable data generation for >1.20.6 +if (!listOf("1.20.1", "1.20.4", "1.20.6").contains(stonecutter.current.version)) { + fabricApi { + configureDataGeneration() + } +} + repositories { mavenCentral() + exclusiveContent { + forRepository { + maven("https://api.modrinth.com/maven") + } + filter { + includeGroup("maven.modrinth") + } + } + maven("https://maven.terraformersmc.com") + maven("https://maven.parchmentmc.org") + maven("https://repo.nyon.dev/releases") + maven("https://maven.isxander.dev/releases") + maven("https://maven.isxander.dev/snapshots") + maven("https://jitpack.io") +} + +dependencies { + minecraft("com.mojang:minecraft:$mcVersion") + mappings(loom.layered { + val parchment: String = property("deps.parchment").toString() + if (parchment.isNotEmpty()) parchment("org.parchmentmc.data:parchment-$parchment@zip") + officialMojangMappings() + }) + + implementation("org.vineflower:vineflower:1.10.1") + modImplementation("net.fabricmc:fabric-loader:0.15.11") + modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}") + modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0") + + modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}") + modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}") + + include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.1.1")!!)!!) + + include(modImplementation("dev.nyon:konfig:2.0.1-1.20.4")!!) +} + +val javaVersion = property("javaVer")!!.toString() +tasks { + processResources { + val modId = "telekinesis" + val modName = "telekinesis" + val modDescription = "Adds a telekinesis enchantment to minecraft" + + val props = mapOf( + "id" to modId, + "name" to modName, + "description" to modDescription, + "version" to project.version, + "github" to githubRepo, + "mc" to mcVersionRange + ) + + props.forEach(inputs::property) + + filesMatching("fabric.mod.json") { + expand(props) + } + } + + register("releaseMod") { + group = "publishing" + + dependsOn("publishMods") + dependsOn("publish") + } + + withType { + options.release = javaVersion.toInt() + } + + withType { + compilerOptions { + jvmTarget = JvmTarget.fromTarget(javaVersion) + } + } +} + +val changelogText = buildString { + append("# v${project.version}\n") + rootProject.file("changelog.md").readText().also(::append) +} + +val supportedMcVersions: List = + property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty) + +publishMods { + displayName = "v${project.version}" + file = tasks.remapJar.get().archiveFile + changelog = changelogText + type = if (beta != null) BETA else STABLE + modLoaders.addAll("fabric", "quilt") + + modrinth { + projectId = "LLfA8jAD" + accessToken = providers.environmentVariable("MODRINTH_API_KEY") + minecraftVersions.addAll(supportedMcVersions) + + requires { slug = "fabric-api" } + requires { slug = "yacl" } + requires { slug = "fabric-language-kotlin" } + optional { slug = "modmenu" } + } + + github { + repository = githubRepo + accessToken = providers.environmentVariable("GITHUB_TOKEN") + commitish = "master" + } } + +publishing { + repositories { + maven { + name = "nyon" + url = uri("https://repo.nyon.dev/releases") + credentials { + username = providers.environmentVariable("NYON_USERNAME").orNull + password = providers.environmentVariable("NYON_PASSWORD").orNull + } + } + } + publications { + create("maven") { + groupId = "dev.nyon" + artifactId = "telekinesis" + version = project.version.toString() + from(components["java"]) + } + } +} + +java { + withSourcesJar() + + javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let { + sourceCompatibility = it + targetCompatibility = it + } +} + +/* +signing { + val signingKey: String? by project + val signingPassword: String? by project + useGpgCmd() + if (signingKey != null && signingPassword != null) { + useInMemoryPgpKeys(signingKey, signingPassword) + } + sign(publishing.publications) +} + */ + diff --git a/changelog.md b/changelog.md index 95cf704..da09f31 100644 --- a/changelog.md +++ b/changelog.md @@ -1 +1,6 @@ -- support 1.20.1, 1.20.4, 1.20.6 +- completely rework project +- config is now in json and **NO** migration is applied! + - now consists of fewer sections - see readme +- telekinesis only applies to tools now + +**I was not able to test everything, so feel free to report ANY errors!** diff --git a/gradle.properties b/gradle.properties index ee05a44..bf86fb7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1 @@ -kotlin.code.style=official -org.gradle.jvmargs=-Xmx2048m -Xms2048m -XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096 \ No newline at end of file +org.gradle.jvmargs=-Xmx2G \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a8382d7..db4c326 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 640c9fd..128d21c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,4 +1,4 @@ -import dev.kikugie.stonecutter.gradle.StonecutterSettings +import dev.kikugie.stonecutter.StonecutterSettings rootProject.name = "telekinesis" @@ -7,25 +7,28 @@ pluginManagement { gradlePluginPortal() maven("https://maven.fabricmc.net/") maven("https://server.bbkr.space/artifactory/libs-release/") - maven("https://maven.quiltmc.org/repository/release/") maven("https://repo.papermc.io/repository/maven-public/") maven("https://maven.kikugie.dev/releases") } } plugins { - id("dev.kikugie.stonecutter") version "0.3.5" + id("dev.kikugie.stonecutter") version "0.4" } -//include("telekinesis-paper") -include("telekinesis-fabric") +buildscript { + repositories { mavenCentral() } + dependencies { + classpath("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0-RC") + } +} extensions.configure { kotlinController = true centralScript = "build.gradle.kts" shared { - versions("1.20.1", "1.20.4", "1.20.6") - vcsVersion = "1.20.6" + versions("1.20.1", "1.20.4", "1.20.6", "1.21") + vcsVersion = "1.21" } - create(project(":telekinesis-fabric")) + create(rootProject) } diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java similarity index 78% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java index f5759ab..a05205b 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/AbstractChestedHorseMixin.java @@ -1,8 +1,9 @@ package dev.nyon.telekinesis.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; +import dev.nyon.telekinesis.utils.MixinHelper; import net.minecraft.world.entity.animal.horse.AbstractChestedHorse; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -17,10 +18,10 @@ public class AbstractChestedHorseMixin { target = "Lnet/minecraft/world/entity/animal/horse/AbstractChestedHorse;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;" ) ) - public boolean redirectEquipmentDrop( + public boolean modifyEquipmentDrop( AbstractChestedHorse instance, ItemLike item ) { - return EntityUtils.spawnAtLocationInject(instance, item); + return MixinHelper.entityDropEquipmentSingle(instance, new ItemStack(item)); } } diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java similarity index 53% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java index 2c98427..04febc9 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/AbstractHorseMixin.java @@ -1,7 +1,7 @@ package dev.nyon.telekinesis.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; +import dev.nyon.telekinesis.utils.MixinHelper; import net.minecraft.world.entity.animal.horse.AbstractHorse; import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; @@ -17,10 +17,24 @@ public class AbstractHorseMixin { target = "Lnet/minecraft/world/entity/animal/horse/AbstractHorse;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" ) ) - public boolean redirectEquipmentDrop( + public boolean modifyEquipmentDrop( AbstractHorse instance, ItemStack stack ) { - return EntityUtils.spawnAtLocationInject(instance, stack); + return MixinHelper.entityDropEquipmentSingle(instance, stack); + } + + @WrapWithCondition( + method = "dropEquipment", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/animal/horse/AbstractHorse;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" + ) + ) + public boolean modifyEquipmentDrops( + AbstractHorse instance, + ItemStack itemStack + ) { + return MixinHelper.entityDropEquipmentSingle(instance, itemStack); } } diff --git a/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java new file mode 100644 index 0000000..f15c07c --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java @@ -0,0 +1,29 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.item.Item; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(AbstractMinecart.class) +public class AbstractMinecartMixin { + + /*? <=1.20.2 {*/ + /*@ModifyExpressionValue( + method = "destroy", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/vehicle/AbstractMinecart;getDropItem()Lnet/minecraft/world/item/Item;" + ) + ) + private Item redirectMinecartDrops( + Item original, + DamageSource damageSource + ) { + return MixinHelper.modifyExpressionValueOldVehicle(original, damageSource); + } + *//*?}*/ +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java new file mode 100644 index 0000000..4523d24 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java @@ -0,0 +1,46 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.world.entity.animal.allay.Allay; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.List; + +@Mixin(Allay.class) +public class AllayMixin { + + @Unique + final Allay instance = (Allay) (Object) this; + + @WrapWithCondition( + method = "dropEquipment", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/animal/allay/Allay;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" + ) + ) + public boolean modifyEquipmentDrop( + Allay instance, + ItemStack stack + ) { + return MixinHelper.entityDropEquipmentSingle(instance, stack); + } + + @ModifyExpressionValue( + method = "dropEquipment", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/SimpleContainer;removeAllItems()Ljava/util/List;" + ) + ) + public List modifyEquipmentDrops( + List original + ) { + return MixinHelper.entityDropEquipmentMultiple(instance, original); + } +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java new file mode 100644 index 0000000..3b0899b --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java @@ -0,0 +1,119 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.nyon.telekinesis.DropEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.valueproviders.IntProvider; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.state.BlockState; +import org.apache.commons.lang3.mutable.MutableInt; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.ArrayList; +import java.util.List; + +import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal; + +@Mixin(Block.class) +public abstract class BlockMixin { + + @ModifyExpressionValue( + method = "dropResources(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/Block;getDrops(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)Ljava/util/List;" + ) + ) + private static List modifyDrops( + List original, + BlockState state, + Level level, + BlockPos pos, + @Nullable + BlockEntity blockEntity, + @Nullable + Entity entity, + ItemStack tool + ) { + if (!(entity instanceof ServerPlayer player)) return original; + + ArrayList mutableList = new ArrayList<>(original); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, new MutableInt(0), player, tool); + + return mutableList; + } + + @WrapOperation( + method = "dropResources(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/state/BlockState;spawnAfterBreak(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;Z)V" + ) + ) + private static void checkForPlayerBreak( + BlockState instance, + ServerLevel serverLevel, + BlockPos blockPos, + ItemStack itemStack, + boolean b, + Operation original, + BlockState state, + Level level, + BlockPos pos, + @Nullable + BlockEntity blockEntity, + @Nullable + Entity entity, + ItemStack tool + ) { + if (!(entity instanceof ServerPlayer player)) { + original.call(instance, serverLevel, blockPos, itemStack, b); + return; + } + + ServerPlayer previous = threadLocal.get(); + threadLocal.set(player); + try { + original.call(instance, serverLevel, blockPos, itemStack, b); + } finally { + threadLocal.set(previous); + } + } + + @ModifyExpressionValue( + method = "tryDropExperience", + at = @At( + value = "INVOKE", + target = /*? if >=1.21 {*/ "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;processBlockExperience(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/item/ItemStack;I)I" /*?} else {*/ /*"Lnet/minecraft/util/valueproviders/IntProvider;sample(Lnet/minecraft/util/RandomSource;)I" *//*?}*/ + ) + ) + private int modifyExp( + int original, + ServerLevel level, + BlockPos pos, + ItemStack heldItem, + IntProvider amount + ) { + ServerPlayer player = threadLocal.get(); + if (player == null) return original; + + MutableInt mutableInt = new MutableInt(original); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(new ArrayList<>(), mutableInt, player, heldItem); + + return mutableInt.getValue(); + } +} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java similarity index 80% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java index 330867c..7cc83bd 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/BoatMixin.java @@ -1,20 +1,17 @@ package dev.nyon.telekinesis.mixins; -import net.minecraft.world.entity.vehicle.Boat; -import org.spongepowered.asm.mixin.Mixin; - -/*? <=1.20.2 {*/ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import dev.nyon.telekinesis.utils.EntityUtils; +import dev.nyon.telekinesis.utils.MixinHelper; import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.vehicle.Boat; import net.minecraft.world.item.Item; +import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -/*?}*/ @Mixin(Boat.class) public class BoatMixin { /*? <=1.20.2 {*/ - @ModifyExpressionValue( + /*@ModifyExpressionValue( method = "destroy(Lnet/minecraft/world/damagesource/DamageSource;)V", at = @At( value = "INVOKE", @@ -25,7 +22,7 @@ private Item changeDroppedItem( Item original, DamageSource damageSource ) { - return EntityUtils.getDropItemInject(original, damageSource); + return MixinHelper.modifyExpressionValueOldVehicle(original, damageSource); } - /*?}*/ + *//*?}*/ } diff --git a/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java new file mode 100644 index 0000000..7225d13 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java @@ -0,0 +1,34 @@ +package dev.nyon.telekinesis.mixins; + +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.world.entity.vehicle.ChestBoat; +import org.spongepowered.asm.mixin.Mixin; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.item.Item; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ChestBoat.class) +public abstract class ChestBoatMixin { + + /*? if >1.20.2 {*/ + @WrapOperation( + method = "destroy(Lnet/minecraft/world/damagesource/DamageSource;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/vehicle/ChestBoat;destroy(Lnet/minecraft/world/item/Item;)V" + ) + ) + private void checkForPlayer( + ChestBoat instance, + Item item, + Operation original, + DamageSource source + ) { + MixinHelper.prepareVehicleServerPlayer(instance, item, original, source); + } + /*?}*/ + + // TODO: boat inventory does still not work!!! as well as furnaces!! +} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java similarity index 91% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java index 7eb9455..0b77e9c 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/EnchantmentsMixin.java @@ -1,22 +1,25 @@ package dev.nyon.telekinesis.mixins; -import dev.nyon.telekinesis.MainKt; +/*? if <1.21 {*/ +/*import dev.nyon.telekinesis.MainKt; import dev.nyon.telekinesis.TelekinesisEnchantment; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.Enchantments; -import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +*//*?}*/ +import net.minecraft.world.item.enchantment.Enchantments; +import org.spongepowered.asm.mixin.Mixin; @Mixin(Enchantments.class) public abstract class EnchantmentsMixin { - @Unique + /*? if <1.21 {*/ + /*@Unique private static boolean isTelekinesisRegistered = false; @Inject( @@ -34,4 +37,5 @@ private static void registerTelekinesis( Registry.register(BuiltInRegistries.ENCHANTMENT, new ResourceLocation("telekinesis", "telekinesis"), MainKt.getTelekinesis()); } } + *//*?}*/ } diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java similarity index 67% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java index 8b91cfa..ce86988 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/EnderManMixin.java @@ -1,7 +1,8 @@ package dev.nyon.telekinesis.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.item.ItemStack; @@ -20,11 +21,15 @@ public class EnderManMixin { ) public boolean redirectEquipmentDrop( EnderMan instance, - ItemStack stack, + ItemStack itemStack, + /*? if >=1.21 {*/ + ServerLevel serverLevel, DamageSource damageSource, - int lootingMultiplier, - boolean allowDrops + boolean bl + /*?} else {*/ + /*DamageSource damageSource, int looting, boolean hitByPlayer + *//*?}*/ ) { - return EntityUtils.spawnAtLocationInject(instance, stack); + return MixinHelper.entityCustomDeathLootSingle(damageSource, itemStack); } } diff --git a/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java new file mode 100644 index 0000000..26738e4 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java @@ -0,0 +1,55 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyReceiver; +import dev.nyon.telekinesis.DropEvent; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.RandomSource; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.entity.projectile.FishingHook; +import net.minecraft.world.item.ItemStack; +import org.apache.commons.lang3.mutable.MutableInt; +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.ArrayList; +import java.util.List; + +@Mixin(FishingHook.class) +public abstract class FishingHookMixin { + + @ModifyReceiver( + method = "retrieve", + at = @At( + value = "INVOKE", + target = "Ljava/util/List;iterator()Ljava/util/Iterator;" + ) + ) + public List modifyFishingDrops( + List instance, + ItemStack fishingHook + ) { + if (!(getPlayerOwner() instanceof ServerPlayer player)) return instance; + + ArrayList mutableList = new ArrayList<>(instance); + mutableList.removeIf(item -> { + ArrayList singleList = new ArrayList<>(List.of(item)); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(singleList, new MutableInt(syncronizedRandom.nextInt(6) + 1), player, fishingHook); + return singleList.isEmpty(); + }); + + return mutableList; + } + + @Shadow + @Nullable + public abstract Player getPlayerOwner(); + + @Shadow + @Final + private RandomSource syncronizedRandom; +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java new file mode 100644 index 0000000..449403c --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java @@ -0,0 +1,103 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.nyon.telekinesis.DropEvent; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.storage.loot.LootParams; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import org.apache.commons.lang3.mutable.MutableInt; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal; + +@Mixin(LivingEntity.class) +public abstract class LivingEntityMixin { + + @ModifyExpressionValue( + method = "dropExperience", + at = @At( + value = "INVOKE", + target = /*? if >=1.21 {*/ "Lnet/minecraft/world/entity/LivingEntity;getExperienceReward(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/entity/Entity;)I" /*?} else {*/ /*"Lnet/minecraft/world/entity/LivingEntity;getExperienceReward()I" *//*?}*/ + ) + ) + public int redirectExp( + int original + /*? if >=1.21*/, Entity entity + ) { + /*? if >=1.21 {*/ + if (!(entity instanceof ServerPlayer player)) return original; + /*?} else {*/ + /*ServerPlayer player = threadLocal.get(); + *//*?}*/ + + return MixinHelper.modifyExpressionValuePlayerExp(player, original); + } + + @ModifyArg( + method = "dropFromLootTable", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/storage/loot/LootTable;getRandomItems(Lnet/minecraft/world/level/storage/loot/LootParams;JLjava/util/function/Consumer;)V" + ), + index = 2 + ) + public Consumer redirectCommonDrops( + LootParams params, + long seed, + Consumer original + ) { + DamageSource source = params.getParamOrNull(LootContextParams.DAMAGE_SOURCE); + if (source == null || !(source.getEntity() instanceof ServerPlayer player)) return original; + + return item -> { + ArrayList mutableList = new ArrayList<>(List.of(item)); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, new MutableInt(0), player, player.getMainHandItem()); + + if (!mutableList.isEmpty()) original.accept(item); + }; + } + + /*? if <1.21 {*/ + /*@WrapOperation( + method = "dropAllDeathLoot", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/LivingEntity;dropExperience()V" + ) + ) + private void cachePlayer( + LivingEntity instance, + Operation original, + DamageSource damageSource + ) { + if (!(damageSource.getEntity() instanceof ServerPlayer player)) { + original.call(instance); + return; + } + + ServerPlayer previous = threadLocal.get(); + threadLocal.set(player); + try { + original.call(instance); + } finally { + threadLocal.set(previous); + } + } + *//*?}*/ +} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java similarity index 50% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java index ce6b015..b1e6475 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/MinecartTNTMixin.java @@ -1,32 +1,35 @@ package dev.nyon.telekinesis.mixins; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.nyon.telekinesis.utils.MixinHelper; import net.minecraft.world.entity.vehicle.MinecartTNT; import org.spongepowered.asm.mixin.Mixin; -/*? if >1.20.2 {*//* -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import dev.nyon.telekinesis.utils.EntityUtils; +/*? if >1.20.2 {*/ import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.item.Item; import org.spongepowered.asm.mixin.injection.At; - *//*?}*/ + /*?}*/ @Mixin(MinecartTNT.class) public class MinecartTNTMixin { - /*? if >1.20.2 {*//* - @ModifyExpressionValue( + /*? if >1.20.2 {*/ + @WrapOperation( method = "destroy(Lnet/minecraft/world/damagesource/DamageSource;)V", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/entity/vehicle/MinecartTNT;getDropItem()Lnet/minecraft/world/item/Item;" + target = "Lnet/minecraft/world/entity/vehicle/MinecartTNT;destroy(Lnet/minecraft/world/item/Item;)V" ) ) - private Item changeDroppedItem( - Item original, - DamageSource damageSource + private void checkForPlayer( + MinecartTNT instance, + Item dropItem, + Operation original, + DamageSource source ) { - return EntityUtils.getDropItemInject(original, damageSource); + MixinHelper.prepareVehicleServerPlayer(instance, dropItem, original, source); } - *//*?}*/ + /*?}*/ } diff --git a/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java new file mode 100644 index 0000000..aa6594e --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java @@ -0,0 +1,45 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(Mob.class) +public class MobMixin { + + @WrapWithCondition( + method = "dropCustomDeathLoot", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Mob;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" + ) + ) + public boolean modifyCustomDeathLoot( + Mob instance, + ItemStack itemStack, + /*? if >=1.21 {*/ ServerLevel serverLevel, DamageSource damageSource, boolean bl /*?} else {*/ /*DamageSource damageSource, int looting, boolean hitByPlayer *//*?}*/ + ) { + return MixinHelper.entityCustomDeathLootSingle(damageSource, itemStack); + } + + /*? if >=1.21 {*/ + @WrapWithCondition( + method = "dropPreservedEquipment(Ljava/util/function/Predicate;)Ljava/util/Set;", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Mob;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" + ) + ) + public boolean modifyCustomDeathLoot( + Mob instance, + ItemStack itemStack + ) { + return MixinHelper.entityDropEquipmentSingle(instance, itemStack); + } + /*?}*/ +} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java similarity index 75% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java index c7bf7b9..b5bf54c 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/PigMixin.java @@ -1,8 +1,9 @@ package dev.nyon.telekinesis.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; +import dev.nyon.telekinesis.utils.MixinHelper; import net.minecraft.world.entity.animal.Pig; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -17,10 +18,10 @@ public class PigMixin { target = "Lnet/minecraft/world/entity/animal/Pig;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;" ) ) - public boolean redirectEquipmentDrop( + public boolean modifyEquipmentDrop( Pig instance, ItemLike item ) { - return EntityUtils.spawnAtLocationInject(instance, item); + return MixinHelper.entityDropEquipmentSingle(instance, new ItemStack(item)); } } diff --git a/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java new file mode 100644 index 0000000..1800f3c --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java @@ -0,0 +1,30 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.monster.piglin.Piglin; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.List; + +@Mixin(Piglin.class) +public class PiglinMixin { + + @ModifyExpressionValue( + method = "dropCustomDeathLoot", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/SimpleContainer;removeAllItems()Ljava/util/List;" + ) + ) + public List redirectDrops( + List original, + /*? if >=1.21 {*/ ServerLevel serverLevel, DamageSource damageSource, boolean bl /*?} else {*/ /*DamageSource damageSource, int looting, boolean hitByPlayer *//*?}*/ + ) { + return MixinHelper.entityCustomDeathLootMultiple(damageSource, original); + } +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java new file mode 100644 index 0000000..faa6897 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/PlayerMixin.java @@ -0,0 +1,40 @@ +package dev.nyon.telekinesis.mixins; + +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import java.util.ArrayList; +import java.util.List; + +@Mixin(Player.class) +public class PlayerMixin { + + /*? if >=1.20.5 {*/@Shadow/*?} else {*/ /*@Unique *//*?}*/ + @Final + Inventory inventory; + @Unique + final Player instance = (Player) (Object) this; + + @Inject( + method = "dropEquipment", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/player/Inventory;dropAll()V" + ) + ) + public void modifyEquipmentDrops(CallbackInfo ci) { + ArrayList items = new ArrayList<>(inventory.items); + List processedItems = MixinHelper.entityDropEquipmentMultiple(instance, items); + inventory.clearContent(); + inventory.items.addAll(processedItems); + } +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java new file mode 100644 index 0000000..0130a86 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java @@ -0,0 +1,54 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.animal.Sheep; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.Block; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal; + +@Mixin(Sheep.class) +public abstract class SheepMixin { + + @WrapOperation( + method = "mobInteract", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/animal/Sheep;shear(Lnet/minecraft/sounds/SoundSource;)V" + ) + ) + private void prepareThreadLocalForShearing( + Sheep instance, + SoundSource source, + Operation original, + Player _player, + InteractionHand hand + ) { + MixinHelper.prepareShearableServerPlayer(instance, source, original, _player); + } + + @ModifyExpressionValue( + method = "shear", + at = @At( + value = "INVOKE", + target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;" + ) + ) + private Object modifyShearDrops(Object original) { + ServerPlayer player = threadLocal.get(); + if (!(original instanceof Block block)) return original; + if (player == null) return original; + + if (MixinHelper.wrapWithConditionPlayerItemSingle(player, new ItemStack(block))) return original; + else return ItemStack.EMPTY; + } +} \ No newline at end of file diff --git a/src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java new file mode 100644 index 0000000..133b7c5 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/SnowGolemMixin.java @@ -0,0 +1,52 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.entity.animal.SnowGolem; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ItemLike; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal; + +@Mixin(SnowGolem.class) +public class SnowGolemMixin { + + @WrapOperation( + method = "mobInteract", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/animal/SnowGolem;shear(Lnet/minecraft/sounds/SoundSource;)V" + ) + ) + private void prepareThreadLocalForShearing( + SnowGolem instance, + SoundSource source, + Operation original, + Player _player + ) { + MixinHelper.prepareShearableServerPlayer(instance, source, original, _player); + } + + @ModifyArg( + method = "shear", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/item/ItemStack;(Lnet/minecraft/world/level/ItemLike;)V" + ) + ) + private ItemLike modifyShearDrops(ItemLike original) { + ServerPlayer player = threadLocal.get(); + if (player == null) return original; + + if (MixinHelper.wrapWithConditionPlayerItemSingle(player, new ItemStack(original))) return original; + else return Items.AIR; + } +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java new file mode 100644 index 0000000..5e74861 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/SpawnerBlockMixin.java @@ -0,0 +1,48 @@ +package dev.nyon.telekinesis.mixins; + +import dev.nyon.telekinesis.DropEvent; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.block.SpawnerBlock; +import net.minecraft.world.level.block.state.BlockState; +import org.apache.commons.lang3.mutable.MutableInt; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +import java.util.ArrayList; + +import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal; + +@Mixin(SpawnerBlock.class) +public class SpawnerBlockMixin { + + @ModifyArgs( + method = "spawnAfterBreak", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/SpawnerBlock;popExperience(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;I)V" + ) + ) + private void modifyDroppedExp( + Args args, + BlockState state, + ServerLevel level, + BlockPos pos, + ItemStack stack, + boolean dropExperience + ) { + ServerPlayer player = threadLocal.get(); + if (player == null) return; + + MutableInt mutableInt = new MutableInt((int) args.get(2)); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(new ArrayList<>(), mutableInt, player, stack); + + args.set(2, mutableInt.getValue()); + } +} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java similarity index 80% rename from telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java rename to src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java index 0599c7f..6e4e0cd 100644 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java +++ b/src/main/java/dev/nyon/telekinesis/mixins/StriderMixin.java @@ -1,8 +1,9 @@ package dev.nyon.telekinesis.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; +import dev.nyon.telekinesis.utils.MixinHelper; import net.minecraft.world.entity.monster.Strider; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ItemLike; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -21,6 +22,6 @@ public boolean redirectEquipmentDrop( Strider instance, ItemLike item ) { - return EntityUtils.spawnAtLocationInject(instance, item); + return MixinHelper.entityDropEquipmentSingle(instance, new ItemStack(item)); } } diff --git a/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java new file mode 100644 index 0000000..f9904c1 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java @@ -0,0 +1,42 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.SweetBerryBushBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(SweetBerryBushBlock.class) +public class SweetBerryBushBlockMixin { + + @WrapWithCondition( + method = /*? >1.20.5 {*/ "useWithoutItem" /*?} else {*/ /*"use" *//*?}*/, + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/SweetBerryBushBlock;popResource(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V" + ) + ) + private boolean manipulateBerryDrops( + Level level, + BlockPos blockPos, + ItemStack itemStack, + BlockState blockState, + Level _level, + BlockPos _blockPos, + Player player, + /*? if <=1.20.4*/ /*InteractionHand hand,*/ + BlockHitResult blockHitResult + ) { + if (!(player instanceof ServerPlayer serverPlayer)) return true; + + return MixinHelper.wrapWithConditionPlayerItemSingle(serverPlayer, itemStack); + } +} diff --git a/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java new file mode 100644 index 0000000..13be492 --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java @@ -0,0 +1,55 @@ +package dev.nyon.telekinesis.mixins; + +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.damagesource.DamageSource; +/*? if >=1.20.4*/ import net.minecraft.world.entity.vehicle.VehicleEntity; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; + +import static dev.nyon.telekinesis.utils.MixinHelper.threadLocal; + +@Pseudo +@Mixin(targets = "net.minecraft.world.entity.vehicle.VehicleEntity") +public class VehicleEntityMixin { + /*? if >=1.20.4 {*/ + @WrapOperation( + method = "destroy(Lnet/minecraft/world/damagesource/DamageSource;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/vehicle/VehicleEntity;destroy(Lnet/minecraft/world/item/Item;)V" + ) + ) + private void checkForPlayer( + VehicleEntity instance, + Item dropItem, + Operation original, + DamageSource source + ) { + MixinHelper.prepareVehicleServerPlayer(instance, dropItem, original, source); + } + + @WrapWithCondition( + method = "destroy(Lnet/minecraft/world/item/Item;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/vehicle/VehicleEntity;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" + ) + ) + private boolean replaceDropItem( + VehicleEntity instance, + ItemStack itemStack + ) { + ServerPlayer player = threadLocal.get(); + if (player == null) return true; + + return MixinHelper.wrapWithConditionPlayerItemSingle(player, itemStack); + } + /*?}*/ +} \ No newline at end of file diff --git a/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java b/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java new file mode 100644 index 0000000..dbec90e --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java @@ -0,0 +1,32 @@ +package dev.nyon.telekinesis.mixins; + +import dev.nyon.telekinesis.utils.MixinHelper; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.boss.wither.WitherBoss; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.level.ItemLike; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArgs; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +@Mixin(WitherBoss.class) +public abstract class WitherBossMixin { + @ModifyArgs( + method = "dropCustomDeathLoot", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/boss/wither/WitherBoss;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;" + ) + ) + protected void redirectEquipmentDrop( + Args args, /*? if >=1.21 {*/ ServerLevel serverLevel, DamageSource damageSource, boolean bl /*?} else {*/ /*DamageSource damageSource, int looting, boolean hitByPlayer *//*?}*/ + ) { + ItemLike original = args.get(0); + + if (MixinHelper.entityCustomDeathLootSingle(damageSource, new ItemStack(original))) return; + args.set(0, Items.AIR); + } +} diff --git a/src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java b/src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java new file mode 100644 index 0000000..0c87c0f --- /dev/null +++ b/src/main/java/dev/nyon/telekinesis/utils/MixinHelper.java @@ -0,0 +1,166 @@ +package dev.nyon.telekinesis.utils; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import dev.nyon.telekinesis.DropEvent; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.sounds.SoundSource; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.Shearable; +import net.minecraft.world.entity.player.Player; +/*? if >=1.20.4 {*/ +import net.minecraft.world.entity.vehicle.VehicleEntity; +import net.minecraft.world.item.Item; +/*?}*/ +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import org.apache.commons.lang3.mutable.MutableInt; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +public class MixinHelper { + public static final ThreadLocal threadLocal = new ThreadLocal<>(); + + public static Item modifyExpressionValueOldVehicle(Item original, DamageSource damageSource) { + if (!(damageSource.getEntity() instanceof ServerPlayer player)) return original; + + ArrayList mutableList = new ArrayList<>(List.of(new ItemStack(original))); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, new MutableInt(0), player, player.getMainHandItem()); + + if (mutableList.isEmpty()) return null; + else return original; + } + + public static boolean wrapWithConditionPlayerItemSingle( + ServerPlayer player, + ItemStack item + ) { + ArrayList mutableList = new ArrayList<>(List.of(item)); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, new MutableInt(0), player, player.getMainHandItem()); + + return !mutableList.isEmpty(); + } + + public static int modifyExpressionValuePlayerExp( + ServerPlayer player, + int exp + ) { + MutableInt mutableInt = new MutableInt(exp); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(new ArrayList<>(), mutableInt, player, player.getMainHandItem()); + + return mutableInt.getValue(); + } + + public static boolean entityDropEquipmentSingle( + LivingEntity entity, + ItemStack item + ) { + LivingEntity lastAttacker = entity.getLastAttacker(); + if (!(lastAttacker instanceof ServerPlayer player)) return true; + return wrapWithConditionPlayerItemSingle(player, item); + } + + public static List entityDropEquipmentMultiple( + LivingEntity entity, + List items + ) { + LivingEntity lastAttacker = entity.getLastAttacker(); + if (!(lastAttacker instanceof ServerPlayer player)) return items; + + ArrayList mutableList = new ArrayList<>(items); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, new MutableInt(0), player, player.getMainHandItem()); + + return mutableList; + } + + public static boolean entityCustomDeathLootSingle( + DamageSource source, + ItemStack item + ) { + Entity lastAttacker = source.getEntity(); + if (!(lastAttacker instanceof ServerPlayer player)) return true; + + ArrayList mutableList = new ArrayList<>(List.of(item)); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, + new MutableInt(0), + player, + Objects.requireNonNullElseGet(/*? if >=1.21 {*/source.getWeaponItem() /*?} else {*/ /*player.getMainHandItem() *//*?}*/, player::getMainHandItem) + ); + + return !mutableList.isEmpty(); + } + + public static List entityCustomDeathLootMultiple( + DamageSource source, + List items + ) { + Entity lastAttacker = source.getEntity(); + if (!(lastAttacker instanceof ServerPlayer player)) return items; + + ArrayList mutableList = new ArrayList<>(items); + DropEvent.INSTANCE.getEvent() + .invoker() + .invoke(mutableList, + new MutableInt(0), + player, + Objects.requireNonNullElseGet(/*? if >=1.21 {*/source.getWeaponItem() /*?} else {*/ /*player.getMainHandItem() *//*?}*/, player::getMainHandItem) + ); + + return mutableList; + } + + /*? if >=1.20.4 {*/ + public static void prepareVehicleServerPlayer( + VehicleEntity instance, + Item item, + Operation original, + DamageSource source + ) { + if (!(source.getEntity() instanceof ServerPlayer player)) { + original.call(instance, item); + return; + } + + ServerPlayer previous = threadLocal.get(); + threadLocal.set(player); + try { + original.call(instance, item); + } finally { + threadLocal.set(previous); + } + } + /*?}*/ + + public static void prepareShearableServerPlayer( + Shearable instance, + SoundSource source, + Operation original, + Player _player + ) { + if (!(_player instanceof ServerPlayer player)) { + original.call(instance, source); + return; + } + + ServerPlayer previous = threadLocal.get(); + threadLocal.set(player); + try { + original.call(instance, source); + } finally { + threadLocal.set(previous); + } + } +} diff --git a/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt b/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt new file mode 100644 index 0000000..7f48c5a --- /dev/null +++ b/src/main/kotlin/dev/nyon/telekinesis/DropEvent.kt @@ -0,0 +1,35 @@ +package dev.nyon.telekinesis + +import dev.nyon.telekinesis.config.config +import net.fabricmc.fabric.api.event.Event +import net.fabricmc.fabric.api.event.EventFactory +import net.minecraft.server.level.ServerPlayer +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.enchantment.EnchantmentHelper +import org.apache.commons.lang3.mutable.MutableInt + +object DropEvent { + val event: Event = EventFactory.createArrayBacked(DropEventConsumer::class.java) { listeners -> + DropEventConsumer { items, exp, player, tool -> + listeners.forEach { + it(items, exp, player, tool) + } + } + } + + @Suppress("unused") + private val listener = event.register { items, exp, player, tool -> + if (config.needSneak && !player.isCrouching) return@register + if (config.needEnchantment && /*? if >=1.21 {*/ !EnchantmentHelper.hasTag(tool, telekinesisEffectId)/*?} else {*/ /*EnchantmentHelper.getItemEnchantmentLevel(telekinesis, tool) == 0 *//*?}*/) return@register + + if (config.itemsAllowed) items.removeIf(player::addItem) + if (config.expAllowed) { + player.giveExperiencePoints(exp.value) + exp.setValue(0) + } + } +} + +fun interface DropEventConsumer { + operator fun invoke(items: MutableList, exp: MutableInt, player: ServerPlayer, tool: ItemStack) +} \ No newline at end of file diff --git a/src/main/kotlin/dev/nyon/telekinesis/Main.kt b/src/main/kotlin/dev/nyon/telekinesis/Main.kt new file mode 100644 index 0000000..f02e0c5 --- /dev/null +++ b/src/main/kotlin/dev/nyon/telekinesis/Main.kt @@ -0,0 +1,18 @@ +@file:Suppress("unused") + +package dev.nyon.telekinesis + +import dev.nyon.konfig.config.config +import dev.nyon.konfig.config.loadConfig +import dev.nyon.telekinesis.config.Config +import net.fabricmc.loader.api.FabricLoader +import dev.nyon.telekinesis.config.config as internalConfig + +//? if <=1.20.6 +/*lateinit var telekinesis: TelekinesisEnchantment*/ + +fun init() { + config(FabricLoader.getInstance().configDir.resolve("telekinesis.json"), 1, Config()) { _, _ -> null } + internalConfig = loadConfig() + DropEvent +} diff --git a/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt new file mode 100644 index 0000000..4b38905 --- /dev/null +++ b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt @@ -0,0 +1,54 @@ +package dev.nyon.telekinesis + +import net.minecraft.ChatFormatting +import net.minecraft.network.chat.Component +import net.minecraft.world.item.enchantment.Enchantment +import net.minecraft.world.entity.EquipmentSlot +/*? if >=1.21 {*/ +import net.minecraft.core.registries.Registries +import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey + +val telekinesisEffectId: TagKey = TagKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath("telekinesis", "auto_move")) +val telekinesisEnchantmentId: ResourceLocation = ResourceLocation.fromNamespaceAndPath("telekinesis", "telekinesis") +/*?} elif <1.21 && >=1.20.5 {*/ +/*import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags +*//*?} elif <=1.20.4 {*/ +/*import net.minecraft.world.damagesource.DamageSource +import net.minecraft.world.entity.MobType +import net.minecraft.world.item.enchantment.EnchantmentCategory +*//*?}*/ + + +/*? if =1.20.6 {*/ +/*class TelekinesisEnchantment : Enchantment( + definition( + ConventionalItemTags.TOOLS, + 2, + 1, + dynamicCost(25, 25), + dynamicCost(75, 75), + 7, + EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND + ) +) { + override fun getFullname(i: Int): Component = + Component.translatable("enchantment.telekinesis.telekinesis.name").withStyle(ChatFormatting.GRAY) +} +*//*?} elif <1.20.5 {*/ +/*class TelekinesisEnchantment : Enchantment( + Rarity.RARE, EnchantmentCategory.BREAKABLE, listOf(EquipmentSlot.OFFHAND, EquipmentSlot.MAINHAND).toTypedArray() +) { + override fun getMinLevel(): Int = 1 + override fun getMaxLevel(): Int = 1 + + override fun getMinCost(i: Int): Int = 25 + override fun getMaxCost(i: Int): Int = 75 + + override fun getDamageProtection(i: Int, damageSource: DamageSource): Int = 0 + override fun getDamageBonus(i: Int, mobType: MobType): Float = 0F + + override fun getFullname(i: Int): Component = + Component.translatable("enchantment.telekinesis.telekinesis.name").withStyle(ChatFormatting.GRAY) +} +*//*?}*/ \ No newline at end of file diff --git a/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt new file mode 100644 index 0000000..ad1e007 --- /dev/null +++ b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt @@ -0,0 +1,65 @@ +package dev.nyon.telekinesis + +import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint +import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator +/*? if >=1.21 {*/ +import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput +import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider +import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider.EnchantmentTagProvider +import net.fabricmc.fabric.api.tag.convention.v2.ConventionalItemTags +import net.minecraft.core.HolderLookup +import net.minecraft.core.registries.Registries +import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.entity.EquipmentSlotGroup +import net.minecraft.world.item.enchantment.Enchantment +import net.minecraft.world.item.enchantment.Enchantment.EnchantmentDefinition +import net.minecraft.world.item.enchantment.Enchantment.dynamicCost +import java.util.concurrent.CompletableFuture +/*?}*/ + +class TelekinesisEnchantmentGenerator : DataGeneratorEntrypoint { + override fun onInitializeDataGenerator(generator: FabricDataGenerator) { + /*? if >=1.21 {*/ + val pack = generator.createPack() + + pack.addProvider(::EnchantmentProvider) + pack.addProvider(::TelekinesisEnchantmentTagProvider) + /*?}*/ + } +} + +/*? if >=1.21 {*/ +private class TelekinesisEnchantmentTagProvider( + output: FabricDataOutput, completableFuture: CompletableFuture +) : EnchantmentTagProvider(output, completableFuture) { + override fun addTags(registries: HolderLookup.Provider) { + getOrCreateTagBuilder(telekinesisEffectId).addOptional(telekinesisEnchantmentId) + } +} + +private class EnchantmentProvider( + output: FabricDataOutput, registriesFuture: CompletableFuture +) : FabricDynamicRegistryProvider(output, registriesFuture) { + override fun getName(): String { + return "Telekinesis Enchantment Generation" + } + + override fun configure(registries: HolderLookup.Provider, entries: Entries) { + val enchantmentDefinition: EnchantmentDefinition = Enchantment.definition( + registries.lookupOrThrow(Registries.ITEM).getOrThrow(ConventionalItemTags.TOOLS), + 2, + 1, + dynamicCost(25, 25), + dynamicCost(75, 75), + 7, + EquipmentSlotGroup.HAND + ) + + val enchantment = Enchantment.enchantment(enchantmentDefinition).build( + ResourceLocation.fromNamespaceAndPath("telekinesis", "telekinesis.name") + ) + entries.add(ResourceKey.create(Registries.ENCHANTMENT, telekinesisEnchantmentId), enchantment) + } +} +/*?}*/ \ No newline at end of file diff --git a/src/main/kotlin/dev/nyon/telekinesis/config/Config.kt b/src/main/kotlin/dev/nyon/telekinesis/config/Config.kt new file mode 100644 index 0000000..20e1e65 --- /dev/null +++ b/src/main/kotlin/dev/nyon/telekinesis/config/Config.kt @@ -0,0 +1,13 @@ +package dev.nyon.telekinesis.config + +import kotlinx.serialization.Serializable + +lateinit var config: Config + +@Serializable +data class Config( + var needEnchantment: Boolean = true, + var needSneak: Boolean = false, + var expAllowed: Boolean = true, + var itemsAllowed: Boolean = true +) \ No newline at end of file diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/ModMenuImpl.kt b/src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt similarity index 90% rename from telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/ModMenuImpl.kt rename to src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt index bd2ac2e..c8b6f1c 100644 --- a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/ModMenuImpl.kt +++ b/src/main/kotlin/dev/nyon/telekinesis/config/ModMenuImpl.kt @@ -1,4 +1,4 @@ -package dev.nyon.telekinesis +package dev.nyon.telekinesis.config import com.terraformersmc.modmenu.api.ConfigScreenFactory import com.terraformersmc.modmenu.api.ModMenuApi diff --git a/src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt b/src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt new file mode 100644 index 0000000..d7125c5 --- /dev/null +++ b/src/main/kotlin/dev/nyon/telekinesis/config/TelekinesisConfigScreen.kt @@ -0,0 +1,77 @@ +package dev.nyon.telekinesis.config + +import dev.isxander.yacl3.api.ConfigCategory +import dev.isxander.yacl3.api.Option +import dev.isxander.yacl3.api.OptionDescription +import dev.isxander.yacl3.api.YetAnotherConfigLib +import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder +import dev.nyon.konfig.config.saveConfig +import net.minecraft.client.gui.screens.Screen +import net.minecraft.network.chat.Component + +fun generateConfigScreen(parent: Screen? = null): Screen { + val configScreenBuilder = YetAnotherConfigLib.createBuilder() + configScreenBuilder.title(Component.translatable("menu.telekinesis.name")) + configScreenBuilder.appendOptionCategory() + configScreenBuilder.save { saveConfig(config) } + val configScreen = configScreenBuilder.build() + return configScreen.generateScreen(parent) +} + +fun YetAnotherConfigLib.Builder.appendOptionCategory() { + this.category( + ConfigCategory.createBuilder() + .name(Component.translatable("menu.telekinesis.config.general")) + .option( + Option.createBuilder() + .name(Component.translatable("menu.telekinesis.config.general.needEnchantment")) + .description( + OptionDescription + .of(Component.translatable("menu.telekinesis.config.general.needEnchantment.description")) + ) + .binding(config.needEnchantment, { config.needEnchantment }, { config.needEnchantment = it }) + .controller { + TickBoxControllerBuilder.create(it) + }.build() + ) + .option( + Option.createBuilder() + .name(Component.translatable("menu.telekinesis.config.general.needSneak")) + .description( + OptionDescription + .of( + Component.translatable("menu.telekinesis.config.general.needSneak.description") + ) + ) + .binding(config.needSneak, { config.needSneak }, { config.needSneak = it }) + .controller { + TickBoxControllerBuilder.create(it) + }.build() + ) + .option( + Option.createBuilder() + .name(Component.translatable("menu.telekinesis.config.general.expAllowed")) + .description( + OptionDescription + .of(Component.translatable("menu.telekinesis.config.general.expAllowed.description")) + ) + .binding(config.expAllowed, { config.expAllowed }, { config.expAllowed = it }) + .controller { + TickBoxControllerBuilder.create(it) + }.build() + ) + .option( + Option.createBuilder() + .name(Component.translatable("menu.telekinesis.config.general.itemsAllowed")) + .description( + OptionDescription + .of(Component.translatable("menu.telekinesis.config.general.itemsAllowed.description")) + ) + .binding(config.itemsAllowed, { config.itemsAllowed }, { config.itemsAllowed = it }) + .controller { + TickBoxControllerBuilder.create(it) + }.build() + ) + .build() + ) +} diff --git a/telekinesis-fabric/src/main/resources/assets/telekinesis/icon.png b/src/main/resources/assets/telekinesis/icon.png similarity index 100% rename from telekinesis-fabric/src/main/resources/assets/telekinesis/icon.png rename to src/main/resources/assets/telekinesis/icon.png diff --git a/src/main/resources/assets/telekinesis/lang/de_de.json b/src/main/resources/assets/telekinesis/lang/de_de.json new file mode 100644 index 0000000..97c7972 --- /dev/null +++ b/src/main/resources/assets/telekinesis/lang/de_de.json @@ -0,0 +1,13 @@ +{ + "menu.telekinesis.name": "telekinesis", + "menu.telekinesis.config.general": "Allgemein", + "menu.telekinesis.config.general.needEnchantment": "Ohne Enchantment", + "menu.telekinesis.config.general.needEnchantment.description": "Entscheidet, ob Telekinesis auch ohne das Enchantment funktionieren soll.", + "menu.telekinesis.config.general.needSneak": "Nur beim sneaken", + "menu.telekinesis.config.general.needSneak.description": "Entscheidet, ob Telekinesis nur funktionieren soll, wenn man sneakt.", + "menu.telekinesis.config.general.expAllowed": "XP", + "menu.telekinesis.config.general.expAllowed.description": "Entscheidet, ob Telekinesis für auch für XP Drops funktionieren soll.", + "menu.telekinesis.config.general.itemsAllowed": "Items", + "menu.telekinesis.config.general.itemsAllowed.description": "Entscheidet, ob Telekinesis für auch für Item Drops funktionieren soll.", + "enchantment.telekinesis.telekinesis.name": "Telekinesis" +} \ No newline at end of file diff --git a/src/main/resources/assets/telekinesis/lang/en_us.json b/src/main/resources/assets/telekinesis/lang/en_us.json new file mode 100644 index 0000000..b7d64dd --- /dev/null +++ b/src/main/resources/assets/telekinesis/lang/en_us.json @@ -0,0 +1,13 @@ +{ + "menu.telekinesis.name": "telekinesis", + "menu.telekinesis.config.general": "General", + "menu.telekinesis.config.general.needEnchantment": "Without enchantment", + "menu.telekinesis.config.general.needEnchantment.description": "Decides whether telekinesis should work without the enchantment.", + "menu.telekinesis.config.general.needSneak": "Only while sneaking", + "menu.telekinesis.config.general.needSneak.description": "Decides whether players should have to sneak to use telekinesis.", + "menu.telekinesis.config.general.expAllowed": "Exp drops", + "menu.telekinesis.config.general.expAllowed.description": "Decides whether telekinesis should also work for exp drops.", + "menu.telekinesis.config.general.itemsAllowed": "Items", + "menu.telekinesis.config.general.itemsAllowed.description": "Decides whether telekinesis should also work for item drops.", + "enchantment.telekinesis.telekinesis.name": "Telekinesis" +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..2d38a96 --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,55 @@ +{ + "schemaVersion": 1, + "id": "${id}", + "name": "${name}", + "description": "${description}", + "contact": { + "issues": "https://github.com/btwonion/telekinesis/issues", + "sources": "https://github.com/btwonion/telekinesis" + }, + "icon": "assets/telekinesis/icon.png", + "authors": [ + "btwonion" + ], + "contributors": [], + "license": [ + "GNU General Public License v3.0" + ], + "version": "${version}", + "environment": "*", + "depends": { + "fabric-language-kotlin": ">=1.11.0+kotlin.2.0.0", + "yet_another_config_lib_v3": "*", + "minecraft": "${mc}" + }, + "suggests": { + "modmenu": "*" + }, + "entrypoints": { + "fabric-datagen": [ + "dev.nyon.telekinesis.TelekinesisEnchantmentGenerator" + ], + "main": [ + { + "adapter": "kotlin", + "value": "dev.nyon.telekinesis.MainKt::init" + } + ], + "modmenu": [ + { + "adapter": "kotlin", + "value": "dev.nyon.telekinesis.config.ModMenuImpl" + } + ] + }, + "mixins": [ + "telekinesis.mixins.json" + ], + "custom": { + "modmenu": { + "links": { + "modmenu.discord": "https://discord.gg/pmHTtZnMd3" + } + } + } +} diff --git a/src/main/resources/telekinesis.mixins.json b/src/main/resources/telekinesis.mixins.json new file mode 100644 index 0000000..ae2d138 --- /dev/null +++ b/src/main/resources/telekinesis.mixins.json @@ -0,0 +1,34 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "dev.nyon.telekinesis.mixins", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "AbstractChestedHorseMixin", + "AbstractHorseMixin", + "AbstractMinecartMixin", + "AllayMixin", + "BlockMixin", + "BoatMixin", + "ChestBoatMixin", + "EnchantmentsMixin", + "EnderManMixin", + "FishingHookMixin", + "LivingEntityMixin", + "MinecartTNTMixin", + "MobMixin", + "PiglinMixin", + "PigMixin", + "PlayerMixin", + "SheepMixin", + "SnowGolemMixin", + "SpawnerBlockMixin", + "StriderMixin", + "SweetBerryBushBlockMixin", + "VehicleEntityMixin", + "WitherBossMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} diff --git a/stonecutter.gradle.kts b/stonecutter.gradle.kts new file mode 100644 index 0000000..343f09f --- /dev/null +++ b/stonecutter.gradle.kts @@ -0,0 +1,108 @@ +import kotlinx.serialization.ExperimentalSerializationApi +import kotlinx.serialization.encodeToString +import kotlinx.serialization.json.* +import java.net.URI +import java.net.http.HttpClient +import java.net.http.HttpRequest +import java.net.http.HttpResponse +import java.time.Instant + +plugins { + id("dev.kikugie.stonecutter") +} +stonecutter active "1.21" /* [SC] DO NOT EDIT */ + +stonecutter registerChiseled tasks.register("buildAllVersions", stonecutter.chiseled) { + group = "mod" + ofTask("build") +} + +stonecutter registerChiseled tasks.register("releaseAllVersions", stonecutter.chiseled) { + group = "mod" + ofTask("releaseMod") +} + +private data class Field(val name: String, val value: String, val inline: Boolean) + +private data class Embed( + val title: String, val description: String, val timestamp: String, val color: Int, val fields: List +) + +private data class DiscordWebhook( + val username: String, val avatarUrl: String, val embeds: List +) + +tasks.register("postUpdate") { + group = "mod" + + val version = project(stonecutter.versions.first().project).version.toString() + val hyphenCount = version.count { it == '-' } + val featureVersion = when (hyphenCount) { + 1 -> version.split("-").first() + 2 -> { + val split = version.split("-") + if (split.last().contains("rc") || split.last().contains("pre")) split.first() + else "${split.first()}-${split[1]}" + } + 3 -> { + val split = version.split("-") + "${split.first()}-${split[1]}" + } + else -> return@register + } + + val url = providers.environmentVariable("DISCORD_WEBHOOK").orNull ?: return@register + val changelogText = rootProject.file("changelog.md").readText() + val webhook = DiscordWebhook( + username = "${rootProject.name} Release Notifier", + avatarUrl = "https://raw.githubusercontent.com/btwonion/skylper/master/src/main/resources/assets/skylper/icon/icon.png", + embeds = listOf( + Embed( + title = "v$featureVersion of ${rootProject.name} released!", + description = "# Changelog\n$changelogText", + timestamp = Instant.now().toString(), + color = 0xff0080, + fields = listOf( + Field( + "Supported versions", stonecutter.versions.joinToString { it.version }, false + ), + Field("Modrinth", "https://modrinth.com/mod/telekinesis", true), + Field("GitHub", "https://github.com/btwonion/telekinesis", true) + ), + ) + ) + ) + + @OptIn(ExperimentalSerializationApi::class) + val embedsJson = buildJsonArray { + webhook.embeds.map { embed -> + add(buildJsonObject { + put("title", embed.title) + put("description", embed.description) + put("timestamp", embed.timestamp) + put("color", embed.color) + putJsonArray("fields") { + addAll(embed.fields.map { field -> + buildJsonObject { + put("name", field.name) + put("value", field.value) + put("inline", field.inline) + } + }) + } + }) + } + } + + val json = buildJsonObject { + put("username", webhook.username) + put("avatar_url", webhook.avatarUrl) + put("embeds", embedsJson) + } + + val jsonString = Json.encodeToString(json) + HttpClient.newHttpClient().send( + HttpRequest.newBuilder(URI.create(url)).header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(jsonString)).build(), HttpResponse.BodyHandlers.ofString() + ) +} diff --git a/telekinesis-fabric/build.gradle.kts b/telekinesis-fabric/build.gradle.kts deleted file mode 100644 index 4a99bf2..0000000 --- a/telekinesis-fabric/build.gradle.kts +++ /dev/null @@ -1,216 +0,0 @@ -@file:Suppress("SpellCheckingInspection") - -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import kotlin.io.path.readText - -plugins { - kotlin("jvm") version "1.9.24" - kotlin("plugin.serialization") version "1.9.24" - id("fabric-loom") version "1.6-SNAPSHOT" - - id("me.modmuss50.mod-publish-plugin") version "0.5.+" - - `maven-publish` - signing -} - -val featureVersion = "2.4.1" -val mcVersion = property("mcVersion")!!.toString() -val mcVersionRange = property("mcVersionRange")!!.toString() -version = "$featureVersion-$mcVersion" - -group = "dev.nyon" -val projectAuthors = listOf("btwonion") -val githubRepo = "btwonion/telekinesis" - -loom { - if (stonecutter.current.isActive) { - runConfigs.all { - ideConfigGenerated(true) - runDir("../../run") - } - - project.tasks.register("runActive") { - group = "mod" - - dependsOn(tasks.named("runClient")) - } - } - - mixin { useLegacyMixinAp = false } - - accessWidenerPath = file("../../src/main/resources/telekinesis.accesswidener") -} - -repositories { - mavenCentral() - exclusiveContent { - forRepository { - maven("https://api.modrinth.com/maven") - } - filter { - includeGroup("maven.modrinth") - } - } - maven("https://maven.terraformersmc.com") - maven("https://maven.parchmentmc.org") - maven("https://repo.nyon.dev/releases") - maven("https://maven.isxander.dev/releases") - maven("https://oss.sonatype.org/content/repositories/snapshots/") - maven("https://jitpack.io") -} - -dependencies { - minecraft("com.mojang:minecraft:$mcVersion") - mappings( - loom.layered { - parchment("org.parchmentmc.data:parchment-${property("deps.parchment")}@zip") - officialMojangMappings() - } - ) - - implementation("org.vineflower:vineflower:1.10.1") - modImplementation("net.fabricmc:fabric-loader:0.15.11") - modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}") - modImplementation("net.fabricmc:fabric-language-kotlin:1.10.20+kotlin.1.9.24") - - modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}") - modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}") - - include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.1.1")!!)!!) - - include(implementation("com.akuleshov7:ktoml-core-jvm:0.5.1")!!) - - // Integration - // modCompileOnly("maven.modrinth:abooMhox:c2klaSgQ") // tree-harvester by ricksouth wait for 1.20.5 - // modCompileOnly("maven.modrinth:MpzVLzy5:9kJblF2V") // better nether by quickueck wait for 1.20.5 - // modCompileOnly("maven.modrinth:EFtixeiF:Gcai736Z") // levelz by Globox1997 wait for 1.20.5 -} - -val javaVersion = property("javaVer")!!.toString() -tasks { - processResources { - val modId = "telekinesis" - val modName = "telekinesis" - val modDescription = "Adds a telekinesis enchantment to minecraft" - - val props = - mapOf( - "id" to modId, - "name" to modName, - "description" to modDescription, - "version" to project.version, - "github" to githubRepo, - "mc" to mcVersionRange - ) - - props.forEach(inputs::property) - - filesMatching("fabric.mod.json") { - expand(props) - } - } - - register("releaseMod") { - group = "publishing" - - dependsOn("publishMods") - dependsOn("publish") - } - - withType { - options.release = javaVersion.toInt() - } - - withType { - kotlinOptions.jvmTarget = javaVersion - } -} - -val changelogText = - buildString { - append("# v${project.version}\n") - file("../../../changelog.md").readText().also { append(it) } - } - -val supportedMcVersions: List = property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty) - -publishMods { - displayName = "v${project.version}" - file = tasks.remapJar.get().archiveFile - changelog = changelogText - type = STABLE - modLoaders.addAll("fabric", "quilt") - - modrinth { - projectId = "LLfA8jAD" - accessToken = providers.environmentVariable("MODRINTH_API_KEY") - minecraftVersions.addAll(supportedMcVersions) - - requires { slug = "fabric-api" } - requires { slug = "yacl" } - requires { slug = "fabric-language-kotlin" } - optional { slug = "modmenu" } - } - - github { - repository = githubRepo - accessToken = providers.environmentVariable("GITHUB_TOKEN") - commitish = "master" - } - - discord { - webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK") - username = "Release Notifier" - content = "# A new version of Telekinesis released!\n$changelogText" - } -} - -publishing { - repositories { - maven { - name = "nyon" - url = uri("https://repo.nyon.dev/releases") - credentials { - username = providers.environmentVariable("NYON_USERNAME").orNull - password = providers.environmentVariable("NYON_PASSWORD").orNull - } - } - } - publications { - create("maven") { - groupId = "dev.nyon" - artifactId = "telekinesis" - version = project.version.toString() - from(components["java"]) - } - } -} - -java { - withSourcesJar() - - javaVersion.toInt() - .let { JavaVersion.values()[it - 1] } - .let { - sourceCompatibility = it - targetCompatibility = it - } -} - -kotlin { - jvmToolchain(javaVersion.toInt()) -} - -/* -signing { - val signingKey: String? by project - val signingPassword: String? by project - useGpgCmd() - if (signingKey != null && signingPassword != null) { - useInMemoryPgpKeys(signingKey, signingPassword) - } - sign(publishing.publications) -} - */ - diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java deleted file mode 100644 index 96d49d8..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AbstractMinecartMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import net.minecraft.world.entity.vehicle.AbstractMinecart; -import org.spongepowered.asm.mixin.Mixin; - -/*? <=1.20.2 {*/ -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.injection.At; -/*?}*/ - -@Mixin(AbstractMinecart.class) -public class AbstractMinecartMixin { - - /*? <=1.20.2 {*/ - @WrapWithCondition(method = "destroy", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/vehicle/AbstractMinecart;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" - )) - private boolean redirectMinecartDrops( - AbstractMinecart instance, - ItemStack itemStack, - DamageSource damageSource - ) { - if (!(damageSource.getEntity() instanceof LivingEntity livingEntity)) return true; - return EntityUtils.spawnAtLocationAttacker(livingEntity, itemStack); - } - /*?}*/ -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java deleted file mode 100644 index 05abdff..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/AllayMixin.java +++ /dev/null @@ -1,65 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.EntityUtils; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.animal.allay.Allay; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; -import java.util.function.Consumer; - -@Mixin(Allay.class) -public class AllayMixin { - - @Unique - final Allay allay = (Allay) (Object) this; - - @WrapWithCondition( - method = "dropEquipment", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/animal/allay/Allay;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" - ) - ) - public boolean redirectEquipmentDrop( - Allay instance, - ItemStack stack - ) { - return EntityUtils.spawnAtLocationInject(instance, stack); - } - - @Redirect( - method = "dropEquipment", - at = @At( - value = "INVOKE", - target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V" - ) - ) - public void redirectInventoryDrops( - List instance, - Consumer consumer - ) { - final var attacker = allay.getLastAttacker(); - if (!(attacker instanceof ServerPlayer serverPlayer)) { - instance.forEach(consumer); - return; - } - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.MobDrops, - serverPlayer, - serverPlayer.getMainHandItem(), - player -> instance.forEach(item -> { - if (!player.addItem(item)) consumer.accept(item); - }) - ); - - if (!hasTelekinesis) instance.forEach(consumer); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java deleted file mode 100644 index 37695ad..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/BlockMixin.java +++ /dev/null @@ -1,89 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.PlayerUtils; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.util.valueproviders.ConstantInt; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.EnchantmentHelper; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.*; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -import java.util.function.Consumer; - -@Mixin(Block.class) -public abstract class BlockMixin { - - @ModifyArgs( - method = "dropResources(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)V", - at = @At( - value = "INVOKE", - target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V" - ) - ) - private static void redirectDrops( - Args args, - BlockState blockState, - Level level, - BlockPos blockPos, - @Nullable BlockEntity blockEntity, - @Nullable Entity entity, - ItemStack itemStack - ) { - args.>set(0, item -> { - if (!TelekinesisUtils.handleTelekinesisBlock(TelekinesisPolicy.BlockDrops, entity, itemStack, player -> { - if (!player.addItem(item)) Block.popResource(level, blockPos, item); - })) Block.popResource(level, blockPos, item); - }); - } - - @Inject( - method = "dropResources(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/item/ItemStack;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/level/block/state/BlockState;spawnAfterBreak(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;Z)V" - ), - cancellable = true - ) - private static void manipulateDrops( - BlockState blockState, - Level level, - BlockPos blockPos, - BlockEntity blockEntity, - Entity entity, - ItemStack itemStack, - CallbackInfo ci - ) { - if (!(level instanceof ServerLevel serverLevel)) return; - Block block = blockState.getBlock(); - if (EnchantmentHelper.hasSilkTouch(itemStack)) return; - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesisBlock(TelekinesisPolicy.ExpDrops, entity, itemStack, player -> { - int expToAdd = 0; - if (block instanceof DropExperienceBlock expBlock) expToAdd = ((DropExperienceBlockAccessor) expBlock).getXpRange() - .sample(level.random); - if (block instanceof RedStoneOreBlock) expToAdd = 1 + level.random.nextInt(5); - if (block instanceof SculkCatalystBlock catalystBlock) expToAdd = ((CatalystBlockAccessor) catalystBlock).getXpRange() - .sample(level.random); - if (block instanceof SculkSensorBlock || block instanceof SculkShriekerBlock) expToAdd = ConstantInt.of(5) - .sample(level.random); - if (block instanceof SpawnerBlock) expToAdd = level.random.nextInt(15) + level.random.nextInt(15); - if (block instanceof InfestedBlock infestedBlock) - infestedBlock.spawnAfterBreak(blockState, serverLevel, blockPos, itemStack, true); - PlayerUtils.addExpToPlayer(player, expToAdd); - }); - - if (hasTelekinesis) ci.cancel(); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/CatalystBlockAccessor.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/CatalystBlockAccessor.java deleted file mode 100644 index cf5a0f8..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/CatalystBlockAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import net.minecraft.util.valueproviders.IntProvider; -import net.minecraft.world.level.block.SculkCatalystBlock; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(SculkCatalystBlock.class) -public interface CatalystBlockAccessor { - - @Accessor - IntProvider getXpRange(); -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java deleted file mode 100644 index 0fd5b5b..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/ChestBoatMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import net.minecraft.world.entity.vehicle.ChestBoat; -import org.spongepowered.asm.mixin.Mixin; - -/*? if >1.20.2 {*//* -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import dev.nyon.telekinesis.utils.EntityUtils; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.item.Item; -import org.spongepowered.asm.mixin.injection.At; - *//*?}*/ - -@Mixin(ChestBoat.class) -public class ChestBoatMixin { - - /*? if >1.20.2 {*//* - @ModifyExpressionValue( - method = "destroy(Lnet/minecraft/world/damagesource/DamageSource;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/vehicle/ChestBoat;getDropItem()Lnet/minecraft/world/item/Item;" - ) - ) - private Item changeDroppedItem( - Item original, - DamageSource damageSource - ) { - return EntityUtils.getDropItemInject(original, damageSource); - } - *//*?}*/ -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/DropExperienceBlockAccessor.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/DropExperienceBlockAccessor.java deleted file mode 100644 index 4220a5b..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/DropExperienceBlockAccessor.java +++ /dev/null @@ -1,13 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import net.minecraft.util.valueproviders.IntProvider; -import net.minecraft.world.level.block.DropExperienceBlock; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(DropExperienceBlock.class) -public interface DropExperienceBlockAccessor { - - @Accessor - IntProvider getXpRange(); -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java deleted file mode 100644 index 1a0fca9..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/FishingHookMixin.java +++ /dev/null @@ -1,64 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.PlayerUtils; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.ExperienceOrb; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.FishingHook; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(FishingHook.class) -public abstract class FishingHookMixin { - - @Shadow - @Nullable - public abstract Player getPlayerOwner(); - - @WrapWithCondition( - method = "retrieve", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z" - ) - ) - private boolean redirectFishingHookDrops( - Level instance, - Entity entity, - ItemStack stack - ) { - if (!(getPlayerOwner() instanceof ServerPlayer _serverPlayer)) return true; - - if (entity instanceof ExperienceOrb expOrb) { - final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - _serverPlayer, - stack, - serverPlayer -> PlayerUtils.addExpToPlayer(serverPlayer, expOrb.getValue()) - ); - - return !hasTelekinesis; - } - - if (entity instanceof ItemEntity itemEntity) { - final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.FishingDrops, - _serverPlayer, - stack, - serverPlayer -> { - if (!serverPlayer.addItem(itemEntity.getItem())) instance.addFreshEntity(itemEntity); - } - ); - - return !hasTelekinesis; - } - return true; - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/InventoryMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/InventoryMixin.java deleted file mode 100644 index d2b7c47..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/InventoryMixin.java +++ /dev/null @@ -1,29 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; -import net.minecraft.world.entity.player.Inventory; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(Inventory.class) -public class InventoryMixin { - - @WrapWithCondition( - method = "dropAll", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/player/Player;drop(Lnet/minecraft/world/item/ItemStack;ZZ)Lnet/minecraft/world/entity/item/ItemEntity;" - ) - ) - public boolean redirectEquipmentDrop( - Player instance, - ItemStack stack, - boolean throwRandomly, - boolean retainOwnership - ) { - return EntityUtils.spawnAtLocationInject(instance, stack); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java deleted file mode 100644 index 03b1f98..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/LivingEntityMixin.java +++ /dev/null @@ -1,71 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.PlayerUtils; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArgs; -import org.spongepowered.asm.mixin.injection.invoke.arg.Args; - -import java.util.function.Consumer; - -@Mixin(LivingEntity.class) -public abstract class LivingEntityMixin { - - @Unique - final LivingEntity livingEntity = (LivingEntity) (Object) this; - - @WrapWithCondition( - method = "dropExperience", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/ExperienceOrb;award(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V" - ) - ) - public boolean redirectExp( - ServerLevel world, - Vec3 pos, - int amount - ) { - final var attacker = livingEntity.getLastAttacker(); - if (!(attacker instanceof ServerPlayer serverPlayer)) return true; - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - serverPlayer, - serverPlayer.getMainHandItem(), - player -> PlayerUtils.addExpToPlayer(player, amount) - ); - - return !hasTelekinesis; - } - - @ModifyArgs( - method = "dropFromLootTable", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/level/storage/loot/LootTable;getRandomItems(Lnet/minecraft/world/level/storage/loot/LootParams;JLjava/util/function/Consumer;)V" - ) - ) - public void redirectCommonDrops( - Args args, - DamageSource damageSource, - boolean bl - ) { - args.>set(2, item -> { - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.MobDrops, damageSource, player -> { - if (!player.addItem(item)) livingEntity.spawnAtLocation(item); - }); - - if (!hasTelekinesis) livingEntity.spawnAtLocation(item); - }); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecraftServerMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecraftServerMixin.java deleted file mode 100644 index 64420eb..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MinecraftServerMixin.java +++ /dev/null @@ -1,24 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import dev.nyon.telekinesis.MainKt; -import net.minecraft.server.MinecraftServer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(MinecraftServer.class) -public class MinecraftServerMixin { - - @Inject( - method = "runServer", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/server/MinecraftServer;initServer()Z", - shift = At.Shift.BEFORE - ) - ) - private void onBeforeInit(CallbackInfo ci) { - MainKt.setServer((MinecraftServer) (Object) this); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java deleted file mode 100644 index a224ec3..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/MobMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.utils.EntityUtils; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Mob; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(Mob.class) -public class MobMixin { - - @WrapWithCondition( - method = "dropCustomDeathLoot", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Mob;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;" - ) - ) - public boolean redirectEquipmentDrop( - Mob instance, - ItemStack stack, - DamageSource damageSource, - int lootingMultiplier, - boolean allowDrops - ) { - return EntityUtils.spawnAtLocationInject(instance, stack); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java deleted file mode 100644 index a57939f..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/PiglinMixin.java +++ /dev/null @@ -1,43 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.monster.piglin.Piglin; -import net.minecraft.world.item.ItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.List; -import java.util.function.Consumer; - -@Mixin(Piglin.class) -public class PiglinMixin { - - @Redirect( - method = "dropCustomDeathLoot", - at = @At( - value = "INVOKE", - target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V" - ) - ) - public void redirectDrops( - List instance, - Consumer consumer, - DamageSource damageSource, - int i, - boolean bl - ) { - var piglin = (Piglin) (Object) this; - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.MobDrops, - damageSource, - player -> instance.forEach(item -> { - if (!player.addItem(item)) piglin.spawnAtLocation(item); - }) - ); - - if (!hasTelekinesis) instance.forEach(piglin::spawnAtLocation); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java deleted file mode 100644 index 304a1c5..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SheepMixin.java +++ /dev/null @@ -1,92 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.util.RandomSource; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.animal.Sheep; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.DyeColor; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.ItemLike; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.Map; - -@Mixin(Sheep.class) -public abstract class SheepMixin { - - @Shadow - @Final - private static Map ITEM_BY_DYE; - @Unique - private final RandomSource random = RandomSource.create(); - - - @Redirect( - method = "mobInteract", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/animal/Sheep;shear(Lnet/minecraft/sounds/SoundSource;)V" - ) - ) - public void manipulateWoolDrops( - Sheep instance, - SoundSource soundSource, - Player player, - InteractionHand interactionHand - ) { - instance.level() - .playSound(null, instance, SoundEvents.SHEEP_SHEAR, soundSource, 1.0F, 1.0F); - instance.setSheared(true); - int i = 1 + random.nextInt(3); - - if (!(player instanceof ServerPlayer serverPlayerr)) { - dropAllNormally(i, instance); - return; - } - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ShearingDrops, - serverPlayerr, - player.getItemInHand(interactionHand), - serverPlayer -> { - for (int j = 0; j < i; ++j) { - if (!serverPlayer.addItem(new ItemStack(ITEM_BY_DYE.get(instance.getColor()), 1))) { - ItemEntity entity = instance.spawnAtLocation(ITEM_BY_DYE.get(instance.getColor()), 1); - entity.setDeltaMovement(entity.getDeltaMovement() - .add((random.nextFloat() - random.nextFloat()) * 0.1F, - random.nextFloat() * 0.05F, - (random.nextFloat() - random.nextFloat()) * 0.1F - )); - } - } - } - ); - - if (!hasTelekinesis) dropAllNormally(i, instance); - } - - @Unique - void dropAllNormally( - int i, - Sheep instance - ) { - for (int j = 0; j < i; ++j) { - ItemEntity entity = instance.spawnAtLocation(ITEM_BY_DYE.get(instance.getColor()), 1); - entity.setDeltaMovement(entity.getDeltaMovement() - .add((random.nextFloat() - random.nextFloat()) * 0.1F, - random.nextFloat() * 0.05F, - (random.nextFloat() - random.nextFloat()) * 0.1F - )); - } - } -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SnowgolemMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SnowgolemMixin.java deleted file mode 100644 index 574a010..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SnowgolemMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.sounds.SoundEvents; -import net.minecraft.sounds.SoundSource; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.animal.SnowGolem; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -@Mixin(SnowGolem.class) -public class SnowgolemMixin { - - @Redirect( - method = "mobInteract", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/animal/SnowGolem;shear(Lnet/minecraft/sounds/SoundSource;)V" - ) - ) - public void manipulateWoolDrops( - SnowGolem instance, - SoundSource soundSource, - Player player, - InteractionHand interactionHand - ) { - instance.level() - .playSound(null, instance, SoundEvents.SNOW_GOLEM_SHEAR, soundSource, 1.0F, 1.0F); - if (!instance.level() - .isClientSide()) { - instance.setPumpkin(false); - - ItemStack item = new ItemStack(Items.CARVED_PUMPKIN); - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ShearingDrops, player, serverPlayer -> { - if (!serverPlayer.addItem(item)) instance.spawnAtLocation(item, 1.7F); - }); - - if (!hasTelekinesis) instance.spawnAtLocation(item, 1.7F); - } - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java deleted file mode 100644 index fd40d74..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/SweetBerryBushBlockMixin.java +++ /dev/null @@ -1,83 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.SweetBerryBushBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(SweetBerryBushBlock.class) -public class SweetBerryBushBlockMixin { - /*? >1.20.5 {*//* - @WrapWithCondition( - method = "useWithoutItem", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/level/block/SweetBerryBushBlock;popResource(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V" - ) - ) - private boolean manipulateBerryDrops( - Level level, - BlockPos blockPos, - ItemStack itemStack, - BlockState blockState, - Level _level, - BlockPos _blockPos, - Player player, - BlockHitResult blockHitResult - ) { - if (!(player instanceof ServerPlayer serverPlayer)) return true; - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.BlockDrops, - serverPlayer, - serverPlayer.getMainHandItem(), - cPlayer -> { - if (!player.addItem(itemStack)) Block.popResource(level, blockPos, itemStack); - } - ); - - return !hasTelekinesis; - } - *//*?} else {*/ - @WrapWithCondition( - method = "use", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/level/block/SweetBerryBushBlock;popResource(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V" - ) - ) - private boolean manipulateBerryDrops( - Level level, - BlockPos blockPos, - ItemStack itemStack, - BlockState state, - Level _level, - BlockPos pos, - Player player, - InteractionHand hand, - BlockHitResult hit - ) { - if (!(player instanceof ServerPlayer serverPlayer)) return true; - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.BlockDrops, - serverPlayer, - serverPlayer.getMainHandItem(), - cPlayer -> { - if (!player.addItem(itemStack)) Block.popResource(level, blockPos, itemStack); - } - ); - - return !hasTelekinesis; - } - /*?}*/ -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java deleted file mode 100644 index 7f44166..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/VehicleEntityMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import dev.nyon.telekinesis.utils.EntityUtils; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.item.Item; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; - -@Pseudo -@Mixin(targets = "net.minecraft.world.entity.vehicle.VehicleEntity") -public class VehicleEntityMixin { - - @ModifyExpressionValue( - method = "destroy(Lnet/minecraft/world/damagesource/DamageSource;)V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/vehicle/VehicleEntity;getDropItem()Lnet/minecraft/world/item/Item;" - ) - ) - private Item changeDroppedItem( - Item original, - DamageSource damageSource - ) { - return EntityUtils.getDropItemInject(original, damageSource); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java deleted file mode 100644 index 996ef00..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/WitherBossMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -package dev.nyon.telekinesis.mixins; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import dev.nyon.telekinesis.TelekinesisPolicy; -import dev.nyon.telekinesis.utils.TelekinesisUtils; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.item.ItemEntity; -import net.minecraft.world.level.ItemLike; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(WitherBoss.class) -public abstract class WitherBossMixin { - @WrapOperation( - method = "dropCustomDeathLoot", - at = @At( - value = "INVOKE", - target = "net/minecraft/world/entity/boss/wither/WitherBoss.spawnAtLocation (Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;" - ) - ) - protected ItemEntity redirectEquipmentDrop( - WitherBoss instance, - ItemLike stack, - Operation original - ) { - final var attacker = instance.getLastAttacker(); - if (!(attacker instanceof ServerPlayer serverPlayer)) return original.call(instance, stack); - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.MobDrops, serverPlayer, null, player -> { - if (!player.addItem(stack.asItem() - .getDefaultInstance())) instance.spawnAtLocation(stack); - }); - - if (!hasTelekinesis) return original.call(instance, stack); - else return null; - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/BetterNetherMixinPlugin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/BetterNetherMixinPlugin.java deleted file mode 100644 index c72730d..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/BetterNetherMixinPlugin.java +++ /dev/null @@ -1,60 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.betternether; - -import net.fabricmc.loader.api.FabricLoader; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; - -@SuppressWarnings("unused") -public class BetterNetherMixinPlugin implements IMixinConfigPlugin { - @Override - public void onLoad(String mixinPackage) { - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin( - String targetClassName, - String mixinClassName - ) { - return FabricLoader.getInstance() - .isModLoaded("betternether"); - } - - @Override - public void acceptTargets( - Set myTargets, - Set otherTargets - ) { - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply( - String targetClassName, - ClassNode targetClass, - String mixinClassName, - IMixinInfo mixinInfo - ) { - } - - @Override - public void postApply( - String targetClassName, - ClassNode targetClass, - String mixinClassName, - IMixinInfo mixinInfo - ) { - } -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/RubyFireMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/RubyFireMixin.java deleted file mode 100644 index 9322d91..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/betternether/RubyFireMixin.java +++ /dev/null @@ -1,99 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.betternether; - -/* - * @Pseudo - * @Mixin(targets = "org.betterx.betternether.enchantments.RubyFire") - * public class RubyFireMixin { - * @WrapWithCondition( method = "getDrops", - * at = @At( - * value = "INVOKE", - * target = "Lorg/betterx/betternether/enchantments/RubyFire;popExperience(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;I)V" - * ) - * ) - * private static boolean redirectExp( - * ServerLevel level, - * BlockPos blockPos, - * int amount, - * BlockState brokenBlock, - * ServerLevel level1, - * BlockPos blockPos1, - * Player player, - * ItemStack breakingItem - * ) { - * if (!(player instanceof ServerPlayer _serverPlayer)) return true; - * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis( - * TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * breakingItem, - * serverPlayer -> PlayerUtils.addExpToPlayer(serverPlayer, amount)); - * return !hasTelekinesis; - * } - * @Redirect( method = "getDrops", - * at = @At( - * value = "INVOKE", - * target = "Ljava/util/List;forEach(Ljava/util/function/Consumer;)V" - * ) - * ) - * private static void redirectCommonDrops( - * List instance, Consumer consumer, BlockState brokenBlock, ServerLevel level, BlockPos blockPos, Player player, ItemStack breakingItem - * ) { - * if (!(player instanceof ServerPlayer _serverPlayer)) { - * instance.forEach(consumer); - * return; - * } - * boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis( - * TelekinesisPolicy.MobDrops, - * _serverPlayer, - * breakingItem, - * serverPlayer -> instance.forEach(item -> { - * if (!serverPlayer.addItem(item)) consumer.accept(item); - * }) - * ); - *

- * if (!hasTelekinesis) instance.forEach(consumer); - * } - * @WrapWithCondition( method = "getDrops", - * at = @At( - * value = "INVOKE", - * target = "Lnet/minecraft/world/level/block/state/BlockState;spawnAfterBreak(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;Z)V" - * ) - * ) - * private static boolean redirectAfterDrops( - * BlockState instance, - * ServerLevel world, - * BlockPos pos, - * ItemStack tool, - * boolean dropExperience, - * BlockState brokenBlock, - * ServerLevel level, - * BlockPos blockPos, - * Player _player, - * ItemStack breakingItem - * ) { - * if (!(_player instanceof ServerPlayer _serverPlayer)) return true; - *

- * Block block = brokenBlock.getBlock(); - * if (EnchantmentHelper.hasSilkTouch(breakingItem)) return true; - * boolean hasTelekinesis = TelekinesisUtils.handleTelekinesisBlock( - * TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * breakingItem, - * player -> { - * int expToAdd = 0; - * if (block instanceof DropExperienceBlock expBlock) - * expToAdd = ((DropExperienceBlockAccessor) expBlock).getXpRange().sample(level.random); - * if (block instanceof RedStoneOreBlock) expToAdd = 1 + level.random.nextInt(5); - * if (block instanceof SculkCatalystBlock catalystBlock) - * expToAdd = ((CatalystBlockAccessor) catalystBlock).getXpRange().sample(level.random); - * if (block instanceof SculkSensorBlock || block instanceof SculkShriekerBlock) - * expToAdd = ConstantInt.of(5).sample(level.random); - * if (block instanceof SpawnerBlock) expToAdd = level.random.nextInt(15) + level.random.nextInt(15); - * if (block instanceof InfestedBlock infestedBlock) - * infestedBlock.spawnAfterBreak(brokenBlock, level, blockPos, breakingItem, true); - * PlayerUtils.addExpToPlayer(player, expToAdd); - * }); - *

- * return !hasTelekinesis; - * } - * } - */ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/BlockMixinMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/BlockMixinMixin.java deleted file mode 100644 index 70f155f..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/BlockMixinMixin.java +++ /dev/null @@ -1,88 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* -@Pseudo -@Mixin( - value = Block.class, - priority = 1500 -) -public abstract class BlockMixinMixin { - @Unique - private static @Nullable ServerPlayer serverPlayer; - - @TargetHandler( - mixin = "net.levelz.mixin.block.BlockMixin", - name = "getDroppedStacksMixin" - ) - @WrapWithCondition( - method = "@MixinSquared:Handler", - at = @At( - value = "INVOKE", - target = "net/minecraft/world/level/block/Block.popResource (Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V" - ) - ) - private static boolean redirectDroppedStacks( - Level world, - BlockPos pos, - ItemStack stack, - BlockState state, - ServerLevel world1, - BlockPos pos1, - @Nullable BlockEntity blockEntity, - @Nullable Entity entity, - ItemStack tool, - CallbackInfoReturnable> info, - LootParams.Builder builder - ) { - if (!(entity instanceof ServerPlayer _serverPlayer)) return true; - final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.BlockDrops, - _serverPlayer, - tool, - serverPlayer -> { - if (!_serverPlayer.addItem(stack)) Block.popResource(world, pos, stack); - } - ); - return !hasTelekinesis; - } - - @TargetHandler( - mixin = "net.levelz.mixin.block.BlockMixin", - name = "dropExperienceMixin" - ) - @WrapWithCondition( - method = "@MixinSquared:Handler", - at = @At( - value = "INVOKE", - target = "net/levelz/entity/LevelExperienceOrbEntity.spawn (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V" - ) - ) - private static boolean redirectExp( - ServerLevel world, - Vec3 pos, - int amount - ) { - final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - serverPlayer, - null, - serverPlayer -> ((PlayerSyncAccess) serverPlayer).addLevelExperience(amount) - ); - return !hasTelekinesis; - } - - @Inject( - method = "playerWillDestroy", - at = { @At("HEAD") } - ) - private void onDestroy( - Level world, - BlockPos pos, - BlockState state, - Player player, - CallbackInfo info - ) { - if (!world.isClientSide) { - serverPlayer = (ServerPlayer) player; - } - } -} -*/ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/EnderDragonEntityMixinMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/EnderDragonEntityMixinMixin.java deleted file mode 100644 index 4d19f98..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/EnderDragonEntityMixinMixin.java +++ /dev/null @@ -1,55 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* - * @Pseudo - * @Mixin( value = EnderDragon.class, - * priority = 1500 - * ) - * public class EnderDragonEntityMixinMixin { - * @Unique final EnderDragon instance = (EnderDragon) (Object) this; - * @TargetHandler( mixin = "net.levelz.mixin.entity.EnderDragonEntityMixin", - * name = "updatePostDeathMixin" - * ) - * @WrapWithCondition( method = "@MixinSquared:Handler", - * at = @At( - * value = "INVOKE", - * target = "net/levelz/entity/LevelExperienceOrbEntity.spawn (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V" - * ) - * ) - * private boolean redirectExp( - * ServerLevel world, - * Vec3 pos, - * int amount - * ) { - * if (!(instance.getLastAttacker() instanceof ServerPlayer _serverPlayer)) return true; - * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * null, - * serverPlayer -> ((PlayerSyncAccess) serverPlayer).addLevelExperience(amount) - * ); - * return !hasTelekinesis; - * } - * @TargetHandler( mixin = "net.levelz.mixin.entity.EnderDragonEntityMixin", - * name = "updatePostDeathXPMixin" - * ) - * @WrapWithCondition( method = "@MixinSquared:Handler", - * at = @At( - * value = "INVOKE", - * target = "net/levelz/entity/LevelExperienceOrbEntity.spawn (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V" - * ) - * ) - * private boolean redirectExp1( - * ServerLevel world, - * Vec3 pos, - * int amount - * ) { - * if (!(instance.getLastAttacker() instanceof ServerPlayer _serverPlayer)) return true; - * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * null, - * serverPlayer -> ((PlayerSyncAccess) serverPlayer).addLevelExperience(amount) - * ); - * return !hasTelekinesis; - * } - * } - */ diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/FishingBobberEntityMixinMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/FishingBobberEntityMixinMixin.java deleted file mode 100644 index 39235fd..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/FishingBobberEntityMixinMixin.java +++ /dev/null @@ -1,36 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* - * @Pseudo - * @Mixin( value = FishingHook.class, - * priority = 1500 - * ) - * public abstract class FishingBobberEntityMixinMixin { - * @Shadow - * @Nullable public abstract Player getPlayerOwner(); - * @TargetHandler( mixin = "net.levelz.mixin.entity.FishingBobberEntityMixin", - * name = "useMixin" - * ) - * @WrapWithCondition( method = "@MixinSquared:Handler", - * at = @At( - * value = "INVOKE", - * target = "net/levelz/entity/LevelExperienceOrbEntity.spawn (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V" - * ) - * ) - * private boolean redirectExp( - * ServerLevel world, - * Vec3 pos, - * int amount, - * ItemStack usedItem, - * CallbackInfoReturnable info - * ) { - * if (!(getPlayerOwner() instanceof ServerPlayer _serverPlayer)) return true; - * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * usedItem, - * serverPlayer -> ((PlayerSyncAccess) serverPlayer).addLevelExperience(amount) - * ); - * return !hasTelekinesis; - * } - * } - */ diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbAccessor.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbAccessor.java deleted file mode 100644 index b070c36..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbAccessor.java +++ /dev/null @@ -1,9 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* - * @Pseudo - * @Mixin(LevelExperienceOrbEntity.class) public interface LevelExperienceOrbAccessor { - * @Accessor Player getTarget(); - * @Invoker("getClumpedMap") Map invokeGetClumpedMap(); - * } - */ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbEntityMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbEntityMixin.java deleted file mode 100644 index 2e62593..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelExperienceOrbEntityMixin.java +++ /dev/null @@ -1,34 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* - * @Pseudo - * @Mixin(net.levelz.entity.LevelExperienceOrbEntity.class) public class LevelExperienceOrbEntityMixin { - * @WrapWithCondition( method = "spawn", - * at = @At( - * value = "INVOKE", - * target = "Lnet/minecraft/server/level/ServerLevel;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z" - * ) - * ) - * private static boolean redirectSpawnOnTelekinesis( - * ServerLevel level, - * Entity entity - * ) { - * if (!(entity instanceof LevelExperienceOrbEntity expOrb)) return true; - *

- * Player target = ((LevelExperienceOrbAccessor) expOrb).getTarget(); - * if (target == null || target.distanceToSqr(expOrb) > 64.0) { - * target = level.getNearestPlayer(expOrb, 8.0); - * } - * if (!(target instanceof ServerPlayer _serverPlayer)) return true; - *

- * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis( - * TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * null, - * serverPlayer -> ((LevelExperienceOrbAccessor) expOrb).invokeGetClumpedMap() - * .forEach((value, amount) -> ((PlayerSyncAccess) serverPlayer).addLevelExperience(value * amount)) - * ); - * return !hasTelekinesis; - * } - * } - */ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelZMixinPlugin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelZMixinPlugin.java deleted file mode 100644 index 680ca49..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LevelZMixinPlugin.java +++ /dev/null @@ -1,61 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -import net.fabricmc.loader.api.FabricLoader; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; - -@SuppressWarnings("unused") -public class LevelZMixinPlugin implements IMixinConfigPlugin { - @Override - public void onLoad(String mixinPackage) { - - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin( - String targetClassName, - String mixinClassName - ) { - return FabricLoader.getInstance() - .isModLoaded("levelz"); - } - - @Override - public void acceptTargets( - Set myTargets, - Set otherTargets - ) { - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply( - String targetClassName, - ClassNode targetClass, - String mixinClassName, - IMixinInfo mixinInfo - ) { - } - - @Override - public void postApply( - String targetClassName, - ClassNode targetClass, - String mixinClassName, - IMixinInfo mixinInfo - ) { - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LivingEntityMixinMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LivingEntityMixinMixin.java deleted file mode 100644 index e40ac1d..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/LivingEntityMixinMixin.java +++ /dev/null @@ -1,35 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* - * @Pseudo - * @Mixin( value = LivingEntity.class, - * priority = 1500 - * ) - * public class LivingEntityMixinMixin { - * @Unique final LivingEntity instance = (LivingEntity) (Object) this; - * @TargetHandler( mixin = "net.levelz.mixin.entity.LivingEntityMixin", - * name = "dropXpMixin" - * ) - * @WrapWithCondition( method = "@MixinSquared:Handler", - * at = @At( - * value = "INVOKE", - * target = "net/levelz/entity/LevelExperienceOrbEntity.spawn (Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/phys/Vec3;I)V" - * ) - * ) - * protected boolean redirectLevelZExpDrop( - * ServerLevel world, - * Vec3 pos, - * int amount - * ) { - * if (!(instance.getLastAttacker() instanceof ServerPlayer _serverPlayer)) return true; - * System.out.println("wtf" + amount); - * System.out.println(amount); - * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.ExpDrops, - * _serverPlayer, - * null, - * serverPlayer -> ((PlayerSyncAccess) serverPlayer).addLevelExperience(amount) - * ); - * return !hasTelekinesis; - * } - * } - */ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/PlantBlockMixinMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/PlantBlockMixinMixin.java deleted file mode 100644 index 4b5704e..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/levelz/PlantBlockMixinMixin.java +++ /dev/null @@ -1,39 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.levelz; - -/* - * @Pseudo - * @Mixin( value = BushBlock.class, - * priority = 1500 - * ) - * public class PlantBlockMixinMixin extends Block { - *

- * public PlantBlockMixinMixin(Properties properties) { - * super(properties); - * } - * @WrapWithCondition( method = "playerWillDestroy(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/player/Player;)V", - * at = @At( - * value = "INVOKE", - * target = "net/minecraft/world/level/block/Block.popResource (Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V" - * ) - * ) - * private boolean checkTelekinesisAndRedirect( - * Level world, - * BlockPos pos, - * ItemStack stack, - * Level world1, - * BlockPos pos1, - * BlockState state, - * Player player - * ) { - * if (!(player instanceof ServerPlayer _serverPlayer)) return true; - * final var hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.BlockDrops, - * _serverPlayer, - * null, - * serverPlayer -> { - * if (!serverPlayer.addItem(stack)) Block.popResource(world, pos, stack); - * } - * ); - * return !hasTelekinesis; - * } - * } - */ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeCutEventsMixin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeCutEventsMixin.java deleted file mode 100644 index 2da886a..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeCutEventsMixin.java +++ /dev/null @@ -1,44 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.treeharvester; - -/* -@Pseudo -@Mixin(targets = "com.natamus.treeharvester_common_fabric.events.TreeCutEvents") -public class TreeCutEventsMixin { - - @Redirect( - method = "onTreeHarvest", - at = @At( - value = "INVOKE", - target = "Lcom/natamus/collective_common_fabric/functions/BlockFunctions;dropBlock(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)V" - ) - ) - private static void redirectDrop( - Level level, - BlockPos blockPos, - Level _level, - Player player, - BlockPos bpos, - BlockState state, - BlockEntity blockEntity - ) { - if ((EnchantmentHelper.getItemEnchantmentLevel( - MainKt.getTelekinesis(), - player.getItemInHand(InteractionHand.MAIN_HAND) - ) == 0 && !TelekinesisConfigKt.getConfig() - .getOnByDefault()) || !TelekinesisConfigKt.getConfig() - .getBlockDrops() || !(level instanceof ServerLevel serverLevel)) return; - - BlockState blockState = level.getBlockState(blockPos); - BlockEntity tileEntity = level.getBlockEntity(blockPos); - - List drops = Block.getDrops(blockState, serverLevel, blockPos, tileEntity); - - drops.forEach(item -> { - if (!player.addItem(item)) Block.popResource(serverLevel, blockPos, item); - }); - - serverLevel.setBlock(blockPos, Blocks.AIR.defaultBlockState(), 3); - } -} - - */ \ No newline at end of file diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeHarvesterMixinPlugin.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeHarvesterMixinPlugin.java deleted file mode 100644 index e1d653f..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/mixins/compat/treeharvester/TreeHarvesterMixinPlugin.java +++ /dev/null @@ -1,60 +0,0 @@ -package dev.nyon.telekinesis.mixins.compat.treeharvester; - -import net.fabricmc.loader.api.FabricLoader; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; - -@SuppressWarnings("unused") -public class TreeHarvesterMixinPlugin implements IMixinConfigPlugin { - @Override - public void onLoad(String mixinPackage) { - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin( - String targetClassName, - String mixinClassName - ) { - return FabricLoader.getInstance() - .isModLoaded("treeharvester"); - } - - @Override - public void acceptTargets( - Set myTargets, - Set otherTargets - ) { - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply( - String targetClassName, - ClassNode targetClass, - String mixinClassName, - IMixinInfo mixinInfo - ) { - } - - @Override - public void postApply( - String targetClassName, - ClassNode targetClass, - String mixinClassName, - IMixinInfo mixinInfo - ) { - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/EntityUtils.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/EntityUtils.java deleted file mode 100644 index f06e1a9..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/EntityUtils.java +++ /dev/null @@ -1,65 +0,0 @@ -package dev.nyon.telekinesis.utils; - -import dev.nyon.telekinesis.TelekinesisPolicy; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.ItemLike; - -import java.util.concurrent.atomic.AtomicReference; - -public class EntityUtils { - - public static boolean spawnAtLocationInject( - LivingEntity entity, - ItemLike item - ) { - return spawnAtLocationInject( - entity, - item.asItem() - .getDefaultInstance() - ); - } - - public static boolean spawnAtLocationInject( - LivingEntity entity, - ItemStack item - ) { - final var attacker = entity.getLastAttacker(); - - return spawnAtLocationAttacker(attacker, item); - } - - public static boolean spawnAtLocationAttacker(LivingEntity attacker, ItemStack item) { - if (!(attacker instanceof ServerPlayer serverPlayer)) return true; - - boolean hasTelekinesis = TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.MobDrops, - serverPlayer, - serverPlayer.getMainHandItem(), - player -> { - if (!player.addItem(item)) attacker.spawnAtLocation(item); - } - ); - - return !hasTelekinesis; - } - - public static Item getDropItemInject( - Item original, - DamageSource source - ) { - final var attacker = source.getEntity(); - if (!(attacker instanceof ServerPlayer)) return original; - - AtomicReference toReturn = new AtomicReference<>(original); - - TelekinesisUtils.handleTelekinesis(TelekinesisPolicy.VehicleDrops, source, player -> { - if (player.addItem(original.asItem() - .getDefaultInstance())) toReturn.set(ItemStack.EMPTY.getItem()); - }); - - return toReturn.get(); - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/PlayerUtils.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/PlayerUtils.java deleted file mode 100644 index e6ad9ba..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/PlayerUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -package dev.nyon.telekinesis.utils; - -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.EnchantmentHelper; -import net.minecraft.world.item.enchantment.Enchantments; - -import java.util.Map; - -public class PlayerUtils { - public static void addExpToPlayer( - Player player, - Integer exp - ) { - var remainingExp = repairPlayerItems(player, exp); - if (remainingExp > 0) player.giveExperiencePoints(remainingExp); - } - - private static int repairPlayerItems( - Player player, - Integer exp - ) { - Map.Entry entry = EnchantmentHelper.getRandomItemWith(Enchantments.MENDING, player, ItemStack::isDamaged); - if (entry != null) { - ItemStack itemStack = entry.getValue(); - int j = Math.min(exp * 2, itemStack.getDamageValue()); - itemStack.setDamageValue(itemStack.getDamageValue() - j); - int k = exp - j * 2; - return k > 0 ? repairPlayerItems(player, k) : 0; - } else return exp; - } -} diff --git a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/TelekinesisUtils.java b/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/TelekinesisUtils.java deleted file mode 100644 index 0be0142..0000000 --- a/telekinesis-fabric/src/main/java/dev/nyon/telekinesis/utils/TelekinesisUtils.java +++ /dev/null @@ -1,94 +0,0 @@ -package dev.nyon.telekinesis.utils; - -import dev.nyon.telekinesis.MainKt; -import dev.nyon.telekinesis.TelekinesisConfigKt; -import dev.nyon.telekinesis.TelekinesisPolicy; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.damagesource.DamageSource; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.EnchantmentHelper; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Consumer; - -public class TelekinesisUtils { - - public static boolean handleTelekinesisBlock( - TelekinesisPolicy neededPolicy, - Entity entity, - ItemStack tool, - Consumer consumer - ) { - if (!(entity instanceof ServerPlayer serverPlayer)) return false; - return handleTelekinesis(neededPolicy, serverPlayer, tool, consumer); - } - - public static boolean handleTelekinesis( - TelekinesisPolicy neededPolicy, - LivingEntity target, - Consumer consumer - ) { - LivingEntity attacker = target.getLastAttacker(); - if (attacker == null) return false; - if (!(attacker instanceof ServerPlayer serverPlayer)) return false; - return handleTelekinesis(neededPolicy, serverPlayer, null, consumer); - } - - public static boolean handleTelekinesis( - TelekinesisPolicy neededPolicy, - DamageSource source, - Consumer consumer - ) { - if (source == null) return false; - Entity attacker = source.getEntity(); - if (attacker == null) return false; - if (!(attacker instanceof ServerPlayer serverPlayer)) return false; - return handleTelekinesis(neededPolicy, serverPlayer, null, consumer); - } - - - public static boolean handleTelekinesis( - TelekinesisPolicy neededPolicy, - ServerPlayer player, - @Nullable ItemStack itemStack, - Consumer consumer - ) { - if (!neededPolicy.isEnabled()) return false; - if (!playerMeetsConditions(neededPolicy, player, itemStack)) return false; - - consumer.accept(player); - return true; - } - - private static boolean playerMeetsConditions( - TelekinesisPolicy policy, - ServerPlayer player, - @Nullable ItemStack itemStack - ) { - boolean conditionsMet = false; - - boolean isEnabledByDefault = TelekinesisConfigKt.getConfig() - .getOnByDefault(); - - boolean hasArmorTelekinesis = player.getInventory().armor.stream() - .allMatch(item -> EnchantmentHelper.getItemEnchantmentLevel(MainKt.getTelekinesis(), item) > 0); - boolean hasMainHandTelekinesis = (itemStack != null && EnchantmentHelper.getItemEnchantmentLevel(MainKt.getTelekinesis(), - itemStack - ) > 0) || EnchantmentHelper.getItemEnchantmentLevel(MainKt.getTelekinesis(), player.getMainHandItem()) > 0; - boolean hasOffHandTelekinesis = EnchantmentHelper.getItemEnchantmentLevel(MainKt.getTelekinesis(), player.getOffhandItem()) > 0; - - if (isEnabledByDefault) conditionsMet = true; - else switch (policy) { - case ExpDrops -> conditionsMet = hasArmorTelekinesis || hasMainHandTelekinesis || hasOffHandTelekinesis; - case MobDrops, ShearingDrops, VehicleDrops, FishingDrops -> conditionsMet = hasMainHandTelekinesis || hasOffHandTelekinesis; - case BlockDrops -> conditionsMet = hasMainHandTelekinesis; - } - - if (TelekinesisConfigKt.getConfig() - .getOnlyOnSneak() && !player.isCrouching()) conditionsMet = false; - - return conditionsMet; - } -} diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/Main.kt b/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/Main.kt deleted file mode 100644 index 6c67387..0000000 --- a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/Main.kt +++ /dev/null @@ -1,12 +0,0 @@ -@file:Suppress("unused") - -package dev.nyon.telekinesis - -import net.minecraft.server.MinecraftServer - -var server: MinecraftServer? = null -lateinit var telekinesis: TelekinesisEnchantment - -fun init() { - loadConfig() -} diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt b/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt deleted file mode 100644 index 1e6f973..0000000 --- a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt +++ /dev/null @@ -1,76 +0,0 @@ -package dev.nyon.telekinesis - -import com.akuleshov7.ktoml.Toml -import com.akuleshov7.ktoml.annotations.TomlComments -import kotlinx.serialization.Serializable -import kotlinx.serialization.decodeFromString -import net.fabricmc.loader.api.FabricLoader -import java.nio.file.Path -import kotlin.io.path.createFile -import kotlin.io.path.exists -import kotlin.io.path.readText -import kotlin.io.path.writeText - -@Serializable -data class TelekinesisConfig( - @TomlComments( - "Uncomment the following values if you want to change them:", - "", - "Decides whether telekinesis can be used without the enchantment." - ) - var onByDefault: Boolean = false, - @TomlComments( - "Decides whether players should be required to sneak to use telekinesis." - ) - var onlyOnSneak: Boolean = false, - @TomlComments( - "Decides whether to add the enchantment to the game." - ) - var enchantment: Boolean = true, - @TomlComments( - "Decides whether telekinesis can be used for block drops." - ) - var blockDrops: Boolean = true, - @TomlComments( - "Decides whether telekinesis can be used for exp drops." - ) - var expDrops: Boolean = true, - @TomlComments( - "Decides whether telekinesis can be used for mob drops." - ) - var mobDrops: Boolean = true, - @TomlComments( - "Decides whether telekinesis can be used for vehicle drops." - ) - var vehicleDrops: Boolean = true, - @TomlComments( - "Decides whether telekinesis can be used for shearing drops." - ) - var shearingDrops: Boolean = true, - @TomlComments( - "Decides whether telekinesis can be used for fishing drops." - ) - var fishingDrops: Boolean = true -) - -var config: TelekinesisConfig = TelekinesisConfig() -lateinit var configPath: Path - -fun saveConfig() = configPath.writeText(Toml.encodeToString(TelekinesisConfig.serializer(), config)) - -fun loadConfig() { - configPath = - FabricLoader.getInstance().configDir.toAbsolutePath().resolve("telekinesis.toml") - .also { if (!it.exists()) it.createFile() } - - if (configPath.readText().isEmpty()) { - saveConfig() - return - } - - try { - config = Toml.decodeFromString(configPath.readText()) - } catch (e: Exception) { - saveConfig() - } -} diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfigScreen.kt b/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfigScreen.kt deleted file mode 100644 index b0b1986..0000000 --- a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfigScreen.kt +++ /dev/null @@ -1,138 +0,0 @@ -package dev.nyon.telekinesis - -import dev.isxander.yacl3.api.ConfigCategory -import dev.isxander.yacl3.api.Option -import dev.isxander.yacl3.api.OptionDescription -import dev.isxander.yacl3.api.YetAnotherConfigLib -import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder -import net.minecraft.client.gui.screens.Screen -import net.minecraft.network.chat.Component - -fun generateConfigScreen(parent: Screen? = null): Screen { - val configScreenBuilder = YetAnotherConfigLib.createBuilder() - configScreenBuilder.title(Component.translatable("menu.telekinesis.name")) - configScreenBuilder.appendOptionCategory() - configScreenBuilder.save { saveConfig() } - val configScreen = configScreenBuilder.build() - return configScreen.generateScreen(parent) -} - -fun YetAnotherConfigLib.Builder.appendOptionCategory() { - this.category( - ConfigCategory.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general")) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.onbydefault")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.onbydefault.description")) - ) - .binding(config.onByDefault, { config.onByDefault }, { config.onByDefault = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.onlywhilesneaking")) - .description( - OptionDescription - .of( - Component.translatable("menu.telekinesis.config.general.onlywhilesneaking.description") - ) - ) - .binding(config.onlyOnSneak, { config.onlyOnSneak }, { config.onlyOnSneak = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.enchantment")) - .description( - OptionDescription.of( - Component.translatable("menu.telekinesis.config.general.enchantment.description1"), - Component.translatable("menu.telekinesis.config.general.enchantment.description2") - ) - ) - .binding(config.enchantment, { config.enchantment }, { config.enchantment = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.blockdrops")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.blockdrops.description")) - ) - .binding(config.blockDrops, { config.blockDrops }, { config.blockDrops = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.expdrops")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.expdrops.description")) - ) - .binding(config.expDrops, { config.expDrops }, { config.expDrops = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.mobdrops")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.mobdrops.description")) - ) - .binding(config.mobDrops, { config.mobDrops }, { config.mobDrops = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.vehicledrops")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.vehicledrops.description")) - ) - .binding(config.vehicleDrops, { config.vehicleDrops }, { config.vehicleDrops = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.shearingdrops")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.shearingdrops.description")) - ) - .binding(config.shearingDrops, { config.shearingDrops }, { config.shearingDrops = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .option( - Option.createBuilder() - .name(Component.translatable("menu.telekinesis.config.general.fishingdrops")) - .description( - OptionDescription - .of(Component.translatable("menu.telekinesis.config.general.fishingdrops.description")) - ) - .binding(config.fishingDrops, { config.fishingDrops }, { config.fishingDrops = it }) - .controller { - TickBoxControllerBuilder.create(it) - }.build() - ) - .build() - ) -} diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt b/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt deleted file mode 100644 index 899024c..0000000 --- a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt +++ /dev/null @@ -1,49 +0,0 @@ -package dev.nyon.telekinesis - -import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Style -import net.minecraft.world.item.enchantment.Enchantment -import net.minecraft.world.entity.EquipmentSlot -/*? >1.20.5 {*//* -import net.minecraft.tags.ItemTags -*//*?} else {*/ -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.entity.MobType -import net.minecraft.world.item.enchantment.EnchantmentCategory -/*?}*/ - - - -/*? >1.20.5 {*//* -class TelekinesisEnchantment : Enchantment( - definition( - ItemTags.DURABILITY_ENCHANTABLE, - 2, - 1, - dynamicCost(25, 25), - dynamicCost(75, 25), - 5, - *EquipmentSlot.entries.toTypedArray() - ) -) { - override fun getFullname(i: Int): Component = - Component.translatable("enchantment.telekinesis.telekinesis.name").withStyle(Style.EMPTY.withColor(0xFFB64C)) -} -*//*?} else {*/ -class TelekinesisEnchantment : Enchantment( - Rarity.RARE, EnchantmentCategory.BREAKABLE, listOf(EquipmentSlot.OFFHAND, EquipmentSlot.MAINHAND).toTypedArray() -) { - - override fun getMinLevel(): Int = 1 - override fun getMaxLevel(): Int = 1 - - override fun getMinCost(i: Int): Int = 25 - override fun getMaxCost(i: Int): Int = 50 - - override fun getDamageProtection(i: Int, damageSource: DamageSource): Int = 0 - override fun getDamageBonus(i: Int, mobType: MobType): Float = 0F - - override fun getFullname(i: Int): Component = - Component.translatable("enchantment.telekinesis.telekinesis.name").withStyle(Style.EMPTY.withColor(0xFFB64C)) -} -/*?}*/ diff --git a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt b/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt deleted file mode 100644 index 3c8e44c..0000000 --- a/telekinesis-fabric/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt +++ /dev/null @@ -1,20 +0,0 @@ -package dev.nyon.telekinesis - -enum class TelekinesisPolicy { - BlockDrops, - ExpDrops, - MobDrops, - VehicleDrops, - ShearingDrops, - FishingDrops; - - fun isEnabled(): Boolean = - when (this) { - BlockDrops -> config.blockDrops - ExpDrops -> config.expDrops - MobDrops -> config.mobDrops - VehicleDrops -> config.vehicleDrops - ShearingDrops -> config.shearingDrops - FishingDrops -> config.fishingDrops - } -} diff --git a/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/de_de.json b/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/de_de.json deleted file mode 100644 index 880f4a2..0000000 --- a/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/de_de.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "menu.telekinesis.name": "telekinesis", - "menu.telekinesis.config.general": "Allgemein", - "menu.telekinesis.config.general.onbydefault": "Immer an", - "menu.telekinesis.config.general.onbydefault.description": "Entscheidet, ob Telekinesis immer an sein sollte, auch ohne das Enchantment.", - "menu.telekinesis.config.general.onlywhilesneaking": "Nur beim sneaken", - "menu.telekinesis.config.general.onlywhilesneaking.description": "Entscheidet, ob Telekinesis nur funktionieren sollte, wenn man sneakt.", - "menu.telekinesis.config.general.enchantment": "Enchantment", - "menu.telekinesis.config.general.enchantment.description1": "Entscheidet, ob das Enchantment registriert werden soll.", - "menu.telekinesis.config.general.enchantment.description2": "Benötigt einen Neustart des Spiels!", - "menu.telekinesis.config.general.blockdrops": "Drops von Blöcken", - "menu.telekinesis.config.general.blockdrops.description": "Entscheidet, ob Telekinesis für Drops von Blöcken funktionieren soll.", - "menu.telekinesis.config.general.expdrops": "XP drops", - "menu.telekinesis.config.general.expdrops.description": "Entscheidet, ob Telekinesis für XP Drops funktionieren soll.", - "menu.telekinesis.config.general.mobdrops": "Drops von Mobs", - "menu.telekinesis.config.general.mobdrops.description": "Entscheidet, ob Telekinesis für Drops von Mobs funktionieren soll.", - "menu.telekinesis.config.general.vehicledrops": "Drops von Fahrzeugen", - "menu.telekinesis.config.general.vehicledrops.description": "Entscheidet, ob Telekinesis für Drops von Fahrzeugen funktionieren soll.", - "menu.telekinesis.config.general.shearingdrops": "Drops vom Scheren", - "menu.telekinesis.config.general.shearingdrops.description": "Entscheidet ob Telekinesis für Drops vom Scheren funktionieren soll.", - "menu.telekinesis.config.general.fishingdrops": "Drops vom Fischen", - "menu.telekinesis.config.general.fishingdrops.description": "Entscheidet ob Telekinesis für Drops vom Fischen funktionieren soll.", - "enchantment.telekinesis.telekinesis.name": "Telekinesis" -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/en_us.json b/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/en_us.json deleted file mode 100644 index 192a511..0000000 --- a/telekinesis-fabric/src/main/resources/assets/telekinesis/lang/en_us.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "menu.telekinesis.name": "telekinesis", - "menu.telekinesis.config.general": "General", - "menu.telekinesis.config.general.onbydefault": "On By Default", - "menu.telekinesis.config.general.onbydefault.description": "Decides whether telekinesis can be used without the enchantment.", - "menu.telekinesis.config.general.onlywhilesneaking": "Only while sneaking", - "menu.telekinesis.config.general.onlywhilesneaking.description": "Decides whether players should be required to sneak to use telekinesis.", - "menu.telekinesis.config.general.enchantment": "Enchantment", - "menu.telekinesis.config.general.enchantment.description1": "Decides whether to add the enchantment to the game.", - "menu.telekinesis.config.general.enchantment.description2": "Requires a restart to work!", - "menu.telekinesis.config.general.blockdrops": "Block drops", - "menu.telekinesis.config.general.blockdrops.description": "Decides whether telekinesis can be used for block drops.", - "menu.telekinesis.config.general.expdrops": "Exp drops", - "menu.telekinesis.config.general.expdrops.description": "Decides whether telekinesis can be used for exp drops.", - "menu.telekinesis.config.general.mobdrops": "Mob drops", - "menu.telekinesis.config.general.mobdrops.description": "Decides whether telekinesis can be used for mob drops.", - "menu.telekinesis.config.general.vehicledrops": "Vehicle drops", - "menu.telekinesis.config.general.vehicledrops.description": "Decides whether telekinesis can be used for vehicle drops.", - "menu.telekinesis.config.general.shearingdrops": "Shearing drops", - "menu.telekinesis.config.general.shearingdrops.description": "Decides whether telekinesis can be used for shearing drops.", - "menu.telekinesis.config.general.fishingdrops": "Fishing drops", - "menu.telekinesis.config.general.fishingdrops.description": "Decides whether telekinesis can be used for fishing drops.", - "enchantment.telekinesis.telekinesis.name": "Telekinesis" -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/resources/compat.betternether.mixins.json b/telekinesis-fabric/src/main/resources/compat.betternether.mixins.json deleted file mode 100644 index f6e04f8..0000000 --- a/telekinesis-fabric/src/main/resources/compat.betternether.mixins.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "plugin": "dev.nyon.telekinesis.mixins.compat.betternether.BetterNetherMixinPlugin", - "package": "dev.nyon.telekinesis.mixins.compat.betternether", - "compatibilityLevel": "JAVA_17", - "client": [ - ], - "injectors": { - "defaultRequire": 1 - }, - "mixins": [ - "RubyFireMixin" - ] -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/resources/compat.levelz.mixins.json b/telekinesis-fabric/src/main/resources/compat.levelz.mixins.json deleted file mode 100644 index 1ffe7fc..0000000 --- a/telekinesis-fabric/src/main/resources/compat.levelz.mixins.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "plugin": "dev.nyon.telekinesis.mixins.compat.levelz.LevelZMixinPlugin", - "package": "dev.nyon.telekinesis.mixins.compat.levelz", - "compatibilityLevel": "JAVA_17", - "client": [ - ], - "injectors": { - "defaultRequire": 1 - }, - "mixins": [ - "BlockMixinMixin", - "EnderDragonEntityMixinMixin", - "FishingBobberEntityMixinMixin", - "LevelExperienceOrbAccessor", - "LevelExperienceOrbEntityMixin", - "LivingEntityMixinMixin", - "PlantBlockMixinMixin" - ] -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/resources/compat.treeharvester.mixins.json b/telekinesis-fabric/src/main/resources/compat.treeharvester.mixins.json deleted file mode 100644 index 6e3a838..0000000 --- a/telekinesis-fabric/src/main/resources/compat.treeharvester.mixins.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "plugin": "dev.nyon.telekinesis.mixins.compat.treeharvester.TreeHarvesterMixinPlugin", - "package": "dev.nyon.telekinesis.mixins.compat.treeharvester", - "compatibilityLevel": "JAVA_17", - "client": [ - "TreeCutEventsMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} \ No newline at end of file diff --git a/telekinesis-fabric/src/main/resources/fabric.mod.json b/telekinesis-fabric/src/main/resources/fabric.mod.json deleted file mode 100644 index 5a0749f..0000000 --- a/telekinesis-fabric/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "schemaVersion": 1, - "id": "${id}", - "name": "${name}", - "description": "${description}", - "contact": { - "issues": "https://github.com/btwonion/telekinesis/issues", - "sources": "https://github.com/btwonion/telekinesis" - }, - "icon": "assets/telekinesis/icon.png", - "authors": [ - "btwonion" - ], - "contributors": [], - "license": [ - "GNU General Public License v3.0" - ], - "version": "${version}", - "environment": "*", - "depends": { - "fabric-language-kotlin": ">=1.10.20+kotlin.1.9.24", - "yet_another_config_lib_v3": "*", - "minecraft": "${mc}" - }, - "suggests": { - "modmenu": "*" - }, - "entrypoints": { - "main": [ - { - "adapter": "kotlin", - "value": "dev.nyon.telekinesis.MainKt::init" - } - ], - "modmenu": [ - { - "adapter": "kotlin", - "value": "dev.nyon.telekinesis.ModMenuImpl" - } - ] - }, - "mixins": [ - "telekinesis.mixins.json" - ], - "accessWidener": "telekinesis.accesswidener", - "custom": { - "modmenu": { - "links": { - "modmenu.discord": "https://discord.gg/pmHTtZnMd3" - } - } - } -} diff --git a/telekinesis-fabric/src/main/resources/telekinesis.accesswidener b/telekinesis-fabric/src/main/resources/telekinesis.accesswidener deleted file mode 100644 index 09fb9bf..0000000 --- a/telekinesis-fabric/src/main/resources/telekinesis.accesswidener +++ /dev/null @@ -1,3 +0,0 @@ -accessWidener v2 named - -accessible method net/minecraft/world/level/block/InfestedBlock spawnAfterBreak (Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;Z)V \ No newline at end of file diff --git a/telekinesis-fabric/src/main/resources/telekinesis.mixins.json b/telekinesis-fabric/src/main/resources/telekinesis.mixins.json deleted file mode 100644 index 4c5bf60..0000000 --- a/telekinesis-fabric/src/main/resources/telekinesis.mixins.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "dev.nyon.telekinesis.mixins", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "AbstractChestedHorseMixin", - "AbstractHorseMixin", - "AbstractMinecartMixin", - "AllayMixin", - "BlockMixin", - "BoatMixin", - "CatalystBlockAccessor", - "ChestBoatMixin", - "DropExperienceBlockAccessor", - "EnchantmentsMixin", - "EnderManMixin", - "FishingHookMixin", - "InventoryMixin", - "LivingEntityMixin", - "MinecartTNTMixin", - "MinecraftServerMixin", - "MobMixin", - "PiglinMixin", - "PigMixin", - "SheepMixin", - "SnowgolemMixin", - "StriderMixin", - "SweetBerryBushBlockMixin", - "VehicleEntityMixin", - "WitherBossMixin" - ], - "injectors": { - "defaultRequire": 1 - } -} diff --git a/telekinesis-fabric/stonecutter.gradle.kts b/telekinesis-fabric/stonecutter.gradle.kts deleted file mode 100644 index 495263e..0000000 --- a/telekinesis-fabric/stonecutter.gradle.kts +++ /dev/null @@ -1,16 +0,0 @@ -plugins { - id("dev.kikugie.stonecutter") -} -stonecutter active "1.20.1" /* [SC] DO NOT EDIT */ - -stonecutter registerChiseled - tasks.register("buildAllVersions", stonecutter.chiseled) { - group = "mod" - ofTask("build") - } - -stonecutter registerChiseled - tasks.register("releaseAllVersions", stonecutter.chiseled) { - group = "mod" - ofTask("releaseMod") - } diff --git a/telekinesis-paper/build.gradle.kts b/telekinesis-paper/build.gradle.kts deleted file mode 100644 index ae1fb0a..0000000 --- a/telekinesis-paper/build.gradle.kts +++ /dev/null @@ -1,142 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import java.nio.file.Path -import kotlin.io.path.notExists -import kotlin.io.path.readText - -plugins { - kotlin("jvm") - kotlin("plugin.serialization") - - id("com.modrinth.minotaur") - id("com.github.breadmoirai.github-release") - - id("io.papermc.paperweight.userdev") - id("xyz.jpenilla.run-paper") version "2.1.0" - - `maven-publish` - signing -} - -group = "dev.nyon" -val majorVersion = "2.3.2" -val mcVersion = "1.20.2" -version = "$majorVersion-$mcVersion" -description = "Adds an telekinesis enchantment to minecraft" -val projectAuthors = listOf("btwonion") -val githubRepo = "btwonion/telekinesis" - -repositories { - mavenCentral() -} - -dependencies { - paperweight.paperDevBundle("$mcVersion-R0.1-SNAPSHOT") - implementation("com.akuleshov7:ktoml-core-jvm:0.5.0") -} - -tasks { - register("releasePlugin") { - group = "publishing" - - dependsOn("modrinthSyncBody") - dependsOn("modrinth") - dependsOn("publish") - dependsOn("githubRelease") - } - - processResources { - val props = mapOf( - "name" to "telekinesis", - "version" to "'${project.version}'", - "main" to "dev.nyon.telekinesis.Main", - "description" to project.description, - "website" to "https://nyon.dev/discord", - "apiVersion" to "'1.20'", - "authors" to projectAuthors.joinToString("\n - ", "\n - "), - "foliaSupported" to true, - "loader" to "dev.nyon.telekinesis.PaperLoader" - ) - - inputs.properties(props) - filesMatching("paper-plugin.yml") { - expand(props) - } - } - - assemble { - dependsOn(reobfJar) - } - - withType { - options.encoding = "UTF-8" - options.release.set(17) - } - - withType { - kotlinOptions.jvmTarget = "17" - } - - runPaper.folia.registerTask() - runServer { - minecraftVersion("1.20.1") - } -} - -val changelogFile: Path = rootDir.toPath().resolve("changelogs/paper-$version.md") -val changelogText = if (changelogFile.notExists()) "" else changelogFile.readText() -val projectVersionName = "paper-${project.version}" - -modrinth { - token.set(findProperty("modrinth.token")?.toString()) - projectId.set("LLfA8jAD") - versionNumber.set(projectVersionName) - versionName.set(projectVersionName) - versionType.set("release") - uploadFile.set(tasks.reobfJar.get().outputJar) - gameVersions.set(listOf("1.20.2")) - loaders.set(listOf("paper", "folia")) - changelog.set(changelogText) - syncBodyFrom.set(file("../README.md").readText()) -} - -githubRelease { - token(findProperty("github.token")?.toString()) - - val split = githubRepo.split("/") - owner = split[0] - repo = split[1] - releaseName = projectVersionName - tagName = projectVersionName - body = changelogText - targetCommitish = "master" - setReleaseAssets(tasks.reobfJar.get().outputJar) -} - -publishing { - repositories { - maven { - name = "nyon" - url = uri("https://repo.nyon.dev/releases") - credentials(PasswordCredentials::class) - authentication { - create("basic") - } - } - } - publications { - create("maven") { - groupId = "dev.nyon" - artifactId = "telekinesis-paper" - version = project.version.toString() - from(components["java"]) - } - } -} - -signing { - sign(publishing.publications) -} - -java { - withSourcesJar() -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java b/telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java deleted file mode 100644 index a281941..0000000 --- a/telekinesis-paper/src/main/java/dev/nyon/telekinesis/PaperLoader.java +++ /dev/null @@ -1,22 +0,0 @@ -package dev.nyon.telekinesis; - -import io.papermc.paper.plugin.loader.PluginClasspathBuilder; -import io.papermc.paper.plugin.loader.PluginLoader; -import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver; -import org.eclipse.aether.artifact.DefaultArtifact; -import org.eclipse.aether.graph.Dependency; -import org.eclipse.aether.repository.RemoteRepository; -import org.jetbrains.annotations.NotNull; - -@SuppressWarnings("UnstableApiUsage") -public class PaperLoader implements PluginLoader { - @Override - public void classloader(@NotNull PluginClasspathBuilder classpathBuilder) { - MavenLibraryResolver resolver = new MavenLibraryResolver(); - resolver.addDependency(new Dependency(new DefaultArtifact("org.jetbrains.kotlin:kotlin-stdlib:1.9.0"), null)); - resolver.addDependency(new Dependency(new DefaultArtifact("com.akuleshov7:ktoml-core-jvm:0.5.0"), null)); - resolver.addRepository(new RemoteRepository.Builder("central", "default", "https://repo1.maven.org/maven2/").build()); - - classpathBuilder.addLibrary(resolver); - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt deleted file mode 100644 index 1d7e1f4..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/Main.kt +++ /dev/null @@ -1,82 +0,0 @@ -package dev.nyon.telekinesis - -import dev.nyon.telekinesis.listeners.initBlockListeners -import dev.nyon.telekinesis.listeners.initMobListeners -import net.minecraft.core.Holder -import net.minecraft.core.MappedRegistry -import net.minecraft.core.Registry -import net.minecraft.core.registries.Registries -import net.minecraft.resources.ResourceLocation -import org.bukkit.Bukkit -import org.bukkit.craftbukkit.v1_20_R2.CraftServer -import org.bukkit.enchantments.Enchantment -import org.bukkit.plugin.java.JavaPlugin -import kotlin.io.path.createFile -import kotlin.io.path.exists - -val bukkitEnchantment: Enchantment = BukkitTelekinesis() -val telekinesis = TelekinesisEnchantment() - -class Main : JavaPlugin() { - companion object { - lateinit var INSTANCE: Main; private set - } - - override fun onLoad() { - INSTANCE = this - configPath = Bukkit.getPluginsFolder().toPath().resolve("telekinesis.toml") - .also { if (!it.exists()) it.createFile() } - loadConfig() - if (dev.nyon.telekinesis.config.enchantment) { - addToBukkitRegistry() - addToMinecraftRegistry() - } - } - - override fun onEnable() { - initBlockListeners() - initMobListeners() - } -} - -private fun addToBukkitRegistry() { - val field = Enchantment::class.java.getDeclaredField("acceptingNew") - field.isAccessible = true - field.set(null, true) - Enchantment.registerEnchantment(BukkitTelekinesis()) - field.set(null, false) - field.isAccessible = true -} - -// Check the values with: https://mappings.cephx.dev/ -@Suppress("unchecked_cast") -private fun addToMinecraftRegistry() { - val server = (Bukkit.getServer() as CraftServer).server - val enchantmentRegistry = server.registryAccess().registryOrThrow(Registries.ENCHANTMENT) as MappedRegistry - val enchantmentRegistryClass = enchantmentRegistry.javaClass - val frozenField = enchantmentRegistryClass.getDeclaredField("l") // l - frozen MappedRegistry - frozenField.isAccessible = true - frozenField.set(enchantmentRegistry, false) - - Registry.register( - enchantmentRegistry, - ResourceLocation("telekinesis", "telekinesis"), - telekinesis - ) - - frozenField.set(enchantmentRegistry, true) - frozenField.isAccessible = false - - val byValueField = enchantmentRegistryClass.getDeclaredField("h") // h - byValue MappedRegistry - byValueField.isAccessible = true - val byValueMap = - byValueField.get(enchantmentRegistry) as Map<*, Holder.Reference<*>> - val value = byValueMap[telekinesis]!! - val method = value.javaClass.getDeclaredMethod("b", Any::class.java) - method.isAccessible = true - method.invoke(value, telekinesis) // b - bindValue Holder$Reference - method.isAccessible = false - byValueField.isAccessible = false -} - -val Plugin by lazy { Main.INSTANCE } \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt deleted file mode 100644 index 93a396f..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisConfig.kt +++ /dev/null @@ -1,75 +0,0 @@ -package dev.nyon.telekinesis - -import com.akuleshov7.ktoml.Toml -import com.akuleshov7.ktoml.TomlInputConfig -import com.akuleshov7.ktoml.annotations.TomlComments -import kotlinx.serialization.Serializable -import kotlinx.serialization.decodeFromString -import java.nio.file.Path -import kotlin.io.path.notExists -import kotlin.io.path.readText -import kotlin.io.path.writeText - -@Serializable -data class TelekinesisConfig( - @TomlComments( - "Uncomment the following values if you want to change them:", - "", - "Decides whether telekinesis can be used without the enchantment." - ) - var onByDefault: Boolean = false, - var onByDefaultPermissionRequirement: String? = null, - @TomlComments( - "Uncomment this to block functionality for those who don't have the required permission.", - "onByDefaultPermissionRequirement = 'permission'", - "", - "Decides whether players should be required to sneak to use telekinesis." - ) - var onlyOnSneak: Boolean = false, - @TomlComments( - "Decides whether telekinesis can be used for block drops." - ) - var blockDrops: Boolean = true, - var blockDropsPermissionRequirement: String? = null, - @TomlComments( - "blockDropsPermissionRequirement = 'permission'", - "", - "Decides whether telekinesis can be used for exp drops." - ) - var expDrops: Boolean = true, - var expDropsPermissionRequirement: String? = null, - @TomlComments( - "expDropsPermissionRequirement = 'permission'", - "", - "Decides whether telekinesis can be used for entity drops." - ) - var entityDrops: Boolean = true, - var entityDropsPermissionRequirement: String? = null, - @TomlComments( - "entityDropsPermissionRequirement = 'permission'", - "", - "Decides whether to add the enchantment to the game." - ) - var enchantment: Boolean = true, -) - -var config: TelekinesisConfig = TelekinesisConfig() -lateinit var configPath: Path -val toml = Toml( - inputConfig = TomlInputConfig(ignoreUnknownNames = true) -) - -fun saveConfig() = configPath.writeText(toml.encodeToString(TelekinesisConfig.serializer(), config)) - -fun loadConfig() { - if (configPath.notExists() || configPath.readText().isEmpty()) { - saveConfig() - return - } - - try { - config = toml.decodeFromString(configPath.readText()) - } catch (e: Exception) { - saveConfig() - } -} diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt deleted file mode 100644 index 3d4b664..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantment.kt +++ /dev/null @@ -1,72 +0,0 @@ -package dev.nyon.telekinesis - -import io.papermc.paper.enchantments.EnchantmentRarity -import net.kyori.adventure.text.format.TextColor -import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Style -import net.minecraft.world.damagesource.DamageSource -import net.minecraft.world.entity.EquipmentSlot -import net.minecraft.world.entity.MobType -import net.minecraft.world.item.enchantment.Enchantment -import net.minecraft.world.item.enchantment.EnchantmentCategory -import org.bukkit.NamespacedKey -import org.bukkit.enchantments.EnchantmentTarget -import org.bukkit.entity.EntityCategory -import org.bukkit.inventory.ItemStack - -/** - * The telekinesis enchantment model - */ -class TelekinesisEnchantment : Enchantment( - Rarity.RARE, EnchantmentCategory.BREAKABLE, listOf(EquipmentSlot.OFFHAND, EquipmentSlot.MAINHAND).toTypedArray() -) { - - override fun getMinLevel(): Int = 1 - override fun getMaxLevel(): Int = 1 - - override fun getMinCost(i: Int): Int = 30 - override fun getMaxCost(i: Int): Int = 30 - - override fun getDamageProtection(i: Int, damageSource: DamageSource): Int = 0 - override fun getDamageBonus(i: Int, mobType: MobType): Float = 0F - - override fun getFullname(i: Int): Component = - Component.literal("Telekinesis").withStyle(Style.EMPTY.withColor(0xFFB64C)) -} - -class BukkitTelekinesis : org.bukkit.enchantments.Enchantment(NamespacedKey("telekinesis", "telekinesis")) { - override fun translationKey(): String = "telekinesis.telekinesis" - - @Deprecated("Deprecated in Java", ReplaceWith("\"Telekinesis\"")) - override fun getName(): String = "Telekinesis" - - override fun getMaxLevel(): Int = 1 - - override fun getStartLevel(): Int = 1 - - override fun getItemTarget(): EnchantmentTarget = EnchantmentTarget.BREAKABLE - - override fun isTreasure(): Boolean = false - - override fun isCursed(): Boolean = false - - override fun conflictsWith(other: org.bukkit.enchantments.Enchantment): Boolean = false - - override fun canEnchantItem(item: ItemStack): Boolean = true - - override fun displayName(level: Int): net.kyori.adventure.text.Component = - net.kyori.adventure.text.Component.text("Telekinesis").color( - TextColor.color(0xFFB64C) - ) - - override fun isTradeable(): Boolean = true - - override fun isDiscoverable(): Boolean = true - - override fun getRarity(): EnchantmentRarity = EnchantmentRarity.RARE - - override fun getDamageIncrease(level: Int, entityCategory: EntityCategory): Float = 0.0f - - override fun getActiveSlots(): MutableSet = - mutableSetOf(org.bukkit.inventory.EquipmentSlot.OFF_HAND, org.bukkit.inventory.EquipmentSlot.HAND) -} diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt deleted file mode 100644 index ff4b071..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/TelekinesisPolicy.kt +++ /dev/null @@ -1,19 +0,0 @@ -package dev.nyon.telekinesis - -enum class TelekinesisPolicy { - BlockDrops, - ExpDrops, - EntityDrops; - - fun isEnabled(): Boolean = when (this) { - BlockDrops -> config.blockDrops - ExpDrops -> config.expDrops - EntityDrops -> config.entityDrops - } - - fun associatedPermission(): String? = when (this) { - BlockDrops -> config.blockDropsPermissionRequirement - ExpDrops -> config.expDropsPermissionRequirement - EntityDrops -> config.entityDropsPermissionRequirement - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt deleted file mode 100644 index 50031a0..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/BlockListeners.kt +++ /dev/null @@ -1,30 +0,0 @@ -package dev.nyon.telekinesis.listeners - -import dev.nyon.telekinesis.TelekinesisPolicy -import dev.nyon.telekinesis.util.handleTelekinesis -import dev.nyon.telekinesis.util.listen -import org.bukkit.event.block.BlockBreakEvent -import org.bukkit.event.block.BlockDropItemEvent - -fun initBlockListeners() { - dropEvent - blockBreakEvent -} - -val dropEvent = listen { - player.handleTelekinesis(TelekinesisPolicy.BlockDrops, player.inventory.itemInMainHand) { - val copy = mutableListOf(items).flatten() - items.clear() - copy.forEach { - val result = inventory.addItem(it.itemStack) - if (result.isNotEmpty()) items.add(it) - } - } -} - -val blockBreakEvent = listen { - player.handleTelekinesis(TelekinesisPolicy.ExpDrops, null) { - giveExp(expToDrop) - expToDrop = 0 - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt deleted file mode 100644 index 590dfc2..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/listeners/MobListeners.kt +++ /dev/null @@ -1,34 +0,0 @@ -package dev.nyon.telekinesis.listeners - -import dev.nyon.telekinesis.TelekinesisPolicy -import dev.nyon.telekinesis.util.handleTelekinesis -import dev.nyon.telekinesis.util.listen -import org.bukkit.event.entity.EntityDeathEvent - -fun initMobListeners() { - mobDie - mobExpDie -} - -val mobDie = listen { - println(entityType.name) - val killer = this.entity.killer ?: return@listen - - killer.handleTelekinesis(TelekinesisPolicy.EntityDrops, null) { - val copy = mutableListOf(drops).flatten() - drops.clear() - copy.forEach { - val result = inventory.addItem(it) - if (result.isNotEmpty()) drops.add(it) - } - } -} - -val mobExpDie = listen { - val killer = this.entity.killer ?: return@listen - - killer.handleTelekinesis(TelekinesisPolicy.ExpDrops, null) { - giveExp(droppedExp, true) - droppedExp = 0 - } -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt deleted file mode 100644 index 2bee9b3..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/Listeners.kt +++ /dev/null @@ -1,25 +0,0 @@ -package dev.nyon.telekinesis.util - -import dev.nyon.telekinesis.Plugin -import org.bukkit.Bukkit -import org.bukkit.event.Event -import org.bukkit.event.EventPriority -import org.bukkit.event.Listener - -abstract class SingleListener : Listener { - abstract fun onEvent(event: T) -} - -inline fun listen(crossinline eventCallback: T.() -> Unit) { - val listener = object : SingleListener() { - override fun onEvent(event: T) = eventCallback(event) - } - Bukkit.getPluginManager() - .registerEvent( - T::class.java, - listener, - EventPriority.NORMAL, - { _, event -> listener.onEvent(event as T) }, - Plugin - ) -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt b/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt deleted file mode 100644 index e8a2a34..0000000 --- a/telekinesis-paper/src/main/kotlin/dev/nyon/telekinesis/util/TelekinesisCheck.kt +++ /dev/null @@ -1,45 +0,0 @@ -package dev.nyon.telekinesis.util - -import dev.nyon.telekinesis.TelekinesisPolicy -import dev.nyon.telekinesis.bukkitEnchantment -import dev.nyon.telekinesis.config -import org.bukkit.entity.Player -import org.bukkit.inventory.ItemStack - -fun ItemStack.hasTelekinesis(): Boolean = hasItemMeta() && itemMeta.enchants.contains(bukkitEnchantment) - -fun Player.handleTelekinesis(policy: TelekinesisPolicy, itemStack: ItemStack?, callback: Player.() -> Unit): Boolean { - if (!policy.isEnabled()) return false - if (!meetCondition(policy, itemStack)) return false - - callback() - return true -} - -private fun Player.meetCondition(policy: TelekinesisPolicy, itemStack: ItemStack?): Boolean { - fun Player.hasPermission(policy: TelekinesisPolicy): Boolean { - val permission = policy.associatedPermission() - return permission == null || this@hasPermission.hasPermission(permission) - } - - var conditionsMet: Boolean - - val isEnabledByDefault = config.onByDefault && - (config.onByDefaultPermissionRequirement == null || hasPermission(config.onByDefaultPermissionRequirement!!)) - - val hasArmorTelekinesis: Boolean = inventory.armorContents.all { it?.hasTelekinesis() == true } - val hasMainHandTelekinesis = - itemStack != null && itemStack.hasTelekinesis() || inventory.itemInMainHand.hasTelekinesis() - val hasOffHandTelekinesis = inventory.itemInOffHand.hasTelekinesis() - - conditionsMet = if (isEnabledByDefault) true else when (policy) { - TelekinesisPolicy.ExpDrops -> hasArmorTelekinesis || hasMainHandTelekinesis || hasOffHandTelekinesis - TelekinesisPolicy.EntityDrops -> hasMainHandTelekinesis || hasOffHandTelekinesis - TelekinesisPolicy.BlockDrops -> hasMainHandTelekinesis - } - - if (!hasPermission(policy)) conditionsMet = false - if (config.onlyOnSneak && !isSneaking) conditionsMet = false - - return conditionsMet -} \ No newline at end of file diff --git a/telekinesis-paper/src/main/resources/paper-plugin.yml b/telekinesis-paper/src/main/resources/paper-plugin.yml deleted file mode 100644 index 724feb6..0000000 --- a/telekinesis-paper/src/main/resources/paper-plugin.yml +++ /dev/null @@ -1,9 +0,0 @@ -name: $name -version: $version -main: $main -description: $description -authors: $authors -website: $website -api-version: $apiVersion -folia-supported: $foliaSupported -loader: $loader \ No newline at end of file diff --git a/telekinesis-fabric/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties similarity index 83% rename from telekinesis-fabric/versions/1.20.1/gradle.properties rename to versions/1.20.1/gradle.properties index 68beccc..86e91d5 100644 --- a/telekinesis-fabric/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -2,7 +2,7 @@ mcVersion=1.20.1 mcVersionRange=>=1.20 <=1.20.3 supportedMcVersions=1.20,1.20.1 -deps.parchment=1.20.1:2023.09.03 +deps.parchment= deps.fapi=0.92.1+1.20.1 deps.yacl=3.4.2+1.20.1-fabric deps.modMenu=7.2.2 diff --git a/telekinesis-fabric/versions/1.20.4/gradle.properties b/versions/1.20.4/gradle.properties similarity index 83% rename from telekinesis-fabric/versions/1.20.4/gradle.properties rename to versions/1.20.4/gradle.properties index 60732ac..b9ea1db 100644 --- a/telekinesis-fabric/versions/1.20.4/gradle.properties +++ b/versions/1.20.4/gradle.properties @@ -2,7 +2,7 @@ mcVersion=1.20.4 mcVersionRange=>=1.20.3 <=1.20.4 supportedMcVersions=1.20.4 -deps.parchment=1.20.4:2024.04.14 +deps.parchment= deps.fapi=0.97.0+1.20.4 deps.yacl=3.4.2+1.20.4-fabric deps.modMenu=9.2.0-beta.2 diff --git a/telekinesis-fabric/versions/1.20.6/gradle.properties b/versions/1.20.6/gradle.properties similarity index 72% rename from telekinesis-fabric/versions/1.20.6/gradle.properties rename to versions/1.20.6/gradle.properties index 7a02cb9..a530c60 100644 --- a/telekinesis-fabric/versions/1.20.6/gradle.properties +++ b/versions/1.20.6/gradle.properties @@ -2,8 +2,8 @@ mcVersion=1.20.6 mcVersionRange=>=1.20.5 <=1.20.6 supportedMcVersions=1.20.5,1.20.6 -deps.parchment=1.20.6:2024.05.01 -deps.fapi=0.97.8+1.20.6 +deps.parchment= +deps.fapi=0.100.0+1.20.6 deps.yacl=3.4.2+1.20.5-fabric deps.modMenu=10.0.0-beta.1 diff --git a/versions/1.21/gradle.properties b/versions/1.21/gradle.properties new file mode 100644 index 0000000..6f14645 --- /dev/null +++ b/versions/1.21/gradle.properties @@ -0,0 +1,10 @@ +mcVersion=1.21 +mcVersionRange=>=1.20.6 <=1.21 +supportedMcVersions=1.21 + +deps.parchment= +deps.fapi=0.100.1+1.21 +deps.yacl=3.5.0+1.21-fabric +deps.modMenu=11.0.0-beta.1 + +javaVer=21