diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8c462b7..3cf65df 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,89 +1,170 @@ name: CI +# release: (release title) +# dispatch (all): Manual release for $target_release_tag +# dispatch (specified): Manual release for $target_release_tag (subproject: $target_subproject) +run-name: |- + ${{ github.event_name == 'workflow_dispatch' && format('Manual release for {0}{1}', inputs.target_release_tag, inputs.target_subproject && format(' (subproject: {0})', inputs.target_subproject) || '') || '' }} on: push: - branches: - - 'nyan-work/dev' - + paths: + - "*.gradle" + - "gradle.properties" + - "src/**" + - "versions/**" + - ".github/**" + release: + types: + - published + pull_request: + workflow_dispatch: + inputs: + target_subproject: + description: |- + The subproject name(s) of the specified Minecraft version to be released, seperated with ",". + By default all subprojects will be released. + type: string + required: false + default: '' + target_release_tag: + description: |- + The tag of the release you want to append the artifact to. + type: string + required: true jobs: - build: - if: ${{ github.event_name == 'push' && !startsWith(github.event.ref, 'refs/tags/') && contains(github.event.head_commit.message, '[build skip]') == false }} - strategy: - matrix: - java: [ 17 ] - os: [ ubuntu-latest ] - runs-on: ${{ matrix.os }} + show_action_parameters: + runs-on: ubuntu-latest + steps: + - name: Show action parameters + run: | + cat < $GITHUB_STEP_SUMMARY + ## Action Parameters + - target_subproject: \`${{ inputs.target_subproject }}\` + - target_release_tag: \`${{ inputs.target_release_tag }}\` + EOF + generate_matrix: + if: ${{ github.event_name != 'pull_request' }} + uses: ./.github/workflows/generate_matrix.yml + with: + target_subproject: ${{ inputs.target_subproject }} + validate_target_subproject: + runs-on: ubuntu-latest steps: - name: Checkout the sources - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - - - name: Set up JDK ${{ matrix.java }} - uses: actions/setup-java@v3 - with: - distribution: 'adopt' - java-version: ${{ matrix.java }} - - - name: Cache Gradle packages - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ./.gradle/loom-caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - - - name: Get short commit sha - id: get_short_sha - run: | - short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) - echo "short_sha=$short_sha" >> $GITHUB_OUTPUT - - - name: Get commit count - id: get_commit_count - run: | - commit_count=$(git log | grep -e 'commit [a-zA-Z0-9]*' | wc -l) - echo "commit_count=$commit_count" >> $GITHUB_OUTPUT - - - name: Read Properties mod info - id: mod_info - uses: christian-draeger/read-properties@1.1.1 - with: - path: gradle.properties - properties: 'mod_name mod_version' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Preprocess sources + - name: Validate target subproject + if: ${{ github.event_name == 'workflow_dispatch' }} + # ubuntu-22.04 uses Python 3.10.6 + run: python3 .github/workflows/scripts/validate_subproject.py env: - BUILD_TYPE: "BETA" - run: ./gradlew preprocessResources --stacktrace - - - name: Publish Maven with Gradle + TARGET_SUBPROJECT: ${{ inputs.target_subproject }} + # Ensure the input release tag is valid. + validate_release: + runs-on: ubuntu-latest + steps: + - name: Get github release information + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: cardinalby/git-get-release-action@1.2.5 env: - BUILD_TYPE: "BETA" - run: ./gradlew build --stacktrace - - - name: Upload assets to GitHub Action - uses: actions/upload-artifact@v3 + GITHUB_TOKEN: ${{ github.token }} with: - name: "${{ steps.mod_info.outputs.mod_name }} ${{ steps.mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_short_sha.outputs.short_sha }}" - path: | - LICENSE - fabricWrapper/build/libs/*.jar - fabricWrapper/build/tmp/submods/META-INF/jars/*.jar - - - name: Create Github release - if: contains(github.event.head_commit.message, '[publish skip]') == false && contains(github.event.ref, 'refs/heads/exp') == false - uses: softprops/action-gh-release@v1 + tag: ${{ inputs.target_release_tag }} + prepare_build_info: + if: ${{ !startsWith(github.event.ref, 'refs/tags/') }} + runs-on: ubuntu-latest + outputs: + build_publish: ${{ steps.build_info.outputs.build_publish }} + build_target_subprojects: ${{ steps.subprojects.outputs.subprojects }} + build_version_type: ${{ steps.build_info.outputs.build_version_type }} + publish_channel: ${{ steps.build_info.outputs.publish_channel }} + publish_target_release_tag: ${{ steps.build_info.outputs.publish_target_release_tag }} + steps: + - name: Checkout the sources + uses: actions/checkout@v4 with: - prerelease: true - files: | - LICENSE - fabricWrapper/build/libs/*.jar - fabricWrapper/build/tmp/submods/META-INF/jars/*.jar - name: "[CI#${{ github.run_number }}]${{ steps.mod_info.outputs.mod_name }} ${{ steps.mod_info.outputs.mod_version }}.${{ steps.get_commit_count.outputs.commit_count }}+${{ steps.get_short_sha.outputs.short_sha }}" - tag_name: "${{ github.ref_name }}.${{ github.run_number }}" - target_commitish: ${{ github.event.ref }} - generate_release_notes: true \ No newline at end of file + fetch-depth: 0 + - name: Determining build info + id: build_info + run: | + if [ ${{ github.event_name }} == 'push' ] + then + build_publish=true + build_version_type=BETA + publish_channel=dev + elif [ ${{ github.event_name }} == 'release' ] + then + build_publish=true + build_version_type=RELEASE + publish_channel=stable + publish_target_release_tag=${{ github.event.ref }} + elif [ ${{ github.event_name }} == 'pull_request' ] + then + build_publish=false + build_version_type=PULL_REQUEST + elif [ ${{ github.event_name }} == 'workflow_dispatch' ] + then + build_publish=true + build_version_type=RELEASE + publish_channel=stable + publish_target_release_tag=${{ inputs.target_release_tag }} + else + echo Unknown github event name $GITHUB_EVENT_NAME + exit 1 + fi + + echo "build_publish=$build_publish" >> $GITHUB_OUTPUT + echo "build_version_type=$build_version_type" >> $GITHUB_OUTPUT + echo "publish_channel=$publish_channel" >> $GITHUB_OUTPUT + echo "publish_target_release_tag=$publish_target_release_tag" >> $GITHUB_OUTPUT + + cat < $GITHUB_STEP_SUMMARY + ## Determining build info + - build_publish: \`$build_publish\` + - build_version_type: \`$build_version_type\` + - publish_channel: \`$publish_channel\` + - publish_target_release_tag: \`$publish_target_release_tag\` + EOF + - name: Determining subprojects + id: subprojects + run: python3 .github/workflows/scripts/determining_subproject.py + env: + TARGET_SUBPROJECT: ${{ github.event.inputs.target_subproject }} + prepare_publish_info: + if: ${{ needs.prepare_build_info.outputs.build_publish == 'true' }} + runs-on: ubuntu-latest + needs: + - prepare_build_info + outputs: + publish_channel: ${{ needs.prepare_build_info.outputs.publish_channel }} + publish_target_release_tag: ${{ needs.prepare_build_info.outputs.publish_target_release_tag }} + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + build: + if: ${{ contains(github.event.head_commit.message, '[build skip]') == false }} + needs: + - prepare_build_info + - validate_target_subproject + - validate_release + uses: ./.github/workflows/build.yml + secrets: inherit + with: + build_publish: ${{ needs.prepare_build_info.outputs.build_publish }} + build_version_type: ${{ needs.prepare_build_info.outputs.build_version_type }} + target_subproject: ${{ needs.prepare_build_info.outputs.build_target_subprojects }} + publish: + if: ${{ github.event_name != 'pull_request' }} + strategy: + matrix: ${{ fromJson(needs.generate_matrix.outputs.matrix) }} + needs: + - build + - generate_matrix + - prepare_publish_info + uses: ./.github/workflows/publish.yml + secrets: inherit + with: + publish_channel: ${{ needs.prepare_publish_info.outputs.publish_channel }} + publish_mc_ver: ${{ matrix.mc_ver }} + publish_platform: ${{ matrix.platform }} + publish_target_release_tag: ${{ needs.prepare_publish_info.outputs.publish_target_release_tag }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9d4528e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,74 @@ +name: step.build +on: + workflow_call: + inputs: + build_publish: + type: string + required: true + build_version_type: + type: string + required: true + target_subproject: + description: see CI.yml, leave it empty to build all + type: string + required: false + default: '' +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 21 + - name: Cache gradle files + if: ${{ inputs.build_version_type != 'PULL_REQUEST' }} + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + ./.gradle/loom-cache + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle.properties', '**/*.accesswidener', 'settings.json') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Build with gradle + run: | + chmod +x gradlew + if [ -z "${{ inputs.target_subproject }}" ]; then + echo "Building all subprojects" + ./gradlew build + else + args=$(echo "${{ inputs.target_subproject }}" | tr ',' '\n' | sed 's/$/:build/' | paste -sd ' ') + echo "Building with arguments=$args" + ./gradlew $args + fi + env: + BUILD_TYPE: ${{ inputs.build_version_type }} + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: versions/*/build/libs/ + summary: + runs-on: ubuntu-22.04 + needs: + - build + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: build-artifacts + - name: Make build summary + # ubuntu-22.04 uses Python 3.10.6 + run: python3 .github/workflows/scripts/summary.py diff --git a/.github/workflows/generate_matrix.yml b/.github/workflows/generate_matrix.yml new file mode 100644 index 0000000..0993a55 --- /dev/null +++ b/.github/workflows/generate_matrix.yml @@ -0,0 +1,29 @@ +name: step.generate_matrix +on: + workflow_call: + inputs: + target_subproject: + description: see CI.yml, for generating matrix entries + type: string + required: false + default: '' + outputs: + matrix: + description: The generated run matrix + value: ${{ jobs.generate_matrix.outputs.matrix }} +jobs: + generate_matrix: + runs-on: ubuntu-22.04 + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate matrix + id: generate_matrix + # ubuntu-22.04 uses Python 3.10.6 + run: python3 .github/workflows/scripts/matrix.py + env: + TARGET_SUBPROJECT: ${{ inputs.target_subproject }} + outputs: + matrix: ${{ steps.generate_matrix.outputs.matrix }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3dfb355 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,126 @@ +name: step.publish +on: + workflow_call: + inputs: + publish_channel: + type: string + required: true + publish_mc_ver: + type: string + required: true + publish_platform: + type: string + required: true + publish_target_release_tag: + description: |- + The tag of the release you want to append the artifact to. + type: string + required: true +jobs: + publish: + runs-on: ubuntu-latest + # Allow the mod publish step to add assets to release + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token + permissions: + contents: write + steps: + - name: Checkout the sources + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-artifacts + path: build-artifacts + - name: Get git info + id: get_git_info + run: | + short_sha=$(echo ${GITHUB_SHA} | cut -c1-7) + commit_count=$(git log | grep -e '^commit [a-zA-Z0-9]*' | wc -l) + echo "short_sha=$short_sha" >> $GITHUB_OUTPUT + echo "commit_count=$commit_count" >> $GITHUB_OUTPUT + - name: Get github release information + if: ${{ github.event_name == 'workflow_dispatch' }} + id: get_release + uses: cardinalby/git-get-release-action@1.2.5 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + tag: ${{ github.event.inputs.publish_target_release_tag }} + - name: Read Properties mod info + id: mod_info + uses: christian-draeger/read-properties@1.1.1 + with: + path: gradle.properties + properties: 'mod.name mod.version' + - name: Prepare file information + id: file_info + run: | + shopt -s extglob + FILE_PATHS=$(ls ${{ format('build-artifacts/{0}-{1}/build/libs/!(*-@(dev|sources|javadoc)).jar', inputs.publish_mc_ver, inputs.publish_platform) }}) + + if (( ${#FILE_PATHS[@]} != 1 )); then + echo "Error: Found ${#FILE_PATHS[@]} files, expected exactly 1" + exit 1 + else + FILE_PATH=${FILE_PATHS[0]} + fi + + FILE_NAME=$(basename $FILE_PATH) + FILE_HASH=$(sha256sum $FILE_PATH | awk '{ print $1 }') + echo "path=$FILE_PATH" >> $GITHUB_OUTPUT + echo "name=$FILE_NAME" >> $GITHUB_OUTPUT + echo "hash=$FILE_HASH" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT + - name: Prepare changelog (Dev Channel) + if: ${{ inputs.publish_channel == 'dev' }} + uses: actions/github-script@v7 + id: changelog_dev + with: + script: return process.env.CHANGELOG + result-encoding: string + env: + CHANGELOG: |- + **This version is automatically released by CI Build** + + Latest commit log: + + ${{ github.event.head_commit.message }} + + ------- + + Build Information + + - File name: `${{ steps.file_info.outputs.name }}` + - SHA-256: `${{ steps.file_info.outputs.hash }}` + - Built from: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + - name: Publish Minecraft Mods (Dev Channel) + if: ${{ inputs.publish_channel == 'dev' }} + uses: Kir-Antipov/mc-publish@v3.3 + with: + # modrinth-id: + # modrinth-token: ${{ secrets.MODRINTH }} + # curseforge-id: + # curseforge-token: ${{ secrets.CF_API_TOKEN }} + github-tag: ${{ inputs.publish_target_release_tag }} + github-token: ${{ secrets.GITHUB_TOKEN }} + github-generate-changelog: true + files: ${{ steps.file_info.outputs.path }} + name: ${{ format('{0} {1}.{2} for Minecraft {3} ({4})', steps.mod_info.outputs.mod-name, steps.mod_info.outputs.mod-version, steps.get_git_info.outputs.commit_count, inputs.publish_mc_ver, inputs.publish_platform) }} + version: ${{ format('mc-{0}-{1}-v{2}.{3}', inputs.publish_mc_ver, inputs.publish_platform, steps.mod_info.outputs.mod-version, steps.get_git_info.outputs.commit_count) }} + version-type: release + github-changelog: ${{ format('{0}{1}', github.event.release.body, steps.get_release.outputs.body) }} + modrinth-changelog: ${{ steps.changelog.outputs.result }} + curseforge-changelog: ${{ steps.changelog.outputs.result }} + loaders: | + ${{ inputs.publish_platform }} + game-versions: | + ${{ inputs.publish_mc_ver }} + game-version-filter: any + dependencies: | + fabric(required){modrinth:P7dR8mSH}{curseforge:306612}#(ignore:github) + magiclib(required) + malilib(required) + retry-attempts: 2 + retry-delay: 10000 diff --git a/.github/workflows/scripts/common.py b/.github/workflows/scripts/common.py new file mode 100644 index 0000000..def4ced --- /dev/null +++ b/.github/workflows/scripts/common.py @@ -0,0 +1,86 @@ +""" +Common functions +""" +__author__ = 'Hendrix_Shen' + +import json +from typing import Dict, List, Set + +__PLATFORM_MAPPING: dict = { + 'fabric': 'Fabric', + 'forge': 'Forge', + 'neoforge': 'NeoForge', + 'quilt': 'Quilt' +} + + +def get_mc_vers(subproject_dict: Dict[str, List[str]]) -> List[str]: + mc_vers: Set[str] = set() + + for subproject in subproject_dict: + for mc_ver in subproject_dict[subproject]: + mc_vers.add(mc_ver) + + return sorted(list(mc_vers)) + + +def get_subproject_dict() -> Dict[str, List[str]]: + with open('settings.json') as f: + settings: dict = json.load(f) + + projects: Dict[str, List[str]] = {} + + for version in settings['versions']: + module: Module = Module.of(version) + + if module.platform() not in projects: + projects[module.platform()] = [] + + projects[module.platform()].append(module.mc_ver()) + + for platform in projects: + projects[platform] = sorted(list(set(projects[platform]))) + + return projects + + +def pretty_platform(platform: str) -> str: + return __PLATFORM_MAPPING.get(platform, '* Unknown *') + + +def read_prop(file_name: str, key: str) -> str: + with open(file_name) as prop: + return next(filter( + lambda x: x.split('=', 1)[0].strip() == key, + prop.readlines() + )).split('=', 1)[1].lstrip() + + +class Module: + __mc_ver: str + __platform: str + + def __init__(self, mc_ver: str, platform: str) -> None: + self.__mc_ver = mc_ver + self.__platform = platform + + @staticmethod + def of(module_name: str) -> 'Module': + s = module_name.split('-') + + if len(s) == 2: + return Module(s[0], s[1]) + else: + return Module('unknown', 'unknown') + + def platform(self) -> str: + return self.__platform + + def mc_ver(self) -> str: + return self.__mc_ver + + def pretty_platform(self) -> str: + return pretty_platform(self.__platform) + + def get_str(self) -> str: + return f'{self.__mc_ver}-{self.__platform}' diff --git a/.github/workflows/scripts/determining_subproject.py b/.github/workflows/scripts/determining_subproject.py new file mode 100644 index 0000000..94c390b --- /dev/null +++ b/.github/workflows/scripts/determining_subproject.py @@ -0,0 +1,31 @@ +__author__ = 'Hendrix_Shen' + +import os +from typing import List, Dict + +import common + + +def main(): + target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + subproject_dict: Dict[str, List[str]] = common.get_subproject_dict() + gradle_subprojects: List[str] = [] + + for target_subproject in target_subprojects: + for platform in subproject_dict: + if target_subproject in subproject_dict[platform]: + gradle_subprojects.append('{}-{}'.format(target_subproject, platform)) + + result: str = ','.join(gradle_subprojects) + + with open(os.environ['GITHUB_STEP_SUMMARY'], 'w') as f: + f.write('## Determining subprojects\n') + f.write('- subprojects={}\n'.format(result)) + + with open(os.environ['GITHUB_OUTPUT'], 'w') as f: + f.write('- subprojects={}\n'.format(result)) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/scripts/matrix.py b/.github/workflows/scripts/matrix.py new file mode 100644 index 0000000..cfc99b6 --- /dev/null +++ b/.github/workflows/scripts/matrix.py @@ -0,0 +1,49 @@ +""" +Modified from github.com/Fallen-Breath/fabric-mod-template +Originally authored by Fallen_Breath + +A script to scan through the versions directory and collect all folder names as the subproject list, +then output a json as the github action include matrix +""" +__author__ = 'Hendrix_Shen' + +import json +import os +from typing import Dict, List + +import common + + +def main(): + # target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subproject_env = '' + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + print('target_subprojects: {}'.format(target_subprojects)) + subproject_dict: Dict[str, List[str]] = common.get_subproject_dict() + matrix: Dict[str, List[Dict[str, str]]] = {'include': []} + + if len(target_subprojects) == 0: + for platform in subproject_dict: + for mc_ver in subproject_dict[platform]: + matrix['include'].append({ + 'platform': platform, + 'mc_ver': mc_ver + }) + else: + for platform in subproject_dict: + for mc_ver in subproject_dict[platform]: + if mc_ver in target_subprojects: + matrix['include'].append({ + 'platform': platform, + 'mc_ver': mc_ver + }) + + with open(os.environ['GITHUB_OUTPUT'], 'w') as f: + f.write('matrix={}\n'.format(json.dumps(matrix))) + + print('matrix:') + print(json.dumps(matrix, indent=2)) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/scripts/summary.py b/.github/workflows/scripts/summary.py new file mode 100644 index 0000000..de64dc6 --- /dev/null +++ b/.github/workflows/scripts/summary.py @@ -0,0 +1,89 @@ +""" +Modified from github.com/Fallen-Breath/fabric-mod-template +Originally authored by Fallen_Breath + +A script to scan through all valid mod jars in build-artifacts.zip/$version/build/libs, +and generate an artifact summary table for that to GitHub action step summary +""" +__author__ = 'Hendrix_Shen' + +import functools +import glob +import hashlib +import json +import os +from typing import List, Dict + +import common + + +def get_sha256_hash(file_path: str) -> str: + sha256_hash = hashlib.sha256() + + with open(file_path, 'rb') as f: + for buf in iter(functools.partial(f.read, 4096), b''): + sha256_hash.update(buf) + + return sha256_hash.hexdigest() + + +def get_file_info(file_paths: List[str], subproject: str, warnings: List[str]) -> dict: + if len(file_paths) == 0: + file_name = '*not found*' + file_size = 0 + sha256 = '*N/A*' + else: + file_name = '`{}`'.format(os.path.basename(file_paths[0])) + file_size = '{} B'.format(os.path.getsize(file_paths[0])) + sha256 = '`{}`'.format(get_sha256_hash(file_paths[0])) + if len(file_paths) > 1: + warnings.append( + 'Found too many build files in subproject {}: {}'.format(subproject, ', '.join(file_paths))) + + return { + 'file_name': file_name, + 'file_size': file_size, + 'sha256': sha256 + } + + +def main(): + target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + print('target_subprojects: {}'.format(target_subprojects)) + subproject_dict: Dict[str, List[str]] = common.get_subproject_dict() + + with open(os.environ['GITHUB_STEP_SUMMARY'], 'w') as f: + warnings = [] + modules: List[common.Module] = [] + + for platform in subproject_dict: + for mc_ver in subproject_dict[platform]: + if len(target_subprojects) > 0 and mc_ver not in target_subprojects: + print('Skipping {}-{}'.format(mc_ver, platform)) + continue + + modules.append(common.Module(mc_ver, platform)) + + modules = sorted(list(set(modules)), key=lambda m: (m.mc_ver(), m.platform())) + f.write('## Build Artifacts Summary\n\n') + f.write('| Minecraft | Platform | File | Size | SHA-256 |\n') + f.write('| --- | --- |--- | --- | --- |\n') + + for module in modules: + file_paths = glob.glob('build-artifacts/{}/build/libs/*.jar'.format(module.get_str())) + file_paths = list( + filter(lambda fp: not fp.endswith('-sources.jar') and not fp.endswith('-javadoc.jar'), file_paths)) + file_info = get_file_info(file_paths, 'magiclib-wrapper', warnings) + f.write('| {} | {} | {} | {} | {} |\n'.format(module.mc_ver(), module.pretty_platform(), + file_info.get('file_name'), file_info.get('file_size'), + file_info.get('sha256'))) + + if len(warnings) > 0: + f.write('\n### Warnings\n\n') + for warning in warnings: + f.write('- {}\n'.format(warning)) + + +if __name__ == '__main__': + main() diff --git a/.github/workflows/scripts/validate_subproject.py b/.github/workflows/scripts/validate_subproject.py new file mode 100644 index 0000000..6920a3f --- /dev/null +++ b/.github/workflows/scripts/validate_subproject.py @@ -0,0 +1,26 @@ +""" +A script to valid TARGET_SUBPROJECT. +""" +__author__ = 'Hendrix_Shen' + +import os +import sys +from typing import List + +import common + + +def main(): + target_subproject_env = os.environ.get('TARGET_SUBPROJECT', '') + target_subprojects = list(filter(None, target_subproject_env.split(',') if target_subproject_env != '' else [])) + subproject_dict: dict = common.get_subproject_dict() + mc_ver: List[str] = common.get_mc_vers(subproject_dict) + + for subproject in target_subprojects: + if subproject not in mc_ver: + print('Could not found subproject {} in any platform!'.format(subproject)) + sys.exit(1) + + +if __name__ == '__main__': + main() diff --git a/build.gradle b/build.gradle index 64ac0b4..a933863 100644 --- a/build.gradle +++ b/build.gradle @@ -1,40 +1,77 @@ +import com.replaymod.gradle.preprocess.Node + plugins { - id("maven-publish") - id("fabric-loom").version("1.4-SNAPSHOT").apply(false) - id("org.ajoberstar.grgit").version("5.2.0") - id("com.replaymod.preprocess").version("SNAPSHOT") + id("dev.architectury.loom").version("${architectury_loom_version}").apply(false) + id("org.ajoberstar.grgit").version("${grgit_version}") + id("com.replaymod.preprocess").version("${preprocessor_version}") + id("me.fallenbreath.yamlang").version("${yamlang_version}").apply(false) } preprocess { - def mc1144 = createNode("1.14.4", 1_14_04, "mojang") - def mc1152 = createNode("1.15.2", 1_15_02, "mojang") - def mc1165 = createNode("1.16.5", 1_16_05, "mojang") - def mc1171 = createNode("1.17.1", 1_17_01, "mojang") - def mc1182 = createNode("1.18.2", 1_18_02, "mojang") - def mc1192 = createNode("1.19.2", 1_19_02, "mojang") - def mc1193 = createNode("1.19.3", 1_19_03, "mojang") - def mc1194 = createNode("1.19.4", 1_19_04, "mojang") - def mc1201 = createNode("1.20.1", 1_20_01, "mojang") - def mc1202 = createNode("1.20.2", 1_20_02, "mojang") - def mc1204 = createNode("1.20.4", 1_20_04, "mojang") - - mc1144.link(mc1152, null) - mc1152.link(mc1165, file("versions/mapping-1.15.2-1.16.5.txt")) - mc1165.link(mc1171, null) - mc1171.link(mc1182, null) - mc1182.link(mc1192, file("versions/mapping-1.18.2-1.19.2.txt")) - mc1192.link(mc1193, file("versions/mapping-1.19.2-1.19.3.txt")) - mc1193.link(mc1194, null) - mc1194.link(mc1201, null) - mc1201.link(mc1202, null) - mc1202.link(mc1204, null) + // Fabric + Node mc11404_fabric = createNode("1.14.4-fabric", 1_14_04, "mojang") + Node mc11502_fabric = createNode("1.15.2-fabric", 1_15_02, "mojang") + Node mc11605_fabric = createNode("1.16.5-fabric", 1_16_05, "mojang") + Node mc11701_fabric = createNode("1.17.1-fabric", 1_17_01, "mojang") + Node mc11802_fabric = createNode("1.18.2-fabric", 1_18_02, "mojang") + Node mc11902_fabric = createNode("1.19.2-fabric", 1_19_02, "mojang") + Node mc11903_fabric = createNode("1.19.3-fabric", 1_19_03, "mojang") + Node mc11904_fabric = createNode("1.19.4-fabric", 1_19_04, "mojang") + Node mc12001_fabric = createNode("1.20.1-fabric", 1_20_01, "mojang") + Node mc12002_fabric = createNode("1.20.2-fabric", 1_20_02, "mojang") + Node mc12004_fabric = createNode("1.20.4-fabric", 1_20_04, "mojang") + Node mc12006_fabric = createNode("1.20.6-fabric", 1_20_06, "mojang") + Node mc12101_fabric = createNode("1.21.1-fabric", 1_21_01, "mojang") + + mc11404_fabric.link(mc11502_fabric, null) + mc11502_fabric.link(mc11605_fabric, file("versions/mapping-1.15.2-1.16.5.txt")) + mc11605_fabric.link(mc11701_fabric, null) + mc11701_fabric.link(mc11802_fabric, null) + mc11802_fabric.link(mc11902_fabric, file("versions/mapping-1.18.2-1.19.2.txt")) + mc11902_fabric.link(mc11903_fabric, file("versions/mapping-1.19.2-1.19.3.txt")) + mc11903_fabric.link(mc11904_fabric, null) + mc11904_fabric.link(mc12001_fabric, null) + mc12001_fabric.link(mc12002_fabric, null) + mc12002_fabric.link(mc12004_fabric, null) + mc12004_fabric.link(mc12006_fabric, null) + mc12006_fabric.link(mc12101_fabric, null) } ext { - env = System.getenv() + Map env = System.getenv() + File localPropsFile = file("${rootDir}/local.properties") + + if (localPropsFile.exists()) { + Properties p = new Properties() + p.load(new FileInputStream(localPropsFile)) + p.each { key, value -> + ext[key as String] = value + } + } + + getEnv = { + return env + } + + getOrDefault = { String key, String defaultValue -> + String value + (value = project.findProperty(key)) && !value.isEmpty() ? value : defaultValue + } + + isGithubCI = { + return env.get("GITHUB_ACTION") != null + } + + isJitpack = { + return env.get("JITPACK") != null + } + + getBuildNumber = { + return env.GITHUB_RUN_NUMBER ? env.GITHUB_RUN_NUMBER : 0 + } getVersionGit = { List paths -> - if (grgit == null) { + if (grgit == null || grgit.head() == null) { return "nogit" } @@ -42,23 +79,33 @@ ext { return latestCommits.isEmpty() ? "uncommited" : "${latestCommits.get(0).id.substring(0, 7)}" } - getBuildNumber = { - return ext.env.GITHUB_RUN_NUMBER ? ext.env.GITHUB_RUN_NUMBER : Integer.MAX_VALUE - } - getVersionType = { - switch (ext.env.BUILD_TYPE) { + String type = getOrDefault("ow.build.environment.buildType", null) + + if (type != null) { + return type + } + + if (isJitpack()) { + return "jitpack" + } + + type = env.BUILD_TYPE + + switch (type) { case "RELEASE": return "stable" case "BETA": return "beta" + case "PULL_REQUEST": + return "pull_request" default: return "dev" } } getVersionPatch = { List paths -> - if (grgit == null) { + if (grgit == null || grgit.head() == null) { return 0 } @@ -66,16 +113,51 @@ ext { return latestCommits.size() } - getMavenArtifactVersion = { - return ext.getVersionType() == "stable" ? "${project.mod_version}.${ext.getVersionPatch([])}" : project.version + getVersion = { Project proj -> + return "${proj.property("mod.version")}.${getVersionPatch(proj == rootProject ? [] : [proj.projectDir.name])}" + } + + getVersionWithCommitHash = { Project proj -> + return "${getVersion(proj)}+${getVersionGit(proj == rootProject ? [] : [proj.projectDir.name])}-${getVersionType()}" } - getModVersion = { - return "${project.mod_version}.${getVersionPatch([])}+${getVersionGit([])}-${getVersionType()}" + getModVersion = { Project proj -> + return "${getVersion(proj)}-${getVersionType()}" + } + + getMavenArtifactVersion = { Project proj -> + return project.getVersionType() == "stable" ? "${getVersion(proj)}" : "${getModVersion(proj)}" } } -setVersion(project.getModVersion()) +tasks.register("genLocalProperties") { + it.group("${project.property("mod.id")}") + + doFirst { + File localPropsFile = file("${rootDir}/local.properties") + + if (localPropsFile.exists()) { + throw new IllegalStateException("local.properties file already generated. If you want to regenerate it, please delete it manually first") + } else { + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(localPropsFile)) + bufferedWriter.writeLine("# Secrets") + bufferedWriter.writeLine("secrets.gpg.signingKey=") + bufferedWriter.writeLine("secrets.gpg.signingPassword=") + bufferedWriter.writeLine("secrets.mavenCentral.username=") + bufferedWriter.writeLine("secrets.mavenCentral.password=") + bufferedWriter.writeLine("") + bufferedWriter.writeLine("# Overwritten configurations") + bufferedWriter.writeLine("ow.build.environment.local=") + bufferedWriter.writeLine("ow.build.environment.buildType=") + bufferedWriter.writeLine("ow.game.window.width=") + bufferedWriter.writeLine("ow.game.window.height=") + bufferedWriter.writeLine("ow.game.window.username=") + bufferedWriter.close() + + project.getLogger().info("local.properties generated successfully!") + } + } +} tasks.register("cleanPreprocessSources") { it.group("${project.mod_id}") diff --git a/common.gradle b/common.gradle deleted file mode 100644 index edaaee8..0000000 --- a/common.gradle +++ /dev/null @@ -1,294 +0,0 @@ -import com.google.common.collect.ImmutableList -import com.google.common.collect.ImmutableMap -import org.objectweb.asm.ClassReader -import org.objectweb.asm.ClassWriter -import org.objectweb.asm.tree.ClassNode -import org.objectweb.asm.tree.LdcInsnNode - -apply(plugin: "maven-publish") -apply(plugin: "fabric-loom") -apply(plugin: "com.replaymod.preprocess") - -int mcVersion = 1 - -preprocess { - mcVersion = vars.get().get("MC") - tabIndentation.set(false) -} - -repositories { - mavenLocal() - - maven { - name("JitPack") - url("https://www.jitpack.io") - } - - maven { - name("CurseForge Maven") - url("https://www.cursemaven.com") - - content { - includeGroup("curse.maven") - } - } - - maven{ - name("Modrinth Maven") - url("https://api.modrinth.com/maven") - - content { - includeGroup("maven.modrinth") - } - } - - mavenCentral() -} - -dependencies { - // Development environment - minecraft("com.mojang:minecraft:${project.minecraft_version}") - mappings(loom.officialMojangMappings()) - - // Annotation processor - modCompileOnly("org.projectlombok:lombok:${project.lombok_version}") - annotationProcessor("org.projectlombok:lombok:${project.lombok_version}") - - // Dependency - modImplementation("top.hendrixshen.magiclib:magiclib-${project.minecraft_version.replace(".", "_")}:${project.magiclib_version}") { - exclude(group: "carpet", module: "fabric-carpet") - } - -// if (mcVersion > 11902) { -// modImplementation("com.github.CaffeineMC:sodium-fabric:${project.sodium_version}") { -// transitive(false) -// } -// } - - // Misc - runtimeOnly(project(path: ":fabricWrapper")) -} - -group(project.mod_maven_group) -version(project.parent.version) - -base { - archivesName.set("${project.mod_archives_base_name}-${project.minecraft_version}") -} - -sourceSets { - dummy { - compileClasspath += main.compileClasspath - runtimeClasspath += main.runtimeClasspath - } - - main.compileClasspath += dummy.output -} - -loom { - interfaceInjection { - enableDependencyInterfaceInjection.set(true) - } - - runConfigs.configureEach { - // Dump modified classes automatically. - property("mixin.debug.export", "true") - } - - runConfigs.named("client") { - programArgs([ - "--width", - "1920", - "--height", - "1080", - ]) - runDir("run/client") - } - - runConfigs.named("server") { - runDir("run/server") - } - - runs { - mixinAuditClient { - inherit(client) - vmArgs("-Dmagiclib.mixin_audit=true") - ideConfigGenerated(false) - runDir("run/client") - } - - mixinAuditServer { - inherit(server) - vmArgs("-Dmagiclib.mixin_audit=true") - ideConfigGenerated(false) - runDir("run/server") - } - } - - // Setup client default settings. - runClient { - defaultCharacterEncoding("UTF-8") - - if (!new File("${projectDir}/run/client/options.txt").exists()) { - new File("${projectDir}/run/client").mkdirs() - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("${projectDir}/run/client/options.txt")) - bufferedWriter.writeLine("autoJump:false") - bufferedWriter.writeLine("enableVsync:false") - bufferedWriter.writeLine("forceUnicodeFont:true") - bufferedWriter.writeLine("fov:1.0") - bufferedWriter.writeLine("gamma:16.0") - bufferedWriter.writeLine("guiScale:3") - bufferedWriter.writeLine("lang:${Locale.getDefault().toString()}") - bufferedWriter.writeLine("maxFps:260") - bufferedWriter.writeLine("renderDistance:10") - bufferedWriter.writeLine("soundCategory_master:0.0") - bufferedWriter.close() - } - } - - // Setup server default settings. - runServer { - defaultCharacterEncoding("UTF-8") - - // Agree eula before server init. - if (!new File("${projectDir}/run/server/eula.txt").exists()) { - new File("${projectDir}/run/server").mkdirs() - BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("${projectDir}/run/server/eula.txt")) - bufferedWriter.writeLine("eula=true") - bufferedWriter.close() - } - } -} - -tasks.findAll { it.name in [ - "runClient", "runServer", - "runMixinAuditClient", "runMixinAuditServer", - "preprocessCode", "preprocessResources", - "preprocessTestCode", "preprocessTestResources"] }.forEach { - it.group("${project.mod_id}") -} - -tasks.withType(JavaCompile).configureEach { - options.setEncoding("UTF-8") - options.getCompilerArgs().add("-Xdiags:verbose") -} - -remapJar { - remapperIsolation.set(true) -} - -processResources { - outputs.upToDateWhen { false } - - from("${rootDir}/icon.png") { - into("assets/${project.mod_id}") - } - - filesMatching("fabric.mod.json") { - filter { line -> - line.trim().startsWith("//") ? "" : line - } - - expand([ - "magiclib_dependency" : project.magiclib_dependency, - "minecraft_dependency": project.minecraft_dependency, - "minecraft_version_id": project.minecraft_version.replace(".", "_"), - "minecraft_version" : project.minecraft_version, - "mod_description" : project.mod_description, - "mod_homepage" : project.mod_homepage, - "mod_id" : project.mod_id, - "mod_license" : project.mod_license, - "mod_name" : project.mod_name, - "mod_sources" : project.mod_sources, - "mod_version" : project.version - ]) - } -} - -java { - sourceCompatibility(JavaVersion.VERSION_1_8) - targetCompatibility(JavaVersion.VERSION_1_8) - withSourcesJar() -} - -jar { - from("${rootDir}/LICENSE") -} - -publishing { - publications { - create("mavenJava", MavenPublication) { - artifactId("${project.mod_id}-${project.minecraft_version.replace(".", "_")}") - from(components.java) - } - } - - repositories { - mavenLocal() - - maven { - url("$rootDir/publish") - } - } -} - -ImmutableMap replaceTokenMap = ImmutableMap.builder() - .put("@MOD_IDENTIFIER@" , project.mod_id) - .put("@MOD_NAME@" , project.mod_name) - .put("@MINECRAFT_VERSION_IDENTIFY@", project.minecraft_version.replace(".", "_")) - .build() -ImmutableList replaceTokenFile = ImmutableList.builder() - .add("OhMyMinecraftClientReference") - .build() - -tasks.classes { - doLast { - File dir = file("build/classes/java") - - dir.eachFileRecurse { - String path = it.path.replace(dir.path, "") - - if (path.endsWith(".class") && replaceTokenFile.stream().anyMatch { path.contains(it as String) }) { - ClassReader cr = new ClassReader(it.newInputStream().bytes) - ClassNode cn = new ClassNode() - cr.accept(cn, ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG) - - // ReplaceToken in fields - cn.fields.each { - if (it.desc == "Ljava/lang/String;" && it.value instanceof String) { - String value = it.value as String - - replaceTokenMap.each { - value = value.replace(it.key as String, it.value as String) - } - - it.value = value - } - } - - // ReplaceToken in methods - cn.methods.each { - it.instructions.each { - if (it instanceof LdcInsnNode) { - LdcInsnNode ldc = it as LdcInsnNode - - if (ldc.cst instanceof String) { - String value = ldc.cst as String - - replaceTokenMap.each { - value = value.replace(it.key as String, it.value as String) - } - - ldc.cst = value - } - } - } - } - - ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES) - cn.accept(cw) - new FileOutputStream(it).write(cw.toByteArray()) - } - } - } -} diff --git a/fabricWrapper/build.gradle b/fabricWrapper/build.gradle deleted file mode 100644 index 0c778ba..0000000 --- a/fabricWrapper/build.gradle +++ /dev/null @@ -1,113 +0,0 @@ -import groovy.json.JsonBuilder -import groovy.json.JsonSlurper - -plugins { - id("java-library") - id("maven-publish") -} - -group(project.mod_maven_group) -version(project.parent.version) - -base { - archivesName.set("${project.mod_archives_base_name}-all") -} - -def fabric_subprojects = project.parent.subprojects.findAll({ - it.name != "fabricWrapper" -}) - -fabric_subprojects.collect { - evaluationDependsOn(":${it.name}") -} - -jar { - // disable cache - outputs.upToDateWhen { false } - - dependsOn(fabric_subprojects.collect { - it.tasks.remapJar - }) - - doFirst { - delete fileTree("build/tmp/submods/META-INF/jars") - - copy { - from { - fabric_subprojects.collect { - it.remapJar.outputs.files - } - } - - into("build/tmp/submods/META-INF/jars") - } - } - - from("${rootDir}/LICENSE") - from("build/tmp/submods") -} - -processResources { - // disable cache - outputs.upToDateWhen { false } - - from("${rootDir}/icon.png") { - into("assets/${project.mod_id}") - } - - filesMatching("fabric.mod.json") { - expand([ - "magiclib_dependency": project.magiclib_dependency, - "mod_description" : project.mod_description, - "mod_homepage" : project.mod_homepage, - "mod_id" : project.mod_id, - "mod_license" : project.mod_license, - "mod_name" : project.mod_name, - "mod_version" : project.version, - "mod_sources" : project.mod_sources - ]) - } - - doLast { - ArrayList mc_condition = [] - ArrayList jars = [] - - fabric_subprojects.each({ - mc_condition.add("${it.minecraft_dependency}") - jars.add(["file": "META-INF/jars/${project.mod_archives_base_name}-${it.minecraft_version}-${project.version}.jar"]) - }) - - File file = file("build/resources/main/fabric.mod.json") - JsonSlurper slurper = new JsonSlurper() - JsonBuilder builder = new JsonBuilder(slurper.parse(file)) - builder.content.depends.minecraft = mc_condition - builder.content.jars = jars - BufferedWriter writer = file.newWriter() - writer.append(builder.toPrettyString()) - writer.flush() - writer.close() - } -} - -java { - sourceCompatibility(JavaVersion.VERSION_1_8) - targetCompatibility(JavaVersion.VERSION_1_8) -} - -publishing { - publications { - create("mavenJava", MavenPublication) { - artifactId("${project.mod_id}") - version("${project.version}") - from(components.java) - } - } - - repositories { - mavenLocal() - - maven { - url("$rootDir/publish") - } - } -} diff --git a/fabricWrapper/src/main/resources/fabric.mod.json b/fabricWrapper/src/main/resources/fabric.mod.json deleted file mode 100644 index fa0b33c..0000000 --- a/fabricWrapper/src/main/resources/fabric.mod.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "schemaVersion": 1, - "id": "${mod_id}", - "version": "${mod_version}", - "icon": "assets/${mod_id}/icon.png", - "name": "${mod_name}", - "description": "${mod_description}", - "authors": [ - { - "name": "plusls", - "contact": { - "homepage": "https://github.com/plusls" - } - } - ], - "contact": { - "homepage": "${mod_homepage}", - "issues": "${mod_sources}/issues", - "sources": "${mod_sources}" - }, - "license": "${mod_license}", - "environment": "client", - "entrypoints": { - "modmenu": [ - "com.plusls.ommc.compat.modmenu.WrapperModMenuApiImpl" - ] - }, - "depends": { - "magiclib": ">=${magiclib_dependency}", - "malilib": "*" - }, - "custom": { - "modmenu:clientsideOnly": true - } -} diff --git a/gradle.properties b/gradle.properties index 988489b..9280d60 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,23 +1,29 @@ # Gradle properties -org.gradle.cache.cleanup=false org.gradle.jvmargs=-Xmx6G -org.gradle.parallel=true # Mod Properties -mod_archives_base_name=oh-my-minecraft-client -mod_description=Make Minecraft Client Great Again! -mod_homepage=https://blog.plusls.com/ -mod_id=ommc -mod_license=LGPL-3 -mod_name=Oh My Minecraft Client -mod_maven_group=com.plusls.oh-my-minecraft-client -mod_sources=https://github.com/plusls/oh-my-minecraft-client -mod_version=0.5 +mod.archives_base_name=OhMyMinecraftClient +mod.artifact_name=oh_my_minecraft_client +mod.description=Make Minecraft Client Great Again! +mod.homepage=https://blog.plusls.com/ +mod.id=ommc +mod.license=LGPL-3 +mod.name=Oh My Minecraft Client +mod.maven_group=com.plusls.oh-my-minecraft-client +mod.sources=https://github.com/plusls/oh-my-minecraft-client +mod.version=0.6 # Required Libraries -# MagicLib - 0.7.398 -magiclib_dependency=0.7.398 -magiclib_version=0.7.398 +# MagicLib +dependencies.magiclib_dependency=0.8.640 +dependencies.magiclib_version=0.8.640-beta # Annotation processor -lombok_version=1.18.30 +dependencies.lombok_version=1.18.34 + +# Gradle Plugins +architectury_loom_version=1.7-SNAPSHOT +grgit_version=5.2.2 +preprocessor_version=ce1aeb2b +replace_token_version=1.1.2 +yamlang_version=1.4.0 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..a4b76b9 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a595206..79eb9d0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1aa94a4..f5feea6 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -84,7 +86,8 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,6 +13,8 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem @if "%DEBUG%"=="" @echo off @rem ########################################################################## @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail diff --git a/settings.gradle b/settings.gradle index 98d388f..d63d817 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonSlurper + pluginManagement { repositories { mavenLocal() @@ -5,46 +7,50 @@ pluginManagement { gradlePluginPortal() maven { - name("Fabric Maven") + name("Fabric") url("https://maven.fabricmc.net") } maven { - name("Jitpack Maven") - url("https://jitpack.io") + name("Architectury") + url("https://maven.architectury.dev") + } + + maven { + name("MinecraftForge") + url("https://files.minecraftforge.net/maven") } maven { - name("Nyan Maven") - url("https://maven.hendrixshen.top") + name("NeoForge") + url("https://maven.neoforged.net/releases") } maven { - name("Cotton") - url("https://server.bbkr.space/artifactory/libs-release") + name("Jitpack") + url("https://jitpack.io") + } + } + + resolutionStrategy { + eachPlugin { + switch (requested.id.id) { + case "com.replaymod.preprocess": { + useModule("com.github.Fallen-Breath:preprocessor:${requested.version}") + break + } + } } } } -def versions = Arrays.asList( - "1.14.4", - "1.15.2", - "1.16.5", - "1.17.1", - "1.18.2", - "1.19.2", - "1.19.3", - "1.19.4", - "1.20.1", - "1.20.2", - "1.20.4", -) - -for (String version : versions) { - include(":$version") - def proj = project(":$version") - proj.projectDir = file("versions/$version") - proj.buildFileName = "../../common.gradle" +Map> settings = file("settings.json").withReader { + new JsonSlurper().parse(it) as Map> } -include(":fabricWrapper") +for (String version : settings.get("versions")) { + include(":$version") + ProjectDescriptor proj = project(":$version") + proj.setProjectDir(file("versions/$version")) + proj.setBuildFileName("../${settings.versions.get(0)}/build.gradle") +} diff --git a/settings.json b/settings.json new file mode 100644 index 0000000..cf37c8e --- /dev/null +++ b/settings.json @@ -0,0 +1,17 @@ +{ + "versions": [ + "1.14.4-fabric", + "1.15.2-fabric", + "1.16.5-fabric", + "1.17.1-fabric", + "1.18.2-fabric", + "1.19.2-fabric", + "1.19.3-fabric", + "1.19.4-fabric", + "1.20.1-fabric", + "1.20.2-fabric", + "1.20.4-fabric", + "1.20.6-fabric", + "1.21.1-fabric" + ] +} \ No newline at end of file diff --git a/src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java new file mode 100644 index 0000000..cb84d41 --- /dev/null +++ b/src/dummy/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java @@ -0,0 +1,9 @@ +package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; + +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; + +public class BlockRenderer { + public native void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin); +} diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java index dc15399..ca73f56 100644 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java +++ b/src/main/java/com/plusls/ommc/OhMyMinecraftClient.java @@ -1,49 +1,25 @@ package com.plusls.ommc; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointResourceLoader; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; -import com.plusls.ommc.feature.preventWastageOfWater.PreventWastageOfWaterHandler; -import com.plusls.ommc.feature.realSneaking.RealSneakingEventHandler; +import com.plusls.ommc.impl.feature.highlightLavaSource.LavaSourceResourceLoader; +import com.plusls.ommc.impl.feature.preventWastageOfWater.PreventWastageOfWaterHelper; +import com.plusls.ommc.impl.feature.realSneaking.RealSneakingEventHelper; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; +import fi.dy.masa.malilib.config.ConfigManager; +import fi.dy.masa.malilib.event.InitializationHandler; import net.fabricmc.api.ClientModInitializer; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; -import top.hendrixshen.magiclib.malilib.impl.ConfigHandler; -import top.hendrixshen.magiclib.malilib.impl.ConfigManager; public class OhMyMinecraftClient implements ClientModInitializer { - private static final int CONFIG_VERSION = 1; - - @Dependencies(and = { - //#if MC > 11701 - @Dependency(value = "canvas", versionPredicate = ">=1.0.2308", optional = true), - //#if MC > 11903 - @Dependency(value = "fabric", versionPredicate = ">=0.84.0", optional = true), - //#else - //$$ @Dependency(value = "fabric", versionPredicate = ">=0.75.0", optional = true), - //#endif - @Dependency(value = "frex", versionPredicate = ">=6.0.242", optional = true), - @Dependency(value = "sodium", versionPredicate = ">=0.4.1", optional = true), - //#elseif MC > 11605 - //$$ @Dependency(value = "sodium", versionPredicate = ">=0.3.4", optional = true), - //#elseif MC > 11502 - //$$ @Dependency(value = "sodium", versionPredicate = ">=0.2.0", optional = true), - //#endif - }) @Override public void onInitializeClient() { + InitializationHandler.getInstance().registerInitializationHandler(() -> + ConfigManager.getInstance().registerConfigHandler(SharedConstants.getModIdentifier(), + SharedConstants.getConfigHandler())); + Configs.init(); LavaSourceResourceLoader.init(); - HighlightWaypointResourceLoader.init(); - ConfigManager cm = ConfigManager.get(OhMyMinecraftClientReference.getModIdentifier()); - cm.parseConfigClass(Configs.class); - OhMyMinecraftClientReference.configHandler = new ConfigHandler(OhMyMinecraftClientReference.getModIdentifier(), cm, CONFIG_VERSION); - OhMyMinecraftClientReference.configHandler.postDeserializeCallback = Configs::postDeserialize; - ConfigHandler.register(OhMyMinecraftClientReference.configHandler); - Configs.init(cm); - RealSneakingEventHandler.init(); - HighlightWaypointUtil.init(); - PreventWastageOfWaterHandler.init(); + HighlightWaypointHandler.init(); + RealSneakingEventHelper.init(); + PreventWastageOfWaterHelper.init(); } } diff --git a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java b/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java deleted file mode 100644 index 85456c6..0000000 --- a/src/main/java/com/plusls/ommc/OhMyMinecraftClientReference.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.plusls.ommc; - -import lombok.Getter; -import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.resources.ResourceLocation; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; -import top.hendrixshen.magiclib.language.api.I18n; -import top.hendrixshen.magiclib.malilib.impl.ConfigHandler; - -//#if MC > 11502 -import net.minecraft.network.chat.MutableComponent; -//#else -//$$ import net.minecraft.network.chat.BaseComponent; -//#endif - -public class OhMyMinecraftClientReference { - @Getter - private static final String currentModIdentifier = "@MOD_IDENTIFIER@-@MINECRAFT_VERSION_IDENTIFY@"; - @Getter - private static final String modIdentifier = "@MOD_IDENTIFIER@"; - @Getter - private static final String currentModName = FabricLoader.getInstance().getModContainer(currentModIdentifier).orElseThrow(RuntimeException::new).getMetadata().getName(); - @Getter - private static final String modName = "@MOD_NAME@"; - @Getter - private static final String modVersion = FabricLoader.getInstance().getModContainer(currentModIdentifier).orElseThrow(RuntimeException::new).getMetadata().getVersion().getFriendlyString(); - @Getter - private static final Logger logger = LogManager.getLogger(modIdentifier); - public static ConfigHandler configHandler; - - public static String translate(String key, Object... objects) { - return I18n.get(OhMyMinecraftClientReference.modIdentifier + "." + key, objects); - } - - public static @NotNull - //#if MC > 11502 - MutableComponent - //#else - //$$ BaseComponent - //#endif - translatable(String key, Object... objects) { - return ComponentCompatApi.translatable(OhMyMinecraftClientReference.modIdentifier + "." + key, objects); - } - - @Contract(value = "_ -> new", pure = true) - public static @NotNull ResourceLocation identifier(String path) { - return new ResourceLocation(OhMyMinecraftClientReference.modIdentifier, path); - } -} diff --git a/src/main/java/com/plusls/ommc/SharedConstants.java b/src/main/java/com/plusls/ommc/SharedConstants.java new file mode 100644 index 0000000..aa3bd40 --- /dev/null +++ b/src/main/java/com/plusls/ommc/SharedConstants.java @@ -0,0 +1,43 @@ +package com.plusls.ommc; + +import lombok.Getter; +import net.minecraft.resources.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; +import top.hendrixshen.magiclib.api.i18n.I18n; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.GlobalConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; +import top.hendrixshen.magiclib.util.VersionUtil; + +public class SharedConstants { + @Getter + private static final String modIdentifier = "@MOD_IDENTIFIER@"; + @Getter + private static final String modName = "@MOD_NAME@"; + @Getter + private static final String modVersion = "@MOD_VERSION@"; + @Getter + private static final String modVersionType = VersionUtil.getVersionType(SharedConstants.modVersion); + @Getter + private static final MagicConfigManager configManager = GlobalConfigManager + .getConfigManager(SharedConstants.getModIdentifier()); + @Getter + private static final MagicConfigHandler configHandler = new MagicConfigHandler(configManager, 1); + @Getter + private static final Logger logger = LogManager.getLogger(SharedConstants.modIdentifier); + + public static @NotNull String getTranslatedModVersionType() { + return VersionUtil.translateVersionType(SharedConstants.modVersion); + } + + public static @NotNull ResourceLocation identifier(String path) { + return ResourceLocationCompat.fromNamespaceAndPath(SharedConstants.getModIdentifier(), path); + } + + public static String getTranslation(String path) { + return I18n.tr(SharedConstants.modIdentifier + "." + path); + } +} diff --git a/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java b/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java index 0bd15f0..6e66032 100644 --- a/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java +++ b/src/main/java/com/plusls/ommc/api/command/ClientBlockPosArgument.java @@ -15,7 +15,7 @@ import net.minecraft.world.level.Level; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import java.util.Arrays; import java.util.Collection; @@ -25,9 +25,9 @@ // Modified from brigadier public class ClientBlockPosArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("0 0 0", "~ ~ ~", "^ ^ ^", "^1 ^ ^-5", "~0.5 ~1 ~-5"); - public static final SimpleCommandExceptionType ERROR_NOT_LOADED = new SimpleCommandExceptionType(ComponentCompatApi.translatable("argument.pos.unloaded")); - public static final SimpleCommandExceptionType ERROR_OUT_OF_WORLD = new SimpleCommandExceptionType(ComponentCompatApi.translatable("argument.pos.outofworld")); - public static final SimpleCommandExceptionType ERROR_OUT_OF_BOUNDS = new SimpleCommandExceptionType(ComponentCompatApi.translatable("argument.pos.outofbounds")); + public static final SimpleCommandExceptionType ERROR_NOT_LOADED = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.unloaded")); + public static final SimpleCommandExceptionType ERROR_OUT_OF_WORLD = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofworld")); + public static final SimpleCommandExceptionType ERROR_OUT_OF_BOUNDS = new SimpleCommandExceptionType(ComponentCompat.translatable("argument.pos.outofbounds")); @Contract(value = " -> new", pure = true) public static @NotNull ClientBlockPosArgument blockPos() { diff --git a/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java b/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java index 169eb90..604e683 100644 --- a/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java +++ b/src/main/java/com/plusls/ommc/api/command/ClientEntityAnchorArgument.java @@ -15,7 +15,7 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import java.util.Arrays; import java.util.Collection; @@ -27,7 +27,7 @@ public class ClientEntityAnchorArgument implements ArgumentType { private static final Collection EXAMPLES = Arrays.asList("eyes", "feet"); private static final DynamicCommandExceptionType ERROR_INVALID = new DynamicCommandExceptionType( - object -> ComponentCompatApi.translatable("argument.anchor.invalid", object) + object -> ComponentCompat.translatable("argument.anchor.invalid", object) ); public static ClientEntityAnchorArgument.Anchor getAnchor(@NotNull CommandContext commandContext, String string) { diff --git a/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java b/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java deleted file mode 100644 index e1ecb53..0000000 --- a/src/main/java/com/plusls/ommc/compat/modmenu/ModMenuApiImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.plusls.ommc.compat.modmenu; - -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.gui.GuiConfigs; -import top.hendrixshen.magiclib.compat.modmenu.ModMenuCompatApi; - -public class ModMenuApiImpl implements ModMenuCompatApi { - @Override - public ConfigScreenFactoryCompat getConfigScreenFactoryCompat() { - return (screen) -> { - GuiConfigs gui = GuiConfigs.getInstance(); - //#if MC > 11903 - gui.setParent(screen); - //#else - //$$ gui.setParentGui(screen); - //#endif - return gui; - }; - } - - @Override - public String getModIdCompat() { - return OhMyMinecraftClientReference.getCurrentModIdentifier(); - } -} diff --git a/src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java b/src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java deleted file mode 100644 index 3971123..0000000 --- a/src/main/java/com/plusls/ommc/compat/modmenu/WrapperModMenuApiImpl.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.plusls.ommc.compat.modmenu; - -import com.plusls.ommc.OhMyMinecraftClientReference; - -public class WrapperModMenuApiImpl extends ModMenuApiImpl { - @Override - public String getModIdCompat() { - return OhMyMinecraftClientReference.getModIdentifier(); - } -} diff --git a/src/main/java/com/plusls/ommc/config/Configs.java b/src/main/java/com/plusls/ommc/config/Configs.java deleted file mode 100644 index 0e4388c..0000000 --- a/src/main/java/com/plusls/ommc/config/Configs.java +++ /dev/null @@ -1,390 +0,0 @@ -package com.plusls.ommc.config; - -import com.google.common.collect.Lists; -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; -import com.plusls.ommc.feature.sortInventory.SortInventoryUtil; -import com.plusls.ommc.gui.GuiConfigs; -import fi.dy.masa.malilib.config.IConfigOptionListEntry; -import fi.dy.masa.malilib.config.options.ConfigBoolean; -import fi.dy.masa.malilib.config.options.ConfigHotkey; -import fi.dy.masa.malilib.hotkeys.KeybindSettings; -import fi.dy.masa.malilib.util.restrictions.UsageRestriction; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.MultiPlayerGameMode; -import net.minecraft.client.resources.language.I18n; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.core.config.Configurator; -import org.jetbrains.annotations.NotNull; -import top.hendrixshen.magiclib.dependency.api.ConfigDependencyPredicate; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; -import top.hendrixshen.magiclib.malilib.api.annotation.Config; -import top.hendrixshen.magiclib.malilib.api.annotation.Hotkey; -import top.hendrixshen.magiclib.malilib.api.annotation.Numeric; -import top.hendrixshen.magiclib.malilib.impl.ConfigHandler; -import top.hendrixshen.magiclib.malilib.impl.ConfigManager; -import top.hendrixshen.magiclib.malilib.impl.ConfigOption; -import top.hendrixshen.magiclib.util.InfoUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -public class Configs { - private static final List OLD_WORLD_EATER_MINE_HELPER_WHITELIST = new ArrayList<>(); - private static final List OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST = new ArrayList<>(); - private static final List OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST = new ArrayList<>(); - - public static void updateOldStringList() { - OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.clear(); - OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.addAll(blockModelNoOffsetBlacklist); - OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.clear(); - OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.addAll(blockModelNoOffsetWhitelist); - OLD_WORLD_EATER_MINE_HELPER_WHITELIST.clear(); - OLD_WORLD_EATER_MINE_HELPER_WHITELIST.addAll(worldEaterMineHelperWhitelist); - } - - public static void checkIsStringListChanged() { - boolean dirty = false; - if (!OLD_WORLD_EATER_MINE_HELPER_WHITELIST.equals(worldEaterMineHelperWhitelist) || - !OLD_BLOCK_MODEL_NO_OFFSET_BLACKLIST.equals(blockModelNoOffsetBlacklist) || - !OLD_BLOCK_MODEL_NO_OFFSET_WHITELIST.equals(blockModelNoOffsetWhitelist)) { - Minecraft.getInstance().levelRenderer.allChanged(); - dirty = true; - } - - - if (dirty) { - updateOldStringList(); - } - } - - // GENERIC - @Hotkey(hotkey = "C") - @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey clearWaypoint; - - @Config(category = ConfigCategory.GENERIC) - public static boolean debug = false; - - @Config(category = ConfigCategory.GENERIC) - public static boolean dontClearChatHistory = false; - - @Hotkey - @Config(category = ConfigCategory.GENERIC) - public static boolean forceParseWaypointFromChat = false; - - @Numeric(minValue = 0, maxValue = Integer.MAX_VALUE) - @Config(category = ConfigCategory.GENERIC) - public static int highlightBeamTime = 10; - - @Hotkey(hotkey = "O,C") - @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey openConfigGui; - - @Hotkey - @Config(category = ConfigCategory.GENERIC) - public static boolean parseWaypointFromChat = true; - - @Hotkey(hotkey = "O,P") - @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey sendLookingAtBlockPos; - - @Hotkey - @Config(category = ConfigCategory.GENERIC) - public static boolean sortInventorySupportEmptyShulkerBoxStack = false; - - @Hotkey(hotkey = "R") - @Config(category = ConfigCategory.GENERIC) - public static ConfigHotkey sortInventory; - - @Config(category = ConfigCategory.GENERIC) - public static IConfigOptionListEntry sortInventoryShulkerBoxLast = SortInventoryShulkerBoxLastType.AUTO; - - // FEATURE_TOGGLE - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean autoSwitchElytra = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean betterSneaking = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE, dependencies = @Dependencies(and = @Dependency(value = "minecraft", versionPredicate = ">1.15.2"))) - public static boolean disableBlocklistCheck = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disableBreakBlock = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disableBreakScaffolding = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disableMoveDownInScaffolding = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean disablePistonPushEntity = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean flatDigger = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean forceBreakingCooldown = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean highlightLavaSource = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean highlightPersistentMob = false; - - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean highlightPersistentMobClientMode = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean preventWastageOfWater = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean preventIntentionalGameDesign = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean realSneaking = false; - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean removeBreakingCooldown = false; - - - @Hotkey - @Config(category = ConfigCategory.FEATURE_TOGGLE) - public static boolean worldEaterMineHelper = false; - - - // LISTS - @Config(category = ConfigCategory.LISTS) - public static ArrayList blockModelNoOffsetBlacklist = new ArrayList<>(); - - @Config(category = ConfigCategory.LISTS) - public static IConfigOptionListEntry blockModelNoOffsetListType = UsageRestriction.ListType.WHITELIST; - - @Config(category = ConfigCategory.LISTS) - public static ArrayList blockModelNoOffsetWhitelist = Lists.newArrayList("minecraft:wither_rose", - "minecraft:poppy", "minecraft:dandelion"); - - @Config(category = ConfigCategory.LISTS) - public static ArrayList breakBlockBlackList = Lists.newArrayList("minecraft:budding_amethyst", "_bud"); - - @Config(category = ConfigCategory.LISTS) - public static ArrayList breakScaffoldingWhiteList = Lists.newArrayList("minecraft:air", "minecraft:scaffolding"); - - @Config(category = ConfigCategory.LISTS) - public static ArrayList highlightEntityBlackList = new ArrayList<>(); - - @Config(category = ConfigCategory.LISTS) - public static IConfigOptionListEntry highlightEntityListType = UsageRestriction.ListType.WHITELIST; - - @Config(category = ConfigCategory.LISTS) - public static ArrayList highlightEntityWhiteList = Lists.newArrayList("minecraft:wandering_trader"); - - @Config(category = ConfigCategory.LISTS) - public static ArrayList moveDownInScaffoldingWhiteList = Lists.newArrayList("minecraft:air", "minecraft:scaffolding"); - - @Config(category = ConfigCategory.LISTS) - public static ArrayList worldEaterMineHelperWhitelist = Lists.newArrayList("_ore", "minecraft:ancient_debris", "minecraft:obsidian"); - - // ADVANCED_INTEGRATED_SERVER - - @Hotkey - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(predicate = SinglePlayerServerOptionPredicate.class)) - public static boolean onlineMode = true; - - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(predicate = SinglePlayerServerOptionPredicate.class)) - public static boolean pvp = true; - - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(predicate = SinglePlayerServerOptionPredicate.class)) - public static boolean flight = true; - - @Numeric(minValue = 0, maxValue = 65535) - @Config(category = ConfigCategory.ADVANCED_INTEGRATED_SERVER, dependencies = @Dependencies(not = @Dependency(value = "minecraft", versionPredicate = "<1.19.3"), predicate = SinglePlayerServerOptionPredicate.class)) - public static int port = 0; - - private static boolean first = true; - - public static void postDeserialize(ConfigHandler configHandler) { - if (Configs.first) { - if (Configs.debug) { - Configurator.setLevel(OhMyMinecraftClientReference.getModIdentifier(), Level.DEBUG); - } - updateOldStringList(); - Configs.first = false; - } - checkIsStringListChanged(); - } - - - public static void init(@NotNull ConfigManager cm) { - // GENERIC - cm.setValueChangeCallback("debug", option -> { - Configurator.setLevel(OhMyMinecraftClientReference.getModIdentifier(), Configs.debug ? Level.DEBUG : Level.INFO); - GuiConfigs.getInstance().reDraw(); - }); - - clearWaypoint.getKeybind().setCallback((keyAction, iKeybind) -> { - HighlightWaypointUtil.clearHighlightPos(); - return false; - }); - - openConfigGui.getKeybind().setCallback((keyAction, iKeybind) -> { - GuiConfigs screen = GuiConfigs.getInstance(); - //#if MC > 11903 - screen.setParent(Minecraft.getInstance().screen); - //#else - //$$ screen.setParentGui(Minecraft.getInstance().screen); - //#endif - Minecraft.getInstance().setScreen(screen); - return true; - }); - - sendLookingAtBlockPos.getKeybind().setCallback((keyAction, iKeybind) -> { - Minecraft client = Minecraft.getInstance(); - Entity cameraEntity = client.getCameraEntity(); - MultiPlayerGameMode clientPlayerInteractionManager = client.gameMode; - if (cameraEntity != null && clientPlayerInteractionManager != null) { - HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.getPickRange(), client.getFrameTime(), false); - if (hitresult.getType() == HitResult.Type.BLOCK) { - BlockPos lookPos = ((BlockHitResult) hitresult).getBlockPos(); - if (client.player != null) { - String message = String.format("[%d, %d, %d]", lookPos.getX(), lookPos.getY(), lookPos.getZ()); - InfoUtil.sendChat(message); - } - } - } - return false; - }); - - sortInventory.getKeybind().setSettings(KeybindSettings.GUI); - - sortInventory.getKeybind().setCallback((keyAction, iKeybind) -> { - Optional.ofNullable(SortInventoryUtil.sort()).ifPresent(Runnable::run); - return false; - }); - - // FEATURE_TOGGLE - cm.setValueChangeCallback("highlightLavaSource", option -> { - OhMyMinecraftClientReference.getLogger().debug("set highlightLavaSource {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); - Minecraft.getInstance().levelRenderer.allChanged(); - }); - cm.setValueChangeCallback("worldEaterMineHelper", option -> { - OhMyMinecraftClientReference.getLogger().debug("set worldEaterMineHelper {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); - Minecraft.getInstance().levelRenderer.allChanged(); - }); - - // LISTS - cm.setValueChangeCallback("blockModelNoOffsetListType", - option -> Minecraft.getInstance().levelRenderer.allChanged()); - - // ADVANCED_INTEGRATED_SERVER - cm.setValueChangeCallback("onlineMode", option -> { - OhMyMinecraftClientReference.getLogger().debug("set onlineMode {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); - if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()).setUsesAuthentication(onlineMode); - } - }); - - cm.setValueChangeCallback("pvp", option -> { - OhMyMinecraftClientReference.getLogger().debug("set pvp {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); - if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()).setPvpAllowed(pvp); - } - }); - cm.setValueChangeCallback("flight", option -> { - OhMyMinecraftClientReference.getLogger().debug("set flight {}", ((ConfigBoolean) option.getConfig()).getBooleanValue()); - if (Minecraft.getInstance().hasSingleplayerServer()) { - Objects.requireNonNull(Minecraft.getInstance().getSingleplayerServer()).setFlightAllowed(flight); - } - }); - } - - public enum SortInventoryShulkerBoxLastType implements IConfigOptionListEntry { - FALSE("false", OhMyMinecraftClientReference.getModIdentifier() + ".gui.label.sort_inventory_shulker_box_last_type.false"), - TRUE("true", OhMyMinecraftClientReference.getModIdentifier() + ".gui.label.sort_inventory_shulker_box_last_type.true"), - AUTO("auto", OhMyMinecraftClientReference.getModIdentifier() + ".gui.label.sort_inventory_shulker_box_last_type.auto"); - private final String configString; - private final String translationKey; - - SortInventoryShulkerBoxLastType(String configString, String translationKey) { - this.configString = configString; - this.translationKey = translationKey; - } - - @Override - public String getStringValue() { - return this.configString; - } - - @Override - public @NotNull String getDisplayName() { - return I18n.get(this.translationKey); - } - - @Override - public IConfigOptionListEntry cycle(boolean forward) { - int id = this.ordinal(); - if (forward) { - ++id; - if (id >= values().length) { - id = 0; - } - } else { - --id; - if (id < 0) { - id = values().length - 1; - } - } - - return values()[id % values().length]; - } - - @Override - public IConfigOptionListEntry fromString(String name) { - SortInventoryShulkerBoxLastType[] values = values(); - for (SortInventoryShulkerBoxLastType mode : values) { - if (mode.configString.equalsIgnoreCase(name)) { - return mode; - } - } - return AUTO; - } - } - - public static class ConfigCategory { - public static final String GENERIC = "generic"; - public static final String FEATURE_TOGGLE = "feature_toggle"; - public static final String LISTS = "lists"; - public static final String ADVANCED_INTEGRATED_SERVER = "advanced_integrated_server"; - } - - public static class SinglePlayerServerOptionPredicate implements ConfigDependencyPredicate { - @Override - public boolean isSatisfied(ConfigOption option) { - return Minecraft.getInstance().hasSingleplayerServer(); - } - } -} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java b/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java deleted file mode 100644 index d364684..0000000 --- a/src/main/java/com/plusls/ommc/feature/autoSwitchElytra/AutoSwitchElytraUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.plusls.ommc.feature.autoSwitchElytra; - -import java.util.ArrayList; -import java.util.function.Predicate; -import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.effect.MobEffects; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.AbstractContainerMenu; -import net.minecraft.world.inventory.ClickType; -import net.minecraft.world.item.ItemStack; - -public class AutoSwitchElytraUtil { - public static final int CHEST_SLOT_IDX = 6; - - public static boolean myCheckFallFlying(Player player) { - return !player.onGround() && !player.isFallFlying() && !player.isInWater() && !player.hasEffect(MobEffects.LEVITATION); - } - - public static void autoSwitch(int sourceSlot, Minecraft client, LocalPlayer clientPlayerEntity, Predicate check) { - if (client.gameMode == null) { - return; - } - if (clientPlayerEntity.containerMenu != clientPlayerEntity.inventoryMenu) { - clientPlayerEntity.closeContainer(); - } - AbstractContainerMenu screenHandler = clientPlayerEntity.containerMenu; - ArrayList itemStacks = new ArrayList<>(); - for (int i = 0; i < screenHandler.slots.size(); ++i) { - itemStacks.add(screenHandler.slots.get(i).getItem().copy()); - } - - int idxToSwitch = -1; - for (int i = 0; i < itemStacks.size(); ++i) { - if (check.test(itemStacks.get(i))) { - idxToSwitch = i; - break; - } - } - if (idxToSwitch != -1) { - client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, clientPlayerEntity); - client.gameMode.handleInventoryMouseClick(screenHandler.containerId, sourceSlot, 0, ClickType.PICKUP, clientPlayerEntity); - client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, clientPlayerEntity); - } - } -} diff --git a/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java b/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java deleted file mode 100644 index b89ba0a..0000000 --- a/src/main/java/com/plusls/ommc/feature/blockModelNoOffset/BlockModelNoOffsetUtil.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.plusls.ommc.feature.blockModelNoOffset; - -import com.plusls.ommc.config.Configs; -import fi.dy.masa.malilib.util.restrictions.UsageRestriction; -import net.minecraft.core.BlockPos; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; - -public class BlockModelNoOffsetUtil { - public static Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - if (shouldNoOffset(blockState)) { - return Vec3.ZERO; - } else { - return blockState.getOffset(world, pos); - } - } - - public static boolean shouldNoOffset(BlockState blockState) { - //#if MC >= 11903 - String blockId = BuiltInRegistries.BLOCK.getKey(blockState.getBlock()).toString(); - //#else - //$$ String blockId = Registry.BLOCK.getKey(blockState.getBlock()).toString(); - //#endif - String blockName = blockState.getBlock().getName().getString(); - - if (Configs.blockModelNoOffsetListType == UsageRestriction.ListType.WHITELIST) { - return Configs.blockModelNoOffsetWhitelist.stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); - } else if (Configs.blockModelNoOffsetListType == UsageRestriction.ListType.BLACKLIST) { - return Configs.blockModelNoOffsetBlacklist.stream().noneMatch(s -> blockId.contains(s) || blockName.contains(s)); - } - return false; - } -} diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java b/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java deleted file mode 100644 index 7fdbaac..0000000 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointUtil.java +++ /dev/null @@ -1,608 +0,0 @@ -package com.plusls.ommc.feature.highlithtWaypoint; - -import com.google.common.collect.Lists; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.*; -import com.mojang.brigadier.context.CommandContext; -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.api.command.ClientBlockPosArgument; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.mixin.accessor.AccessorTextComponent; -import com.plusls.ommc.mixin.accessor.AccessorTranslatableComponent; -import com.plusls.ommc.util.Tuple; -import lombok.AllArgsConstructor; -import lombok.Getter; -import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; -import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; -import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; -import net.minecraft.ChatFormatting; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Font; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.core.BlockPos; -import net.minecraft.network.chat.*; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.util.Mth; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.inventory.InventoryMenu; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import top.hendrixshen.magiclib.compat.minecraft.api.blaze3d.vertex.VertexFormatCompatApi; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.StyleCompatApi; - -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -//#if MC > 11902 -import com.mojang.math.Axis; -//#else -//$$ import top.hendrixshen.magiclib.compat.minecraft.api.math.Vector3fCompatApi; -//#endif - -//#if MC > 11901 -import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; -//#endif - -//#if MC > 11802 -import net.minecraft.network.chat.contents.*; -//#else -//$$ import net.minecraft.client.Option; -//#endif - -//#if MC < 11700 -//$$ import net.minecraft.client.renderer.texture.TextureAtlas; -//#endif - -//#if MC < 11600 -//$$ import net.minecraft.world.level.dimension.DimensionType; -//#endif - -public class HighlightWaypointUtil { - private static final String HIGHLIGHT_COMMAND = "highlightWaypoint"; - private static final Tuple highlightPos = new Tuple<>(null, null); - - public static long lastBeamTime = 0; - public static Pattern pattern = Pattern.compile("(?:(?:x\\s*:\\s*)?(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)(?:(?:(?:\\s*[,,]\\s*(?:y\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)?(?:(?:(?:\\s*[,,]\\s*(?:z\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)", Pattern.CASE_INSENSITIVE); - - public static void init() { - //#if MC > 11901 - ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( - //#else - //$$ ClientCommandManager.DISPATCHER.register( - //#endif - ClientCommandManager.literal(HIGHLIGHT_COMMAND).then( - ClientCommandManager.argument("pos", ClientBlockPosArgument.blockPos()) - .executes(HighlightWaypointUtil::runCommand) - //#if MC > 11901 - ))); - //#else - //$$ )); - //#endif - ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> HighlightWaypointUtil.clearHighlightPos()); - } - - private static int runCommand(CommandContext context) { - BlockPos pos = ClientBlockPosArgument.getBlockPos(context, "pos"); - HighlightWaypointUtil.setHighlightPos(pos, false); - - return 0; - } - - private static @NotNull List parsePositions(@NotNull String message) { - List ret = Lists.newArrayList(); - Matcher matcher = HighlightWaypointUtil.pattern.matcher(message); - - while (matcher.find()) { - ret.add(HighlightWaypointUtil.parsePosition(matcher)); - } - - ret.removeIf(Objects::isNull); - ret.sort(Comparator.comparingInt(ParseResult::getMatcherStart)); - return ret; - } - - private static @Nullable ParseResult parsePosition(@NotNull Matcher matcher) { - Integer x = null; - int y = 64; - Integer z = null; - String xStr = matcher.group("x"); - String yStr = matcher.group("y"); - String zStr = matcher.group("z"); - - try { - x = xStr.contains(".") ? (int) Double.parseDouble(xStr) : Integer.parseInt(xStr); - z = zStr.contains(".") ? (int) Double.parseDouble(zStr) : Integer.parseInt(zStr); - - if (yStr != null) { - y = zStr.contains(".") ? (int) Double.parseDouble(yStr) : Integer.parseInt(yStr); - } - } catch (NumberFormatException e) { - OhMyMinecraftClientReference.getLogger().error("Failed to parse coordinate {}: {}", matcher.group(), e); - } - - if (x == null || z == null) { - return null; - } - - return new ParseResult(matcher.group(), new BlockPos(x, y, z), matcher.start()); - } - - public static void parseMessage(@NotNull Component chat) { - chat.getSiblings().forEach(HighlightWaypointUtil::parseMessage); - //#if MC > 11802 - ComponentContents componentContents = chat.getContents(); - //#endif - - if ( - //#if MC > 11802 - !(componentContents instanceof TranslatableContents) - //#else - //$$ !(chat instanceof TranslatableComponent) - //#endif - ) { - HighlightWaypointUtil.updateMessage(chat); - return; - } - - //#if MC > 11802 - Object[] args = ((TranslatableContents) componentContents).getArgs(); - //#else - //$$ Object[] args = ((TranslatableComponent) chat).getArgs(); - //#endif - boolean updateTranslatableText = false; - - for (int i = 0; i < args.length; i++) { - if (args[i] instanceof Component) { - HighlightWaypointUtil.parseMessage((Component) args[i]); - } else if (args[i] instanceof String) { - Component text = ComponentCompatApi.literal((String) args[i]); - - if (HighlightWaypointUtil.updateMessage(text)) { - args[i] = text; - updateTranslatableText = true; - } - } - } - - if (updateTranslatableText) { - //#if MC > 11802 - ((AccessorTranslatableComponent) componentContents).setDecomposedWith(null); - //#elseif MC > 11502 - //$$ ((AccessorTranslatableComponent) chat).setDecomposedWith(null); - //#else - //$$ ((AccessorTranslatableComponent) chat).setDecomposedLanguageTime(-1); - //#endif - } - - HighlightWaypointUtil.updateMessage(chat); - } - - public static boolean updateMessage(@NotNull Component chat) { - //#if MC > 11802 - ComponentContents componentContents = chat.getContents(); - - //#endif - if ( - //#if MC > 12002 - !(componentContents instanceof PlainTextContents.LiteralContents) - //#elseif MC > 11802 - //$$ !(componentContents instanceof LiteralContents) - //#else - //$$ !(chat instanceof TextComponent) - //#endif - ) { - return false; - } - - //#if MC > 12002 - PlainTextContents.LiteralContents literalChatText = (PlainTextContents.LiteralContents) componentContents; - //#elseif MC > 11802 - //$$ LiteralContents literalChatText = (LiteralContents) componentContents; - //#else - //$$ TextComponent literalChatText = (TextComponent) chat; - //#endif - String message = ((AccessorTextComponent) (Object) literalChatText).getText(); - List positions = HighlightWaypointUtil.parsePositions(message); - - if (positions.isEmpty()) { - return false; - } - - Style originalStyle = chat.getStyle(); - ClickEvent originalClickEvent = originalStyle.getClickEvent(); - ArrayList texts = Lists.newArrayList(); - int prevIdx = 0; - - // Rebuild components. - for (ParseResult position : positions) { - String waypointString = position.getText(); - int waypointIdx = position.getMatcherStart(); - texts.add(ComponentCompatApi.literal(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); - BlockPos pos = position.getPos(); - texts.add(ComponentCompatApi.literal(waypointString) - .withStyle(ChatFormatting.GREEN) - .withStyle(ChatFormatting.UNDERLINE) - .withStyle(style -> style.withClickEvent(originalClickEvent == null || - Configs.forceParseWaypointFromChat ? new ClickEvent(ClickEvent.Action.RUN_COMMAND, - String.format("/%s %d %d %d", HIGHLIGHT_COMMAND, pos.getX(), pos.getY(), pos.getZ())) : - originalClickEvent)) - .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - ComponentCompatApi.literal(OhMyMinecraftClientReference.translate("highlight_waypoint.tooltip")))))); - prevIdx = waypointIdx + waypointString.length(); - } - - // Add tail if existed. - if (prevIdx < message.length()) { - texts.add(ComponentCompatApi.literal(message.substring(prevIdx)).withStyle(originalStyle)); - } - - texts.forEach(chat.getSiblings()::add); - ((AccessorTextComponent) (Object) literalChatText).setText(""); - //#if MC > 11502 - ((MutableComponent) chat).withStyle(StyleCompatApi.empty()); - //#else - //$$ ((BaseComponent) chat).withStyle(StyleCompatApi.empty()); - //#endif - return true; - } - - private static double getDistanceToEntity(@NotNull Entity entity, @NotNull BlockPos pos) { - double dx = pos.getX() + 0.5 - entity.getX(); - double dy = pos.getY() + 0.5 - entity.getY(); - double dz = pos.getZ() + 0.5 - entity.getZ(); - return Math.sqrt(dx * dx + dy * dy + dz * dz); - } - - private static boolean isPointedAt(@NotNull BlockPos pos, double distance, @NotNull Entity cameraEntity, float tickDelta) { - Vec3 cameraPos = cameraEntity.getEyePosition(tickDelta); - double degrees = 5.0 + Math.min((5.0 / distance), 5.0); - double angle = degrees * 0.0174533; - double size = Math.sin(angle) * distance; - Vec3 cameraPosPlusDirection = cameraEntity.getViewVector(tickDelta); - Vec3 cameraPosPlusDirectionTimesDistance = cameraPos.add(cameraPosPlusDirection.x() * distance, cameraPosPlusDirection.y() * distance, cameraPosPlusDirection.z() * distance); - AABB axisalignedbb = new AABB(pos.getX() + 0.5f - size, pos.getY() + 0.5f - size, pos.getZ() + 0.5f - size, - pos.getX() + 0.5f + size, pos.getY() + 0.5f + size, pos.getZ() + 0.5f + size); - Optional raycastResult = axisalignedbb.clip(cameraPos, cameraPosPlusDirectionTimesDistance); - return axisalignedbb.contains(cameraPos) ? distance >= 1.0 : raycastResult.isPresent(); - } - - public static void drawWaypoint(PoseStack matrixStack, float tickDelta) { - Minecraft mc = Minecraft.getInstance(); - Player player = mc.player; - - if (player == null) { - return; - } - - BlockPos pos = HighlightWaypointUtil.inNether(player) ? - HighlightWaypointUtil.highlightPos.getB() : HighlightWaypointUtil.highlightPos.getA(); - - if (pos == null) { - return; - } - - Entity cameraEntity = mc.getCameraEntity(); - - if (cameraEntity == null) { - return; - } - - RenderSystem.enableBlend(); - RenderSystem.disableDepthTest(); - RenderSystem.depthMask(false); - double distance = getDistanceToEntity(cameraEntity, pos); - HighlightWaypointUtil.renderLabel(matrixStack, distance, cameraEntity, tickDelta, - HighlightWaypointUtil.isPointedAt(pos, distance, cameraEntity, tickDelta), pos); - RenderSystem.enableDepthTest(); - RenderSystem.depthMask(true); - RenderSystem.disableBlend(); - } - - // code from BeaconBlockEntityRenderer - @SuppressWarnings("all") - public static void renderBeam(@NotNull PoseStack matrices, float tickDelta, float heightScale, long worldTime, - int yOffset, int maxY, float @NotNull [] color, float innerRadius, float outerRadius) { - ResourceLocation textureId = new ResourceLocation("textures/entity/beacon_beam.png"); - //#if MC > 11605 - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); - RenderSystem.setShaderTexture(0, textureId); - //#else - //$$ Minecraft.getInstance().getTextureManager().bind(textureId); - //#endif - int i = yOffset + maxY; - matrices.pushPose(); - matrices.translate(0.5D, 0.0D, 0.5D); - float f = (float) Math.floorMod(worldTime, 40L) + tickDelta; - float g = maxY < 0 ? f : -f; - float h = (float) Mth.frac(g * 0.2F - (float) Mth.floor(g * 0.1F)); - float red = color[0]; - float green = color[1]; - float blue = color[2]; - matrices.pushPose(); - //#if MC >= 11903 - matrices.mulPose(Axis.YP.rotationDegrees(f * 2.25F - 45.0F)); - //#else - //$$ matrices.mulPose(Vector3fCompatApi.YP.rotationDegrees(f * 2.25F - 45.0F)); - //#endif - float y = 0.0F; - float ab = 0.0F; - float ac = -innerRadius; - float r = 0.0F; - float s = 0.0F; - float t = -innerRadius; - float ag = 0.0F; - float ah = 1.0F; - float ai = -1.0F + h; - float aj = (float) maxY * heightScale * (0.5F / innerRadius) + ai; - Tesselator tesselator = Tesselator.getInstance(); - BufferBuilder bufferBuilder = tesselator.getBuilder(); - bufferBuilder.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - renderBeamLayer(matrices, bufferBuilder, red, green, green, 1.0F, yOffset, i, 0.0F, innerRadius, innerRadius, - 0.0F, ac, 0.0F, 0.0F, t, 0.0F, 1.0F, aj, ai); - tesselator.end(); - matrices.popPose(); - y = -outerRadius; - float z = -outerRadius; - ab = -outerRadius; - ac = -outerRadius; - ag = 0.0F; - ah = 1.0F; - ai = -1.0F + h; - aj = (float) maxY * heightScale + ai; - bufferBuilder.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - renderBeamLayer(matrices, bufferBuilder, red, green, green, 0.125F, yOffset, i, y, z, outerRadius, ab, ac, outerRadius, outerRadius, outerRadius, 0.0F, 1.0F, aj, ai); - tesselator.end(); - matrices.popPose(); - //#if MC > 11605 - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - //#endif - } - - private static void renderBeamFace(Matrix4f modelMatrix, Matrix3f normalMatrix, BufferBuilder vertices, float red, float green, float blue, float alpha, int yOffset, int height, float x1, float z1, float x2, float z2, float u1, float u2, float v1, float v2) { - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, height, x1, z1, u2, v1); - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, yOffset, x1, z1, u2, v2); - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, yOffset, x2, z2, u1, v2); - renderBeamVertex(modelMatrix, normalMatrix, vertices, red, green, blue, alpha, height, x2, z2, u1, v1); - } - - private static void renderBeamVertex(Matrix4f modelMatrix, Matrix3f normalMatrix, @NotNull BufferBuilder vertices, float red, float green, float blue, float alpha, int y, float x, float z, float u, float v) { - vertices.vertex(modelMatrix, x, (float) y, z) - .uv(u, v) - .color(red, green, blue, alpha).endVertex(); - } - - @SuppressWarnings("all") - private static void renderBeamLayer(@NotNull PoseStack matrices, BufferBuilder vertices, float red, float green, float blue, float alpha, int yOffset, int height, float x1, float z1, float x2, float z2, float x3, float z3, float x4, float z4, float u1, float u2, float v1, float v2) { - PoseStack.Pose entry = matrices.last(); - Matrix4f matrix4f = entry.pose(); - Matrix3f matrix3f = entry.normal(); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x1, z1, x2, z2, u1, u2, v1, v2); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x4, z4, x3, z3, u1, u2, v1, v2); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x2, z2, x4, z4, u1, u2, v1, v2); - renderBeamFace(matrix4f, matrix3f, vertices, red, green, blue, alpha, yOffset, height, x3, z3, x1, z1, u1, u2, v1, v2); - } - - public static void renderLabel(PoseStack matrixStack, double distance, @NotNull Entity cameraEntity, float tickDelta, boolean isPointedAt, @NotNull BlockPos pos) { - Minecraft mc = Minecraft.getInstance(); - String name = String.format("x:%d, y:%d, z:%d (%dm)", pos.getX(), pos.getY(), pos.getZ(), (int) distance); - double baseX = pos.getX() - Mth.lerp(tickDelta, cameraEntity.xo, cameraEntity.getX()); - double baseY = pos.getY() - Mth.lerp(tickDelta, cameraEntity.yo, cameraEntity.getY()) - 1.5; - double baseZ = pos.getZ() - Mth.lerp(tickDelta, cameraEntity.zo, cameraEntity.getZ()); - // Max render distance - //#if MC > 11802 - double maxDistance = Minecraft.getInstance().options.renderDistance().get() * 16; - //#else - //$$ double maxDistance = Option.RENDER_DISTANCE.get(mc.options) * 16; - //#endif - double adjustedDistance = distance; - - if (distance > maxDistance) { - baseX = baseX / distance * maxDistance; - baseY = baseY / distance * maxDistance; - baseZ = baseZ / distance * maxDistance; - adjustedDistance = maxDistance; - } - - // 根据调节后的距离决定绘制的大小 - float scale = (float) (adjustedDistance * 0.1f + 1.0f) * 0.0265f; - matrixStack.pushPose(); - // 当前绘制位置是以玩家为中心的,转移到目的地 - matrixStack.translate(baseX, baseY, baseZ); - - if (lastBeamTime >= System.currentTimeMillis()) { - // 画信标光柱 - float[] color = {1.0f, 0.0f, 0.0f}; - renderBeam(matrixStack, tickDelta, 1.0f, - Objects.requireNonNull(mc.level).getGameTime(), - (int) (baseY - 512), 1024, color, 0.2F, 0.25F); - - // 画完后会关闭半透明,需要手动打开 - RenderSystem.enableBlend(); - } - - // 移动到方块中心 - matrixStack.translate(0.5f, 0.5f, 0.5f); - - // 在玩家正对着的平面进行绘制 - //#if MC >= 11903 - matrixStack.mulPose(Axis.YP.rotationDegrees(-cameraEntity.getYRot())); - matrixStack.mulPose(Axis.XP.rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot())); - //#else - //$$ matrixStack.mulPose(Vector3fCompatApi.YP.rotationDegrees(-cameraEntity.getYRot())); - //$$ matrixStack.mulPose(Vector3fCompatApi.XP.rotationDegrees(mc.getEntityRenderDispatcher().camera.getXRot())); - //#endif - // 缩放绘制的大小,让 waypoint 根据距离缩放 - matrixStack.scale(-scale, -scale, -scale); - Matrix4f matrix4f = matrixStack.last().pose(); - Tesselator tessellator = Tesselator.getInstance(); - BufferBuilder vertexBuffer = tessellator.getBuilder(); - // 透明度 - float fade = distance < 5.0 ? 1.0f : (float) distance / 5.0f; - fade = Math.min(fade, 1.0f); - // 渲染的图标的大小 - float xWidth = 10.0f; - float yWidth = 10.0f; - // 绿色 - float iconR = 1.0f; - float iconG = 0.0f; - float iconB = 0.0f; - float textFieldR = 3.0f; - float textFieldG = 0.0f; - float textFieldB = 0.0f; - // 图标 - TextureAtlasSprite icon = HighlightWaypointResourceLoader.targetIdSprite; - // 不设置渲染不出 - //#if MC > 11605 - RenderSystem.setShader(GameRenderer::getPositionTexColorShader); - RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); - //#else - //$$ RenderSystem.bindTexture(Objects.requireNonNull(mc.getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS)).getId()); - //#endif - - // 渲染图标 - //#if MC < 11904 - //$$ RenderSystem.enableTexture(); - //#endif - vertexBuffer.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); - vertexBuffer.vertex(matrix4f, -xWidth, -yWidth, 0.0f).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - vertexBuffer.vertex(matrix4f, -xWidth, yWidth, 0.0f).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); - vertexBuffer.vertex(matrix4f, xWidth, yWidth, 0.0f).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, fade).endVertex(); - vertexBuffer.vertex(matrix4f, xWidth, -yWidth, 0.0f).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, fade).endVertex(); - tessellator.end(); - //#if MC < 11904 - //$$ RenderSystem.disableTexture(); - //#endif - - Font textRenderer = mc.font; - if (isPointedAt && textRenderer != null) { - // 渲染高度 - int elevateBy = -19; - RenderSystem.enablePolygonOffset(); - int halfStringWidth = textRenderer.width(name) / 2; - //#if MC > 11605 - RenderSystem.setShader(GameRenderer::getPositionColorShader); - //#endif - - // 渲染内框 - RenderSystem.polygonOffset(1.0f, 11.0f); - vertexBuffer.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, -halfStringWidth - 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 2, 9 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 2, -2 + elevateBy, 0.0f).color(textFieldR, textFieldG, textFieldB, 0.6f * fade).endVertex(); - tessellator.end(); - - // 渲染外框 - RenderSystem.polygonOffset(1.0f, 9.0f); - vertexBuffer.begin(VertexFormatCompatApi.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR); - vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, -halfStringWidth - 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 1, 8 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - vertexBuffer.vertex(matrix4f, halfStringWidth + 1, -1 + elevateBy, 0.0f).color(0.0f, 0.0f, 0.0f, 0.15f * fade).endVertex(); - tessellator.end(); - RenderSystem.disablePolygonOffset(); - - // 渲染文字 - //#if MC < 11904 - //$$ RenderSystem.enableTexture(); - //#endif - int textColor = (int) (255.0f * fade) << 24 | 0xCCCCCC; - RenderSystem.disableDepthTest(); - textRenderer.drawInBatch(ComponentCompatApi.literal(name), (float) (-textRenderer.width(name) / 2), elevateBy, textColor, false, matrix4f, true, 0, 0xF000F0); - } - //#if MC > 11605 - RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); - //#endif - matrixStack.popPose(); - // 1.14 need enableTexture - //#if MC < 11904 - //$$ RenderSystem.enableTexture(); - //#endif - } - - public static void setHighlightPos(@NotNull BlockPos pos, boolean directHighlight) { - Player player = Minecraft.getInstance().player; - - if (player == null) { - return; - } - - boolean posChanged; - - if (HighlightWaypointUtil.inOverworld(player)) { - posChanged = HighlightWaypointUtil.setHighlightBlockPos( - pos, new BlockPos(pos.getX() / 8, pos.getY(), pos.getZ() / 8)); - } else if (HighlightWaypointUtil.inNether(player)) { - posChanged = HighlightWaypointUtil.setHighlightBlockPos( - new BlockPos(pos.getX() * 8, pos.getY(), pos.getZ() * 8), pos); - } else { - posChanged = HighlightWaypointUtil.setHighlightBlockPos(pos, pos); - } - - if (directHighlight || !posChanged) { - HighlightWaypointUtil.lastBeamTime = System.currentTimeMillis() + Configs.highlightBeamTime * 1000L; - } - } - - public static BlockPos getHighlightPos() { - Player player = Minecraft.getInstance().player; - return player == null ? BlockPos.ZERO : HighlightWaypointUtil.getHighlightPos(player); - } - - public static BlockPos getHighlightPos(Player player) { - return HighlightWaypointUtil.inNether(player) ? - HighlightWaypointUtil.highlightPos.getB() : HighlightWaypointUtil.highlightPos.getA(); - } - - private static boolean setHighlightBlockPos(@NotNull BlockPos overworldPos, @NotNull BlockPos netherWorldPos) { - if (overworldPos.equals(HighlightWaypointUtil.highlightPos.getA()) && - netherWorldPos.equals(HighlightWaypointUtil.highlightPos.getB())) { - return false; - } - - HighlightWaypointUtil.highlightPos.setA(overworldPos); - HighlightWaypointUtil.highlightPos.setB(netherWorldPos); - return true; - } - - public static void clearHighlightPos() { - HighlightWaypointUtil.highlightPos.setA(null); - HighlightWaypointUtil.highlightPos.setB(null); - HighlightWaypointUtil.lastBeamTime = 0; - } - - private static boolean inOverworld(@NotNull Player player) { - return - //#if MC > 11502 - player.getLevelCompat().dimension() == Level.OVERWORLD; - //#else - //$$ player.getLevelCompat().getDimension().getType() == DimensionType.OVERWORLD; - //#endif - } - - private static boolean inNether(@NotNull Player player) { - return - //#if MC > 11502 - player.getLevelCompat().dimension() == Level.NETHER; - //#else - //$$ player.getLevelCompat().getDimension().getType() == DimensionType.NETHER; - //#endif - } - - @Getter - @AllArgsConstructor - public static class ParseResult { - private final String text; - private final BlockPos pos; - private final int matcherStart; - } -} diff --git a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java b/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java deleted file mode 100644 index aaf6c26..0000000 --- a/src/main/java/com/plusls/ommc/feature/realSneaking/RealSneakingEventHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.plusls.ommc.feature.realSneaking; - -import com.plusls.ommc.config.Configs; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; -import net.minecraft.client.Minecraft; - -public class RealSneakingEventHandler { - final private static float MIN_STEP_HEIGHT = 0.001f; - private static float prevStepHeight; - - public static void init() { - ClientTickEvents.START_CLIENT_TICK.register(RealSneakingEventHandler::preClientTick); - } - - private static void preClientTick(Minecraft minecraftClient) { - if (minecraftClient.player != null) { - if (minecraftClient.player.maxUpStepCompat() - MIN_STEP_HEIGHT >= 0.00001) { - prevStepHeight = minecraftClient.player.maxUpStepCompat(); - } - if (Configs.realSneaking && minecraftClient.player.isShiftKeyDown()) { - minecraftClient.player.setMaxUpStepCompat(MIN_STEP_HEIGHT); - } else { - minecraftClient.player.setMaxUpStepCompat(prevStepHeight); - } - } - } -} diff --git a/src/main/java/com/plusls/ommc/game/ConfigGui.java b/src/main/java/com/plusls/ommc/game/ConfigGui.java new file mode 100644 index 0000000..940da30 --- /dev/null +++ b/src/main/java/com/plusls/ommc/game/ConfigGui.java @@ -0,0 +1,50 @@ +package com.plusls.ommc.game; + +import com.plusls.ommc.SharedConstants; +import fi.dy.masa.malilib.gui.GuiBase; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.i18n.I18n; +import top.hendrixshen.magiclib.impl.malilib.config.gui.MagicConfigGui; +import top.hendrixshen.magiclib.util.collect.ValueContainer; + +public class ConfigGui extends MagicConfigGui { + private static ConfigGui currentInstance = null; + + public ConfigGui() { + super( + SharedConstants.getModIdentifier(), + SharedConstants.getConfigManager(), + I18n.tr("ommc.gui.title.configs", SharedConstants.getModVersion()) + ); + } + + @Override + public void init() { + super.init(); + ConfigGui.currentInstance = this; + } + + @Override + public void removed() { + super.removed(); + ConfigGui.currentInstance = null; + } + + @Override + public boolean isDebug() { + return Configs.debug.getBooleanValue(); + } + + public static void openGui() { + GuiBase.openGui(new ConfigGui()); + } + + @Override + public boolean hideUnAvailableConfigs() { + return top.hendrixshen.magiclib.game.malilib.Configs.hideUnavailableConfigs.getBooleanValue(); + } + + public static @NotNull ValueContainer getCurrentInstance() { + return ValueContainer.ofNullable(ConfigGui.currentInstance); + } +} diff --git a/src/main/java/com/plusls/ommc/game/Configs.java b/src/main/java/com/plusls/ommc/game/Configs.java new file mode 100644 index 0000000..e4fc92a --- /dev/null +++ b/src/main/java/com/plusls/ommc/game/Configs.java @@ -0,0 +1,208 @@ +package com.plusls.ommc.game; + +import com.google.common.collect.ImmutableList; +import com.plusls.ommc.SharedConstants; +import com.plusls.ommc.impl.feature.sortInventory.SortInventoryShulkerBoxLastType; +import com.plusls.ommc.impl.feature.sortInventory.SortInventoryHelper; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; +import fi.dy.masa.malilib.config.IConfigOptionListEntry; +import fi.dy.masa.malilib.config.options.ConfigBoolean; +import fi.dy.masa.malilib.hotkeys.KeybindSettings; +import fi.dy.masa.malilib.interfaces.IValueChangeCallback; +import fi.dy.masa.malilib.util.restrictions.UsageRestriction; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.MultiPlayerGameMode; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.malilib.annotation.Config; +import top.hendrixshen.magiclib.api.malilib.annotation.Statistic; +import top.hendrixshen.magiclib.api.malilib.config.MagicConfigManager; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigFactory; +import top.hendrixshen.magiclib.impl.malilib.config.MagicConfigHandler; +import top.hendrixshen.magiclib.impl.malilib.config.option.*; +import top.hendrixshen.magiclib.util.collect.ValueContainer; +import top.hendrixshen.magiclib.util.minecraft.InfoUtil; + +public class Configs { + private static final MagicConfigManager cm = SharedConstants.getConfigManager(); + private static final MagicConfigFactory cf = Configs.cm.getConfigFactory(); + + // Generic + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey clearWaypoint = Configs.cf.newConfigHotkey("clearWaypoint", "C"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBoolean debug = Configs.cf.newConfigBoolean("debug", false); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBoolean dontClearChatHistory = Configs.cf.newConfigBoolean("dontClearChatHistory", false); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBooleanHotkeyed forceParseWaypointFromChat = Configs.cf.newConfigBooleanHotkeyed("forceParseWaypointFromChat", false); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigInteger highlightBeamTime = Configs.cf.newConfigInteger("highlightBeamTime", 10, 0, Integer.MAX_VALUE); + + @Statistic(hotkey = false) + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey openConfigGui = Configs.cf.newConfigHotkey("openConfigGui", "O,C"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBooleanHotkeyed parseWaypointFromChat = Configs.cf.newConfigBooleanHotkeyed("parseWaypointFromChat", true); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey sendLookingAtBlockPos = Configs.cf.newConfigHotkey("sendLookingAtBlockPos", "O,P"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigBooleanHotkeyed sortInventorySupportEmptyShulkerBoxStack = Configs.cf.newConfigBooleanHotkeyed("sortInventorySupportEmptyShulkerBoxStack", true); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigHotkey sortInventory = Configs.cf.newConfigHotkey("sortInventory", "R"); + + @Config(category = ConfigCategory.GENERIC) + public static MagicConfigOptionList sortInventoryShulkerBoxLast = Configs.cf.newConfigOptionList("sortInventoryShulkerBoxLast", SortInventoryShulkerBoxLastType.AUTO); + + // Feature + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed autoSwitchElytra = Configs.cf.newConfigBooleanHotkeyed("autoSwitchElytra", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed betterSneaking = Configs.cf.newConfigBooleanHotkeyed("betterSneaking", false); + + @Dependencies(require = @Dependency(value = "minecraft", versionPredicates = ">1.15.2")) + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableBlocklistCheck = Configs.cf.newConfigBooleanHotkeyed("disableBlocklistCheck", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableBreakBlock = Configs.cf.newConfigBooleanHotkeyed("disableBreakBlock", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableBreakScaffolding = Configs.cf.newConfigBooleanHotkeyed("disableBreakScaffolding", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disableMoveDownInScaffolding = Configs.cf.newConfigBooleanHotkeyed("disableMoveDownInScaffolding", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed disablePistonPushEntity = Configs.cf.newConfigBooleanHotkeyed("disablePistonPushEntity", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed flatDigger = Configs.cf.newConfigBooleanHotkeyed("flatDigger", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed forceBreakingCooldown = Configs.cf.newConfigBooleanHotkeyed("forceBreakingCooldown", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed highlightLavaSource = Configs.cf.newConfigBooleanHotkeyed("highlightLavaSource", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed highlightPersistentMob = Configs.cf.newConfigBooleanHotkeyed("highlightPersistentMob", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBoolean highlightPersistentMobClientMode = Configs.cf.newConfigBoolean("highlightPersistentMobClientMode", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed preventWastageOfWater = Configs.cf.newConfigBooleanHotkeyed("preventWastageOfWater", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed preventIntentionalGameDesign = Configs.cf.newConfigBooleanHotkeyed("preventIntentionalGameDesign", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed realSneaking = Configs.cf.newConfigBooleanHotkeyed("realSneaking", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed removeBreakingCooldown = Configs.cf.newConfigBooleanHotkeyed("removeBreakingCooldown", false); + + @Config(category = ConfigCategory.FEATURE) + public static MagicConfigBooleanHotkeyed worldEaterMineHelper = Configs.cf.newConfigBooleanHotkeyed("worldEaterMineHelper", false); + + // List + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList blockModelNoOffsetBlacklist = Configs.cf.newConfigStringList("blockModelNoOffsetBlacklist"); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigOptionList blockModelNoOffsetListType = Configs.cf.newConfigOptionList("blockModelNoOffsetListType", UsageRestriction.ListType.NONE); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList blockModelNoOffsetWhitelist = Configs.cf.newConfigStringList("blockModelNoOffsetWhitelist", ImmutableList.of("minecraft:wither_rose", "minecraft:poppy", "minecraft:dandelion")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList breakBlockBlackList = Configs.cf.newConfigStringList("breakBlockBlackList", ImmutableList.of("minecraft:budding_amethyst", "_bud")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList breakScaffoldingWhiteList = Configs.cf.newConfigStringList("breakScaffoldingWhiteList", ImmutableList.of("minecraft:air", "minecraft:scaffolding")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList highlightEntityBlackList = Configs.cf.newConfigStringList("highlightEntityBlackList"); + + @Config(category = ConfigCategory.LIST) + public static IConfigOptionListEntry highlightEntityListType = UsageRestriction.ListType.WHITELIST; + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList highlightEntityWhiteList = Configs.cf.newConfigStringList("highlightEntityWhiteList", ImmutableList.of("minecraft:wandering_trader")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList moveDownInScaffoldingWhiteList = Configs.cf.newConfigStringList("moveDownInScaffoldingWhiteList", ImmutableList.of("minecraft:air", "minecraft:scaffolding")); + + @Config(category = ConfigCategory.LIST) + public static MagicConfigStringList worldEaterMineHelperWhitelist = Configs.cf.newConfigStringList("worldEaterMineHelperWhitelist", ImmutableList.of("_ore", "minecraft:ancient_debris", "minecraft:obsidian")); + + public static void init() { + Configs.cm.parseConfigClass(Configs.class); + SharedConstants.getConfigHandler().setPostDeserializeCallback(Configs::onConfigLoaded); + + // Generic + IValueChangeCallback reloadLevelRender = (option) -> Minecraft.getInstance().levelRenderer.allChanged(); + + MagicConfigManager.setHotkeyCallback(Configs.clearWaypoint, () -> HighlightWaypointHandler.getInstance().clearHighlightPos(), true); + MagicConfigManager.setHotkeyCallback(Configs.openConfigGui, ConfigGui::openGui, true); + + MagicConfigManager.setHotkeyCallback(Configs.sendLookingAtBlockPos, () -> { + Minecraft client = Minecraft.getInstance(); + Entity cameraEntity = client.getCameraEntity(); + MultiPlayerGameMode clientPlayerInteractionManager = client.gameMode; + + if (cameraEntity != null && clientPlayerInteractionManager != null) { + //#if MC < 12005 + HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.getPickRange(), client.getFrameTime(), false); + //#elseif MC >= 12005 && MC <12007 + //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTime(), false); + //#elseif MC >= 12100 + //$$ HitResult hitresult = cameraEntity.pick(clientPlayerInteractionManager.hasInfiniteItems() ? 5.0F : 4.5F, client.getFrameTimeNs(), false); + //#endif + + if (hitresult.getType() == HitResult.Type.BLOCK) { + BlockPos lookPos = ((BlockHitResult) hitresult).getBlockPos(); + if (client.player != null) { + String message = String.format("[%d, %d, %d]", lookPos.getX(), lookPos.getY(), lookPos.getZ()); + InfoUtil.sendChat(message); + } + } + } + }, true); + + + MagicConfigManager.setHotkeyCallback(Configs.sortInventory, + () -> ValueContainer.ofNullable(SortInventoryHelper.sort()).ifPresent(Runnable::run), + false); + + Configs.highlightLavaSource.setValueChangeCallback(reloadLevelRender); + Configs.worldEaterMineHelper.setValueChangeCallback(reloadLevelRender); + + // List + Configs.blockModelNoOffsetListType.setValueChangeCallback(option -> Minecraft.getInstance().levelRenderer.allChanged()); + } + + private static void onConfigLoaded(MagicConfigHandler magicConfigHandler) { + Configs.sortInventory.getKeybind().setSettings(KeybindSettings.GUI); + } + + public static class ConfigCategory { + public static final String GENERIC = "generic"; + public static final String FEATURE = "feature"; + public static final String LIST = "list"; + } +} diff --git a/src/main/java/com/plusls/ommc/gui/GuiConfigs.java b/src/main/java/com/plusls/ommc/gui/GuiConfigs.java deleted file mode 100644 index 192dfce..0000000 --- a/src/main/java/com/plusls/ommc/gui/GuiConfigs.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.plusls.ommc.gui; - -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.config.Configs; -import lombok.Getter; -import top.hendrixshen.magiclib.malilib.impl.ConfigManager; -import top.hendrixshen.magiclib.malilib.impl.gui.ConfigGui; - -public class GuiConfigs extends ConfigGui { - @Getter(lazy = true) - private static final GuiConfigs instance = new GuiConfigs(OhMyMinecraftClientReference.getModIdentifier(), Configs.ConfigCategory.GENERIC, OhMyMinecraftClientReference.configHandler.configManager); - - private GuiConfigs(String identifier, String defaultTab, ConfigManager configManager) { - super(identifier, defaultTab, configManager, () -> OhMyMinecraftClientReference.translate("gui.title.configs", OhMyMinecraftClientReference.getModVersion())); - } -} diff --git a/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java new file mode 100644 index 0000000..8c07bc8 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/compat/modmenu/ModMenuApiImpl.java @@ -0,0 +1,25 @@ +package com.plusls.ommc.impl.compat.modmenu; + +import com.plusls.ommc.SharedConstants; +import com.plusls.ommc.game.ConfigGui; +import top.hendrixshen.magiclib.api.compat.modmenu.ModMenuApiCompat; + +public class ModMenuApiImpl implements ModMenuApiCompat { + @Override + public ConfigScreenFactoryCompat getConfigScreenFactoryCompat() { + return (screen) -> { + ConfigGui configGui = new ConfigGui(); + //#if MC > 11903 + configGui.setParent(screen); + //#else + //$$ configGui.setParentGui(screen); + //#endif + return configGui; + }; + } + + @Override + public String getModIdCompat() { + return SharedConstants.getModIdentifier(); + } +} diff --git a/src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java b/src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java new file mode 100644 index 0000000..335b999 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/feature/autoSwitchElytra/AutoSwitchElytraHelper.java @@ -0,0 +1,68 @@ +package com.plusls.ommc.impl.feature.autoSwitchElytra; + +import java.util.List; +import java.util.function.Predicate; + +import com.google.common.collect.Lists; +import com.plusls.ommc.util.InventoryUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.ClickType; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.player.PlayerCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; + +public class AutoSwitchElytraHelper { + public static final int CHEST_SLOT_IDX = 6; + + public static boolean checkFall(Player player) { + PlayerCompat playerCompat = PlayerCompat.of(player); + return !playerCompat.isOnGround() && + !player.isFallFlying() && + !player.isInWaterOrBubble() && + !player.isInLava() && + !player.hasEffect(MobEffects.LEVITATION); + } + + public static boolean isChestArmor(ItemStack itemStack) { + return InventoryUtil.getEquipmentSlotForItem(itemStack) == EquipmentSlot.CHEST && + !ItemStackCompat.of(itemStack).is(Items.ELYTRA); + } + + public static void autoSwitch(int sourceSlot, Minecraft client, LocalPlayer localPlayer, Predicate check) { + if (client.gameMode == null) { + return; + } + + if (localPlayer.containerMenu != localPlayer.inventoryMenu) { + localPlayer.closeContainer(); + } + + AbstractContainerMenu screenHandler = localPlayer.containerMenu; + List itemStacks = Lists.newArrayList(); + + for (int i = 0; i < screenHandler.slots.size(); i++) { + itemStacks.add(screenHandler.slots.get(i).getItem().copy()); + } + + int idxToSwitch = -1; + + for (int i = 0; i < itemStacks.size(); i++) { + if (check.test(itemStacks.get(i))) { + idxToSwitch = i; + break; + } + } + + if (idxToSwitch != -1) { + client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, localPlayer); + client.gameMode.handleInventoryMouseClick(screenHandler.containerId, sourceSlot, 0, ClickType.PICKUP, localPlayer); + client.gameMode.handleInventoryMouseClick(screenHandler.containerId, idxToSwitch, 0, ClickType.PICKUP, localPlayer); + } + } +} diff --git a/src/main/java/com/plusls/ommc/impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java b/src/main/java/com/plusls/ommc/impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java new file mode 100644 index 0000000..942c487 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/feature/blockModelNoOffset/BlockModelNoOffsetHelper.java @@ -0,0 +1,31 @@ +package com.plusls.ommc.impl.feature.blockModelNoOffset; + +import com.plusls.ommc.game.Configs; +import fi.dy.masa.malilib.util.restrictions.UsageRestriction; +import net.minecraft.world.level.block.state.BlockState; + +//#if MC > 11902 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + +public class BlockModelNoOffsetHelper { + public static boolean shouldNoOffset(BlockState blockState) { + //#if MC > 11902 + String blockId = BuiltInRegistries.BLOCK.getKey(blockState.getBlock()).toString(); + //#else + //$$ String blockId = Registry.BLOCK.getKey(blockState.getBlock()).toString(); + //#endif + + String blockName = blockState.getBlock().getName().getString(); + + if (Configs.blockModelNoOffsetListType.getOptionListValue() == UsageRestriction.ListType.WHITELIST) { + return Configs.blockModelNoOffsetWhitelist.getStrings().stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + } else if (Configs.blockModelNoOffsetListType.getOptionListValue() == UsageRestriction.ListType.BLACKLIST) { + return Configs.blockModelNoOffsetBlacklist.getStrings().stream().noneMatch(s -> blockId.contains(s) || blockName.contains(s)); + } + + return false; + } +} diff --git a/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java b/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java similarity index 88% rename from src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java rename to src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java index efbc8af..2a60fab 100644 --- a/src/main/java/com/plusls/ommc/feature/highlightLavaSource/LavaSourceResourceLoader.java +++ b/src/main/java/com/plusls/ommc/impl/feature/highlightLavaSource/LavaSourceResourceLoader.java @@ -1,13 +1,9 @@ -package com.plusls.ommc.feature.highlightLavaSource; +package com.plusls.ommc.impl.feature.highlightLavaSource; -import com.plusls.ommc.OhMyMinecraftClientReference; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.SharedConstants; +import com.plusls.ommc.game.Configs; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler; import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandlerRegistry; -//#if MC < 11903 -//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -//$$ import net.minecraft.client.renderer.texture.TextureAtlas; -//#endif import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.Minecraft; @@ -25,12 +21,17 @@ import java.util.function.Function; +//#if MC < 11903 +//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; +//$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//#endif + public class LavaSourceResourceLoader implements SimpleSynchronousResourceReloadListener { public static final TextureAtlasSprite[] lavaSourceSpites = new TextureAtlasSprite[2]; public static final TextureAtlasSprite[] defaultLavaSourceSpites = new TextureAtlasSprite[2]; - private static final ResourceLocation listenerId = OhMyMinecraftClientReference.identifier("lava_reload_listener"); - private static final ResourceLocation flowingSpriteId = OhMyMinecraftClientReference.identifier("block/lava_flow"); - private static final ResourceLocation stillSpriteId = OhMyMinecraftClientReference.identifier("block/lava_still"); + private static final ResourceLocation listenerId = SharedConstants.identifier("lava_reload_listener"); + private static final ResourceLocation flowingSpriteId = SharedConstants.identifier("block/lava_flow"); + private static final ResourceLocation stillSpriteId = SharedConstants.identifier("block/lava_still"); public static TextureAtlasSprite lavaSourceFlowSprite; public static TextureAtlasSprite lavaSourceStillSprite; public static TextureAtlasSprite defaultLavaSourceFlowSprite; @@ -75,13 +76,14 @@ public void onResourceManagerReload(@NotNull ResourceManager manager) { defaultLavaSourceSpites[0] = defaultLavaSourceStillSprite; defaultLavaSourceSpites[1] = defaultLavaSourceFlowSprite; FluidRenderHandler lavaSourceRenderHandler = (view, pos, state) -> { - - if (view != null && pos != null && Configs.highlightLavaSource) { + if (view != null && pos != null && Configs.highlightLavaSource.getBooleanValue()) { BlockState blockState = view.getBlockState(pos); + if (blockState.hasProperty(LiquidBlock.LEVEL) && blockState.getValue(LiquidBlock.LEVEL) == 0) { return lavaSourceSpites; } } + return defaultLavaSourceSpites; }; FluidRenderHandlerRegistry.INSTANCE.register(Fluids.LAVA, lavaSourceRenderHandler); diff --git a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java b/src/main/java/com/plusls/ommc/impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java similarity index 79% rename from src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java rename to src/main/java/com/plusls/ommc/impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java index 644f37a..b76b67d 100644 --- a/src/main/java/com/plusls/ommc/feature/preventWastageOfWater/PreventWastageOfWaterHandler.java +++ b/src/main/java/com/plusls/ommc/impl/feature/preventWastageOfWater/PreventWastageOfWaterHelper.java @@ -1,6 +1,6 @@ -package com.plusls.ommc.feature.preventWastageOfWater; +package com.plusls.ommc.impl.feature.preventWastageOfWater; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.fabricmc.fabric.api.event.player.UseItemCallback; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResultHolder; @@ -13,16 +13,16 @@ //$$ import net.minecraft.world.InteractionResult; //#endif -public class PreventWastageOfWaterHandler implements UseItemCallback { +public class PreventWastageOfWaterHelper implements UseItemCallback { public static void init() { - PreventWastageOfWaterHandler handler = new PreventWastageOfWaterHandler(); + PreventWastageOfWaterHelper handler = new PreventWastageOfWaterHelper(); UseItemCallback.EVENT.register(handler); } //#if MC > 11404 @Override public InteractionResultHolder interact(Player player, Level world, InteractionHand hand) { - return (Configs.preventWastageOfWater + return (Configs.preventWastageOfWater.getBooleanValue() && world.isClientSide && player.getItemInHand(hand).getItem() == Items.WATER_BUCKET //#if MC > 11502 @@ -36,7 +36,7 @@ public InteractionResultHolder interact(Player player, Level world, I //#else //$$ @Override //$$ public InteractionResult interact(Player player, Level world, InteractionHand hand) { - //$$ return (Configs.preventWastageOfWater + //$$ return (Configs.preventWastageOfWater.getBooleanValue() //$$ && world.isClientSide //$$ && player.getItemInHand(hand).getItem() == Items.WATER_BUCKET //$$ && world.getDimension().isUltraWarm()) diff --git a/src/main/java/com/plusls/ommc/impl/feature/realSneaking/RealSneakingEventHelper.java b/src/main/java/com/plusls/ommc/impl/feature/realSneaking/RealSneakingEventHelper.java new file mode 100644 index 0000000..a7353c5 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/feature/realSneaking/RealSneakingEventHelper.java @@ -0,0 +1,32 @@ +package com.plusls.ommc.impl.feature.realSneaking; + +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.util.CompatGetUtil; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.minecraft.client.Minecraft; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; + +public class RealSneakingEventHelper { + private static final float MIN_STEP_HEIGHT = 0.001F; + private static float prevStepHeight; + + public static void init() { + ClientTickEvents.START_CLIENT_TICK.register(RealSneakingEventHelper::preClientTick); + } + + private static void preClientTick(Minecraft minecraftClient) { + if (minecraftClient.player != null) { + LivingEntityCompat entityCompat = CompatGetUtil.getLivingEntityCompat(minecraftClient.player); + if (EntityCompat.of(minecraftClient.player).getMaxUpStep() - MIN_STEP_HEIGHT >= 0.00001) { + prevStepHeight = entityCompat.getMaxUpStep(); + } + + if (Configs.realSneaking.getBooleanValue() && minecraftClient.player.isShiftKeyDown()) { + entityCompat.setMaxUpStep(MIN_STEP_HEIGHT); + } else { + entityCompat.setMaxUpStep(prevStepHeight); + } + } + } +} diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java similarity index 51% rename from src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java index b195048..83d3ee2 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/ShulkerBoxItemUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/ShulkerBoxItemHelper.java @@ -1,6 +1,6 @@ -package com.plusls.ommc.feature.sortInventory; +package com.plusls.ommc.impl.feature.sortInventory; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.world.item.BlockItem; @@ -8,30 +8,42 @@ import net.minecraft.world.level.block.ShulkerBoxBlock; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.hendrixshen.magiclib.compat.minecraft.api.nbt.TagCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.nbt.TagCompat; -public class ShulkerBoxItemUtil { +//#if MC > 12005 +//$$ import net.minecraft.core.component.DataComponents; +//$$ import net.minecraft.world.item.component.ItemContainerContents; +//#endif + +public class ShulkerBoxItemHelper { public static final int SHULKERBOX_MAX_STACK_AMOUNT = 64; public static boolean isEmptyShulkerBoxItem(ItemStack itemStack) { - if (!ShulkerBoxItemUtil.isShulkerBoxBlockItem(itemStack)) { + if (!ShulkerBoxItemHelper.isShulkerBoxBlockItem(itemStack)) { return false; } + //#if MC < 12005 CompoundTag nbt = itemStack.getTag(); - - if (nbt == null || !nbt.contains("BlockEntityTag", TagCompatApi.TAG_COMPOUND)) { + if (nbt == null || !nbt.contains("BlockEntityTag", TagCompat.TAG_COMPOUND)) { return true; } - CompoundTag tag = nbt.getCompound("BlockEntityTag"); - - if (tag.contains("Items", TagCompatApi.TAG_LIST)) { - ListTag tagList = tag.getList("Items", TagCompatApi.TAG_COMPOUND); + if (tag.contains("Items", TagCompat.TAG_LIST)) { + ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); return tagList.isEmpty(); } - return true; + //#else + //$$ ItemContainerContents icc = itemStack.get(DataComponents.CONTAINER); + //$$ if (icc == null) { + //$$ return true; + //$$ } + //$$ if (icc.stream().allMatch(ItemStack::isEmpty)) { + //$$ return true; + //$$ } + //$$ return true; + //#endif } public static boolean isShulkerBoxBlockItem(@NotNull ItemStack itemStack) { @@ -39,14 +51,15 @@ public static boolean isShulkerBoxBlockItem(@NotNull ItemStack itemStack) { ((BlockItem) itemStack.getItem()).getBlock() instanceof ShulkerBoxBlock; } + //#if MC < 12005 public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundTag b) { int aSize = 0, bSize = 0; if (a != null) { CompoundTag tag = a.getCompound("BlockEntityTag"); - if (tag.contains("Items", TagCompatApi.TAG_LIST)) { - ListTag tagList = tag.getList("Items", TagCompatApi.TAG_COMPOUND); + if (tag.contains("Items", TagCompat.TAG_LIST)) { + ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); aSize = tagList.size(); } } @@ -54,19 +67,31 @@ public static int compareShulkerBox(@Nullable CompoundTag a, @Nullable CompoundT if (b != null) { CompoundTag tag = b.getCompound("BlockEntityTag"); - if (tag.contains("Items", TagCompatApi.TAG_LIST)) { - ListTag tagList = tag.getList("Items", TagCompatApi.TAG_COMPOUND); + if (tag.contains("Items", TagCompat.TAG_LIST)) { + ListTag tagList = tag.getList("Items", TagCompat.TAG_COMPOUND); bSize = tagList.size(); } } return aSize - bSize; } + //#else + //$$ public static int compareShulkerBox(@Nullable ItemContainerContents a, @Nullable ItemContainerContents b) { + //$$ int aSize = 0, bSize = 0; + //$$ if (a != null) { + //$$ aSize = a.stream().toList().size(); + //$$ } + //$$ if (b != null) { + //$$ bSize = b.stream().toList().size(); + //$$ } + //$$ return aSize - bSize; + //$$ } + //#endif public static int getMaxCount(ItemStack itemStack) { - if (Configs.sortInventorySupportEmptyShulkerBoxStack && - ShulkerBoxItemUtil.isEmptyShulkerBoxItem(itemStack)) { - return ShulkerBoxItemUtil.SHULKERBOX_MAX_STACK_AMOUNT; + if (Configs.sortInventorySupportEmptyShulkerBoxStack.getBooleanValue() && + ShulkerBoxItemHelper.isEmptyShulkerBoxItem(itemStack)) { + return ShulkerBoxItemHelper.SHULKERBOX_MAX_STACK_AMOUNT; } else { return itemStack.getMaxStackSize(); } diff --git a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java similarity index 62% rename from src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java index 0aa5d18..5475ad8 100644 --- a/src/main/java/com/plusls/ommc/feature/sortInventory/SortInventoryUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryHelper.java @@ -1,10 +1,10 @@ -package com.plusls.ommc.feature.sortInventory; +package com.plusls.ommc.impl.feature.sortInventory; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.mojang.blaze3d.platform.Window; import com.plusls.ommc.api.sortInventory.IDyeBlock; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.mixin.accessor.AccessorAbstractContainerScreen; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; @@ -26,89 +26,104 @@ import net.minecraft.world.level.material.MapColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import top.hendrixshen.magiclib.compat.minecraft.api.world.item.ItemStackCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; +//#if MC > 12005 +//$$ import net.minecraft.world.item.component.ItemContainerContents; +//$$ import net.minecraft.core.component.DataComponents; +//#endif + //#if MC > 11902 import net.minecraft.core.registries.BuiltInRegistries; //#else //$$ import net.minecraft.core.Registry; //#endif +//#if MC < 11700 +//$$ import com.plusls.ommc.mixin.accessor.AccessorSlot; +//#endif + //#if MC < 11600 //$$ import com.plusls.ommc.mixin.accessor.AccessorBlock; //#endif -public class SortInventoryUtil { +public class SortInventoryHelper { public static final int SLOT_CLICKED_OUTSIDE = -999; private static boolean allShulkerBox; private static final Map DYE_COLOR_MAPPING = Maps.newHashMap(); private static final Map MAP_COLOR_MAPPING = Maps.newHashMap(); static { - SortInventoryUtil.DYE_COLOR_MAPPING.put(null, 0); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.WHITE, 1); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_GRAY, 2); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.GRAY, 3); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.BLACK, 4); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.BROWN, 5); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.RED, 6); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.ORANGE, 7); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.YELLOW, 8); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.LIME, 9); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.GREEN, 10); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.CYAN, 11); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_BLUE, 12); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.BLUE, 13); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.PURPLE, 14); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.MAGENTA, 15); - SortInventoryUtil.DYE_COLOR_MAPPING.put(DyeColor.PINK, 16); - SortInventoryUtil.MAP_COLOR_MAPPING.put(null, 0); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.SNOW, 1); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GRAY, 2); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_GRAY, 3); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLACK, 4); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_BROWN, 5); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_RED, 6); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_ORANGE, 7); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_YELLOW, 8); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GREEN, 9); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_GREEN, 10); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_CYAN, 11); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_BLUE, 12); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLUE, 13); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_PURPLE, 14); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_MAGENTA, 15); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.COLOR_PINK, 16); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_WHITE, 1); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GRAY, 2); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GRAY, 3); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLACK, 4); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BROWN, 5); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_RED, 6); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_ORANGE, 7); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_YELLOW, 8); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GREEN, 9); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GREEN, 10); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_CYAN, 11); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_BLUE, 12); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLUE, 13); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PURPLE, 14); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_MAGENTA, 15); - SortInventoryUtil.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PINK, 16); + SortInventoryHelper.DYE_COLOR_MAPPING.put(null, 0); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.WHITE, 1); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_GRAY, 2); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.GRAY, 3); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.BLACK, 4); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.BROWN, 5); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.RED, 6); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.ORANGE, 7); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.YELLOW, 8); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.LIME, 9); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.GREEN, 10); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.CYAN, 11); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.LIGHT_BLUE, 12); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.BLUE, 13); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.PURPLE, 14); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.MAGENTA, 15); + SortInventoryHelper.DYE_COLOR_MAPPING.put(DyeColor.PINK, 16); + SortInventoryHelper.MAP_COLOR_MAPPING.put(null, 0); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.SNOW, 1); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GRAY, 2); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_GRAY, 3); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLACK, 4); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_BROWN, 5); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_RED, 6); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_ORANGE, 7); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_YELLOW, 8); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_GREEN, 9); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_GREEN, 10); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_CYAN, 11); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_LIGHT_BLUE, 12); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_BLUE, 13); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_PURPLE, 14); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_MAGENTA, 15); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.COLOR_PINK, 16); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_WHITE, 1); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GRAY, 2); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GRAY, 3); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLACK, 4); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BROWN, 5); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_RED, 6); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_ORANGE, 7); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_YELLOW, 8); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_GREEN, 9); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_GREEN, 10); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_CYAN, 11); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_LIGHT_BLUE, 12); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_BLUE, 13); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PURPLE, 14); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_MAGENTA, 15); + SortInventoryHelper.MAP_COLOR_MAPPING.put(MapColor.TERRACOTTA_PINK, 16); } @Nullable public static Tuple getSortRange(AbstractContainerMenu screenHandler, @NotNull Slot mouseSlot) { int mouseIdx = mouseSlot.index; + //#if MC > 11605 if (mouseIdx == 0 && mouseSlot.getContainerSlot() != 0) { mouseIdx = mouseSlot.getContainerSlot(); } + //#else + //$$ if (mouseIdx == 0 && ((AccessorSlot) mouseSlot).getSlot() != 0) { + //$$ mouseIdx = ((AccessorSlot) mouseSlot).getSlot(); + //$$ } + //#endif int l = mouseIdx; int r = mouseIdx + 1; @@ -166,7 +181,11 @@ public static Tuple getSortRange(AbstractContainerMenu screenH } AbstractContainerScreen handledScreen = (AbstractContainerScreen) client.screen; + //#if MC > 11404 Window window = client.getWindow(); + //#else + //$$ Window window = client.window; + //#endif double x = client.mouseHandler.xpos() * window.getGuiScaledWidth() / window.getScreenWidth(); double y = client.mouseHandler.ypos() * window.getGuiScaledHeight() / window.getScreenHeight(); Slot mouseSlot = ((AccessorAbstractContainerScreen) handledScreen).invokeFindSlot(x, y); @@ -182,7 +201,7 @@ public static Tuple getSortRange(AbstractContainerMenu screenH } AbstractContainerMenu screenHandler = player.containerMenu; - Tuple sortRange = SortInventoryUtil.getSortRange(screenHandler, mouseSlot); + Tuple sortRange = SortInventoryHelper.getSortRange(screenHandler, mouseSlot); if (sortRange == null) { return null; @@ -196,11 +215,11 @@ public static Tuple getSortRange(AbstractContainerMenu screenH //#endif screenHandler.slots.stream().map(slot -> slot.getItem().copy()).forEach(itemStacks::add); // Merge picked item to inventory. - List mergeQueue = SortInventoryUtil.mergeItems(cursorStack, itemStacks, sortRange.getA(), + List mergeQueue = SortInventoryHelper.mergeItems(cursorStack, itemStacks, sortRange.getA(), sortRange.getB()); - List> swapQueue = SortInventoryUtil.quickSort(itemStacks, sortRange.getA(), + List> swapQueue = SortInventoryHelper.quickSort(itemStacks, sortRange.getA(), sortRange.getB()); - SortInventoryUtil.doClick(player, screenHandler.containerId, client.gameMode, mergeQueue, swapQueue); + SortInventoryHelper.doClick(player, screenHandler.containerId, client.gameMode, mergeQueue, swapQueue); return (!mergeQueue.isEmpty() || !swapQueue.isEmpty()) ? () -> Minecraft.getInstance().getSoundManager() .play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)) : @@ -211,7 +230,7 @@ public static Tuple getSortRange(AbstractContainerMenu screenH public static void doClick(Player player, int syncId, @NotNull MultiPlayerGameMode interactionManager, @NotNull List mergeQueue, List> swapQueue) { for (Integer slotId : mergeQueue) { - if (slotId < 0 && slotId != SortInventoryUtil.SLOT_CLICKED_OUTSIDE) { + if (slotId < 0 && slotId != SortInventoryHelper.SLOT_CLICKED_OUTSIDE) { // 放入打捆包需要右键 interactionManager.handleInventoryMouseClick(syncId, -slotId, 1, ClickType.PICKUP, player); } else { @@ -228,9 +247,9 @@ public static void doClick(Player player, int syncId, @NotNull MultiPlayerGameMo private static boolean canStackAddMore(@NotNull ItemStack existingStack, ItemStack stack) { return !existingStack.isEmpty() && - ItemStackCompatApi.isSameItemSameTags(existingStack, stack) && - ShulkerBoxItemUtil.isStackable(existingStack) && - existingStack.getCount() < ShulkerBoxItemUtil.getMaxCount(existingStack) && + ItemStackCompat.isSameItemSameTags(existingStack, stack) && + ShulkerBoxItemHelper.isStackable(existingStack) && + existingStack.getCount() < ShulkerBoxItemHelper.getMaxCount(existingStack) && existingStack.getCount() < 64; } @@ -246,8 +265,8 @@ private static boolean canStackAddMore(@NotNull ItemStack existingStack, ItemSta continue; } - if (SortInventoryUtil.canStackAddMore(stack, stackToAdd)) { - int addNum = ShulkerBoxItemUtil.getMaxCount(stack) - stack.getCount(); + if (SortInventoryHelper.canStackAddMore(stack, stackToAdd)) { + int addNum = ShulkerBoxItemHelper.getMaxCount(stack) - stack.getCount(); if (addNum <= 0) { continue; @@ -295,7 +314,7 @@ private static int getItemId(@NotNull ItemStack itemStack) { for (int i = startSlot; i < endSlot; ++i) { ItemStack itemStack = itemStacks.get(i); - if (!itemStack.isEmpty() && !ShulkerBoxItemUtil.isShulkerBoxBlockItem(itemStack)) { + if (!itemStack.isEmpty() && !ShulkerBoxItemHelper.isShulkerBoxBlockItem(itemStack)) { allShulkerBox = false; } @@ -342,7 +361,7 @@ private static int getItemId(@NotNull ItemStack itemStack) { // 先把手中的物品尽量的放入背包或容器中,从而保证后续的整理不会被手中物品合并而影响 if (!cursorStack.isEmpty()) { - ret.addAll(SortInventoryUtil.addItemStack(targetItemStacks, cursorStack, beginSlot, endSlot)); + ret.addAll(SortInventoryHelper.addItemStack(targetItemStacks, cursorStack, beginSlot, endSlot)); } for (int i = endSlot - 1; i >= beginSlot; i--) { @@ -353,7 +372,7 @@ private static int getItemId(@NotNull ItemStack itemStack) { } targetItemStacks.set(i, new ItemStack(Blocks.AIR)); - List addItemStackClickList = SortInventoryUtil.addItemStack(targetItemStacks, stack, + List addItemStackClickList = SortInventoryHelper.addItemStack(targetItemStacks, stack, beginSlot, i + 1); if (!addItemStackClickList.isEmpty()) { @@ -393,22 +412,32 @@ private static boolean bothContains(String target, @NotNull String a, @NotNull S static class ItemStackComparator implements Comparator { @Override public int compare(ItemStack a, ItemStack b) { - int aId = SortInventoryUtil.getItemId(a); - int bId = SortInventoryUtil.getItemId(b); + int aId = SortInventoryHelper.getItemId(a); + int bId = SortInventoryHelper.getItemId(b); - if (Configs.sortInventoryShulkerBoxLast == Configs.SortInventoryShulkerBoxLastType.TRUE || - (Configs.sortInventoryShulkerBoxLast == Configs.SortInventoryShulkerBoxLastType.AUTO && + if (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == SortInventoryShulkerBoxLastType.ENABLE || + (Configs.sortInventoryShulkerBoxLast.getOptionListValue() == SortInventoryShulkerBoxLastType.AUTO && !allShulkerBox)) { - if (ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && !ShulkerBoxItemUtil.isShulkerBoxBlockItem(b)) { + if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && !ShulkerBoxItemHelper.isShulkerBoxBlockItem(b)) { return 1; - } else if (!ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && ShulkerBoxItemUtil.isShulkerBoxBlockItem(b)) { + } else if (!ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b)) { return -1; } } - if (ShulkerBoxItemUtil.isShulkerBoxBlockItem(a) && ShulkerBoxItemUtil.isShulkerBoxBlockItem(b) && + //#if MC < 12005 + CompoundTag tagA = a.getTag(); + CompoundTag tagB = b.getTag(); + //#else + //$$ ItemContainerContents tagA = a.get(DataComponents.CONTAINER), tagB = b.get(DataComponents.CONTAINER); + //$$ if (tagA == null || tagB == null) { + //$$ return -1; + //$$ } + //#endif + + if (ShulkerBoxItemHelper.isShulkerBoxBlockItem(a) && ShulkerBoxItemHelper.isShulkerBoxBlockItem(b) && a.getItem() == b.getItem()) { - return -ShulkerBoxItemUtil.compareShulkerBox(a.getTag(), b.getTag()); + return -ShulkerBoxItemHelper.compareShulkerBox(tagA, tagB); } if (a.getItem() instanceof BlockItem && b.getItem() instanceof BlockItem) { @@ -416,8 +445,8 @@ public int compare(ItemStack a, ItemStack b) { Block blockB = ((BlockItem) b.getItem()).getBlock(); if (blockA instanceof IDyeBlock && blockB instanceof IDyeBlock) { - return SortInventoryUtil.DYE_COLOR_MAPPING.get(((IDyeBlock) blockA).ommc$getColor()) - - SortInventoryUtil.DYE_COLOR_MAPPING.get(((IDyeBlock) blockB).ommc$getColor()); + return SortInventoryHelper.DYE_COLOR_MAPPING.get(((IDyeBlock) blockA).ommc$getColor()) - + SortInventoryHelper.DYE_COLOR_MAPPING.get(((IDyeBlock) blockB).ommc$getColor()); } //#if MC > 11902 @@ -428,11 +457,11 @@ public int compare(ItemStack a, ItemStack b) { //$$ String idb = Registry.BLOCK.getKey(blockB).getPath(); //#endif - if (SortInventoryUtil.bothContains("wool", ida, idb) || - SortInventoryUtil.bothContains("terracotta", ida, idb) || - SortInventoryUtil.bothContains("concrete", ida, idb) || - SortInventoryUtil.bothContains("candle", ida, idb)) { - return SortInventoryUtil.MAP_COLOR_MAPPING.getOrDefault( + if (SortInventoryHelper.bothContains("wool", ida, idb) || + SortInventoryHelper.bothContains("terracotta", ida, idb) || + SortInventoryHelper.bothContains("concrete", ida, idb) || + SortInventoryHelper.bothContains("candle", ida, idb)) { + return SortInventoryHelper.MAP_COLOR_MAPPING.getOrDefault( //#if MC > 11502 blockA.defaultMapColor(), //#else @@ -440,7 +469,7 @@ public int compare(ItemStack a, ItemStack b) { //#endif 0 ) - - SortInventoryUtil.MAP_COLOR_MAPPING.getOrDefault( + SortInventoryHelper.MAP_COLOR_MAPPING.getOrDefault( //#if MC > 11502 blockB.defaultMapColor(), //#else @@ -452,8 +481,8 @@ public int compare(ItemStack a, ItemStack b) { } if (a.getItem() instanceof DyeItem && b.getItem() instanceof DyeItem) { - return SortInventoryUtil.DYE_COLOR_MAPPING.get(((DyeItem) a.getItem()).getDyeColor()) - - SortInventoryUtil.DYE_COLOR_MAPPING.get(((DyeItem) b.getItem()).getDyeColor()); + return SortInventoryHelper.DYE_COLOR_MAPPING.get(((DyeItem) a.getItem()).getDyeColor()) - + SortInventoryHelper.DYE_COLOR_MAPPING.get(((DyeItem) b.getItem()).getDyeColor()); } if (a.isEmpty() && !b.isEmpty()) { @@ -466,13 +495,17 @@ public int compare(ItemStack a, ItemStack b) { if (aId == bId) { // 有 nbt 标签的排在前面 - if (!a.hasTag() && b.hasTag()) { + if (!hasTag(a) && hasTag(b)) { return 1; - } else if (a.hasTag() && !b.hasTag()) { + } else if (hasTag(a) && !hasTag(b)) { return -1; - } else if (a.hasTag()) { + } else if (hasTag(a)) { // 如果都有 nbt 的话,确保排序后相邻的物品 nbt 标签一致 - return Objects.compare(a.getTag(), b.getTag(), Comparator.comparingInt(CompoundTag::hashCode)); + //#if MC < 12005 + return Objects.compare(tagA, tagB, Comparator.comparingInt(CompoundTag::hashCode)); + //#else + //$$ return Objects.compare(tagA, tagB, Comparator.comparingInt(ItemContainerContents::hashCode)); + //#endif } // 物品少的排在后面 @@ -482,4 +515,18 @@ public int compare(ItemStack a, ItemStack b) { return aId - bId; } } + + public static boolean hasTag(ItemStack itemStack) { + //#if MC < 12005 + return itemStack.hasTag(); + //#else + //$$ ItemContainerContents data = itemStack.get(DataComponents.CONTAINER); + //$$ + //$$ if (data != null) { + //$$ return !itemStack.isEmpty() && !data.stream().toList().isEmpty(); + //$$ } + //$$ + //$$ return false; + //#endif + } } diff --git a/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java new file mode 100644 index 0000000..a20e973 --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/feature/sortInventory/SortInventoryShulkerBoxLastType.java @@ -0,0 +1,25 @@ +package com.plusls.ommc.impl.feature.sortInventory; + +import com.plusls.ommc.SharedConstants; +import top.hendrixshen.magiclib.api.malilib.config.option.EnumOptionEntry; + +public enum SortInventoryShulkerBoxLastType implements EnumOptionEntry { + AUTO, + ENABLE, + DISABLE; + + @Override + public EnumOptionEntry[] getAllValues() { + return SortInventoryShulkerBoxLastType.values(); + } + + @Override + public EnumOptionEntry getDefault() { + return null; + } + + @Override + public String getTranslationPrefix() { + return String.format("%s.config.option.sortInventoryShulkerBoxLast", SharedConstants.getModIdentifier()); + } +} diff --git a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/BlockModelRendererContext.java b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/BlockModelRendererContext.java similarity index 81% rename from src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/BlockModelRendererContext.java rename to src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/BlockModelRendererContext.java index e1d42c1..c627eca 100644 --- a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/BlockModelRendererContext.java +++ b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/BlockModelRendererContext.java @@ -1,4 +1,4 @@ -package com.plusls.ommc.feature.worldEaterMineHelper; +package com.plusls.ommc.impl.feature.worldEaterMineHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; diff --git a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java similarity index 65% rename from src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java rename to src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java index f3acb7e..8feed8c 100644 --- a/src/main/java/com/plusls/ommc/feature/worldEaterMineHelper/WorldEaterMineHelperUtil.java +++ b/src/main/java/com/plusls/ommc/impl/feature/worldEaterMineHelper/WorldEaterMineHelper.java @@ -1,6 +1,6 @@ -package com.plusls.ommc.feature.worldEaterMineHelper; +package com.plusls.ommc.impl.feature.worldEaterMineHelper; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; @@ -8,11 +8,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; @@ -23,7 +18,13 @@ import java.util.Map; import java.util.function.Supplier; -public class WorldEaterMineHelperUtil { +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + +public class WorldEaterMineHelper { public static final Map customModels = new HashMap<>(); public static final Map customFullModels = new HashMap<>(); @@ -34,43 +35,58 @@ public static boolean blockInWorldEaterMineHelperWhitelist(Block block) { //#else //$$ String blockId = Registry.BLOCK.getKey(block).toString(); //#endif - return Configs.worldEaterMineHelperWhitelist.stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + return Configs.worldEaterMineHelperWhitelist + .getStrings() + .stream() + .anyMatch(s -> blockId.contains(s) || blockName.contains(s)); } public static boolean shouldUseCustomModel(BlockState blockState, BlockPos pos) { Block block = blockState.getBlock(); - // ModInfo.LOGGER.debug("test model {} {}", pos, block); - if (Configs.worldEaterMineHelper && blockInWorldEaterMineHelperWhitelist(block)) { - ClientLevel world = Minecraft.getInstance().level; - if (world != null) { - int x = pos.getX(); - int y = pos.getY(); - int z = pos.getZ(); - int yMax = world.getHeight(Heightmap.Types.WORLD_SURFACE, x, z); - if (y < yMax) { - int j = 0; - for (int i = y + 1; i <= yMax; ++i) { + + if (!Configs.worldEaterMineHelper.getBooleanValue() || + !WorldEaterMineHelper.blockInWorldEaterMineHelperWhitelist(block)) { + return false; + } + + ClientLevel world = Minecraft.getInstance().level; + + if (world == null) { + return false; + } + + int x = pos.getX(); + int y = pos.getY(); + int z = pos.getZ(); + int yMax = world.getHeight(Heightmap.Types.WORLD_SURFACE, x, z); + + if (y < yMax) { + int j = 0; + + for (int i = y + 1; i <= yMax; ++i) { + if (world.getBlockState(new BlockPos(x, i, z)) //#if MC > 11904 - if (world.getBlockState(new BlockPos(x, i, z)).isSolid() && j < 20) { + .isSolid() //#else - //$$ if (world.getBlockState(new BlockPos(x, i, z)).getMaterial().isSolidBlocking() && j < 20) { + //$$ .getMaterial().isSolidBlocking() //#endif - return false; - } - ++j; - } + && j < 20 + ) { + return false; } - // ModInfo.LOGGER.debug("update model! {} {}", pos, block); - return true; + + j++; } } - return false; + + return true; } static public void emitCustomFullBlockQuads(FabricBakedModel model, BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { Block block = state.getBlock(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(state, pos)) { - FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelperUtil.customFullModels.get(block); + + if (WorldEaterMineHelper.shouldUseCustomModel(state, pos)) { + FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelper.customFullModels.get(block); if (customModel != null) { int luminance = ((AccessorBlockStateBase) state).getLightEmission(); ((AccessorBlockStateBase) state).setLightEmission(15); @@ -79,13 +95,16 @@ static public void emitCustomFullBlockQuads(FabricBakedModel model, BlockAndTint return; } } + model.emitBlockQuads(blockView, state, pos, MiscUtil.cast(randomSupplier), context); } - static public void emitCustomBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { + public static void emitCustomBlockQuads(BlockAndTintGetter blockView, BlockState state, BlockPos pos, Supplier randomSupplier, RenderContext context) { Block block = state.getBlock(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(state, pos)) { - FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelperUtil.customModels.get(block); + + if (WorldEaterMineHelper.shouldUseCustomModel(state, pos)) { + FabricBakedModel customModel = (FabricBakedModel) WorldEaterMineHelper.customModels.get(block); + if (customModel != null) { int luminance = ((AccessorBlockStateBase) state).getLightEmission(); ((AccessorBlockStateBase) state).setLightEmission(15); @@ -94,5 +113,4 @@ static public void emitCustomBlockQuads(BlockAndTintGetter blockView, BlockState } } } - } diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java new file mode 100644 index 0000000..755735d --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointHandler.java @@ -0,0 +1,310 @@ +package com.plusls.ommc.impl.generic.highlightWaypoint; + +import com.google.common.collect.Lists; +import com.mojang.brigadier.context.CommandContext; +import com.plusls.ommc.SharedConstants; +import com.plusls.ommc.api.command.ClientBlockPosArgument; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.mixin.accessor.AccessorTextComponent; +import com.plusls.ommc.mixin.accessor.AccessorTranslatableComponent; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.minecraft.ChatFormatting; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.network.chat.*; +import net.minecraft.world.entity.player.Player; +import org.apache.commons.lang3.tuple.MutablePair; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.StyleCompat; +import top.hendrixshen.magiclib.impl.compat.minecraft.world.level.dimension.DimensionWrapper; +import top.hendrixshen.magiclib.util.minecraft.ComponentUtil; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +//#if MC > 11901 +import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback; +//#endif + +//#if MC > 11802 +import net.minecraft.network.chat.contents.*; +//#endif + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class HighlightWaypointHandler { + @Getter + private static final HighlightWaypointHandler instance = new HighlightWaypointHandler(); + private static final String highlightWaypoint = "highlightWaypoint"; + private static final Pattern pattern = Pattern.compile("(?:(?:x\\s*:\\s*)?(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)(?:(?:(?:\\s*[,,]\\s*(?:y\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)?(?:(?:(?:\\s*[,,]\\s*(?:z\\s*:\\s*)?)|(?:\\s+))(?(?:[+-]?\\d+)(?:\\.\\d+)?)(?:[df])?)", Pattern.CASE_INSENSITIVE); + + private final MutablePair highlightPos = MutablePair.of(null, null); + private final HighlightWaypointRenderer renderer = HighlightWaypointRenderer.getInstance(); + + public static void init() { + //#if MC > 11901 + ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register( + //#else + //$$ ClientCommandManager.DISPATCHER.register( + //#endif + ClientCommandManager.literal(HighlightWaypointHandler.highlightWaypoint).then( + ClientCommandManager.argument("pos", ClientBlockPosArgument.blockPos()) + .executes(HighlightWaypointHandler.instance::runCommand) + //#if MC > 11901 + ))); + //#else + //$$ )); + //#endif + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> HighlightWaypointHandler.instance.clearHighlightPos()); + HighlightWaypointRenderer.init(); + HighlightWaypointResourceLoader.init(); + } + + private int runCommand(CommandContext context) { + BlockPos pos = ClientBlockPosArgument.getBlockPos(context, "pos"); + this.setHighlightPos(pos, false); + + return 0; + } + + private @NotNull List parsePositions(@NotNull String message) { + List ret = Lists.newArrayList(); + Matcher matcher = HighlightWaypointHandler.pattern.matcher(message); + + while (matcher.find()) { + ret.add(this.parsePosition(matcher)); + } + + ret.removeIf(Objects::isNull); + ret.sort(Comparator.comparingInt(HighlightWaypointHandler.ParseResult::getMatcherStart)); + return ret; + } + + private @Nullable HighlightWaypointHandler.ParseResult parsePosition(@NotNull Matcher matcher) { + Integer x = null; + int y = 64; + Integer z = null; + String xStr = matcher.group("x"); + String yStr = matcher.group("y"); + String zStr = matcher.group("z"); + + try { + x = xStr.contains(".") ? (int) Double.parseDouble(xStr) : Integer.parseInt(xStr); + z = zStr.contains(".") ? (int) Double.parseDouble(zStr) : Integer.parseInt(zStr); + + if (yStr != null) { + y = zStr.contains(".") ? (int) Double.parseDouble(yStr) : Integer.parseInt(yStr); + } + } catch (NumberFormatException e) { + SharedConstants.getLogger().error("Failed to parse coordinate {}: {}", matcher.group(), e); + } + + if (x == null || z == null) { + return null; + } + + return new HighlightWaypointHandler.ParseResult(matcher.group(), new BlockPos(x, y, z), matcher.start()); + } + + public void parseMessage(@NotNull Component chat) { + chat.getSiblings().forEach(this::parseMessage); + + //#if MC > 11802 + ComponentContents + //#else MC > 11502 + //$$ BaseComponent + //#endif + contents = ComponentUtil.getTextContent((MutableComponent) chat); + + if ( + //#if MC > 11802 + !(contents instanceof TranslatableContents) + //#else + //$$ !(contents instanceof TranslatableComponent) + //#endif + ) { + this.updateMessage(chat); + return; + } + + //#if MC > 11802 + Object[] args = ((TranslatableContents) contents).getArgs(); + //#else + //$$ Object[] args = ((TranslatableComponent) contents).getArgs(); + //#endif + boolean updateTranslatableText = false; + + for (int i = 0; i < args.length; i++) { + if (args[i] instanceof Component) { + this.parseMessage(ComponentUtil.simple(((Component) args[i]).getString())); + } else if (args[i] instanceof String) { + Component text = ComponentUtil.simple(args[i]); + + if (this.updateMessage(text)) { + args[i] = text; + updateTranslatableText = true; + } + } + } + + if (updateTranslatableText) { + //#if MC > 11502 + ((AccessorTranslatableComponent) contents).setDecomposedWith(null); + //#else + //$$ ((AccessorTranslatableComponent) contents).setDecomposedLanguageTime(-1); + //#endif + } + + this.updateMessage(chat); + } + + private boolean updateMessage(@NotNull Component chat) { + //#if MC > 11802 + ComponentContents + //#else MC > 11502 + //$$ BaseComponent + //#endif + contents = ComponentUtil.getTextContent((MutableComponent) chat); + + if ( + //#if MC > 12002 + !(contents instanceof PlainTextContents.LiteralContents) + //#elseif MC > 11802 + //$$ !(contents instanceof LiteralContents) + //#else + //$$ !(contents instanceof TextComponent) + //#endif + ) { + return false; + } + + //#if MC > 12002 + PlainTextContents.LiteralContents literalChatText = (PlainTextContents.LiteralContents) contents; + //#elseif MC > 11802 + //$$ LiteralContents literalChatText = (LiteralContents) contents; + //#else + //$$ TextComponent literalChatText = (TextComponent) contents; + //#endif + String message = ((AccessorTextComponent) (Object) literalChatText).getText(); + List positions = this.parsePositions(message); + + if (positions.isEmpty()) { + return false; + } + + StyleCompat originalStyle = StyleCompat.of(chat.getStyle()); + ClickEvent originalClickEvent = originalStyle.get().getClickEvent(); + ArrayList texts = Lists.newArrayList(); + int prevIdx = 0; + + // Rebuild components. + for (HighlightWaypointHandler.ParseResult position : positions) { + String waypointString = position.getText(); + int waypointIdx = position.getMatcherStart(); + texts.add(ComponentCompat.literalCompat(message.substring(prevIdx, waypointIdx)).withStyle(originalStyle)); + BlockPos pos = position.getPos(); + texts.add(ComponentCompat.literalCompat(waypointString) + .withStyle(ChatFormatting.GREEN) + .withStyle(ChatFormatting.UNDERLINE) + .withStyle(style -> style.withClickEvent(originalClickEvent == null || + Configs.forceParseWaypointFromChat.getBooleanValue() ? new ClickEvent(ClickEvent.Action.RUN_COMMAND, + String.format("/%s %d %d %d", HighlightWaypointHandler.highlightWaypoint, pos.getX(), pos.getY(), pos.getZ())) : + originalClickEvent)) + .withStyle(style -> style.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, + ComponentCompat.literal(SharedConstants.getTranslation("highlight_waypoint.tooltip")) + )))); + prevIdx = waypointIdx + waypointString.length(); + } + + // Add tail if existed. + if (prevIdx < message.length()) { + texts.add(ComponentCompat.literalCompat(message.substring(prevIdx)).withStyle(originalStyle)); + } + + texts.forEach(value -> chat.getSiblings().add(value.get())); + ((AccessorTextComponent) (Object) literalChatText).setText(""); + //#if MC > 11502 + ((MutableComponent) chat).withStyle(StyleCompat.empty()); + //#else + //$$ ((BaseComponent) chat).withStyle(); + //#endif + return true; + } + + public void setHighlightPos(@NotNull BlockPos pos, boolean directHighlight) { + Player player = Minecraft.getInstance().player; + + if (player == null) { + return; + } + + boolean posChanged; + + if (this.inOverworld(player)) { + posChanged = this.setHighlightBlockPos( + pos, new BlockPos(pos.getX() / 8, pos.getY(), pos.getZ() / 8)); + } else if (this.inNether(player)) { + posChanged = this.setHighlightBlockPos( + new BlockPos(pos.getX() * 8, pos.getY(), pos.getZ() * 8), pos); + } else { + posChanged = this.setHighlightBlockPos(pos, pos); + } + + if (directHighlight || !posChanged) { + this.renderer.lastBeamTime = System.currentTimeMillis() + Configs.highlightBeamTime.getIntegerValue() * 1000L; + } + } + + public BlockPos getHighlightPos() { + Player player = Minecraft.getInstance().player; + return player == null ? BlockPos.ZERO : this.getHighlightPos(player); + } + + public BlockPos getHighlightPos(Player player) { + return this.inNether(player) ? this.highlightPos.getRight() : this.highlightPos.getLeft(); + } + + private boolean setHighlightBlockPos(@NotNull BlockPos overworldPos, @NotNull BlockPos netherWorldPos) { + if (overworldPos.equals(this.highlightPos.getLeft()) && + netherWorldPos.equals(this.highlightPos.getRight())) { + return false; + } + + this.highlightPos.setLeft(overworldPos); + this.highlightPos.setRight(netherWorldPos); + return true; + } + + public void clearHighlightPos() { + this.highlightPos.setLeft(null); + this.highlightPos.setRight(null); + this.renderer.lastBeamTime = 0; + } + + private boolean inOverworld(@NotNull Player player) { + return DimensionWrapper.of(player).equals(DimensionWrapper.OVERWORLD); + } + + private boolean inNether(@NotNull Player player) { + return DimensionWrapper.of(player).equals(DimensionWrapper.NETHER); + } + + @Getter + @AllArgsConstructor + public static class ParseResult { + private final String text; + private final BlockPos pos; + private final int matcherStart; + } +} diff --git a/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java new file mode 100644 index 0000000..414ceed --- /dev/null +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointRenderer.java @@ -0,0 +1,308 @@ +package com.plusls.ommc.impl.generic.highlightWaypoint; + +import com.mojang.blaze3d.vertex.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.blockentity.BeaconRenderer; +import net.minecraft.client.renderer.texture.TextureAtlasSprite; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.MagicLib; +import top.hendrixshen.magiclib.api.compat.minecraft.client.gui.FontCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; +import top.hendrixshen.magiclib.api.compat.mojang.blaze3d.vertex.VertexFormatCompat; +import top.hendrixshen.magiclib.api.event.minecraft.render.RenderLevelListener; +import top.hendrixshen.magiclib.api.render.context.RenderContext; +import top.hendrixshen.magiclib.impl.render.context.RenderGlobal; +import top.hendrixshen.magiclib.util.minecraft.PositionUtil; +import top.hendrixshen.magiclib.util.minecraft.render.RenderUtil; + +//#if MC > 12006 +//$$ import top.hendrixshen.magiclib.api.compat.mojang.blaze3d.vertex.VertexFormatCompat; +//#endif + +//#if MC < 11900 +//$$ import net.minecraft.client.Option; +//#endif + +//#if MC > 11605 +import net.minecraft.world.inventory.InventoryMenu; +import net.minecraft.client.renderer.GameRenderer; +//#else +//$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//$$ import org.lwjgl.opengl.GL11; +//$$ import java.util.Objects; +//#endif + +//#if MC > 11404 +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.renderer.MultiBufferSource; +import org.joml.Matrix4f; +//#else +//$$ import com.mojang.blaze3d.platform.GlStateManager; +//$$ import net.minecraft.client.renderer.entity.EntityRenderDispatcher; +//#endif + +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public class HighlightWaypointRenderer implements RenderLevelListener { + @Getter + private static final HighlightWaypointRenderer instance = new HighlightWaypointRenderer(); + private static final ResourceLocation BEAM_LOCATION = ResourceLocationCompat.withDefaultNamespace("textures/entity/beacon_beam.png"); + + public TextureAtlasSprite targetIdSprite; + protected long lastBeamTime = 0; + + public static void init() { + MagicLib.getInstance().getEventManager().register(RenderLevelListener.class, HighlightWaypointRenderer.instance); + } + + @Override + public void preRenderLevel(Level level, RenderContext context, float partialTicks) { + // NO-OP + } + + @Override + public void postRenderLevel(Level level, RenderContext context, float partialTicks) { + BlockPos waypointPos = HighlightWaypointHandler.getInstance().getHighlightPos(); + + if (waypointPos == null) { + return; + } + + Camera camera = Minecraft.getInstance().gameRenderer.getMainCamera(); + Vec3 cameraPos = camera.getEntity().getEyePosition(partialTicks); + //#if MC > 11802 + double maxDistance = Minecraft.getInstance().options.renderDistance().get() * 16; + //#else + //$$ double maxDistance = Option.RENDER_DISTANCE.get(Minecraft.getInstance().options) * 16; + //#endif + Vec3 target = PositionUtil.centerOf(waypointPos); + double distance = target.distanceTo(cameraPos); + double renderDistance = distance; + + if (distance > maxDistance) { + Vec3 direction = target.subtract(cameraPos); + target = cameraPos.add(direction.normalize().multiply(maxDistance, maxDistance, maxDistance)); + renderDistance = maxDistance; + } + + Vec3 vec3 = target.subtract(cameraPos); + context = RenderContext.of( + //#if MC > 11502 + new PoseStack() + //#endif + ); + context.pushMatrix(); + context.translate(vec3.x(), vec3.y(), vec3.z()); + RenderGlobal.disableDepthTest(); + + if (this.lastBeamTime >= System.currentTimeMillis()) { + context.pushMatrix(); + context.translate(-0.5, -0.5, -0.5); + // TODO: 1.16+ RenderType hook to support beam seeThrough + this.renderBeam(level, context, partialTicks); + context.popMatrix(); + } + + context.pushMatrix(); + //#if MC > 11404 + context.mulPoseMatrix( + //#if MC > 11902 + new Matrix4f().rotation(camera.rotation()) + //#else + //$$ new Matrix4f(camera.rotation()) + //#endif + ); + //#else + //$$ EntityRenderDispatcher entityRenderDispatcher = Minecraft.getInstance().getEntityRenderDispatcher(); + //$$ GlStateManager.rotatef(-entityRenderDispatcher.playerRotY, 0.0F, 1.0F, 0.0F); + //$$ GlStateManager.rotatef(entityRenderDispatcher.playerRotX, 1.0F, 0.0F, 0.0F); + //#endif + + float scale = (float) ((renderDistance > 8 ? renderDistance - 8 : 0) * 0.2 + 1) * 0.0265F; + context.scale(RenderUtil.getSizeScalingXSign() * scale, -scale, -scale); + + context.pushMatrix(); + context.translate(0.0, 5.0, 0.0); + this.renderText(context, String.format("x:%d, y:%d, z:%d (%dm)", + waypointPos.getX(), waypointPos.getY(), waypointPos.getZ(), (int) distance)); + context.popMatrix(); + + RenderGlobal.disableDepthTest(); + this.renderIcon(context); + RenderGlobal.enableDepthTest(); + context.popMatrix(); + context.popMatrix(); + } + + private void renderBeam(@NotNull Level level, @NotNull RenderContext context, float partialTicks) { + //#if MC > 11404 + MultiBufferSource.BufferSource bufferBuilder = RenderUtil.getBufferSource(); + //#else + //$$ Minecraft.getInstance().getTextureManager().bind(HighlightWaypointRenderer.BEAM_LOCATION); + //#endif + + BeaconRenderer.renderBeaconBeam( + //#if MC > 11502 + context.getMatrixStack().getPoseStack(), + //#elseif MC > 11404 + //$$ new PoseStack(), + //#else + //$$ 0, + //$$ 0, + //$$ 0, + //#endif + //#if MC > 11404 + bufferBuilder, + HighlightWaypointRenderer.BEAM_LOCATION, + //#endif + partialTicks, + 1.0F, + level.getGameTime(), + -128, + 256, + //#if MC > 12006 + //$$ 0xFF0000, + //#else + new float[]{1.0f, 0.0f, 0.0f}, + //#endif + 0.2F, + 0.25F + ); + //#if MC > 11404 + bufferBuilder.endBatch(); + //#endif + + RenderGlobal.enableBlend(); + + //#if MC > 11605 + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + //#endif + } + + private void renderText(@NotNull RenderContext context, String text) { + FontCompat fontCompat = FontCompat.of(Minecraft.getInstance().font); + int halfTextWidth = fontCompat.get().width(text) / 2; + int bgColor = 0x80000000; + + //#if MC < 11700 + //$$ RenderGlobal.disableLighting(); + //#endif + + while (true) { + //#if MC > 11404 + MultiBufferSource.BufferSource immediate = RenderUtil.getBufferSource(); + //#endif + + fontCompat.drawInBatch( + text, + (float) -halfTextWidth, + 0.0F, + 0xFFFFFF, + false, + //#if MC > 11404 + //#if MC > 11502 + context.getMatrixStack().getPoseStack().last().pose(), + //#else + //$$ new PoseStack().last().pose(), + //#endif + immediate, + //#endif + FontCompat.DisplayMode.SEE_THROUGH, + bgColor, + 0xF000F0 + ); + + //#if MC > 11404 + immediate.endBatch(); + //#endif + + if (bgColor == 0) { + break; + } else { + bgColor = 0; + } + } + + //#if MC < 11600 + //$$ RenderGlobal.color4f(1.0F, 1.0F, 1.0F, 1.0F); + //#endif + + //#if MC < 11904 + RenderGlobal.enableDepthTest(); + //#endif + } + + private void renderIcon(@NotNull RenderContext context) { + TextureAtlasSprite icon = HighlightWaypointResourceLoader.targetIdSprite; + RenderGlobal.enableBlend(); + + //#if MC > 11605 + RenderSystem.setShader(GameRenderer::getPositionTexColorShader); + RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS); + //#elseif MC > 11404 + //$$ RenderSystem.bindTexture(Objects.requireNonNull(Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS)).getId()); + //#else + //$$ GlStateManager.bindTexture(Objects.requireNonNull(Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_BLOCKS)).getId()); + //#endif + + //#if MC < 11904 + //$$ RenderGlobal.enableTexture(); + //#endif + + Tesselator tesselator = Tesselator.getInstance(); + //#if MC > 12006 + //$$ BufferBuilder bufferBuilder = tesselator.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#else + BufferBuilder bufferBuilder = tesselator.getBuilder(); + bufferBuilder.begin(VertexFormatCompat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR); + //#endif + + //#if MC > 11502 + Matrix4f matrix4f = context.getMatrixStack().getPoseStack().last().pose(); + //#elseif MC > 11404 + //$$ Matrix4f matrix4f = new PoseStack().last().pose(); + //#endif + + float xWidth = 10.0f; + float yWidth = 10.0f; + float iconR = 1.0f; + float iconG = 0.0f; + float iconB = 0.0f; + + //#if MC > 12006 + //$$ bufferBuilder.addVertex(matrix4f, -xWidth, -yWidth, 0.0F).setUv(icon.getU0(), icon.getV0()).setColor(iconR, iconG, iconB, 0.5F); + //$$ bufferBuilder.addVertex(matrix4f, -xWidth, yWidth, 0.0F).setUv(icon.getU0(), icon.getV1()).setColor(iconR, iconG, iconB, 0.5F); + //$$ bufferBuilder.addVertex(matrix4f, xWidth, yWidth, 0.0F).setUv(icon.getU1(), icon.getV1()).setColor(iconR, iconG, iconB, 0.5F); + //$$ bufferBuilder.addVertex(matrix4f, xWidth, -yWidth, 0.0F).setUv(icon.getU1(), icon.getV0()).setColor(iconR, iconG, iconB, 0.5F); + //$$ HighlightWaypointRenderer.end(bufferBuilder); + //#elseif MC > 11404 + bufferBuilder.vertex(matrix4f, -xWidth, -yWidth, 0.0F).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + bufferBuilder.vertex(matrix4f, -xWidth, yWidth, 0.0F).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + bufferBuilder.vertex(matrix4f, xWidth, yWidth, 0.0F).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + bufferBuilder.vertex(matrix4f, xWidth, -yWidth, 0.0F).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + tesselator.end(); + //#else + //$$ bufferBuilder.vertex(-xWidth, -yWidth, 0.0F).uv(icon.getU0(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ bufferBuilder.vertex(-xWidth, yWidth, 0.0F).uv(icon.getU0(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ bufferBuilder.vertex(xWidth, yWidth, 0.0F).uv(icon.getU1(), icon.getV1()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ bufferBuilder.vertex(xWidth, -yWidth, 0.0F).uv(icon.getU1(), icon.getV0()).color(iconR, iconG, iconB, 0.5F).endVertex(); + //$$ tesselator.end(); + //#endif + } + + //#if MC > 12006 + //$$ private static void end(BufferBuilder builder) { + //$$ try (MeshData meshData = builder.buildOrThrow()) { + //$$ BufferUploader.drawWithShader(meshData); + //$$ } catch (Exception ignore) { + //$$ } + //$$ } + //#endif +} diff --git a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointResourceLoader.java b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java similarity index 57% rename from src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointResourceLoader.java rename to src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java index c92d48b..49992d4 100644 --- a/src/main/java/com/plusls/ommc/feature/highlithtWaypoint/HighlightWaypointResourceLoader.java +++ b/src/main/java/com/plusls/ommc/impl/generic/highlightWaypoint/HighlightWaypointResourceLoader.java @@ -1,10 +1,8 @@ -package com.plusls.ommc.feature.highlithtWaypoint; +package com.plusls.ommc.impl.generic.highlightWaypoint; -import com.plusls.ommc.OhMyMinecraftClientReference; -//#if MC < 11903 -//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; -//$$ import net.minecraft.client.renderer.texture.TextureAtlas; -//#endif +import com.plusls.ommc.SharedConstants; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.Minecraft; @@ -15,32 +13,40 @@ import net.minecraft.world.inventory.InventoryMenu; import java.util.function.Function; +//#if MC < 11903 +//$$ import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback; +//$$ import net.minecraft.client.renderer.texture.TextureAtlas; +//#endif + +@NoArgsConstructor(access = AccessLevel.PRIVATE) public class HighlightWaypointResourceLoader implements SimpleSynchronousResourceReloadListener { - private static final ResourceLocation listenerId = OhMyMinecraftClientReference.identifier("target_reload_listener"); - private static final ResourceLocation targetId = OhMyMinecraftClientReference.identifier("block/target"); + private static final HighlightWaypointResourceLoader instance = new HighlightWaypointResourceLoader(); + private static final ResourceLocation listenerId = SharedConstants.identifier("target_reload_listener"); + public static final ResourceLocation targetId = SharedConstants.identifier("block/target"); + public static TextureAtlasSprite targetIdSprite; - public static void init() { + protected static void init() { //#if MC < 11903 //$$ ClientSpriteRegistryCallback.event(TextureAtlas.LOCATION_BLOCKS).register( - //$$ (atlasTexture, registry) -> registry.register(targetId) + //$$ (atlasTexture, registry) -> registry.register(HighlightWaypointResourceLoader.targetId) //$$ ); //#endif - ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new HighlightWaypointResourceLoader()); + ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(HighlightWaypointResourceLoader.instance); } @Override public ResourceLocation getFabricId() { - return listenerId; + return HighlightWaypointResourceLoader.listenerId; } @Override public void onResourceManagerReload(ResourceManager manager) { //#if MC > 11404 - final Function atlas = Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS); - targetIdSprite = atlas.apply(targetId); + Function atlas = Minecraft.getInstance().getTextureAtlas(InventoryMenu.BLOCK_ATLAS); + HighlightWaypointResourceLoader.targetIdSprite = atlas.apply(HighlightWaypointResourceLoader.targetId); //#else - //$$ targetIdSprite = Minecraft.getInstance().getTextureAtlas().getSprite(targetId); + //$$ targetIdSprite = Minecraft.getInstance().getTextureAtlas().getSprite(HighlightWaypointResourceLoader.targetId); //#endif } } diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java index 9f3db08..bc0ac37 100644 --- a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java @@ -4,10 +4,10 @@ import net.minecraft.client.resources.model.BakedModel; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.8")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.8")) @Mixin(BlockRenderContext.class) public interface AccessorBlockRenderContext { @Accessor diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java index 6ca483f..79b762e 100644 --- a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.accessor; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public interface AccessorHelpCommand { diff --git a/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java new file mode 100644 index 0000000..50a06ce --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java @@ -0,0 +1,8 @@ +package com.plusls.ommc.mixin.accessor; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; + +@Mixin(DummyClass.class) +public interface AccessorSlot { +} diff --git a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java deleted file mode 100644 index 07eb718..0000000 --- a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinIntegratedServer.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.plusls.ommc.mixin.advancedIntegratedServer; - -import com.plusls.ommc.config.Configs; -import net.minecraft.client.server.IntegratedServer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -@Mixin(IntegratedServer.class) -public abstract class MixinIntegratedServer { - - @ModifyArg(method = "initServer", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setUsesAuthentication(Z)V", ordinal = 0), index = 0) - private boolean modifySetOnlineModeArg(boolean onlineMode) { - return Configs.onlineMode; - } - - @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setPvpAllowed(Z)V", ordinal = 0), index = 0) - private boolean modifySetPvpEnabledArg(boolean arg) { - return Configs.pvp; - } - - @ModifyArg(method = "initServer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/server/IntegratedServer;setFlightAllowed(Z)V", ordinal = 0), index = 0) - private boolean modifySetFlightEnabledArg(boolean arg) { - return Configs.flight; - } - -} diff --git a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java deleted file mode 100644 index cb1c509..0000000 --- a/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.plusls.ommc.mixin.advancedIntegratedServer; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; - -@Mixin(DummyClass.class) -public class MixinOpenToLanScreen { -} diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java index cf18ae5..16fba97 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinClientPacketListener { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java index 94e0c0e..217b6eb 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinClientSuggestionProvider { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java index ea8ad49..f81cb4c 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinLocalPlayer { diff --git a/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java b/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java index 7f2452c..874ddfc 100644 --- a/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java +++ b/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.api.command; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinMinecraft { diff --git a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java deleted file mode 100644 index d06a0f0..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinClientPlayerEntity.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.plusls.ommc.mixin.feature.autoSwitchElytra; - -import com.mojang.authlib.GameProfile; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.autoSwitchElytra.AutoSwitchElytraUtil; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.client.player.AbstractClientPlayer; -import net.minecraft.client.player.LocalPlayer; -import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -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 org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -//#if MC >= 11902 && MC < 11903 -//$$ import net.minecraft.world.entity.player.ProfilePublicKey; -//#endif - -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif - -@Mixin(LocalPlayer.class) -public abstract class MixinClientPlayerEntity extends AbstractClientPlayer { - @Shadow - @Final - protected Minecraft minecraft; - - boolean prevFallFlying = false; - - //#if MC != 11902 - public MixinClientPlayerEntity(ClientLevel world, GameProfile profile) { - super(world, profile); - } - //#else - //$$ public MixinClientPlayerEntity(ClientLevel world, GameProfile profile, ProfilePublicKey profilePublicKey) { - //$$ super(world, profile, profilePublicKey); - //$$ } - //#endif - - @SuppressWarnings("ConstantConditions") - @Inject(method = "aiStep", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getItemBySlot(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;", ordinal = 0)) - private void autoSwitchElytra(CallbackInfo ci) { - if (!Configs.autoSwitchElytra) { - return; - } - ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); - if (chestItemStack.is(Items.ELYTRA) || !AutoSwitchElytraUtil.myCheckFallFlying(this)) { - return; - } - AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> itemStack.is(Items.ELYTRA)); - } - - @SuppressWarnings("ConstantConditions") - @Inject(method = "aiStep", at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/client/player/LocalPlayer;isFallFlying()Z", - //#if MC > 11404 - ordinal = 0 - //#else - //$$ ordinal = 1 - //#endif - )) - private void autoSwitchChest(CallbackInfo ci) { - if (!Configs.autoSwitchElytra) { - return; - } - ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); - if (!chestItemStack.is(Items.ELYTRA) || !prevFallFlying || this.isFallFlying()) { - prevFallFlying = this.isFallFlying(); - return; - } - prevFallFlying = this.isFallFlying(); - //#if MC >= 11903 - AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> BuiltInRegistries.ITEM.getKey(itemStack.getItem()).toString().contains("_chestplate")); - //#else - //$$ AutoSwitchElytraUtil.autoSwitch(AutoSwitchElytraUtil.CHEST_SLOT_IDX, this.minecraft, (LocalPlayer) (Object) this, itemStack -> Registry.ITEM.getKey(itemStack.getItem()).toString().contains("_chestplate")); - //#endif - } -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java new file mode 100644 index 0000000..182d2f3 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/feature/autoSwitchElytra/MixinLocalPlayer.java @@ -0,0 +1,114 @@ +package com.plusls.ommc.mixin.feature.autoSwitchElytra; + +import com.mojang.authlib.GameProfile; +import com.plusls.ommc.impl.feature.autoSwitchElytra.AutoSwitchElytraHelper; +import com.plusls.ommc.game.Configs; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +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 top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; + +//#if MC < 11903 +//$$ import net.minecraft.core.Registry; +//$$ +//#if MC > 11901 +//$$ import net.minecraft.world.entity.player.ProfilePublicKey; +//#endif +//#endif + +@Mixin(LocalPlayer.class) +public abstract class MixinLocalPlayer extends AbstractClientPlayer { + @Shadow + @Final + protected Minecraft minecraft; + + @Unique + boolean ommc$prevFallFlying = false; + + public MixinLocalPlayer( + ClientLevel world, + GameProfile profile + //#if MC == 11902 + //$$ , ProfilePublicKey profilePublicKey + //#endif + ) { + super( + world, + profile + //#if MC == 11902 + //$$ , profilePublicKey + //#endif + ); + } + + @SuppressWarnings("ConstantConditions") + @Inject( + method = "aiStep", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/player/LocalPlayer;getItemBySlot(Lnet/minecraft/world/entity/EquipmentSlot;)Lnet/minecraft/world/item/ItemStack;" + ) + ) + private void autoSwitchElytra(CallbackInfo ci) { + if (!Configs.autoSwitchElytra.getBooleanValue()) { + return; + } + + ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); + ItemStackCompat chestItemStackCompat = ItemStackCompat.of(chestItemStack); + + if (chestItemStackCompat.is(Items.ELYTRA) || !AutoSwitchElytraHelper.checkFall(this)) { + return; + } + + AutoSwitchElytraHelper.autoSwitch(AutoSwitchElytraHelper.CHEST_SLOT_IDX, this.minecraft, + (LocalPlayer) (Object) this, itemStack -> ItemStackCompat.of(itemStack).is(Items.ELYTRA)); + } + + @SuppressWarnings("ConstantConditions") + @Inject( + method = "aiStep", + at = @At( + value = "INVOKE_ASSIGN", + target = "Lnet/minecraft/client/player/LocalPlayer;isFallFlying()Z", + //#if MC > 11404 + ordinal = 0 + //#else + //$$ ordinal = 1 + //#endif + ) + ) + private void autoSwitchChest(CallbackInfo ci) { + if (!Configs.autoSwitchElytra.getBooleanValue()) { + return; + } + + ItemStack chestItemStack = this.getItemBySlot(EquipmentSlot.CHEST); + ItemStackCompat chestItemStackCompat = ItemStackCompat.of(chestItemStack); + + if (!chestItemStackCompat.is(Items.ELYTRA) || !this.ommc$prevFallFlying || this.isFallFlying()) { + this.ommc$prevFallFlying = this.isFallFlying(); + return; + } + + this.ommc$prevFallFlying = this.isFallFlying(); + + AutoSwitchElytraHelper.autoSwitch( + AutoSwitchElytraHelper.CHEST_SLOT_IDX, + this.minecraft, + (LocalPlayer) (Object) this, + AutoSwitchElytraHelper::isChestArmor + ); + } +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java index 004d1fc..cba4366 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/betterSneaking/MixinPlayerEntity.java @@ -1,84 +1,136 @@ package com.plusls.ommc.mixin.feature.betterSneaking; -import com.plusls.ommc.config.Configs; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.game.Configs; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.MoverType; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.LavaFluid; import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.Vec3; -import org.objectweb.asm.Opcodes; 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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.util.MiscUtil; - -//#if MC > 11404 -@Mixin(Player.class) -//#else -//$$ @Mixin(Entity.class) +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.util.collect.Provider; + +//#if MC > 12004 +//$$ import org.spongepowered.asm.mixin.Shadow; //#endif + +@Mixin( + //#if MC > 11404 + Player.class + //#else + //$$ Entity.class + //#endif +) + public abstract class MixinPlayerEntity { + @Unique + private static final float ommc$MAX_STEP_HEIGHT = 1.2F; - final private static float MAX_STEP_HEIGHT = 1.25f; - final private static float DEFAULT_STEP_HEIGHT = 114514; - private float prevStepHeight = DEFAULT_STEP_HEIGHT; + @Unique + private float ommc$original_step_height = 0.0F; - @Inject(method = "maybeBackOffFromEdge", at = @At(value = "FIELD", target = "Lnet/minecraft/world/phys/Vec3;x:D", opcode = Opcodes.GETFIELD, ordinal = 0)) - private void setStepHeight(Vec3 movement, MoverType type, CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide()) { - return; - } - prevStepHeight = thisObj.maxUpStepCompat(); - thisObj.setMaxUpStepCompat(MAX_STEP_HEIGHT); - } + //#if MC > 12004 + //$$ @Shadow + //$$ protected abstract boolean canFallAtLeast(double par1, double par2, float par3); + //#endif - @Inject(method = "maybeBackOffFromEdge", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;(DDD)V", ordinal = 0)) - private void restoreStepHeight(Vec3 movement, MoverType type, CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide() || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001) { - return; - } - thisObj.setMaxUpStepCompat(prevStepHeight); - prevStepHeight = DEFAULT_STEP_HEIGHT; - } + @WrapOperation( + method = "maybeBackOffFromEdge", + at = @At( + //#if MC > 11903 + value = "INVOKE", + target = "Lnet/minecraft/world/entity/player/Player;maxUpStep()F" + //#else + //$$ value = "FIELD", + //#if MC > 11404 + //$$ target = "Lnet/minecraft/world/entity/player/Player;maxUpStep:F" + //#else + //$$ target = "Lnet/minecraft/world/entity/Entity;maxUpStep:F" + //#endif + //#endif + ) + ) + private float fakeStepHeight( + //#if MC > 11404 + Player instance, + //#else + //$$ Entity instance, + //#endif + Operation original + ) { + EntityCompat entityCompat = EntityCompat.of(instance); + this.ommc$original_step_height = original.call(instance); - @Redirect(method = "maybeBackOffFromEdge", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z", ordinal = -1)) - private boolean myIsSpaceEmpty(Level world, Entity entity, AABB box) { - Entity thisObj = MiscUtil.cast(this); - boolean retOld = world.noCollision(entity, box.move(0, thisObj.maxUpStepCompat() - prevStepHeight, 0)); - boolean retNew = world.noCollision(entity, box); - if (Configs.betterSneaking && thisObj.getLevelCompat().isClientSide() && (retOld && !retNew) && - world.getFluidState(thisObj.blockPosition().below()).getType() instanceof LavaFluid) { - return true; + if (!Configs.betterSneaking.getBooleanValue() || !entityCompat.getLevel().isClientSide()) { + return this.ommc$original_step_height; } - return retNew; + + return MixinPlayerEntity.ommc$MAX_STEP_HEIGHT; } - //#if MC > 11502 - @Inject(method = "isAboveGround", at = @At(value = "HEAD")) - private void setStepHeight(CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide()) { - return; + @WrapOperation( + method = "maybeBackOffFromEdge", + at = @At( + value = "INVOKE", + //#if MC > 12004 + //$$ target = "Lnet/minecraft/world/entity/player/Player;canFallAtLeast(DDF)Z" + //#else + target = "Lnet/minecraft/world/level/Level;noCollision(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Z" + //#endif + ) + ) + private boolean checkFallAtLava( + //#if MC > 12004 + //$$ Player entity, + //$$ double d, + //$$ double e, + //$$ float f, + //#else + Level level, + Entity entity, + AABB aabb, + //#endif + Operation original + ) { + EntityCompat entityCompat = EntityCompat.of(entity); + + //#if MC > 12004 + //$$ Level level = entity.level(); + //#endif + + // Patched value if betterSneak is enabled, otherwise vanilla value. + boolean result = original.call( + //#if MC > 12004 + //$$ entity, + //$$ d, + //$$ e, + //$$ f + //#else + level, + entity, + aabb + //#endif + ); + + if (!Configs.betterSneaking.getBooleanValue() || !level.isClientSide()) { + return result; } - Player playerEntity = MiscUtil.cast(this); - prevStepHeight = playerEntity.maxUpStepCompat(); - playerEntity.setMaxUpStepCompat(MAX_STEP_HEIGHT); - } - @Inject(method = "isAboveGround", at = @At(value = "RETURN")) - private void restoreStepHeight(CallbackInfoReturnable cir) { - Entity thisObj = MiscUtil.cast(this); - if (!Configs.betterSneaking || !thisObj.getLevelCompat().isClientSide() || Math.abs(prevStepHeight - DEFAULT_STEP_HEIGHT) <= 0.001) { - return; + // Always vanilla value and bypass WrapOperation chain invoke. + //#if MC > 12004 + //$$ boolean originalResult = this.canFallAtLeast(d, e, this.ommc$original_step_height); + //#else + boolean originalResult = level.noCollision(entity, aabb.move(0, MixinPlayerEntity.ommc$MAX_STEP_HEIGHT - this.ommc$original_step_height, 0)); + //#endif + + if ((originalResult && !result) && level.getFluidState(entityCompat.getBlockPosition().below()).getType() instanceof LavaFluid) { + return true; } - thisObj.setMaxUpStepCompat(prevStepHeight); - prevStepHeight = DEFAULT_STEP_HEIGHT; + + return result; } - //#endif } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java index 4044c72..87959cf 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/fabric/MixinTerrainRenderContext.java @@ -1,13 +1,11 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.fabric; -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -19,6 +17,12 @@ //$$ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; //$$ import org.spongepowered.asm.mixin.Final; //$$ import org.spongepowered.asm.mixin.Shadow; +//$$ +//#if MC > 11701 +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; +//#else +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; +//#endif //#endif //#if MC > 11802 @@ -27,48 +31,57 @@ //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; //#endif -//#if MC > 11701 -import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; +//#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; //#else -//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; -//#endif - -//#if MC <= 11404 //$$ import com.mojang.blaze3d.platform.GlStateManager; //#endif +@SuppressWarnings("UnstableApiUsage") @Mixin(value = TerrainRenderContext.class, remap = false) -//#if MC > 11903 -public abstract class MixinTerrainRenderContext extends AbstractBlockRenderContext { -//#else -//$$ public abstract class MixinTerrainRenderContext implements RenderContext { -//$$ @Shadow -//$$ @Final -//#if MC > 11701 -//$$ private BlockRenderInfo blockInfo; -//#else -//$$ private TerrainBlockRenderInfo blockInfo; -//#endif -//#endif +public abstract class MixinTerrainRenderContext + //#if MC > 11903 + extends AbstractBlockRenderContext + //#else + //$$ implements RenderContext + //#endif +{ + //#if MC < 11904 + //$$ @Shadow + //$$ @Final + //#if MC > 11701 + //$$ private BlockRenderInfo blockInfo; + //#else + //$$ private TerrainBlockRenderInfo blockInfo; + //#endif + //#endif @Dynamic - @Inject(method = { - "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above - "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below - }, at = @At(value = "HEAD")) - private void blockModelNoOffset(@NotNull BlockState blockState, BlockPos blockPos, BakedModel model, - //#if MC > 11404 - PoseStack matrixStack, - //#endif - //#if MC > 11802 - CallbackInfo ci) { - //#else - //$$ CallbackInfoReturnable cir) { - //#endif - Vec3 offsetPos = blockState.getOffset(blockInfo.blockView, blockPos); - if (BlockModelNoOffsetUtil.shouldNoOffset(blockState)) { + @Inject( + method = { + "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above + "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below + }, + at = @At("HEAD") + ) + private void blockModelNoOffset( + BlockState blockState, + BlockPos blockPos, + BakedModel model, + //#if MC > 11404 + PoseStack poseStack, + //#endif + //#if MC > 11802 + CallbackInfo ci + //#else + //$$ CallbackInfoReturnable cir + //#endif + ) { + Vec3 offsetPos = blockState.getOffset(this.blockInfo.blockView, blockPos); + + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { //#if MC > 11404 - matrixStack.translate(-offsetPos.x, -offsetPos.y, -offsetPos.z); + poseStack.translate(-offsetPos.x, -offsetPos.y, -offsetPos.z); //#else //$$ // will cause crash, i don't know why //$$ ////$$ GlStateManager.translated(-offsetPos.x, -offsetPos.y, -offsetPos.z); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java deleted file mode 100644 index 2b967b8..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/optifine/MixinBlockModelRenderer.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.plusls.ommc.mixin.feature.blockModelNoOffset.optifine; - - -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; -import net.minecraft.client.renderer.block.ModelBlockRenderer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; - -//#if MC <= 11605 -//$$ import org.spongepowered.asm.mixin.Dynamic; -//#endif - -@Dependencies(and = @Dependency("optifabric")) -@Mixin(ModelBlockRenderer.class) -public class MixinBlockModelRenderer { - - //#if MC > 11605 - @Redirect(method = "tesselateBlock", - at = @At(value = "INVOKE", - target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - remap = true, ordinal = 0), - remap = false) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); - } - //#else - //$$ @Dynamic - //$$ @Redirect(method = "renderModel", at = @At(value = "INVOKE", - //$$ target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - //$$ remap = true), - //$$ remap = false) - //$$ private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - //$$ return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); - //$$ } - //#endif -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java index df36815..6d1d3da 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRendererLegacy.java @@ -1,6 +1,8 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; @@ -9,20 +11,28 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.4.9")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.4.9")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer", remap = false) public class MixinBlockRendererLegacy { @Dynamic - @Redirect(method = "renderModel", - at = @At(value = "INVOKE", + @WrapOperation( + method = "renderModel", + at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - ordinal = 0, remap = true)) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); + ordinal = 0, + remap = true + ) + ) + private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return Vec3.ZERO; + } + + return original.call(blockState, world, pos); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java index a14ffad..605d0ca 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_4_9.java @@ -1,6 +1,8 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; @@ -8,20 +10,30 @@ import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.8 <0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.4.9- <0.5-")) +@Pseudo @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_4_9 { @Dynamic - @Redirect(method = "renderModel", - at = @At(value = "INVOKE", + @WrapOperation( + method = "renderModel", + at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - ordinal = 0, remap = true)) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); + ordinal = 0, + remap = true + ) + ) + private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return Vec3.ZERO; + } + + return original.call(blockState, world, pos); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java index 692ec47..89cf6a7 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_5.java @@ -1,31 +1,37 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.Operation; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "~0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.5- <0.6-")) +@Pseudo @Mixin(value = BlockRenderer.class, remap = false) public class MixinBlockRenderer_0_5 { @Dynamic - @Redirect( + @WrapOperation( method = "renderModel", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;hasOffsetFunction()Z", - ordinal = 0, remap = true - ) + ordinal = 0, + remap = true + ), + remap = false ) - private boolean blockModelNoOffset(BlockState blockState) { - return !BlockModelNoOffsetUtil.shouldNoOffset(blockState); + private boolean blockModelNoOffset(BlockState blockState, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return false; + } + + return original.call(blockState); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java new file mode 100644 index 0000000..065bbf7 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer_0_6.java @@ -0,0 +1,41 @@ +package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; + +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; +import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import top.hendrixshen.magiclib.libs.com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; + +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.6- <0.7-")) +@Pseudo +@Mixin(value = BlockRenderer.class, remap = false) +public abstract class MixinBlockRenderer_0_6 { + @Dynamic + @WrapOperation( + method = "renderModel", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/state/BlockState;hasOffsetFunction()Z", + ordinal = 0, + remap = true + ), + remap = false + ) + private boolean blockModelNoOffset(BlockState blockState, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return false; + } + + return original.call(blockState); + } +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java index 3f9c457..471e286 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinTerrainRenderContext.java @@ -1,6 +1,7 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; -import com.plusls.ommc.feature.blockModelNoOffset.BlockModelNoOffsetUtil; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.plusls.ommc.impl.feature.blockModelNoOffset.BlockModelNoOffsetHelper; import net.minecraft.core.BlockPos; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.state.BlockState; @@ -10,19 +11,28 @@ import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.0.0")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.0.0")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.render.renderer.TerrainRenderContext", remap = false) public class MixinTerrainRenderContext { @Dynamic - @Redirect(method = "renderBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", - ordinal = 0, - remap = true)) - private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos) { - return BlockModelNoOffsetUtil.blockModelNoOffset(blockState, world, pos); + @Redirect( + method = "renderBlock", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/block/state/BlockState;getOffset(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/phys/Vec3;", + ordinal = 0, + remap = true + ) + ) + private Vec3 blockModelNoOffset(BlockState blockState, BlockGetter world, BlockPos pos, Operation original) { + if (BlockModelNoOffsetHelper.shouldNoOffset(blockState)) { + return Vec3.ZERO; + } + + return original.call(blockState, world, pos); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java index d92f84b..34d2b3e 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java @@ -1,6 +1,7 @@ package com.plusls.ommc.mixin.feature.disableBlocklistCheck; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; +import net.minecraft.client.gui.screens.social.PlayerSocialManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -8,24 +9,16 @@ import java.util.UUID; -//#if MC > 11502 -import net.minecraft.client.gui.screens.social.PlayerSocialManager; -//#else -//$$ import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; -//#endif - -//#if MC > 11502 @Mixin(PlayerSocialManager.class) -//#else -//$$ @Mixin(DummyClass.class) -//#endif public class MixinSocialInteractionsManager { - //#if MC > 11502 - @Inject(method = "isBlocked", at = @At("HEAD"), cancellable = true) + @Inject( + method = "isBlocked", + at = @At("HEAD"), + cancellable = true + ) public void disableBlocklistCheck(UUID uuid, CallbackInfoReturnable cir) { - if (Configs.disableBlocklistCheck) { + if (Configs.disableBlocklistCheck.getBooleanValue()) { cir.setReturnValue(false); } } - //#endif } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java index 48cf1cd..a1de3ac 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakBlock/MixinClientPlayerInteractionManager.java @@ -1,55 +1,64 @@ package com.plusls.ommc.mixin.feature.disableBreakBlock; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; 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; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - - @Inject(method = "startDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "startDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakBlock(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakBlock(pos)) { + if (this.ommc$shouldDisableBreakBlock(pos)) { cir.setReturnValue(false); } } - @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "continueDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakBlock1(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakBlock(pos)) { + if (this.ommc$shouldDisableBreakBlock(pos)) { cir.setReturnValue(false); } } - private boolean shouldDisableBreakBlock(BlockPos pos) { - Level world = Minecraft.getInstance().level; + @Unique + private boolean ommc$shouldDisableBreakBlock(BlockPos pos) { + Level level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.disableBreakBlock && - world != null && player != null) { + + if (Configs.disableBreakBlock.getBooleanValue() && level != null && player != null) { //#if MC >= 11903 - String blockId = BuiltInRegistries.BLOCK.getKey(world.getBlockState(pos).getBlock()).toString(); + String blockId = BuiltInRegistries.BLOCK.getKey(level.getBlockState(pos).getBlock()).toString(); //#else - //$$ String blockId = Registry.BLOCK.getKey(world.getBlockState(pos).getBlock()).toString(); + //$$ String blockId = Registry.BLOCK.getKey(level.getBlockState(pos).getBlock()).toString(); //#endif - String blockName = world.getBlockState(pos).getBlock().getName().getString(); - return Configs.breakBlockBlackList.stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); + String blockName = level.getBlockState(pos).getBlock().getName().getString(); + return Configs.breakBlockBlackList.getStrings().stream().anyMatch(s -> blockId.contains(s) || blockName.contains(s)); } + return false; } - } - diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java index c2d2224..22b4022 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableBreakScaffolding/MixinClientPlayerInteractionManager.java @@ -1,55 +1,73 @@ package com.plusls.ommc.mixin.feature.disableBreakScaffolding; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; 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; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - - @Inject(method = "startDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "startDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakScaffolding(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakScaffolding(pos)) { + if (this.ommc$shouldDisableBreakScaffolding(pos)) { cir.setReturnValue(false); } } - @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "continueDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void disableBreakScaffolding1(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldDisableBreakScaffolding(pos)) { + if (this.ommc$shouldDisableBreakScaffolding(pos)) { cir.setReturnValue(false); } } - private boolean shouldDisableBreakScaffolding(BlockPos pos) { - Level world = Minecraft.getInstance().level; + @Unique + private boolean ommc$shouldDisableBreakScaffolding(BlockPos pos) { + Level level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.disableBreakScaffolding && - world != null && world.getBlockState(pos).is(Blocks.SCAFFOLDING) && - player != null) { + + if ( + Configs.disableBreakScaffolding.getBooleanValue() && + level != null && + //#if MC <= 11502 + //$$ level.getBlockState(pos).getBlock() == Blocks.SCAFFOLDING && + //#else + level.getBlockState(pos).is(Blocks.SCAFFOLDING) && + //#endif + player != null + ) { //#if MC >= 11903 String itemId = BuiltInRegistries.ITEM.getKey(player.getMainHandItem().getItem()).toString(); //#else //$$ String itemId = Registry.ITEM.getKey(player.getMainHandItem().getItem()).toString(); //#endif String itemName = player.getMainHandItem().getItem().getDescription().getString(); - return Configs.breakScaffoldingWhiteList.stream().noneMatch(s -> itemId.contains(s) || itemName.contains(s)); + return Configs.breakScaffoldingWhiteList.getStrings().stream().noneMatch(s -> itemId.contains(s) || itemName.contains(s)); } + return false; } - } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java index 5ae7400..8a695c7 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disableMoveDownInScaffolding/MixinScaffoldingBlock.java @@ -1,13 +1,8 @@ package com.plusls.ommc.mixin.feature.disableMoveDownInScaffolding; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.item.Item; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.block.ScaffoldingBlock; @@ -22,30 +17,47 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(ScaffoldingBlock.class) public class MixinScaffoldingBlock { @Shadow @Final private static VoxelShape STABLE_SHAPE; - @Inject(method = "getCollisionShape", at = @At(value = "RETURN"), cancellable = true) - private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context, CallbackInfoReturnable cir) { - if (cir.getReturnValue() != STABLE_SHAPE) { - if (Configs.disableMoveDownInScaffolding && - context.isDescending() && context.isAbove(Shapes.block(), pos, true)) { - assert Minecraft.getInstance().player != null; - Item item = Minecraft.getInstance().player.getMainHandItem().getItem(); - //#if MC >= 11903 - String itemId = BuiltInRegistries.ITEM.getKey(item).toString(); - //#else - //$$ String itemId = Registry.ITEM.getKey(item).toString(); - //#endif - String itemName = item.getDescription().getString(); - if (Configs.moveDownInScaffoldingWhiteList.stream().anyMatch(s -> itemId.contains(s) || itemName.contains(s))) { - return; - } - cir.setReturnValue(STABLE_SHAPE); + @Inject( + method = "getCollisionShape", + at = @At("RETURN"), + cancellable = true + ) + private void setNormalOutlineShape(BlockState state, BlockGetter world, BlockPos pos, + CollisionContext context, CallbackInfoReturnable cir) { + if (context.isDescending() && Configs.disableMoveDownInScaffolding.getBooleanValue() && + context.isAbove(Shapes.block(), pos, true) && + cir.getReturnValue() != MixinScaffoldingBlock.STABLE_SHAPE) { + + assert Minecraft.getInstance().player != null; + Item item = Minecraft.getInstance().player.getMainHandItem().getItem(); + //#if MC >= 11903 + String itemId = BuiltInRegistries.ITEM.getKey(item).toString(); + //#else + //$$ String itemId = Registry.ITEM.getKey(item).toString(); + //#endif + String itemName = item.getDescription().getString(); + + if (Configs.moveDownInScaffoldingWhiteList + .getStrings() + .stream() + .anyMatch(s -> itemId.contains(s) || itemName.contains(s)) + ) { + return; } + + cir.setReturnValue(MixinScaffoldingBlock.STABLE_SHAPE); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java index f49459d..bcc8b17 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/disablePistonPushEntity/MixinPistonBlockEntity.java @@ -1,7 +1,9 @@ package com.plusls.ommc.mixin.feature.disablePistonPushEntity; import com.google.common.collect.ImmutableList; -import com.plusls.ommc.config.Configs; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.world.entity.Entity; @@ -10,27 +12,35 @@ import net.minecraft.world.phys.AABB; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import java.util.List; @Mixin(PistonMovingBlockEntity.class) public class MixinPistonBlockEntity { - @Redirect(method = "moveCollidedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;", ordinal = 0)) + @WrapOperation( + method = "moveCollidedEntities", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;" + ) + ) + private //#if MC > 11605 - private static List removeNoPlayerEntity(Level world, Entity except, AABB box) { - //#else - //$$ private List removeNoPlayerEntity(Level world, Entity except, AABB box) { + static //#endif - if (world.isClientSide() && Configs.disablePistonPushEntity) { + List removeNoPlayerEntity(Level instance, Entity entity, AABB aabb, Operation> original) { + if (instance.isClientSide() && Configs.disablePistonPushEntity.getBooleanValue()) { LocalPlayer playerEntity = Minecraft.getInstance().player; + if (playerEntity != null && !playerEntity.isSpectator() && - playerEntity.getBoundingBox().intersects(box) + playerEntity.getBoundingBox().intersects(aabb) ) { return ImmutableList.of(playerEntity); } + return ImmutableList.of(); } - return world.getEntities(except, box); + + return original.call(instance, entity, aabb); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java index 291afd1..548069f 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/flatDigger/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.flatDigger; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; @@ -8,35 +8,45 @@ import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; 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 top.hendrixshen.magiclib.api.compat.minecraft.world.entity.player.PlayerCompat; @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - - @Inject(method = "startDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "startDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void flatDigger(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldFlatDigger(pos)) { + if (this.ommc$shouldFlatDigger(pos)) { cir.setReturnValue(false); } } - @Inject(method = "continueDestroyBlock", at = @At(value = "HEAD"), cancellable = true) + @Inject( + method = "continueDestroyBlock", + at = @At("HEAD"), + cancellable = true + ) private void flatDigger1(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (shouldFlatDigger(pos)) { + if (this.ommc$shouldFlatDigger(pos)) { cir.setReturnValue(false); } } - private boolean shouldFlatDigger(BlockPos pos) { - Level world = Minecraft.getInstance().level; + @Unique + private boolean ommc$shouldFlatDigger(BlockPos pos) { + Level level = Minecraft.getInstance().level; Player player = Minecraft.getInstance().player; - if (Configs.flatDigger && - world != null && player != null) { - return !player.isShiftKeyDown() && pos.getY() < player.getBlockY(); + + if (Configs.flatDigger.getBooleanValue() && level != null && player != null) { + return !player.isShiftKeyDown() && pos.getY() < PlayerCompat.of(player).getBlockPosition().getY(); } + return false; } - -} \ No newline at end of file +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java index 9e79dc9..8dce7d8 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/forceBreakingCooldown/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.forceBreakingCooldown; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -33,23 +33,26 @@ public class MixinClientPlayerInteractionManager { remap = false ) private void addBreakingCooldown(BlockState blockState, BlockPos blockPos, Direction direction, int i, CallbackInfoReturnable> cir) { - if (Configs.forceBreakingCooldown) { - destroyDelay = 5; + if (Configs.forceBreakingCooldown.getBooleanValue()) { + this.destroyDelay = 5; } } //#else - //$$ @Inject(method = "startDestroyBlock", - //$$ at = @At(value = "INVOKE", + //$$ @Inject( + //$$ method = "startDestroyBlock", + //$$ at = @At( + //$$ value = "INVOKE", //$$ target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;destroyBlock(Lnet/minecraft/core/BlockPos;)Z", //$$ //#if MC > 11502 //$$ ordinal = 1 //$$ //#else //$$ //$$ ordinal = 0 //$$ //#endif - //$$ )) + //$$ ) + //$$ ) //$$ private void addBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - //$$ if (Configs.forceBreakingCooldown) { - //$$ destroyDelay = 5; + //$$ if (Configs.forceBreakingCooldown.getBooleanValue()) { + //$$ this.destroyDelay = 5; //$$ } //$$ } //#endif diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java index c8e8430..bb28bb2 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightEntity/MixinEntity.java @@ -1,12 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightEntity; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import fi.dy.masa.malilib.util.restrictions.UsageRestriction; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; @@ -16,29 +11,46 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(Entity.class) public abstract class MixinEntity { @Shadow public abstract EntityType getType(); @Shadow - public Level level; + //#if MC > 11904 + private + //#else + //$$ public + //#endif + Level level; - @Inject(method = "isCurrentlyGlowing", at = @At(value = "RETURN"), cancellable = true) + @Inject( + method = "isCurrentlyGlowing", + at = @At("RETURN"), + cancellable = true + ) private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { if (cir.getReturnValue() || !this.level.isClientSide) { return; } + //#if MC >= 11903 String entityId = BuiltInRegistries.ENTITY_TYPE.getKey(this.getType()).toString(); //#else //$$ String entityId = Registry.ENTITY_TYPE.getKey(this.getType()).toString(); //#endif + String entityName = this.getType().getDescription().getString(); if (Configs.highlightEntityListType == UsageRestriction.ListType.WHITELIST) { - cir.setReturnValue(Configs.highlightEntityWhiteList.stream().anyMatch(s -> entityId.contains(s) || entityName.contains(s))); + cir.setReturnValue(Configs.highlightEntityWhiteList.getStrings().stream().anyMatch(s -> entityId.contains(s) || entityName.contains(s))); } else if (Configs.highlightEntityListType == UsageRestriction.ListType.BLACKLIST) { - cir.setReturnValue(Configs.highlightEntityBlackList.stream().noneMatch(s -> entityId.contains(s) || entityName.contains(s))); + cir.setReturnValue(Configs.highlightEntityBlackList.getStrings().stream().noneMatch(s -> entityId.contains(s) || entityName.contains(s))); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java index 30ca70f..8d83b94 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/canvas/MixinSimpleFluidSpriteProvider.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightLavaSource.canvas; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.impl.feature.highlightLavaSource.LavaSourceResourceLoader; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; @@ -12,42 +12,48 @@ import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; +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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; - -@Dependencies(and = @Dependency("frex")) +@Dependencies(require = @Dependency("frex")) @Pseudo @Mixin(targets = "io.vram.frex.impl.model.SimpleFluidSpriteProvider", remap = false) public abstract class MixinSimpleFluidSpriteProvider { - private boolean isLava; - private final TextureAtlasSprite[] lavaSourceSpites = new TextureAtlasSprite[3]; + @Unique + private boolean ommc$isLava; + @Unique + private final TextureAtlasSprite[] ommc$lavaSourceSpites = new TextureAtlasSprite[3]; @Dynamic - @Inject(method = "", at = @At(value = "RETURN")) + @Inject(method = "", at = @At("RETURN")) private void preInit(ResourceLocation stillSpriteName, ResourceLocation flowingSpriteName, ResourceLocation overlaySpriteName, CallbackInfo ci) { - this.isLava = stillSpriteName.toString().equals("minecraft:block/lava_still"); + this.ommc$isLava = stillSpriteName.toString().equals("minecraft:block/lava_still"); } @Dynamic - @Inject(method = "getFluidSprites", at = @At(value = "RETURN"), cancellable = true) + @Inject( + method = "getFluidSprites", + at = @At("RETURN"), + cancellable = true + ) private void setLavaSprite(BlockAndTintGetter view, BlockPos pos, FluidState state, CallbackInfoReturnable cir) { - if (this.isLava) { - if (lavaSourceSpites[0] != LavaSourceResourceLoader.lavaSourceSpites[0]) { - lavaSourceSpites[0] = LavaSourceResourceLoader.lavaSourceSpites[0]; - lavaSourceSpites[1] = LavaSourceResourceLoader.lavaSourceSpites[1]; + if (this.ommc$isLava) { + if (this.ommc$lavaSourceSpites[0] != LavaSourceResourceLoader.lavaSourceSpites[0]) { + this.ommc$lavaSourceSpites[0] = LavaSourceResourceLoader.lavaSourceSpites[0]; + this.ommc$lavaSourceSpites[1] = LavaSourceResourceLoader.lavaSourceSpites[1]; } - if (Configs.highlightLavaSource && state.is(FluidTags.LAVA) && + + if (Configs.highlightLavaSource.getBooleanValue() && state.is(FluidTags.LAVA) && view.getBlockState(pos).getValue(LiquidBlock.LEVEL) == 0) { - cir.setReturnValue(lavaSourceSpites); + cir.setReturnValue(this.ommc$lavaSourceSpites); } } } - } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java index 653e4b1..71e0f19 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightLavaSource/sodium/MixinFluidRenderer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.highlightLavaSource.sodium; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlightLavaSource.LavaSourceResourceLoader; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.impl.feature.highlightLavaSource.LavaSourceResourceLoader; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.core.BlockPos; import net.minecraft.tags.FluidTags; @@ -13,10 +13,10 @@ import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.3")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.3")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.FluidRenderer", remap = false) public class MixinFluidRenderer { @@ -28,7 +28,7 @@ public class MixinFluidRenderer { @Inject(method = "render", at = @At("HEAD")) public void modifyLavaSprites(BlockAndTintGetter world, FluidState fluidState, BlockPos pos, @Coerce Object buffers, CallbackInfoReturnable info) { - if (Configs.highlightLavaSource && fluidState.is(FluidTags.LAVA) && + if (Configs.highlightLavaSource.getBooleanValue() && fluidState.is(FluidTags.LAVA) && world.getBlockState(pos).getValue(LiquidBlock.LEVEL) == 0) { lavaSprites[0] = LavaSourceResourceLoader.lavaSourceStillSprite; lavaSprites[1] = LavaSourceResourceLoader.lavaSourceFlowSprite; @@ -42,5 +42,4 @@ public void restoreLavaSprites(BlockAndTintGetter world, FluidState fluidState, lavaSprites[0] = LavaSourceResourceLoader.defaultLavaSourceStillSprite; lavaSprites[1] = LavaSourceResourceLoader.defaultLavaSourceFlowSprite; } - } \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java index c091b83..8f2e1b0 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightPersistentMob/MixinEntity.java @@ -1,13 +1,8 @@ package com.plusls.ommc.mixin.feature.highlightPersistentMob; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import fi.dy.masa.malilib.util.WorldUtils; import net.minecraft.client.Minecraft; -//#if MC >= 11903 -import net.minecraft.core.registries.BuiltInRegistries; -//#else -//$$ import net.minecraft.core.Registry; -//#endif import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import net.minecraft.world.level.Level; @@ -20,47 +15,65 @@ import java.util.Arrays; import java.util.List; +//#if MC >= 11903 +import net.minecraft.core.registries.BuiltInRegistries; +//#else +//$$ import net.minecraft.core.Registry; +//#endif + @Mixin(Entity.class) public class MixinEntity { - private static final List itemBlackList = Arrays.asList("sword", "bow", "trident", "axe", "fishing_rod"); + private static final List ommc$itemBlackList = Arrays.asList("sword", "bow", "trident", "axe", "fishing_rod"); - private static T getBestEntity(T entity) { + private static T ommc$getBestEntity(T entity) { // Only try to fetch the corresponding server world if the entity is in the actual client world. // Otherwise the entity may be for example in Litematica's schematic world. Level world = entity.getCommandSenderWorld(); Minecraft client = Minecraft.getInstance(); T ret = entity; + if (world == client.level) { world = WorldUtils.getBestWorld(client); + if (world != null && world != client.level) { Entity bestEntity = world.getEntity(entity.getId()); + if (entity.getClass().isInstance(bestEntity)) { ret = MiscUtil.cast(bestEntity); } } } + return ret; } - @Inject(method = "isCurrentlyGlowing", at = @At(value = "RETURN"), cancellable = true) + @Inject( + method = "isCurrentlyGlowing", + at = @At("RETURN"), + cancellable = true + ) private void checkWanderingTraderEntity(CallbackInfoReturnable cir) { - if (Configs.highlightPersistentMob && !cir.getReturnValue()) { - Entity entity = getBestEntity(MiscUtil.cast(this)); + if (Configs.highlightPersistentMob.getBooleanValue() && !cir.getReturnValue()) { + Entity entity = ommc$getBestEntity(MiscUtil.cast(this)); + if (entity instanceof Mob) { Mob mobEntity = (Mob) entity; + if (mobEntity.requiresCustomPersistence() || mobEntity.isPersistenceRequired()) { cir.setReturnValue(true); return; } - if (!Configs.highlightPersistentMobClientMode) { + + if (!Configs.highlightPersistentMobClientMode.getBooleanValue()) { return; } + //#if MC >= 11903 String mainHandItemName = BuiltInRegistries.ITEM.getKey(mobEntity.getMainHandItem().getItem()).toString(); //#else //$$ String mainHandItemName = Registry.ITEM.getKey(mobEntity.getMainHandItem().getItem()).toString(); //#endif - if (!mobEntity.getMainHandItem().isEmpty() && itemBlackList.stream().noneMatch(mainHandItemName::contains) || + if (!mobEntity.getMainHandItem().isEmpty() && ommc$itemBlackList.stream().noneMatch(mainHandItemName::contains) || entity.getCustomName() != null) { cir.setReturnValue(true); } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java index 89b8da0..752f9b9 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinChatHud.java @@ -1,7 +1,9 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; -import com.plusls.ommc.config.Configs; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; +import com.plusls.ommc.game.Configs; +import com.plusls.ommc.impl.generic.highlightWaypoint.HighlightWaypointHandler; +import net.minecraft.network.chat.MutableComponent; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import net.minecraft.client.gui.components.ChatComponent; import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; @@ -11,6 +13,11 @@ //#if MC > 11802 import net.minecraft.client.GuiMessageTag; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.MutableComponentCompat; +//#endif + +//#if MC >=12005 +//$$ import net.minecraft.client.GuiMessage; //#endif @Mixin(value = ChatComponent.class, priority = 999) @@ -21,21 +28,27 @@ public class MixinChatHud { //#else //$$ method = "addMessage(Lnet/minecraft/network/chat/Component;I)V", //#endif - at = @At( - value = "HEAD" - ) + at = @At(value = "HEAD") ) public void modifyMessage( + //#if MC >= 12005 + //$$ GuiMessage message, + //#else Component message, - //#if MC > 11802 + //#endif + //#if MC > 11802 && MC < 12005 GuiMessageTag guiMessageTag, - //#else + //#elseif MC <=11802 //$$ int messageId, //#endif CallbackInfo ci ) { - if (Configs.parseWaypointFromChat) { - HighlightWaypointUtil.parseMessage(message); + if (Configs.parseWaypointFromChat.getBooleanValue()) { + HighlightWaypointHandler.getInstance().parseMessage(message + //#if MC > 12004 + //$$ .content() + //#endif + ); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java deleted file mode 100644 index 2ff5238..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; - -@Mixin(DummyClass.class) -public class MixinGameRenderer { -} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java deleted file mode 100644 index 4493395..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - - -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; -import net.minecraft.client.Camera; -import net.minecraft.client.renderer.GameRenderer; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import org.joml.Matrix4f; -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(LevelRenderer.class) -public class MixinLevelRenderer { - @Inject(method = "renderLevel", at = @At("RETURN")) - private void postRender(PoseStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightTexture lightmapTextureManager, Matrix4f matrix4f, CallbackInfo ci) { - HighlightWaypointUtil.drawWaypoint(matrices, tickDelta); - } -} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java index 27a4ae6..91ac537 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java @@ -1,5 +1,9 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentContents; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.network.chat.Style; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -11,23 +15,8 @@ import java.util.ArrayList; import java.util.List; -//#if MC > 12002 -import net.minecraft.network.chat.MutableComponent; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.ComponentContents; -import net.minecraft.network.chat.Style; -//#else -//$$ import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; -//#endif - -//#if MC > 12002 @Mixin(MutableComponent.class) -//#else -//$$ @Mixin(DummyClass.class) -//#endif public class MixinMutableComponent { - - //#if MC > 12002 @Final @Mutable @Shadow @@ -39,5 +28,4 @@ private void makeMutable(ComponentContents componentContents, List li siblings = new ArrayList<>(list); } } - //#endif } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java index faa98bf..9cb34dc 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/preventIntentionalGameDesign/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.preventIntentionalGameDesign; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.client.player.LocalPlayer; @@ -21,29 +21,37 @@ @Mixin(MultiPlayerGameMode.class) public class MixinClientPlayerInteractionManager { - @Inject(method = "useItemOn", - at = @At(value = "HEAD"), - cancellable = true) - private void preventIntentionalGameDesign(LocalPlayer player, - //#if MC <= 11802 - //$$ ClientLevel world, - //#endif - InteractionHand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) { + @Inject( + method = "useItemOn", + at = @At("HEAD"), + cancellable = true + ) + private void preventIntentionalGameDesign( + LocalPlayer player, + //#if MC <= 11802 + //$$ ClientLevel level, + //#endif + InteractionHand hand, + BlockHitResult hitResult, + CallbackInfoReturnable cir + ) { //#if MC > 11802 - ClientLevel world = (ClientLevel) player.level(); + ClientLevel level = (ClientLevel) player.level(); //#endif - if (!Configs.preventIntentionalGameDesign) { + + if (!Configs.preventIntentionalGameDesign.getBooleanValue()) { return; } + BlockPos blockPos = hitResult.getBlockPos(); - BlockState blockState = world.getBlockState(blockPos); + BlockState blockState = level.getBlockState(blockPos); if ((blockState.getBlock() instanceof BedBlock && //#if MC > 11502 - !world.dimensionType().bedWorks()) || - (blockState.getBlock() instanceof RespawnAnchorBlock && !world.dimensionType().respawnAnchorWorks()) - //#else - //$$ !world.getDimension().mayRespawn()) - //#endif + !level.dimensionType().bedWorks()) || + (blockState.getBlock() instanceof RespawnAnchorBlock && !level.dimensionType().respawnAnchorWorks()) + //#else + //$$ !level.getDimension().mayRespawn()) + //#endif ) { cir.setReturnValue(InteractionResult.SUCCESS); } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java b/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java index 7291d16..92f9e78 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/removeBreakCooldown/MixinClientPlayerInteractionManager.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.removeBreakCooldown; -import com.plusls.ommc.config.Configs; +import com.plusls.ommc.game.Configs; import net.minecraft.client.multiplayer.MultiPlayerGameMode; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -16,13 +16,18 @@ public class MixinClientPlayerInteractionManager { @Shadow private int destroyDelay; - @Inject(method = "continueDestroyBlock", - at = @At(value = "FIELD", + @Inject( + method = "continueDestroyBlock", + at = @At( + value = "FIELD", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;destroyDelay:I", opcode = Opcodes.PUTFIELD, - ordinal = 2, shift = At.Shift.AFTER)) + ordinal = 2, + shift = At.Shift.AFTER + ) + ) private void removeBreakingCooldown(BlockPos pos, Direction direction, CallbackInfoReturnable cir) { - if (Configs.removeBreakingCooldown && !Configs.forceBreakingCooldown) { + if (Configs.removeBreakingCooldown.getBooleanValue() && !Configs.forceBreakingCooldown.getBooleanValue()) { destroyDelay = 0; } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java index 3c6865d..901b74b 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/MixinJsonUnbakedModel.java @@ -2,7 +2,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockModel; import net.minecraft.client.renderer.block.model.BlockElement; import net.minecraft.client.renderer.block.model.BlockElementFace; @@ -18,9 +18,11 @@ import org.joml.Vector3f; 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.CallbackInfoReturnable; +import top.hendrixshen.magiclib.api.compat.minecraft.resources.ResourceLocationCompat; import top.hendrixshen.magiclib.util.MiscUtil; import java.util.List; @@ -35,7 +37,7 @@ @Mixin(value = BlockModel.class, priority = 999) public abstract class MixinJsonUnbakedModel implements UnbakedModel { - + @Unique private final ThreadLocal ommc$bakeTag = ThreadLocal.withInitial(() -> Boolean.TRUE); @Shadow @@ -47,14 +49,18 @@ public abstract class MixinJsonUnbakedModel implements UnbakedModel { @SuppressWarnings("InvalidInjectorMethodSignature") @Inject( - //#if MC >= 11903 + //#if MC > 12006 + //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Z)Lnet/minecraft/client/resources/model/BakedModel;", + //#elseif MC > 11902 method = "bake(Lnet/minecraft/client/resources/model/ModelBaker;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;", //#elseif MC > 11404 //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;Lnet/minecraft/resources/ResourceLocation;Z)Lnet/minecraft/client/resources/model/BakedModel;", //#else //$$ method = "bake(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/client/renderer/block/model/BlockModel;Ljava/util/function/Function;Lnet/minecraft/client/resources/model/ModelState;)Lnet/minecraft/client/resources/model/BakedModel;", //#endif - at = @At(value = "HEAD"), cancellable = true) + at = @At(value = "HEAD"), + cancellable = true + ) private void generateCustomBakedModel( //#if MC > 11902 ModelBaker baker, @@ -69,10 +75,13 @@ private void generateCustomBakedModel( //#endif ModelState modelSettings, //#if MC > 11404 + //#if MC < 12100 ResourceLocation resourceLocation, + //#endif boolean hasDepth, //#endif - CallbackInfoReturnable cir) { + CallbackInfoReturnable cir + ) { if (!this.ommc$bakeTag.get()) { return; } @@ -84,7 +93,7 @@ private void generateCustomBakedModel( } String[] splitResult = identifier.getPath().split("/"); - ResourceLocation blockId = new ResourceLocation(splitResult[splitResult.length - 1]); + ResourceLocation blockId = ResourceLocationCompat.parse(splitResult[splitResult.length - 1]); //#if MC >= 11903 Block block = BuiltInRegistries.BLOCK.get(blockId); //#else @@ -102,14 +111,18 @@ private void generateCustomBakedModel( originalModelElements.clear(); for (BlockElement modelElement : originalModelElementsBackup) { - Vector3f origin = new Vector3f(0F, 80F, 180F); + Vector3f origin = new Vector3f(0F, 67F, 150F); origin.mul(0.0625F); BlockElementRotation newModelRotation = new BlockElementRotation(origin, Direction.Axis.X, 45, false); Map faces = Maps.newHashMap(); for (Map.Entry entry : modelElement.faces.entrySet()) { BlockElementFace originalModelElementFace = entry.getValue(); + //#if MC > 12006 + //$$ BlockElementFace modelElementFace = new BlockElementFace(null, originalModelElementFace.tintIndex(), originalModelElementFace.texture(), originalModelElementFace.uv()); + //#else BlockElementFace modelElementFace = new BlockElementFace(null, originalModelElementFace.tintIndex, originalModelElementFace.texture, originalModelElementFace.uv); + //#endif faces.put(entry.getKey(), modelElementFace); } @@ -140,13 +153,15 @@ private void generateCustomBakedModel( textureGetter, //#if MC > 11404 modelSettings, + //#if MC <= 12006 identifier, + //#endif hasDepth //#else //$$ modelSettings //#endif ); - WorldEaterMineHelperUtil.customModels.put(block, customBakedModel); + WorldEaterMineHelper.customModels.put(block, customBakedModel); // Full model bake originalModelElements.addAll(originalModelElementsBackup); @@ -156,13 +171,15 @@ private void generateCustomBakedModel( textureGetter, //#if MC > 11404 modelSettings, + //#if MC <= 12006 identifier, + //#endif hasDepth //#else //$$ modelSettings //#endif ); - WorldEaterMineHelperUtil.customFullModels.put(block, customFullBakedModel); + WorldEaterMineHelper.customFullModels.put(block, customFullBakedModel); // Restore model attribute ((AccessorBlockModel) blockModel).setHasAmbientOcclusion(originalAmbientOcclusion); originalModelElements.clear(); @@ -174,7 +191,9 @@ private void generateCustomBakedModel( textureGetter, //#if MC > 11404 modelSettings, + //#if MC <= 12006 identifier, + //#endif hasDepth //#else //$$ modelSettings diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java index c2c69f8..1d5b150 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinBlockRenderContext.java @@ -1,7 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.fabric; -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderContext; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -22,17 +21,14 @@ //#if MC > 11802 import net.minecraft.util.RandomSource; -//#else -//$$ import java.util.Random; -//#endif - -//#if MC > 11802 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#else //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//$$ import java.util.Random; //#endif //#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; //#else //$$ import com.mojang.blaze3d.vertex.BufferBuilder; @@ -91,6 +87,6 @@ private void emitCustomBlockQuads( //#else //$$ CallbackInfoReturnable cir) { //#endif - WorldEaterMineHelperUtil.emitCustomBlockQuads(blockView, state, pos, this.blockInfo.randomSupplier, this); + WorldEaterMineHelper.emitCustomBlockQuads(blockView, state, pos, this.blockInfo.randomSupplier, this); } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java index 8630213..461f852 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/fabric/MixinTerrainRenderContext.java @@ -1,7 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.fabric; -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainRenderContext; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -17,6 +16,12 @@ //$$ import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; //$$ import org.spongepowered.asm.mixin.Final; //$$ import org.spongepowered.asm.mixin.Shadow; +//$$ +//#if MC > 11701 +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; +//#else +//$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; +//#endif //#endif //#if MC > 11802 @@ -26,30 +31,38 @@ //#endif //#if MC > 11701 -import net.fabricmc.fabric.impl.client.indigo.renderer.render.BlockRenderInfo; //#else //$$ import net.fabricmc.fabric.impl.client.indigo.renderer.render.TerrainBlockRenderInfo; //#endif -@Mixin(value = TerrainRenderContext.class, remap = false) -//#if MC > 11903 -public abstract class MixinTerrainRenderContext extends AbstractBlockRenderContext { -//#else -//$$ public abstract class MixinTerrainRenderContext implements RenderContext { -//$$ @Final -//$$ @Shadow -//#if MC > 11701 -//$$ private BlockRenderInfo blockInfo; -//#else -//$$ private TerrainBlockRenderInfo blockInfo; -//#endif +//#if MC > 11404 +import com.mojang.blaze3d.vertex.PoseStack; //#endif +@SuppressWarnings("UnstableApiUsage") +@Mixin(value = TerrainRenderContext.class, remap = false) +public abstract class MixinTerrainRenderContext + //#if MC > 11903 + extends AbstractBlockRenderContext + //#else + //$$ implements RenderContext + //#endif +{ + //#if MC < 11904 + //$$ @Shadow + //$$ @Final + //#if MC > 11701 + //$$ private BlockRenderInfo blockInfo; + //#else + //$$ private TerrainBlockRenderInfo blockInfo; + //#endif + //#endif + @Dynamic @Inject( method = { - "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above - "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below + "tessellateBlock", // For fabric-renderer-indigo 0.5.0 and above + "tesselateBlock" // For fabric-renderer-indigo 0.5.0 below }, at = @At(value = "INVOKE", //#if MC > 11903 @@ -64,9 +77,9 @@ private void emitCustomBlockQuads(BlockState blockState, BlockPos blockPos, Bake //#endif //#if MC > 11802 CallbackInfo ci) { - //#else - //$$ CallbackInfoReturnable cir) { - //#endif - WorldEaterMineHelperUtil.emitCustomBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this); + //#else + //$$ CallbackInfoReturnable cir) { + //#endif + WorldEaterMineHelper.emitCustomBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this); } } \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java deleted file mode 100644 index 5bb45b2..0000000 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/optifine/MixinBlockRenderManager.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.plusls.ommc.mixin.feature.worldEaterMineHelper.optifine; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.worldEaterMineHelper.BlockModelRendererContext; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; -import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; -import net.minecraft.client.resources.model.BakedModel; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.BlockAndTintGetter; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.state.BlockState; -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; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; - - -//#if MC > 11802 -import net.minecraft.util.RandomSource; -//#else -//$$ import java.util.Random; -//#endif - -//#if MC > 11404 -import com.mojang.blaze3d.vertex.VertexConsumer; -//#endif - -// 兼容 opt -@Dependencies(and = @Dependency("optifabric")) -@Mixin(BlockRenderDispatcher.class) -public class MixinBlockRenderManager { - // TODO 开摆 - //#if MC > 11404 - private final ThreadLocal ommcRenderContext = ThreadLocal.withInitial(BlockModelRendererContext::new); - private final ThreadLocal ommcOriginalLuminance = ThreadLocal.withInitial(() -> -1); - - @Inject(method = "renderBreakingTexture", at = @At(value = "HEAD")) - private void initRenderContext0(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, CallbackInfo ci) { - BlockModelRendererContext context = ommcRenderContext.get(); - context.pos = pos; - context.state = state; - } - - @Inject(method = "renderBreakingTexture", at = @At(value = "RETURN")) - private void clearRenderContext0(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, CallbackInfo ci) { - ommcRenderContext.get().clear(); - int originalLuminance = ommcOriginalLuminance.get(); - if (originalLuminance != -1) { - ((AccessorBlockStateBase) state).setLightEmission(originalLuminance); - ommcOriginalLuminance.set(-1); - } - } - - @Inject(method = "renderBatched", at = @At(value = "HEAD")) - private void initRenderContext1(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, boolean cull, - //#if MC > 11802 - RandomSource random, - CallbackInfo ci - //#else - //$$ Random random, - //$$ CallbackInfoReturnable cir - //#endif - ) { - BlockModelRendererContext context = ommcRenderContext.get(); - context.pos = pos; - context.state = state; - } - - @Inject(method = "renderBatched", at = @At(value = "RETURN")) - private void clearRenderContext1(BlockState state, BlockPos pos, BlockAndTintGetter world, PoseStack matrix, - VertexConsumer vertexConsumer, boolean cull, - //#if MC > 11802 - RandomSource random, - CallbackInfo ci - //#else - //$$ Random random, - //$$ CallbackInfoReturnable cir - //#endif - ) { - ommcRenderContext.get().clear(); - int originalLuminance = ommcOriginalLuminance.get(); - if (originalLuminance != -1) { - ((AccessorBlockStateBase) state).setLightEmission(originalLuminance); - ommcOriginalLuminance.set(-1); - } - } - - @Inject(method = "getBlockModel", at = @At(value = "RETURN"), cancellable = true) - private void useCustomModel(BlockState state, CallbackInfoReturnable cir) { - BlockModelRendererContext context = ommcRenderContext.get(); - if (context.pos == null) { - return; - } - Block block = context.state.getBlock(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(state, context.pos)) { - BakedModel model = WorldEaterMineHelperUtil.customFullModels.get(block); - if (model != null) { - ommcOriginalLuminance.set(((AccessorBlockStateBase) state).getLightEmission()); - ((AccessorBlockStateBase) state).setLightEmission(15); - cir.setReturnValue(model); - } - } - } - //#endif -} \ No newline at end of file diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java index 28d6f9b..d407659 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRendererLegacy.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.BlockModelRendererContext; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.BlockModelRendererContext; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.core.BlockPos; @@ -10,60 +10,86 @@ import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Coerce; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.4.9")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.4.9")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer", remap = false) public class MixinBlockRendererLegacy { - private final ThreadLocal ommcRenderContext = ThreadLocal.withInitial(BlockModelRendererContext::new); - private final ThreadLocal ommcOriginalLuminance = ThreadLocal.withInitial(() -> -1); + @Unique + private final ThreadLocal ommc$renderContext = ThreadLocal.withInitial(BlockModelRendererContext::new); + @Unique + private final ThreadLocal ommc$originalLuminance = ThreadLocal.withInitial(() -> -1); @Dynamic @Inject(method = "renderModel", at = @At(value = "HEAD")) - private void initRenderContext(BlockAndTintGetter world, BlockState state, BlockPos pos, - //#if MC > 11605 - BlockPos origin, - //#endif - BakedModel model, @Coerce Object buffers, boolean cull, long seed, CallbackInfoReturnable cir) { - BlockModelRendererContext context = ommcRenderContext.get(); + private void initRenderContext( + BlockAndTintGetter world, + BlockState state, + BlockPos pos, + //#if MC > 11605 + BlockPos origin, + //#endif + BakedModel model, + @Coerce Object buffers, + boolean cull, + long seed, + CallbackInfoReturnable cir + ) { + BlockModelRendererContext context = this.ommc$renderContext.get(); context.pos = pos; context.state = state; } @Dynamic - @ModifyVariable(method = "renderModel", at = @At(value = "HEAD"), ordinal = 0) + @ModifyVariable( + method = "renderModel", + at = @At("HEAD"), + ordinal = 0 + ) private BakedModel modifyBakedModel(BakedModel bakedModel) { - BlockModelRendererContext context = ommcRenderContext.get(); - if (WorldEaterMineHelperUtil.shouldUseCustomModel(context.state, context.pos)) { - BakedModel customModel = WorldEaterMineHelperUtil.customFullModels.get(context.state.getBlock()); + BlockModelRendererContext context = this.ommc$renderContext.get(); + + if (WorldEaterMineHelper.shouldUseCustomModel(context.state, context.pos)) { + BakedModel customModel = WorldEaterMineHelper.customFullModels.get(context.state.getBlock()); + if (customModel != null) { - ommcOriginalLuminance.set(((AccessorBlockStateBase) context.state).getLightEmission()); + this.ommc$originalLuminance.set(((AccessorBlockStateBase) context.state).getLightEmission()); ((AccessorBlockStateBase) context.state).setLightEmission(15); return customModel; } } + return bakedModel; } @Dynamic - @Inject(method = "renderModel", at = @At(value = "RETURN")) - private void postRenderModel(BlockAndTintGetter world, BlockState state, BlockPos pos, - //#if MC > 11605 - BlockPos origin, - //#endif - BakedModel model, @Coerce Object buffers, boolean cull, - long seed, CallbackInfoReturnable cir) { - int originalLuminance = ommcOriginalLuminance.get(); + @Inject(method = "renderModel", at = @At("RETURN")) + private void postRenderModel( + BlockAndTintGetter world, + BlockState state, + BlockPos pos, + //#if MC > 11605 + BlockPos origin, + //#endif + BakedModel model, + @Coerce Object buffers, + boolean cull, + long seed, + CallbackInfoReturnable cir + ) { + int originalLuminance = ommc$originalLuminance.get(); + if (originalLuminance != -1) { ((AccessorBlockStateBase) state).setLightEmission(originalLuminance); - ommcOriginalLuminance.set(-1); + ommc$originalLuminance.set(-1); } } } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index f9c263d..5e1977a 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -1,12 +1,8 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; - -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.10 <0.5")) @Mixin(DummyClass.class) public class MixinBlockRenderer_0_4_11 { } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java index 5140957..eff6116 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockRenderContext; import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; @@ -10,8 +10,8 @@ import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.*; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; //#if MC == 11904 //$$ import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; @@ -19,7 +19,7 @@ //$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; //#endif -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.8 <0.4.11")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.4.9- <0.4.11-")) @Mixin(value = BlockRenderer.class, remap = false) public abstract class MixinBlockRenderer_0_4_9 { @Shadow(remap = false) @@ -29,20 +29,14 @@ public abstract class MixinBlockRenderer_0_4_9 { private final ThreadLocal ommc$renderTag = ThreadLocal.withInitial(() -> false); @Dynamic - @Inject( - method = "renderModel", - at = @At( - value = "RETURN" - ) - ) - private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkModelBuilder buffers, CallbackInfoReturnable cir - ) { - if (WorldEaterMineHelperUtil.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { - BakedModel customModel = WorldEaterMineHelperUtil.customModels.get(ctx.state().getBlock()); + @Inject(method = "renderModel", at = @At("RETURN")) + private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkModelBuilder buffers, CallbackInfoReturnable cir) { + if (WorldEaterMineHelper.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(ctx.state().getBlock()); if (customModel != null) { this.ommc$renderTag.set(true); - // This impl will break light system, so disable it. + // This impl will break light systems, so disable it. // int originalLightEmission = ctx.state().getLightEmission(); BakedModel originalModel = ctx.model(); // ((AccessorBlockStateBase) ctx.state()).setLightEmission(15); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java index b3b3b0c..70bfa05 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockRenderContext; import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; @@ -14,14 +14,14 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; @Dependencies( - and = { - @Dependency(value = "minecraft", versionPredicate = ">1.19.4"), + require = { + @Dependency(value = "minecraft", versionPredicates = ">1.19.4"), // TODO: Once sodium 0.5+ backport to MC 1.19.4 and below, we can compat it. - @Dependency(value = "sodium", versionPredicate = "~0.5") + @Dependency(value = "sodium", versionPredicates = ">=0.5- <0.6-") } ) @Mixin(value = BlockRenderer.class, remap = false) @@ -33,19 +33,14 @@ public abstract class MixinBlockRenderer_0_5 { private final ThreadLocal ommc$renderTag = ThreadLocal.withInitial(() -> false); @Dynamic - @Inject( - method = "renderModel", - at = @At( - value = "RETURN" - ) - ) + @Inject(method = "renderModel", at = @At("RETURN")) private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkBuildBuffers buffers, CallbackInfo ci) { - if (WorldEaterMineHelperUtil.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { - BakedModel customModel = WorldEaterMineHelperUtil.customModels.get(ctx.state().getBlock()); + if (WorldEaterMineHelper.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(ctx.state().getBlock()); if (customModel != null) { this.ommc$renderTag.set(true); - // This impl will break light system, so disable it. + // This impl will break light systems, so disable it. // int originalLightEmission = ctx.state().getLightEmission(); BakedModel originalModel = ctx.model(); // ((AccessorBlockStateBase) ctx.state()).setLightEmission(15); diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java new file mode 100644 index 0000000..e2cf287 --- /dev/null +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_6.java @@ -0,0 +1,42 @@ +package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; + +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; +import com.plusls.ommc.mixin.accessor.AccessorBlockStateBase; +import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderer; +import net.minecraft.client.resources.model.BakedModel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.block.state.BlockState; +import org.spongepowered.asm.mixin.*; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; + +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">=0.6- <0.7-")) +@Pseudo +@Mixin(value = BlockRenderer.class, remap = false) +public abstract class MixinBlockRenderer_0_6 { + @Shadow(remap = false) + public abstract void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin); + + @Unique + private final ThreadLocal ommc$renderTag = ThreadLocal.withInitial(() -> false); + + @Dynamic + @Inject(method = "renderModel", at = @At("RETURN")) + private void postRenderModel(BakedModel model, BlockState state, BlockPos pos, BlockPos origin, CallbackInfo ci) { + if (WorldEaterMineHelper.shouldUseCustomModel(state, pos) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(state.getBlock()); + + if (customModel != null) { + this.ommc$renderTag.set(true); + int originalLightEmission = state.getLightEmission(); + ((AccessorBlockStateBase) state).setLightEmission(15); + this.renderModel(customModel, state, pos, origin); + ((AccessorBlockStateBase) state).setLightEmission(originalLightEmission); + this.ommc$renderTag.set(false); + } + } + } +} diff --git a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java index 39896df..e5eea0d 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java +++ b/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinTerrainRenderContext.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import net.fabricmc.fabric.api.renderer.v1.model.FabricBakedModel; import net.fabricmc.fabric.api.renderer.v1.render.RenderContext; import net.minecraft.core.BlockPos; @@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; import top.hendrixshen.magiclib.util.MiscUtil; import java.util.function.Supplier; @@ -24,25 +24,33 @@ //#endif // TODO -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = "<0.0.0")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = "<0.0.0")) @Pseudo @Mixin(targets = "me.jellysquid.mods.sodium.render.renderer.TerrainRenderContext", remap = false) public class MixinTerrainRenderContext { @Dynamic - @Redirect(method = "renderBlock", at = @At(value = "INVOKE", - target = "Lnet/fabricmc/fabric/api/renderer/v1/model/FabricBakedModel;emitBlockQuads(Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Ljava/util/function/Supplier;Lnet/fabricmc/fabric/api/renderer/v1/render/RenderContext;)V", - ordinal = 0, - remap = true)) - private void emitCustomBlockQuads(FabricBakedModel model, BlockAndTintGetter blockView, BlockState state, BlockPos pos, - //#if MC > 11802 - Supplier randomSupplier, - //#else - //$$ Supplier randomSupplier, - //#endif - RenderContext context) { + @Redirect( + method = "renderBlock", + at = @At( + value = "INVOKE", + target = "Lnet/fabricmc/fabric/api/renderer/v1/model/FabricBakedModel;emitBlockQuads(Lnet/minecraft/world/level/BlockAndTintGetter;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Ljava/util/function/Supplier;Lnet/fabricmc/fabric/api/renderer/v1/render/RenderContext;)V", + ordinal = 0, + remap = true + ) + ) + private void emitCustomBlockQuads( + FabricBakedModel model, + BlockAndTintGetter blockView, + BlockState state, + BlockPos pos, + //#if MC > 11802 + Supplier randomSupplier, + //#else + //$$ Supplier randomSupplier, + //#endif + RenderContext context + ) { model.emitBlockQuads(blockView, state, pos, randomSupplier, context); - WorldEaterMineHelperUtil.emitCustomBlockQuads(blockView, state, pos, MiscUtil.cast(randomSupplier), context); + WorldEaterMineHelper.emitCustomBlockQuads(blockView, state, pos, MiscUtil.cast(randomSupplier), context); } - - } diff --git a/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java b/src/main/java/com/plusls/ommc/mixin/generic/dontClearChatHistory/MixinChatHud.java similarity index 56% rename from src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java rename to src/main/java/com/plusls/ommc/mixin/generic/dontClearChatHistory/MixinChatHud.java index 6a14438..bc33337 100644 --- a/src/main/java/com/plusls/ommc/mixin/feature/dontClearChatHistory/MixinChatHud.java +++ b/src/main/java/com/plusls/ommc/mixin/generic/dontClearChatHistory/MixinChatHud.java @@ -1,16 +1,18 @@ -package com.plusls.ommc.mixin.feature.dontClearChatHistory; +package com.plusls.ommc.mixin.generic.dontClearChatHistory; -import com.plusls.ommc.config.Configs; -//#if MC <= 11802 -//$$ import net.minecraft.client.GuiMessage; -//#endif +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.plusls.ommc.game.Configs; import net.minecraft.client.gui.components.ChatComponent; 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//#if MC <= 11802 +//$$ import net.minecraft.client.GuiMessage; +//#endif + //#if MC > 11502 import net.minecraft.util.FormattedCharSequence; //#else @@ -22,16 +24,25 @@ // From https://www.curseforge.com/minecraft/mc-mods/dont-clear-chat-history @Mixin(ChatComponent.class) public class MixinChatHud { - @Inject(method = "clearMessages", at = @At(value = "INVOKE", target = "Ljava/util/List;clear()V", ordinal = 2), cancellable = true) + @Inject( + method = "clearMessages", + at = @At( + value = "INVOKE", + target = "Ljava/util/List;clear()V", + ordinal = 2 + ), cancellable = true + ) private void dontClearChatHistory(boolean clearHistory, CallbackInfo ci) { - if (Configs.dontClearChatHistory) { + if (Configs.dontClearChatHistory.getBooleanValue()) { ci.cancel(); } } - @Redirect( - //#if MC > 11802 + @WrapOperation( + //#if MC > 11802 && MC < 12005 method = "addMessage(Lnet/minecraft/network/chat/Component;Lnet/minecraft/network/chat/MessageSignature;ILnet/minecraft/client/GuiMessageTag;Z)V", + //#elseif MC >= 12005 + //$$ method = "addMessageToDisplayQueue", //#else //$$ method = "addMessage(Lnet/minecraft/network/chat/Component;IIZ)V", //#endif @@ -45,16 +56,20 @@ private void dontClearChatHistory(boolean clearHistory, CallbackInfo ci) { //#endif ) ) - //#if MC > 11802 - private int modifySize(List list) { - //#elseif MC > 11502 - //$$ private int modifySize(List> list) { - //#else - //$$ private int modifySize(List list) { - //#endif - if (Configs.dontClearChatHistory) { + private int modifySize( + //#if MC > 11802 + List list, + //#elseif MC > 11502 + //$$ List> list, + //#else + //$$ List list, + //#endif + Operation original + ) { + if (Configs.dontClearChatHistory.getBooleanValue()) { return 1; } - return list.size(); + + return original.call(list); } } diff --git a/src/main/java/com/plusls/ommc/util/CompatGetUtil.java b/src/main/java/com/plusls/ommc/util/CompatGetUtil.java new file mode 100644 index 0000000..8fd23a5 --- /dev/null +++ b/src/main/java/com/plusls/ommc/util/CompatGetUtil.java @@ -0,0 +1,41 @@ +package com.plusls.ommc.util; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.jetbrains.annotations.NotNull; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.EntityCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.entity.LivingEntityCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.level.LevelCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.inventory.SlotCompat; +import top.hendrixshen.magiclib.api.compat.minecraft.world.item.ItemStackCompat; +import top.hendrixshen.magiclib.util.MiscUtil; + +public class CompatGetUtil { + public static LivingEntityCompat getLivingEntityCompat(@NotNull Object obj) { + LivingEntity thisObj = MiscUtil.cast(obj); + return LivingEntityCompat.of(thisObj); + } + + + public static EntityCompat getEntityCompat(@NotNull Object obj) { + Entity thisObj = MiscUtil.cast(obj); + return EntityCompat.of(thisObj); + } + + public static LevelCompat getLevelCompat(@NotNull Object obj) { + Level thisObj = MiscUtil.cast(obj); + return LevelCompat.of(thisObj); + } + + public static SlotCompat getSlotCompat(@NotNull Object obj) { + Slot thisObj = MiscUtil.cast(obj); + return SlotCompat.of(thisObj); + } + + public static ItemStackCompat getItemStackCompat(@NotNull Object obj) { + ItemStack thisObj = MiscUtil.cast(obj); + return ItemStackCompat.of(thisObj); + } +} diff --git a/src/main/java/com/plusls/ommc/util/InventoryUtil.java b/src/main/java/com/plusls/ommc/util/InventoryUtil.java new file mode 100644 index 0000000..1eff56b --- /dev/null +++ b/src/main/java/com/plusls/ommc/util/InventoryUtil.java @@ -0,0 +1,26 @@ +package com.plusls.ommc.util; + +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.item.ItemStack; +import org.jetbrains.annotations.NotNull; + +//#if MC > 12006 +//$$ import net.minecraft.world.item.Equipable; +//#elseif MC > 11605 +import net.minecraft.world.entity.LivingEntity; +//#else +//$$ import net.minecraft.world.entity.Mob; +//#endif + +public class InventoryUtil { + public static @NotNull EquipmentSlot getEquipmentSlotForItem(ItemStack itemStack) { + //#if MC > 12006 + //$$ Equipable equipable = Equipable.get(itemStack); + //$$ return equipable != null ? equipable.getEquipmentSlot() : EquipmentSlot.MAINHAND; + //#elseif MC > 11605 + return LivingEntity.getEquipmentSlotForItem(itemStack); + //#else + //$$ return Mob.getEquipmentSlotForItem(itemStack); + //#endif + } +} diff --git a/src/main/java/com/plusls/ommc/util/Tuple.java b/src/main/java/com/plusls/ommc/util/Tuple.java deleted file mode 100644 index c128300..0000000 --- a/src/main/java/com/plusls/ommc/util/Tuple.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.plusls.ommc.util; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; -import org.jetbrains.annotations.Nullable; - -@Getter -@Setter -@AllArgsConstructor -public class Tuple { - @Nullable - private A a; - @Nullable - private B b; -} diff --git a/src/main/resources/assets/ommc/lang/en_us.json b/src/main/resources/assets/ommc/lang/en_us.json index 4948ae7..767fbde 100644 --- a/src/main/resources/assets/ommc/lang/en_us.json +++ b/src/main/resources/assets/ommc/lang/en_us.json @@ -1,95 +1,88 @@ { "ommc.gui.title.configs": "Oh My Minecraft Client - Config - Version: %s", - "ommc.gui.button.tab.generic": "Generic", - "ommc.gui.button.tab.feature_toggle": "Feature Toggles", - "ommc.gui.button.tab.lists": "Lists", - "ommc.gui.button.tab.advanced_integrated_server": "Advanced Integrated Server", - "ommc.gui.label.sort_inventory_shulker_box_last_type.false": "FALSE", - "ommc.gui.label.sort_inventory_shulker_box_last_type.true": "TRUE", - "ommc.gui.label.sort_inventory_shulker_box_last_type.auto": "AUTO", - "ommc.config.generic.openConfigGui.name": "openConfigGui", - "ommc.config.generic.openConfigGui.comment": "A hotkey to open the in-game Config GUI", - "ommc.config.generic.debug.name": "debug", - "ommc.config.generic.debug.comment": "Display debug message", - "ommc.config.generic.dontClearChatHistory.name": "dontClearChatHistory", - "ommc.config.generic.dontClearChatHistory.comment": "Don't clear chat history and input history.", - "ommc.config.generic.clearWaypoint.name": "clearWaypoint", - "ommc.config.generic.clearWaypoint.comment": "A hotkey to clear highlight waypoint.", - "ommc.config.generic.forceParseWaypointFromChat.name": "forceParseWaypointFromChat", - "ommc.config.generic.forceParseWaypointFromChat.comment": "Force parse waypoint from chat (such it will override the clickevent of rtext).", - "ommc.config.generic.highlightBeamTime.name": "highlightBeamTime", - "ommc.config.generic.highlightBeamTime.comment": "Highlighted waypoint beam display time.", - "ommc.config.generic.parseWaypointFromChat.name": "parseWaypointFromChat", - "ommc.config.generic.parseWaypointFromChat.comment": "Parse waypoint from chat.", - "ommc.config.generic.sendLookingAtBlockPos.name": "sendLookingAtPos", - "ommc.config.generic.sendLookingAtBlockPos.comment": "A hotkey to send looking at pos.", - "ommc.config.generic.sortInventory.name": "sortInventory", - "ommc.config.generic.sortInventory.comment": "A hotkey to sort inventory.", - "ommc.config.generic.sortInventoryShulkerBoxLast.name": "sortInventoryShulkerBoxLast", - "ommc.config.generic.sortInventoryShulkerBoxLast.comment": "Sort inventory shulker box last.", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.name": "sortInventorySupportEmptyShulkerBoxStack", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.comment": "Support empty shulker box stack when sort inventory.", - "ommc.config.feature_toggle.autoSwitchElytra.name": "autoSwitchElytra", - "ommc.config.feature_toggle.autoSwitchElytra.comment": "Auto switch elytra and chestplate.", - "ommc.config.feature_toggle.betterSneaking.name": "betterSneaking", - "ommc.config.feature_toggle.betterSneaking.comment": "Player can move down 1 height when sneaking.", - "ommc.config.feature_toggle.disableBlocklistCheck.name": "disableBlocklistCheck", - "ommc.config.feature_toggle.disableBlocklistCheck.comment": "Workaround for MC-218167, prevent network request from blocking the Render Thread.", - "ommc.config.feature_toggle.disableBreakBlock.name": "disableBreakBlock", - "ommc.config.feature_toggle.disableBreakBlock.comment": "You can't break blocks in §6breakBlockBlackList§r.", - "ommc.config.feature_toggle.disableBreakScaffolding.name": "disableBreakScaffolding", - "ommc.config.feature_toggle.disableBreakScaffolding.comment": "You can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.name": "disableMoveDownInScaffolding", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.comment": "You can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", - "ommc.config.feature_toggle.disablePistonPushEntity.name": "disablePistonPushEntity", - "ommc.config.feature_toggle.disablePistonPushEntity.comment": "Prevent piston push entities (except the player) to reduce piston lag (such as the carpet duper), it will cause entities pos error when entity push by piston.", - "ommc.config.feature_toggle.flatDigger.name": "flatDigger", - "ommc.config.feature_toggle.flatDigger.comment": "Which allowed you mine a flat road while digging stone by preventing digging of blocks under your feet while standing,sneak to dig blocks under you.", - "ommc.config.feature_toggle.forceBreakingCooldown.name": "forceBreakingCooldown", - "ommc.config.feature_toggle.forceBreakingCooldown.comment": "You will have 5gt cooldown after instant breaking.", - "ommc.config.feature_toggle.highlightPersistentMob.name": "highlightPersistentMob", - "ommc.config.feature_toggle.highlightPersistentMob.comment": "Highlight persistent mobs (Mob have item in hand or mob have custom name).", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.name": "highlightPersistentMobClientMode", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.comment": "Use client data to check persistent mob, such as hand item, custom name. Tips: in local game should disable this option, in server also can use syncAllEntityData in MasaGadget to sync entity data to local.", - "ommc.config.feature_toggle.highlightLavaSource.name": "highlightLavaSource", - "ommc.config.feature_toggle.highlightLavaSource.comment": "Highlight lava sources.", - "ommc.config.feature_toggle.preventIntentionalGameDesign.name": "preventIntentionalGameDesign", - "ommc.config.feature_toggle.preventIntentionalGameDesign.comment": "Prevent Intentional Game Design (Bed and Respawn Anchor).", - "ommc.config.feature_toggle.preventWastageOfWater.name": "preventWastageOfWater", - "ommc.config.feature_toggle.preventWastageOfWater.comment": "Prevent water bucket from vanishing in nether.", - "ommc.config.feature_toggle.worldEaterMineHelper.name": "worldEaterMineHelper", - "ommc.config.feature_toggle.worldEaterMineHelper.comment": "When the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", - "ommc.config.feature_toggle.realSneaking.name": "realSneaking", - "ommc.config.feature_toggle.realSneaking.comment": "You cannot ascend or descend non-full blocks when sneaking, e.g. carpets.", - "ommc.config.feature_toggle.removeBreakingCooldown.name": "removeBreakingCooldown", - "ommc.config.feature_toggle.removeBreakingCooldown.comment": "Remove cooldown after break block (default is 5gt), it will not work when enable §6forceBreakingCooldown§r.", - "ommc.config.lists.blockModelNoOffsetBlacklist.name": "blockModelNoOffsetBlacklist", - "ommc.config.lists.blockModelNoOffsetBlacklist.comment": "blockModelNoOffsetBlacklist", - "ommc.config.lists.blockModelNoOffsetListType.name": "blockModelNoOffsetListType", - "ommc.config.lists.blockModelNoOffsetListType.comment": "blockModelNoOffsetListType", - "ommc.config.lists.blockModelNoOffsetWhitelist.name": "blockModelNoOffsetWhitelist", - "ommc.config.lists.blockModelNoOffsetWhitelist.comment": "blockModelNoOffsetWhitelist", - "ommc.config.lists.highlightEntityBlackList.name": "highlightEntityBlackList", - "ommc.config.lists.highlightEntityBlackList.comment": "highlightEntityBlackList", - "ommc.config.lists.highlightEntityListType.name": "highlightEntityListType", - "ommc.config.lists.highlightEntityListType.comment": "highlightEntityListType", - "ommc.config.lists.highlightEntityWhiteList.name": "highlightEntityWhiteList", - "ommc.config.lists.highlightEntityWhiteList.comment": "highlightEntityWhiteList", - "ommc.config.lists.breakBlockBlackList.name": "breakBlockBlackList", - "ommc.config.lists.breakBlockBlackList.comment": "If §6disableBreakScaffolding§r is enabled, you can't break blocks in §6breakBlockBlackList§r.", - "ommc.config.lists.breakScaffoldingWhiteList.name": "breakScaffoldingWhiteList", - "ommc.config.lists.breakScaffoldingWhiteList.comment": "If §6disableBreakScaffolding§r is enabled, you can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", - "ommc.config.lists.moveDownInScaffoldingWhiteList.name": "moveDownInScaffoldingWhiteList", - "ommc.config.lists.moveDownInScaffoldingWhiteList.comment": "If §6disableMoveDownInScaffolding§r is enabled, you can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", - "ommc.config.lists.worldEaterMineHelperWhitelist.name": "worldEaterMineHelperWhitelist", - "ommc.config.lists.worldEaterMineHelperWhitelist.comment": "If §6worldEaterMineHelper§r is enabled, when the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", - "ommc.config.advanced_integrated_server.onlineMode.name": "onlineMode", - "ommc.config.advanced_integrated_server.onlineMode.comment": "Integrated server use online mode.", - "ommc.config.advanced_integrated_server.pvp.name": "pvp", - "ommc.config.advanced_integrated_server.pvp.comment": "Integrated server enable pvp.", - "ommc.config.advanced_integrated_server.flight.name": "flight", - "ommc.config.advanced_integrated_server.flight.comment": "Integrated server enable flight.", - "ommc.config.advanced_integrated_server.port.name": "port", - "ommc.config.advanced_integrated_server.port.comment": "Integrated server lan port, 0 to use default port.", + "ommc.config.category.all.name": "All", + "ommc.config.category.generic.name": "Generic", + "ommc.config.category.feature.name": "Feature", + "ommc.config.category.list.name": "List", + + "ommc.config.option.sortInventoryShulkerBoxLast.auto": "Auto", + "ommc.config.option.sortInventoryShulkerBoxLast.disable": "Disable", + "ommc.config.option.sortInventoryShulkerBoxLast.enable": "Enable", + "ommc.config.option.openConfigGui.name": "openConfigGui", + "ommc.config.option.openConfigGui.comment": "A hotkey to open the in-game Config GUI", + "ommc.config.option.debug.name": "debug", + "ommc.config.option.debug.comment": "Display debug message", + "ommc.config.option.dontClearChatHistory.name": "dontClearChatHistory", + "ommc.config.option.dontClearChatHistory.comment": "Don't clear chat history and input history.", + "ommc.config.option.clearWaypoint.name": "clearWaypoint", + "ommc.config.option.clearWaypoint.comment": "A hotkey to clear highlight waypoint.", + "ommc.config.option.forceParseWaypointFromChat.name": "forceParseWaypointFromChat", + "ommc.config.option.forceParseWaypointFromChat.comment": "Force parse waypoint from chat (such it will override the clickevent of rtext).", + "ommc.config.option.highlightBeamTime.name": "highlightBeamTime", + "ommc.config.option.highlightBeamTime.comment": "Highlighted waypoint beam display time.", + "ommc.config.option.parseWaypointFromChat.name": "parseWaypointFromChat", + "ommc.config.option.parseWaypointFromChat.comment": "Parse waypoint from chat.", + "ommc.config.option.sendLookingAtBlockPos.name": "sendLookingAtPos", + "ommc.config.option.sendLookingAtBlockPos.comment": "A hotkey to send looking at pos.", + "ommc.config.option.sortInventory.name": "sortInventory", + "ommc.config.option.sortInventory.comment": "A hotkey to sort inventory.", + "ommc.config.option.sortInventoryShulkerBoxLast.name": "sortInventoryShulkerBoxLast", + "ommc.config.option.sortInventoryShulkerBoxLast.comment": "Sort inventory shulker box last.", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.name": "sortInventorySupportEmptyShulkerBoxStack", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.comment": "Support empty shulker box stack when sort inventory.", + "ommc.config.option.autoSwitchElytra.name": "autoSwitchElytra", + "ommc.config.option.autoSwitchElytra.comment": "Auto switch elytra and chestplate.", + "ommc.config.option.betterSneaking.name": "betterSneaking", + "ommc.config.option.betterSneaking.comment": "Player can move down 1 height when sneaking.", + "ommc.config.option.disableBlocklistCheck.name": "disableBlocklistCheck", + "ommc.config.option.disableBlocklistCheck.comment": "Workaround for MC-218167, prevent network request from blocking the Render Thread.", + "ommc.config.option.disableBreakBlock.name": "disableBreakBlock", + "ommc.config.option.disableBreakBlock.comment": "You can't break blocks in §6breakBlockBlackList§r.", + "ommc.config.option.disableBreakScaffolding.name": "disableBreakScaffolding", + "ommc.config.option.disableBreakScaffolding.comment": "You can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", + "ommc.config.option.disableMoveDownInScaffolding.name": "disableMoveDownInScaffolding", + "ommc.config.option.disableMoveDownInScaffolding.comment": "You can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", + "ommc.config.option.disablePistonPushEntity.name": "disablePistonPushEntity", + "ommc.config.option.disablePistonPushEntity.comment": "Prevent piston push entities (except the player) to reduce piston lag (such as the carpet duper), it will cause entities pos error when entity push by piston.", + "ommc.config.option.flatDigger.name": "flatDigger", + "ommc.config.option.flatDigger.comment": "Which allowed you mine a flat road while digging stone by preventing digging of blocks under your feet while standing,sneak to dig blocks under you.", + "ommc.config.option.forceBreakingCooldown.name": "forceBreakingCooldown", + "ommc.config.option.forceBreakingCooldown.comment": "You will have 5gt cooldown after instant breaking.", + "ommc.config.option.highlightPersistentMob.name": "highlightPersistentMob", + "ommc.config.option.highlightPersistentMob.comment": "Highlight persistent mobs (Mob have item in hand or mob have custom name).", + "ommc.config.option.highlightPersistentMobClientMode.name": "highlightPersistentMobClientMode", + "ommc.config.option.highlightPersistentMobClientMode.comment": "Use client data to check persistent mob, such as hand item, custom name. Tips: in local game should disable this option, in server also can use syncAllEntityData in MasaGadget to sync entity data to local.", + "ommc.config.option.highlightLavaSource.name": "highlightLavaSource", + "ommc.config.option.highlightLavaSource.comment": "Highlight lava sources.", + "ommc.config.option.preventIntentionalGameDesign.name": "preventIntentionalGameDesign", + "ommc.config.option.preventIntentionalGameDesign.comment": "Prevent Intentional Game Design (Bed and Respawn Anchor).", + "ommc.config.option.preventWastageOfWater.name": "preventWastageOfWater", + "ommc.config.option.preventWastageOfWater.comment": "Prevent water bucket from vanishing in nether.", + "ommc.config.option.worldEaterMineHelper.name": "worldEaterMineHelper", + "ommc.config.option.worldEaterMineHelper.comment": "When the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", + "ommc.config.option.realSneaking.name": "realSneaking", + "ommc.config.option.realSneaking.comment": "You cannot ascend or descend non-full blocks when sneaking, e.g. carpets.", + "ommc.config.option.removeBreakingCooldown.name": "removeBreakingCooldown", + "ommc.config.option.removeBreakingCooldown.comment": "Remove cooldown after break block (default is 5gt), it will not work when enable §6forceBreakingCooldown§r.", + "ommc.config.option.blockModelNoOffsetBlacklist.name": "blockModelNoOffsetBlacklist", + "ommc.config.option.blockModelNoOffsetBlacklist.comment": "blockModelNoOffsetBlacklist", + "ommc.config.option.blockModelNoOffsetListType.name": "blockModelNoOffsetListType", + "ommc.config.option.blockModelNoOffsetListType.comment": "blockModelNoOffsetListType", + "ommc.config.option.blockModelNoOffsetWhitelist.name": "blockModelNoOffsetWhitelist", + "ommc.config.option.blockModelNoOffsetWhitelist.comment": "blockModelNoOffsetWhitelist", + "ommc.config.option.highlightEntityBlackList.name": "highlightEntityBlackList", + "ommc.config.option.highlightEntityBlackList.comment": "highlightEntityBlackList", + "ommc.config.option.highlightEntityListType.name": "highlightEntityListType", + "ommc.config.option.highlightEntityListType.comment": "highlightEntityListType", + "ommc.config.option.highlightEntityWhiteList.name": "highlightEntityWhiteList", + "ommc.config.option.highlightEntityWhiteList.comment": "highlightEntityWhiteList", + "ommc.config.option.breakBlockBlackList.name": "breakBlockBlackList", + "ommc.config.option.breakBlockBlackList.comment": "If §6disableBreakScaffolding§r is enabled, you can't break blocks in §6breakBlockBlackList§r.", + "ommc.config.option.breakScaffoldingWhiteList.name": "breakScaffoldingWhiteList", + "ommc.config.option.breakScaffoldingWhiteList.comment": "If §6disableBreakScaffolding§r is enabled, you can only break scaffolding with the items in §6breakScaffoldingWhiteList§r.", + "ommc.config.option.moveDownInScaffoldingWhiteList.name": "moveDownInScaffoldingWhiteList", + "ommc.config.option.moveDownInScaffoldingWhiteList.comment": "If §6disableMoveDownInScaffolding§r is enabled, you can only move down scaffolding with the items inside §6moveDownInScaffoldingWhiteList§r in your hand.", + "ommc.config.option.worldEaterMineHelperWhitelist.name": "worldEaterMineHelperWhitelist", + "ommc.config.option.worldEaterMineHelperWhitelist.comment": "If §6worldEaterMineHelper§r is enabled, when the blocks in §6worldEaterMineHelperWhitelist§r are exposed to the air, the game will render a mirror image above them, which is convenient for world eater maintenance and mining.", "ommc.highlight_waypoint.tooltip": "Click to highlight waypoint. Click again to display the beam." } diff --git a/src/main/resources/assets/ommc/lang/zh_cn.json b/src/main/resources/assets/ommc/lang/zh_cn.json index 72cd4a8..91b5da5 100644 --- a/src/main/resources/assets/ommc/lang/zh_cn.json +++ b/src/main/resources/assets/ommc/lang/zh_cn.json @@ -1,95 +1,88 @@ { "ommc.gui.title.configs": "Oh My Minecraft Client 设置 - 版本: %s", - "ommc.gui.button.tab.generic": "通用", - "ommc.gui.button.tab.feature_toggle": "特性开关", - "ommc.gui.button.tab.lists": "列表", - "ommc.gui.button.tab.advanced_integrated_server": "本地服务器设置", - "ommc.gui.label.sort_inventory_shulker_box_last_type.false": "关闭", - "ommc.gui.label.sort_inventory_shulker_box_last_type.true": "开启", - "ommc.gui.label.sort_inventory_shulker_box_last_type.auto": "自动", - "ommc.config.generic.openConfigGui.name": "打开设置界面", - "ommc.config.generic.openConfigGui.comment": "打开设置界面的快捷键", - "ommc.config.generic.debug.name": "调试模式", - "ommc.config.generic.debug.comment": "开启后将会打印调试日志", - "ommc.config.generic.dontClearChatHistory.name": "不清空聊天历史记录", - "ommc.config.generic.dontClearChatHistory.comment": "不清空聊天历史记录,以及输入的历史记录", - "ommc.config.generic.clearWaypoint.name": "取消高亮坐标点", - "ommc.config.generic.clearWaypoint.comment": "取消高亮坐标点的快捷键", - "ommc.config.generic.forceParseWaypointFromChat.name": "强制从聊天中解析路径点", - "ommc.config.generic.forceParseWaypointFromChat.comment": "强制从聊天中解析路径点,就算该信息中存在 click event 也会将其覆盖", - "ommc.config.generic.highlightBeamTime.name": "高亮光柱时间", - "ommc.config.generic.highlightBeamTime.comment": "高亮坐标点光束展示时间.", - "ommc.config.generic.parseWaypointFromChat.name": "从聊天中解析路径点", - "ommc.config.generic.parseWaypointFromChat.comment": "从聊天中解析路径点", - "ommc.config.generic.sendLookingAtBlockPos.name": "发送当前注视的方块的坐标", - "ommc.config.generic.sendLookingAtBlockPos.comment": "发送当前注视的方块的坐标", - "ommc.config.generic.sortInventory.name": "整理仓库", - "ommc.config.generic.sortInventory.comment": "整理仓库的快捷键", - "ommc.config.generic.sortInventoryShulkerBoxLast.name": "整理仓库时潜影盒放在最后", - "ommc.config.generic.sortInventoryShulkerBoxLast.comment": "整理仓库时潜影盒放在最后", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.name": "整理仓库时支持空潜影盒堆叠", - "ommc.config.generic.sortInventorySupportEmptyShulkerBoxStack.comment": "整理仓库时支持空潜影盒堆叠(请配合 PCA 使用)", - "ommc.config.feature_toggle.autoSwitchElytra.name": "自动切换鞘翅", - "ommc.config.feature_toggle.autoSwitchElytra.comment": "自动切换鞘翅和胸甲", - "ommc.config.feature_toggle.betterSneaking.name": "更好的潜行", - "ommc.config.feature_toggle.betterSneaking.comment": "在潜行时玩家可以向下移动 1 格高", - "ommc.config.feature_toggle.disableBlocklistCheck.name": "关闭玩家黑名单检查", - "ommc.config.feature_toggle.disableBlocklistCheck.comment": "避免 MC-218167,避免网络请求阻塞主线程", - "ommc.config.feature_toggle.disableBreakBlock.name": "禁止破坏特定方块", - "ommc.config.feature_toggle.disableBreakBlock.comment": "玩家无法破坏在 §6破坏方块黑名单§r 中的方块", - "ommc.config.feature_toggle.disableBreakScaffolding.name": "禁止破坏脚手架", - "ommc.config.feature_toggle.disableBreakScaffolding.comment": "玩家只有在手持 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.name": "禁止在脚手架中下降", - "ommc.config.feature_toggle.disableMoveDownInScaffolding.comment": "玩家只有在手持 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", - "ommc.config.feature_toggle.disablePistonPushEntity.name": "禁止活塞推动实体", - "ommc.config.feature_toggle.disablePistonPushEntity.comment": "通过阻止客户端活塞推动实体(玩家除外)来减少活塞卡顿(比如地毯复制机),会导致一些实体位置渲染错误", - "ommc.config.feature_toggle.flatDigger.name": "平坦挖掘", - "ommc.config.feature_toggle.flatDigger.comment": "只有在潜行时才能挖掘比自己低的方块", - "ommc.config.feature_toggle.forceBreakingCooldown.name": "强制添加破坏冷却", - "ommc.config.feature_toggle.forceBreakingCooldown.comment": "玩家在秒破方块后会有 5gt 的破坏冷却时间", - "ommc.config.feature_toggle.highlightPersistentMob.name": "高亮不会消失的怪物", - "ommc.config.feature_toggle.highlightPersistentMob.comment": "高亮不会消失的怪物(受到客户端的限制,现在只能高亮手里有特殊物品或者被命名的怪物)", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.name": "高亮不会消失的怪物客户端模式", - "ommc.config.feature_toggle.highlightPersistentMobClientMode.comment": "使用客户端的数据来检查怪物是否会消失,比如手上的物品以及是否有名字,这可能会导致误判。提示:在本地游戏中应该关闭这个选项,在服务器中可以使用 MasaGadget 中的 同步全部实体数据来同步实体信息到本地。", - "ommc.config.feature_toggle.highlightLavaSource.name": "高亮岩浆源", - "ommc.config.feature_toggle.highlightLavaSource.comment": "岩浆源将会使用特殊的贴图高亮", - "ommc.config.feature_toggle.preventIntentionalGameDesign.name": "防止刻意的游戏设计", - "ommc.config.feature_toggle.preventIntentionalGameDesign.comment": "防止刻意的游戏设计(床或者重生锚爆炸)", - "ommc.config.feature_toggle.preventWastageOfWater.name": "防止浪费水", - "ommc.config.feature_toggle.preventWastageOfWater.comment": "防止在地狱使用水桶", - "ommc.config.feature_toggle.worldEaterMineHelper.name": "世吞挖矿助手", - "ommc.config.feature_toggle.worldEaterMineHelper.comment": "当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", - "ommc.config.feature_toggle.realSneaking.name": "真潜行", - "ommc.config.feature_toggle.realSneaking.comment": "玩家在潜行时无法上升或者下降,比如走上或者离开地毯,半砖,台阶这类方块", - "ommc.config.feature_toggle.removeBreakingCooldown.name": "移除挖掘冷却", - "ommc.config.feature_toggle.removeBreakingCooldown.comment": "移除在非秒破方块后的挖掘冷却(默认是 5gt),该功能在开启 §6强制添加破坏冷却§r 时不会生效", - "ommc.config.lists.blockModelNoOffsetBlacklist.name": "方块模型没有偏移列表黑名单", - "ommc.config.lists.blockModelNoOffsetBlacklist.comment": "方块模型没有偏移列表黑名单", - "ommc.config.lists.blockModelNoOffsetListType.name": "方块模型没有偏移列表类型", - "ommc.config.lists.blockModelNoOffsetListType.comment": "方块模型没有偏移列表类型", - "ommc.config.lists.blockModelNoOffsetWhitelist.name": "方块模型没有偏移列表白名单", - "ommc.config.lists.blockModelNoOffsetWhitelist.comment": "方块模型没有偏移列表白名单", - "ommc.config.lists.highlightEntityBlackList.name": "高亮实体列表黑名单", - "ommc.config.lists.highlightEntityBlackList.comment": "高亮实体列表黑名单", - "ommc.config.lists.highlightEntityListType.name": "高亮实体列表类型", - "ommc.config.lists.highlightEntityListType.comment": "高亮实体列表类型", - "ommc.config.lists.highlightEntityWhiteList.name": "高亮实体列表白名单", - "ommc.config.lists.highlightEntityWhiteList.comment": "高亮实体列表白名单", - "ommc.config.lists.breakBlockBlackList.name": "破坏方块黑名单", - "ommc.config.lists.breakBlockBlackList.comment": "如果开启 §6禁止破坏特定方块§r,玩家无法破坏在 §6破坏方块黑名单§r 中的方块", - "ommc.config.lists.breakScaffoldingWhiteList.name": "破坏脚手架白名单", - "ommc.config.lists.breakScaffoldingWhiteList.comment": "如果开启 §6禁止破坏脚手架§r,玩家只有在使用 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", - "ommc.config.lists.moveDownInScaffoldingWhiteList.name": "在脚手架中下降白名单", - "ommc.config.lists.moveDownInScaffoldingWhiteList.comment": "如果开启 §6禁止在脚手架中下降§r,玩家手中拿着 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", - "ommc.config.lists.worldEaterMineHelperWhitelist.name": "世吞挖矿助手白名单", - "ommc.config.lists.worldEaterMineHelperWhitelist.comment": "如果开启 §6世吞挖矿助手白名单§r,当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", - "ommc.config.advanced_integrated_server.onlineMode.name": "正版验证", - "ommc.config.advanced_integrated_server.onlineMode.comment": "本地服务器开启正版验证", - "ommc.config.advanced_integrated_server.pvp.name": "pvp", - "ommc.config.advanced_integrated_server.pvp.comment": "本地服务器开启 PVP", - "ommc.config.advanced_integrated_server.flight.name": "允许飞行", - "ommc.config.advanced_integrated_server.flight.comment": "本地服务器允许飞行", - "ommc.config.advanced_integrated_server.port.name": "局域网端口", - "ommc.config.advanced_integrated_server.port.comment": "本地服务器的局域网端口,0 表示使用随机端口", + "ommc.config.category.all.name": "全部", + "ommc.config.category.generic.name": "通用", + "ommc.config.category.feature.name": "特性", + "ommc.config.category.list.name": "列表", + + "ommc.config.option.sortInventoryShulkerBoxLast.auto": "自动", + "ommc.config.option.sortInventoryShulkerBoxLast.disable": "禁用", + "ommc.config.option.sortInventoryShulkerBoxLast.enable": "启用", + "ommc.config.option.openConfigGui.name": "打开设置界面", + "ommc.config.option.openConfigGui.comment": "打开设置界面的快捷键", + "ommc.config.option.debug.name": "调试模式", + "ommc.config.option.debug.comment": "开启后将会打印调试日志", + "ommc.config.option.dontClearChatHistory.name": "不清空聊天历史记录", + "ommc.config.option.dontClearChatHistory.comment": "不清空聊天历史记录,以及输入的历史记录", + "ommc.config.option.clearWaypoint.name": "取消高亮坐标点", + "ommc.config.option.clearWaypoint.comment": "取消高亮坐标点的快捷键", + "ommc.config.option.forceParseWaypointFromChat.name": "强制从聊天中解析路径点", + "ommc.config.option.forceParseWaypointFromChat.comment": "强制从聊天中解析路径点,就算该信息中存在 click event 也会将其覆盖", + "ommc.config.option.highlightBeamTime.name": "高亮光柱时间", + "ommc.config.option.highlightBeamTime.comment": "高亮坐标点光束展示时间.", + "ommc.config.option.parseWaypointFromChat.name": "从聊天中解析路径点", + "ommc.config.option.parseWaypointFromChat.comment": "从聊天中解析路径点", + "ommc.config.option.sendLookingAtBlockPos.name": "发送当前注视的方块的坐标", + "ommc.config.option.sendLookingAtBlockPos.comment": "发送当前注视的方块的坐标", + "ommc.config.option.sortInventory.name": "整理仓库", + "ommc.config.option.sortInventory.comment": "整理仓库的快捷键", + "ommc.config.option.sortInventoryShulkerBoxLast.name": "整理仓库时潜影盒放在最后", + "ommc.config.option.sortInventoryShulkerBoxLast.comment": "整理仓库时潜影盒放在最后", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.name": "整理仓库时支持空潜影盒堆叠", + "ommc.config.option.sortInventorySupportEmptyShulkerBoxStack.comment": "整理仓库时支持空潜影盒堆叠(请配合 PCA 使用)", + "ommc.config.option.autoSwitchElytra.name": "自动切换鞘翅", + "ommc.config.option.autoSwitchElytra.comment": "自动切换鞘翅和胸甲", + "ommc.config.option.betterSneaking.name": "更好的潜行", + "ommc.config.option.betterSneaking.comment": "在潜行时玩家可以向下移动 1 格高", + "ommc.config.option.disableBlocklistCheck.name": "关闭玩家黑名单检查", + "ommc.config.option.disableBlocklistCheck.comment": "避免 MC-218167,避免网络请求阻塞主线程", + "ommc.config.option.disableBreakBlock.name": "禁止破坏特定方块", + "ommc.config.option.disableBreakBlock.comment": "玩家无法破坏在 §6破坏方块黑名单§r 中的方块", + "ommc.config.option.disableBreakScaffolding.name": "禁止破坏脚手架", + "ommc.config.option.disableBreakScaffolding.comment": "玩家只有在手持 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", + "ommc.config.option.disableMoveDownInScaffolding.name": "禁止在脚手架中下降", + "ommc.config.option.disableMoveDownInScaffolding.comment": "玩家只有在手持 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", + "ommc.config.option.disablePistonPushEntity.name": "禁止活塞推动实体", + "ommc.config.option.disablePistonPushEntity.comment": "通过阻止客户端活塞推动实体(玩家除外)来减少活塞卡顿(比如地毯复制机),会导致一些实体位置渲染错误", + "ommc.config.option.flatDigger.name": "平坦挖掘", + "ommc.config.option.flatDigger.comment": "只有在潜行时才能挖掘比自己低的方块", + "ommc.config.option.forceBreakingCooldown.name": "强制添加破坏冷却", + "ommc.config.option.forceBreakingCooldown.comment": "玩家在秒破方块后会有 5gt 的破坏冷却时间", + "ommc.config.option.highlightPersistentMob.name": "高亮不会消失的怪物", + "ommc.config.option.highlightPersistentMob.comment": "高亮不会消失的怪物(受到客户端的限制,现在只能高亮手里有特殊物品或者被命名的怪物)", + "ommc.config.option.highlightPersistentMobClientMode.name": "高亮不会消失的怪物客户端模式", + "ommc.config.option.highlightPersistentMobClientMode.comment": "使用客户端的数据来检查怪物是否会消失,比如手上的物品以及是否有名字,这可能会导致误判。提示:在本地游戏中应该关闭这个选项,在服务器中可以使用 MasaGadget 中的 同步全部实体数据来同步实体信息到本地。", + "ommc.config.option.highlightLavaSource.name": "高亮岩浆源", + "ommc.config.option.highlightLavaSource.comment": "岩浆源将会使用特殊的贴图高亮", + "ommc.config.option.preventIntentionalGameDesign.name": "防止刻意的游戏设计", + "ommc.config.option.preventIntentionalGameDesign.comment": "防止刻意的游戏设计(床或者重生锚爆炸)", + "ommc.config.option.preventWastageOfWater.name": "防止浪费水", + "ommc.config.option.preventWastageOfWater.comment": "防止在地狱使用水桶", + "ommc.config.option.worldEaterMineHelper.name": "世吞挖矿助手", + "ommc.config.option.worldEaterMineHelper.comment": "当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", + "ommc.config.option.realSneaking.name": "真潜行", + "ommc.config.option.realSneaking.comment": "玩家在潜行时无法上升或者下降,比如走上或者离开地毯,半砖,台阶这类方块", + "ommc.config.option.removeBreakingCooldown.name": "移除挖掘冷却", + "ommc.config.option.removeBreakingCooldown.comment": "移除在非秒破方块后的挖掘冷却(默认是 5gt),该功能在开启 §6强制添加破坏冷却§r 时不会生效", + "ommc.config.option.blockModelNoOffsetBlacklist.name": "方块模型没有偏移列表黑名单", + "ommc.config.option.blockModelNoOffsetBlacklist.comment": "方块模型没有偏移列表黑名单", + "ommc.config.option.blockModelNoOffsetListType.name": "方块模型没有偏移列表类型", + "ommc.config.option.blockModelNoOffsetListType.comment": "方块模型没有偏移列表类型", + "ommc.config.option.blockModelNoOffsetWhitelist.name": "方块模型没有偏移列表白名单", + "ommc.config.option.blockModelNoOffsetWhitelist.comment": "方块模型没有偏移列表白名单", + "ommc.config.option.highlightEntityBlackList.name": "高亮实体列表黑名单", + "ommc.config.option.highlightEntityBlackList.comment": "高亮实体列表黑名单", + "ommc.config.option.highlightEntityListType.name": "高亮实体列表类型", + "ommc.config.option.highlightEntityListType.comment": "高亮实体列表类型", + "ommc.config.option.highlightEntityWhiteList.name": "高亮实体列表白名单", + "ommc.config.option.highlightEntityWhiteList.comment": "高亮实体列表白名单", + "ommc.config.option.breakBlockBlackList.name": "破坏方块黑名单", + "ommc.config.option.breakBlockBlackList.comment": "如果开启 §6禁止破坏特定方块§r,玩家无法破坏在 §6破坏方块黑名单§r 中的方块", + "ommc.config.option.breakScaffoldingWhiteList.name": "破坏脚手架白名单", + "ommc.config.option.breakScaffoldingWhiteList.comment": "如果开启 §6禁止破坏脚手架§r,玩家只有在使用 §6破坏脚手架白名单§r 中的物品时才能破坏脚手架", + "ommc.config.option.moveDownInScaffoldingWhiteList.name": "在脚手架中下降白名单", + "ommc.config.option.moveDownInScaffoldingWhiteList.comment": "如果开启 §6禁止在脚手架中下降§r,玩家手中拿着 §6在脚手架中下降白名单§r 中的物品时才能在脚手架下降", + "ommc.config.option.worldEaterMineHelperWhitelist.name": "世吞挖矿助手白名单", + "ommc.config.option.worldEaterMineHelperWhitelist.comment": "如果开启 §6世吞挖矿助手白名单§r,当 §6世吞挖矿助手白名单§r 中的方块暴露在空气中时,客户端会在它们上方渲染出自己的镜像,方便世吞运维以及挖矿", "ommc.highlight_waypoint.tooltip": "点击以高亮坐标点。再次点击展示光束。" -} \ No newline at end of file +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 5e913b8..7dc5083 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,9 +1,9 @@ { "schemaVersion": 1, - "id": "${mod_id}-${minecraft_version_id}", + "id": "${mod_id}", "version": "${mod_version}", "icon": "assets/${mod_id}/icon.png", - "name": "${mod_name} for ${minecraft_version}", + "name": "${mod_name}", "description": "${mod_description}", "authors": [ { @@ -25,22 +25,19 @@ "com.plusls.ommc.OhMyMinecraftClient" ], "modmenu": [ - "com.plusls.ommc.compat.modmenu.ModMenuApiImpl" + "com.plusls.ommc.impl.compat.modmenu.ModMenuApiImpl" ] }, "mixins": [ "${mod_id}.mixins.json" ], "depends": { - "magiclib-${minecraft_version_id}": ">=${magiclib_dependency}", + "fabric": "*", + "magiclib": ">=${magiclib_dependency}", "malilib": "*", "minecraft": "${minecraft_dependency}" }, "custom": { - "modmenu:clientsideOnly": true, - "modmenu:parent": "${mod_id}", - "modmenu": { - "parent": "${mod_id}" - } + "modmenu:clientsideOnly": true } } diff --git a/src/main/resources/ommc.mixins.json b/src/main/resources/ommc.mixins.json index 40b36ae..1a17ab0 100644 --- a/src/main/resources/ommc.mixins.json +++ b/src/main/resources/ommc.mixins.json @@ -3,7 +3,7 @@ "minVersion": "0.8", "package": "com.plusls.ommc.mixin", "compatibilityLevel": "JAVA_8", - "plugin": "top.hendrixshen.magiclib.dependency.impl.MagicMixinPlugin", + "plugin": "top.hendrixshen.magiclib.impl.mixin.MagicMixinPlugin", "client": [ "accessor.AccessorAbstractContainerScreen", "accessor.AccessorBlock", @@ -11,20 +11,19 @@ "accessor.AccessorBlockRenderContext", "accessor.AccessorBlockStateBase", "accessor.AccessorHelpCommand", + "accessor.AccessorSlot", "accessor.AccessorTextComponent", "accessor.AccessorTranslatableComponent", - "advancedIntegratedServer.MixinIntegratedServer", - "advancedIntegratedServer.MixinOpenToLanScreen", "api.command.MixinClientPacketListener", "api.command.MixinClientSuggestionProvider", "api.command.MixinLocalPlayer", "api.command.MixinMinecraft", - "feature.autoSwitchElytra.MixinClientPlayerEntity", + "feature.autoSwitchElytra.MixinLocalPlayer", "feature.betterSneaking.MixinPlayerEntity", "feature.blockModelNoOffset.fabric.MixinTerrainRenderContext", - "feature.blockModelNoOffset.optifine.MixinBlockModelRenderer", "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_4_9", "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_5", + "feature.blockModelNoOffset.sodium.MixinBlockRenderer_0_6", "feature.blockModelNoOffset.sodium.MixinBlockRendererLegacy", "feature.blockModelNoOffset.sodium.MixinTerrainRenderContext", "feature.disableBlocklistCheck.MixinSocialInteractionsManager", @@ -32,7 +31,6 @@ "feature.disableBreakScaffolding.MixinClientPlayerInteractionManager", "feature.disableMoveDownInScaffolding.MixinScaffoldingBlock", "feature.disablePistonPushEntity.MixinPistonBlockEntity", - "feature.dontClearChatHistory.MixinChatHud", "feature.flatDigger.MixinClientPlayerInteractionManager", "feature.forceBreakingCooldown.MixinClientPlayerInteractionManager", "feature.highlightEntity.MixinEntity", @@ -40,20 +38,19 @@ "feature.highlightLavaSource.sodium.MixinFluidRenderer", "feature.highlightPersistentMob.MixinEntity", "feature.highlightWaypoint.MixinChatHud", - "feature.highlightWaypoint.MixinGameRenderer", - "feature.highlightWaypoint.MixinLevelRenderer", "feature.highlightWaypoint.MixinMutableComponent", "feature.preventIntentionalGameDesign.MixinClientPlayerInteractionManager", "feature.removeBreakCooldown.MixinClientPlayerInteractionManager", "feature.worldEaterMineHelper.MixinJsonUnbakedModel", "feature.worldEaterMineHelper.fabric.MixinBlockRenderContext", "feature.worldEaterMineHelper.fabric.MixinTerrainRenderContext", - "feature.worldEaterMineHelper.optifine.MixinBlockRenderManager", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_4_11", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_4_9", "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_5", + "feature.worldEaterMineHelper.sodium.MixinBlockRenderer_0_6", "feature.worldEaterMineHelper.sodium.MixinBlockRendererLegacy", "feature.worldEaterMineHelper.sodium.MixinTerrainRenderContext", + "generic.dontClearChatHistory.MixinChatHud", "generic.sortInventory.MixinAbstractBannerBlockBannerBlock", "generic.sortInventory.MixinBedBlock", "generic.sortInventory.MixinShulkerBoxBlock", diff --git a/versions/1.14.4-fabric/build.gradle b/versions/1.14.4-fabric/build.gradle new file mode 100644 index 0000000..661ebb7 --- /dev/null +++ b/versions/1.14.4-fabric/build.gradle @@ -0,0 +1,379 @@ +plugins { + id("maven-publish") + id("top.hendrixshen.replace-token").version("${replace_token_version}") +} + +apply(plugin: "dev.architectury.loom") +apply(plugin: "com.replaymod.preprocess") +apply(plugin: "me.fallenbreath.yamlang") + +String modPlatform = loom.platform.get().toString().toLowerCase() +boolean fabricLike = modPlatform == "fabric" || modPlatform == "quilt" +boolean forgeLike = modPlatform == "forge" || modPlatform == "neoforge" +int mcVersion = 0 + +preprocess { + mcVersion = vars.get().get("MC") + vars.put("MC", mcVersion) + vars.put("FABRIC", modPlatform == "fabric" ? 1 : 0) + vars.put("FORGE", modPlatform == "forge" ? 1 : 0) + vars.put("NEO_FORGE", modPlatform == "neoforge" ? 1 : 0) + vars.put("FABRIC_LIKE", fabricLike ? 1 : 0) + vars.put("FORGE_LIKE", forgeLike ? 1 : 0) +} + +loom { + silentMojangMappingsLicense() +} + +repositories { + mavenLocal() + + maven { + name("NeoForge") + url("https://maven.neoforged.net/releases/") + } + + maven { + name("Curse Maven") + url("https://www.cursemaven.com") + } + + maven { + name("Modrinth Maven") + url("https://api.modrinth.com/maven") + } + + maven { + name("Jitpack Maven") + url("https://jitpack.io") + } + + maven { + name("Nyan Maven") + url("https://maven.hendrixshen.top/releases") + } + + mavenCentral() +} + +dependencies { + // Development environment + minecraft("com.mojang:minecraft:${project.property("dependencies.minecraft_version")}") + mappings(loom.officialMojangMappings()) + + // Annotation processor + modCompileOnly("org.projectlombok:lombok:${project.property("dependencies.lombok_version")}") + annotationProcessor("org.projectlombok:lombok:${project.property("dependencies.lombok_version")}") + + // Dependency + modApi(annotationProcessor("top.hendrixshen.magiclib:magiclib-all-${project.name}:${project.property("dependencies.magiclib_version")}")) + + switch (modPlatform) { + case "fabric": + break + case "forge": + forge("net.minecraftforge:forge:${project.property("dependencies.minecraft_version")}-${project.property("dependencies.forge_version")}") + break + case "neoforge": + neoForge("net.neoforged:neoforge:${project.property("dependencies.neoforge_version")}") + break + } +} + +loom { + // accessWidenerPath.set(file("src/main/resources/${project.parent.property("mod.id")}.accesswidener")) + enableTransitiveAccessWideners.set(false) + + interfaceInjection { + enableDependencyInterfaceInjection.set(false) + isEnabled.set(false) + } + + if (modPlatform == "forge") { + forge { + convertAccessWideners.set(true) + mixinConfig("${project.parent.property("mod.id")}.mixins.json") + } + } + + runConfigs.configureEach { + // Dump modified classes automatically. + property("mixin.debug.export", "true") + } + + runConfigs.named("client") { + programArgs([ + "--width", + project.getOrDefault("ow.game.window.width", "1920"), + "--height", + project.getOrDefault("ow.game.window.height", "1080"), + "--username", + project.getOrDefault("ow.game.window.username", "dev") + ]) + vmArgs("-Dmagiclib.debug=true") + vmArgs("-Dmagiclib.dev.qol=true") + vmArgs("-Dmagiclib.dev.qol.dfu.destroy=true") + runDir("run/client") + } + + runConfigs.named("server") { + vmArgs("-Dmagiclib.debug=true") + vmArgs("-Dmagiclib.dev.qol=true") + vmArgs("-Dmagiclib.dev.qol.dfu.destroy=true") + runDir("run/server") + } + + if (fabricLike) { + runs { + mixinAuditClient { + inherit(client) + vmArgs("-Dmagiclib.debug.mixinAuditor.enable=true") + ideConfigGenerated(false) + runDir("run/client") + } + + mixinAuditServer { + inherit(server) + vmArgs("-Dmagiclib.debug.mixinAuditor.enable=true") + ideConfigGenerated(false) + runDir("run/server") + } + } + } + + // Setup client default settings. + runClient { + defaultCharacterEncoding("UTF-8") + + doFirst { + file("${projectDir}/run/client/config").mkdirs() + file("${projectDir}/run/client/options.txt").with { File f -> + { + if (!f.exists()) { + f.parentFile.mkdirs() + f.withWriter { BufferedWriter writer -> + writer.writeLine("autoJump:false") + writer.writeLine("enableVsync:false") + writer.writeLine("forceUnicodeFont:true") + writer.writeLine("fov:1.0") + writer.writeLine("gamma:16.0") + writer.writeLine("guiScale:3") + writer.writeLine("lang:${Locale.getDefault().toString().toLowerCase()}") + writer.writeLine("maxFps:260") + writer.writeLine("renderDistance:10") + writer.writeLine("soundCategory_master:0.0") + } + } + } + } + } + } + + // Setup server default settings. + runServer { + defaultCharacterEncoding("UTF-8") + + doFirst { + // Agree eula before server init. + file("${projectDir}/run/server/eula.txt").with { File f -> + { + if (!f.exists()) { + f.parentFile.mkdirs() + f.withWriter { BufferedWriter writer -> + writer.writeLine("#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).") + writer.writeLine("#${new Date()}") + writer.writeLine("eula=true") + } + } + } + } + } + } +} + +base { + setArchivesName("${project.parent.property("mod.archives_base_name")}-mc${project.property("dependencies.minecraft_version")}-${modPlatform}") + group("${project.property("mod.maven_group")}") + version(project.getModVersion(project.parent)) +} + +sourceSets { + dummy { + compileClasspath += main.compileClasspath + runtimeClasspath += main.runtimeClasspath + } + + main.compileClasspath += dummy.output +} + +java { + if (mcVersion > 11204) { + sourceCompatibility(JavaVersion.VERSION_21) + targetCompatibility(JavaVersion.VERSION_21) + } else if (mcVersion > 11701) { + sourceCompatibility(JavaVersion.VERSION_17) + targetCompatibility(JavaVersion.VERSION_17) + } else if (mcVersion > 11605) { + sourceCompatibility(JavaVersion.VERSION_16) + targetCompatibility(JavaVersion.VERSION_16) + } else { + sourceCompatibility(JavaVersion.VERSION_1_8) + targetCompatibility(JavaVersion.VERSION_1_8) + } + + withSourcesJar() +} + +remapJar { + if (forgeLike) { + if (modPlatform == "neoforge") { + atAccessWideners.add("${project.parent.property("mod.id")}.accesswidener") + } + + exclude("${project.parent.property("mod.id")}.accesswidener") + } + + setRemapperIsolation(true) +} + +replaceToken { + targetSourceSets.set([sourceSets.main]) + replace("@MOD_IDENTIFIER@", project.parent.property("mod.id").toString().replace("-", "_")) + replace("@MOD_NAME@" , project.parent.property("mod.name")) + replace("@MOD_VERSION@" , project.getVersionWithCommitHash(this.project.parent) as String) + replaceIn("com/plusls/ommc/OhMyMinecraftClientReference") + replaceIn("com/plusls/ommc/SharedConstants") +} + +processResources { + outputs.upToDateWhen { false } + + [ + "fabric.mod.json" : ["fabric"], + "META-INF" : ["forge", "neoforge"], + "META-INF/mods.toml" : ["forge", "neoforge", mcVersion < 12005 ? "neoforge": "none"], + "META-INF/neoforge.mods.toml": [mcVersion > 12004 ? "neoforge" : "none"] + ].forEach { file, platforms -> + if (platforms.contains(modPlatform)) { + filesMatching(file) { + expand([ + "magiclib_dependency" : project.property("dependencies.magiclib_dependency"), + "minecraft_dependency": project.property("dependencies.minecraft_dependency"), + "mod_alias" : project.parent.property("mod.id"), + "mod_description" : project.parent.property("mod.description"), + "mod_homepage" : project.parent.property("mod.homepage"), + "mod_id" : project.parent.property("mod.id").toString().replace("-", "_"), + "mod_license" : project.parent.property("mod.license"), + "mod_name" : project.parent.property("mod.name"), + "mod_sources" : project.parent.property("mod.sources"), + "mod_version" : project.getVersionWithCommitHash(this.project.parent) + ]) + } + } else { + exclude(file) + } + } + + from("${rootDir}/LICENSE") + from("${rootDir}/icon.png") { + if (fabricLike) { + into("assets/${project.parent.property("mod.id")}") + } + } +} + +yamlang { + targetSourceSets.set([sourceSets.main]) + inputDir.set("assets/${project.parent.property("mod.id")}/lang") +} + +publishing { + publications { + register("release", MavenPublication) { MavenPublication publication -> + artifactId("${this.project.parent.property("mod.artifact_name")}-${project.name}") + from(this.project.components.java) + version("${this.project.getMavenArtifactVersion(this.project.parent)}") + } + + register("snapshot", MavenPublication) { MavenPublication publication -> + artifactId("${this.project.parent.property("mod.artifact_name")}-${project.name}") + from(this.project.components.java) + version("${this.project.parent.property("mod.version")}-SNAPSHOT") + } + } + + repositories { + mavenLocal { + name("mavenLocal") + } + + maven { + name("projectLocalSnapshot") + url("${rootDir}/publish/snapshot") + } + + maven { + name("projectLocalRelease") + url("${rootDir}/publish/release") + } + } +} + +tasks.withType(PublishToMavenRepository).configureEach { + Provider predicate = provider { + repository == publishing.repositories.mavenLocal || + (repository == publishing.repositories.projectLocalSnapshot && publication == publishing.publications.snapshot) || + (repository == publishing.repositories.projectLocalRelease && publication == publishing.publications.release) + } + + onlyIf { + predicate.get() + } +} + +tasks.withType(JavaCompile).configureEach { JavaCompile task -> + task.options.encoding("UTF-8") + + if (mcVersion > 12005) { + task.options.release.set(21) + } else if (mcVersion > 11701) { + task.options.release.set(17) + } else if (mcVersion > 11605) { + task.options.release.set(16) + } else { + task.options.release.set(8) + } +} + +tasks.register("cleanRuns", DefaultTask.class) { + doLast { + file(loom.runConfigs.client.runDir).parentFile.deleteDir() + } +} + +tasks.register("cleanRunClient", DefaultTask.class) { + doLast { + file(loom.runConfigs.client.runDir).deleteDir() + } +} + +tasks.register("cleanRunServer", DefaultTask.class) { + doLast { + file(loom.runConfigs.server.runDir).deleteDir() + } +} + +[ + "cleanRuns", "cleanRunClient", "cleanRunServer", + "runClient", "runServer", + "runMixinAuditClient", "runMixinAuditServer", + "preprocessCode", "preprocessResources", + "preprocessTestCode", "preprocessTestResources" +].forEach { taskName -> + if (tasks.getNames().contains(taskName)) { + tasks.named(taskName) { + it.group("${project.property("mod.id")}") + } + } +} diff --git a/versions/1.14.4-fabric/gradle.properties b/versions/1.14.4-fabric/gradle.properties new file mode 100644 index 0000000..213b488 --- /dev/null +++ b/versions/1.14.4-fabric/gradle.properties @@ -0,0 +1,4 @@ +# Development Environment +dependencies.minecraft_version=1.14.4 +dependencies.minecraft_dependency=1.14.x + diff --git a/versions/1.14.4/gradle.properties b/versions/1.14.4/gradle.properties deleted file mode 100644 index 4322a82..0000000 --- a/versions/1.14.4/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Development Environment -minecraft_version=1.14.4 -minecraft_dependency=1.14.x - diff --git a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java b/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java deleted file mode 100644 index bc387c1..0000000 --- a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinGameRenderer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.plusls.ommc.mixin.feature.highlightWaypoint; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.plusls.ommc.feature.highlithtWaypoint.HighlightWaypointUtil; -import net.minecraft.client.renderer.GameRenderer; -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; - -/** - * The implementation for mc [1.14.4, ~) - */ -@Mixin(GameRenderer.class) -public class MixinGameRenderer { - @Inject(method = "render(FJ)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/GameRenderer;renderHand:Z")) - private void postRender(float partialTicks, long finishTimeNano, CallbackInfo ci) { - PoseStack poseStack = new PoseStack(); - HighlightWaypointUtil.drawWaypoint(poseStack, partialTicks); - } -} \ No newline at end of file diff --git a/versions/1.15.2-fabric/gradle.properties b/versions/1.15.2-fabric/gradle.properties new file mode 100644 index 0000000..022b546 --- /dev/null +++ b/versions/1.15.2-fabric/gradle.properties @@ -0,0 +1,4 @@ +# Development Environment +dependencies.minecraft_version=1.15.2 +dependencies.minecraft_dependency=1.15.x + diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java similarity index 96% rename from versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java index 5c00cc0..1260f8e 100644 --- a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java +++ b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandInternals.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import top.hendrixshen.magiclib.compat.minecraft.api.network.chat.ComponentCompatApi; +import top.hendrixshen.magiclib.api.compat.minecraft.network.chat.ComponentCompat; import java.util.HashMap; import java.util.List; @@ -81,7 +81,7 @@ public static boolean executeCommand(String message) { return true; } catch (RuntimeException e) { LOGGER.warn("Error while executing client-sided command '{}'", message, e); - commandSource.sendError(ComponentCompatApi.literal(e.getMessage())); + commandSource.sendError(ComponentCompat.literal(e.getMessage())); return true; } finally { client.getProfiler().pop(); @@ -109,7 +109,7 @@ private static Component getErrorMessage(CommandSyntaxException e) { Component message = ComponentUtils.fromMessage(e.getRawMessage()); String context = e.getContext(); - return context != null ? ComponentCompatApi.translatable("command.context.parse_error", message, context) : message; + return context != null ? ComponentCompat.translatable("command.context.parse_error", message, context) : message; } /** @@ -153,7 +153,7 @@ private static int executeHelp(CommandNode startNode, Map, String> commands = ClientCommandManager.DISPATCHER.getSmartUsage(startNode, context.getSource()); for (String command : commands.values()) { - context.getSource().sendFeedback(ComponentCompatApi.literal("/" + command)); + context.getSource().sendFeedback(ComponentCompat.literal("/" + command)); } return commands.size(); diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/ClientCommandManager.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/api/command/FabricClientCommandSource.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlock.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorHelpCommand.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientPacketListener.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinClientSuggestionProvider.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinLocalPlayer.java diff --git a/versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java similarity index 100% rename from versions/1.15.2/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java rename to versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/api/command/MixinMinecraft.java diff --git a/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java new file mode 100644 index 0000000..07d1d0f --- /dev/null +++ b/versions/1.15.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/disableBlocklistCheck/MixinSocialInteractionsManager.java @@ -0,0 +1,8 @@ +package com.plusls.ommc.mixin.feature.disableBlocklistCheck; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; + +@Mixin(DummyClass.class) +public class MixinSocialInteractionsManager { +} diff --git a/versions/1.15.2/gradle.properties b/versions/1.15.2/gradle.properties deleted file mode 100644 index 1c4f3bb..0000000 --- a/versions/1.15.2/gradle.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Development Environment -minecraft_version=1.15.2 -minecraft_dependency=1.15.x - diff --git a/versions/1.16.5-fabric/gradle.properties b/versions/1.16.5-fabric/gradle.properties new file mode 100644 index 0000000..fa1434d --- /dev/null +++ b/versions/1.16.5-fabric/gradle.properties @@ -0,0 +1,5 @@ +# Development Environment +dependencies.minecraft_version=1.16.5 +dependencies.minecraft_dependency=1.16.x + + diff --git a/versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java b/versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java new file mode 100644 index 0000000..0be2c32 --- /dev/null +++ b/versions/1.16.5-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorSlot.java @@ -0,0 +1,11 @@ +package com.plusls.ommc.mixin.accessor; + +import net.minecraft.world.inventory.Slot; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Slot.class) +public interface AccessorSlot { + @Accessor + int getSlot(); +} diff --git a/versions/1.16.5/gradle.properties b/versions/1.16.5/gradle.properties deleted file mode 100644 index 2e33acd..0000000 --- a/versions/1.16.5/gradle.properties +++ /dev/null @@ -1,5 +0,0 @@ -# Development Environment -minecraft_version=1.16.5 -minecraft_dependency=1.16.x - - diff --git a/versions/1.17.1-fabric/gradle.properties b/versions/1.17.1-fabric/gradle.properties new file mode 100644 index 0000000..ff80156 --- /dev/null +++ b/versions/1.17.1-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.17.1 +dependencies.minecraft_dependency=1.17.x diff --git a/versions/1.17.1/gradle.properties b/versions/1.17.1/gradle.properties deleted file mode 100644 index 3b44dd8..0000000 --- a/versions/1.17.1/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.17.1 -minecraft_dependency=1.17.x diff --git a/versions/1.18.2-fabric/gradle.properties b/versions/1.18.2-fabric/gradle.properties new file mode 100644 index 0000000..73628f3 --- /dev/null +++ b/versions/1.18.2-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.18.2 +dependencies.minecraft_dependency=1.18.x diff --git a/versions/1.18.2/gradle.properties b/versions/1.18.2/gradle.properties deleted file mode 100644 index 6b35460..0000000 --- a/versions/1.18.2/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.18.2 -minecraft_dependency=1.18.x diff --git a/versions/1.19.2-fabric/gradle.properties b/versions/1.19.2-fabric/gradle.properties new file mode 100644 index 0000000..0069552 --- /dev/null +++ b/versions/1.19.2-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.19.2 +dependencies.minecraft_dependency=1.19.2 diff --git a/versions/1.19.2/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java b/versions/1.19.2-fabric/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java similarity index 100% rename from versions/1.19.2/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java rename to versions/1.19.2-fabric/src/dummy/java/me/jellysquid/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java similarity index 70% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java index 344686f..e9021c6 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/accessor/AccessorBlockRenderContext.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.accessor; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public interface AccessorBlockRenderContext { diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java similarity index 72% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java index b1709ac..9a0a26e 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/blockModelNoOffset/sodium/MixinBlockRenderer.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.blockModelNoOffset.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinBlockRenderer { diff --git a/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java new file mode 100644 index 0000000..336ecb0 --- /dev/null +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -0,0 +1,10 @@ +package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; + +import org.spongepowered.asm.mixin.Mixin; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; + +@Mixin(DummyClass.class) +public class MixinBlockRenderer_0_4_11 { +} diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java similarity index 72% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java index 8ac79a0..2e6d8ab 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_9.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinBlockRenderer_0_4_9 { diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java similarity index 72% rename from versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java rename to versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java index a5762f6..a54c449 100644 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java +++ b/versions/1.19.2-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_5.java @@ -1,7 +1,7 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) public class MixinBlockRenderer_0_5 { diff --git a/versions/1.19.2/gradle.properties b/versions/1.19.2/gradle.properties deleted file mode 100644 index a1c5646..0000000 --- a/versions/1.19.2/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.19.2 -minecraft_dependency=1.19.2 diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java b/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java deleted file mode 100644 index db89a6f..0000000 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/advancedIntegratedServer/MixinOpenToLanScreen.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.plusls.ommc.mixin.advancedIntegratedServer; - -import com.plusls.ommc.config.Configs; -import net.minecraft.client.gui.screens.ShareToLanScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; - -/** - * The implementation for mc [1.14.4, ~) - */ -@Mixin(ShareToLanScreen.class) -public class MixinOpenToLanScreen { - @SuppressWarnings("InvalidInjectorMethodSignature") - @ModifyVariable( - method = "method_19851", - at = @At( - value = "INVOKE_ASSIGN", - target = "Lnet/minecraft/util/HttpUtil;getAvailablePort()I", - ordinal = 0, - remap = true - ), - ordinal = 0, - remap = false - ) - private int modifyPort(int port) { - int ret = Configs.port; - - if (ret == 0) { - ret = port; - } - - return ret; - } -} diff --git a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java deleted file mode 100644 index b2d7ade..0000000 --- a/versions/1.19.2/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; - -import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; - -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.10 <0.5")) -@Mixin(DummyClass.class) -public class MixinBlockRenderer_0_4_11 { -} diff --git a/versions/1.19.3/gradle.properties b/versions/1.19.3-fabric/gradle.properties similarity index 50% rename from versions/1.19.3/gradle.properties rename to versions/1.19.3-fabric/gradle.properties index a0e9ef1..fe1fcdf 100644 --- a/versions/1.19.3/gradle.properties +++ b/versions/1.19.3-fabric/gradle.properties @@ -1,6 +1,6 @@ # Development Environment -minecraft_version=1.19.3 -minecraft_dependency=1.19.3 +dependencies.minecraft_version=1.19.3 +dependencies.minecraft_dependency=1.19.3 # Compatible Libraries sodium_version=mc1.19.3-0.4.9 diff --git a/versions/1.19.3/src/main/resources/assets/minecraft/atlases/lava_patterns.json b/versions/1.19.3-fabric/src/main/resources/assets/minecraft/atlases/lava_patterns.json similarity index 100% rename from versions/1.19.3/src/main/resources/assets/minecraft/atlases/lava_patterns.json rename to versions/1.19.3-fabric/src/main/resources/assets/minecraft/atlases/lava_patterns.json diff --git a/versions/1.19.4/gradle.properties b/versions/1.19.4-fabric/gradle.properties similarity index 50% rename from versions/1.19.4/gradle.properties rename to versions/1.19.4-fabric/gradle.properties index 5c13ca9..599f0c1 100644 --- a/versions/1.19.4/gradle.properties +++ b/versions/1.19.4-fabric/gradle.properties @@ -1,6 +1,6 @@ # Development Environment -minecraft_version=1.19.4 -minecraft_dependency=1.19.4 +dependencies.minecraft_version=1.19.4 +dependencies.minecraft_dependency=1.19.4 # Compatible Libraries sodium_version=mc1.19.4-0.4.11 diff --git a/versions/1.19.4/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java b/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java similarity index 79% rename from versions/1.19.4/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java rename to versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java index 00dc0d6..663cfdf 100644 --- a/versions/1.19.4/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java +++ b/versions/1.19.4-fabric/src/main/java/com/plusls/ommc/mixin/feature/worldEaterMineHelper/sodium/MixinBlockRenderer_0_4_11.java @@ -1,6 +1,6 @@ package com.plusls.ommc.mixin.feature.worldEaterMineHelper.sodium; -import com.plusls.ommc.feature.worldEaterMineHelper.WorldEaterMineHelperUtil; +import com.plusls.ommc.impl.feature.worldEaterMineHelper.WorldEaterMineHelper; import com.plusls.ommc.mixin.accessor.AccessorBlockRenderContext; import me.jellysquid.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; import me.jellysquid.mods.sodium.client.render.chunk.compile.pipeline.BlockRenderContext; @@ -15,13 +15,13 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependencies; -import top.hendrixshen.magiclib.dependency.api.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependency; +import top.hendrixshen.magiclib.api.dependency.annotation.Dependencies; /** * The implementation for mc [1.19.3, ~) */ -@Dependencies(and = @Dependency(value = "sodium", versionPredicate = ">0.4.10 <0.5")) +@Dependencies(require = @Dependency(value = "sodium", versionPredicates = ">0.4.10 <0.5")) @Mixin(value = BlockRenderer.class, remap = false) public abstract class MixinBlockRenderer_0_4_11 { @Shadow(remap = false) @@ -38,12 +38,12 @@ public abstract class MixinBlockRenderer_0_4_11 { ) ) private void postRenderModel(@NotNull BlockRenderContext ctx, ChunkBuildBuffers buffers, ChunkRenderBounds.Builder bounds, CallbackInfo ci) { - if (WorldEaterMineHelperUtil.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { - BakedModel customModel = WorldEaterMineHelperUtil.customModels.get(ctx.state().getBlock()); + if (WorldEaterMineHelper.shouldUseCustomModel(ctx.state(), ctx.pos()) && !this.ommc$renderTag.get()) { + BakedModel customModel = WorldEaterMineHelper.customModels.get(ctx.state().getBlock()); if (customModel != null) { this.ommc$renderTag.set(true); - // This impl will break light system, so disable it. + // This impl will break light systems, so disable it. // int originalLightEmission = ctx.state().getLightEmission(); BakedModel originalModel = ctx.model(); // ((AccessorBlockStateBase) ctx.state()).setLightEmission(15); diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1-fabric/gradle.properties similarity index 50% rename from versions/1.20.1/gradle.properties rename to versions/1.20.1-fabric/gradle.properties index c83eff9..3c14933 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1-fabric/gradle.properties @@ -1,6 +1,6 @@ # Development Environment -minecraft_version=1.20.1 -minecraft_dependency=1.20.1 +dependencies.minecraft_version=1.20.1 +dependencies.minecraft_dependency=1.20.1 # Compatible Libraries sodium_version=mc1.20-0.4.10 diff --git a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java b/versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java similarity index 56% rename from versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java rename to versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java index f6596c8..08fdcc5 100644 --- a/versions/1.14.4/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinLevelRenderer.java +++ b/versions/1.20.1-fabric/src/main/java/com/plusls/ommc/mixin/feature/highlightWaypoint/MixinMutableComponent.java @@ -1,8 +1,8 @@ package com.plusls.ommc.mixin.feature.highlightWaypoint; import org.spongepowered.asm.mixin.Mixin; -import top.hendrixshen.magiclib.compat.preprocess.api.DummyClass; +import top.hendrixshen.magiclib.api.preprocess.DummyClass; @Mixin(DummyClass.class) -public class MixinLevelRenderer { +public class MixinMutableComponent { } diff --git a/versions/1.20.2-fabric/gradle.properties b/versions/1.20.2-fabric/gradle.properties new file mode 100644 index 0000000..b15ca89 --- /dev/null +++ b/versions/1.20.2-fabric/gradle.properties @@ -0,0 +1,6 @@ +# Development Environment +dependencies.minecraft_version=1.20.2 +dependencies.minecraft_dependency=1.20.2 + +# Compatible Libraries +sodium_version=0 diff --git a/versions/1.20.2/gradle.properties b/versions/1.20.2/gradle.properties deleted file mode 100644 index 719de15..0000000 --- a/versions/1.20.2/gradle.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Development Environment -minecraft_version=1.20.2 -minecraft_dependency=1.20.2 - -# Compatible Libraries -sodium_version=0 diff --git a/versions/1.20.4-fabric/gradle.properties b/versions/1.20.4-fabric/gradle.properties new file mode 100644 index 0000000..9ed1d52 --- /dev/null +++ b/versions/1.20.4-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.20.4 +dependencies.minecraft_dependency=>=1.20.3- <1.20.5- diff --git a/versions/1.20.4/gradle.properties b/versions/1.20.4/gradle.properties deleted file mode 100644 index 6ddd275..0000000 --- a/versions/1.20.4/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Development Environment -minecraft_version=1.20.4 -minecraft_dependency=1.20.4 diff --git a/versions/1.20.6-fabric/gradle.properties b/versions/1.20.6-fabric/gradle.properties new file mode 100644 index 0000000..b3e9105 --- /dev/null +++ b/versions/1.20.6-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Development Environment +dependencies.minecraft_version=1.20.6 +dependencies.minecraft_dependency=>=1.20.5- <1.20.7- diff --git a/versions/1.21.1-fabric/gradle.properties b/versions/1.21.1-fabric/gradle.properties new file mode 100644 index 0000000..e2019da --- /dev/null +++ b/versions/1.21.1-fabric/gradle.properties @@ -0,0 +1,3 @@ +# Dependency Versions +dependencies.minecraft_dependency=>=1.21- <1.21.2- +dependencies.minecraft_version=1.21.1 \ No newline at end of file diff --git a/versions/mainProject b/versions/mainProject index 1b9335f..66d55ba 100644 --- a/versions/mainProject +++ b/versions/mainProject @@ -1 +1 @@ -1.20.4 \ No newline at end of file +1.20.4-fabric \ No newline at end of file diff --git a/versions/mapping-1.15.2-1.16.5.txt b/versions/mapping-1.15.2-1.16.5.txt index b4a85ac..5944d63 100644 --- a/versions/mapping-1.15.2-1.16.5.txt +++ b/versions/mapping-1.15.2-1.16.5.txt @@ -1,2 +1,2 @@ com.plusls.ommc.api.command.ClientCommandManager net.fabricmc.fabric.api.client.command.v1.ClientCommandManager -com.plusls.ommc.api.command.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource \ No newline at end of file +com.plusls.ommc.api.command.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource diff --git a/versions/mapping-1.18.2-1.19.2.txt b/versions/mapping-1.18.2-1.19.2.txt index 0506edb..89f92b4 100644 --- a/versions/mapping-1.18.2-1.19.2.txt +++ b/versions/mapping-1.18.2-1.19.2.txt @@ -1,2 +1,3 @@ net.fabricmc.fabric.api.client.command.v1.ClientCommandManager net.fabricmc.fabric.api.client.command.v2.ClientCommandManager -net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource \ No newline at end of file +net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource +net.minecraft.network.chat.BaseComponent net.minecraft.network.chat.MutableComponent diff --git a/versions/mapping-1.19.2-1.19.3.txt b/versions/mapping-1.19.2-1.19.3.txt index d12ee62..4050de0 100644 --- a/versions/mapping-1.19.2-1.19.3.txt +++ b/versions/mapping-1.19.2-1.19.3.txt @@ -1,3 +1,3 @@ com.mojang.math.Vector3f org.joml.Vector3f com.mojang.math.Matrix3f org.joml.Matrix3f -com.mojang.math.Matrix4f org.joml.Matrix4f \ No newline at end of file +com.mojang.math.Matrix4f org.joml.Matrix4f