Ver Fonte

first commit

hsj há 3 dias atrás
commit
933566382c
38 ficheiros alterados com 1559 adições e 0 exclusões
  1. 9 0
      .gitattributes
  2. 40 0
      .gitignore
  3. 121 0
      LICENSE
  4. 50 0
      README_拆解台模组.md
  5. 90 0
      build.gradle
  6. 21 0
      gradle.properties
  7. BIN
      gradle/wrapper/gradle-wrapper.jar
  8. 7 0
      gradle/wrapper/gradle-wrapper.properties
  9. 248 0
      gradlew
  10. 93 0
      gradlew.bat
  11. 10 0
      settings.gradle
  12. 14 0
      src/client/java/com/husj/HusjClient.java
  13. 56 0
      src/client/java/com/husj/client/screen/DisassemblerScreen.java
  14. 15 0
      src/client/java/com/husj/mixin/client/ExampleClientMixin.java
  15. 11 0
      src/client/resources/husj.client.mixins.json
  16. 27 0
      src/main/java/com/husj/Husj.java
  17. 38 0
      src/main/java/com/husj/ModBlocks.java
  18. 78 0
      src/main/java/com/husj/block/DisassemblerBlock.java
  19. 182 0
      src/main/java/com/husj/block/entity/DisassemblerBlockEntity.java
  20. 69 0
      src/main/java/com/husj/block/entity/ImplementedInventory.java
  21. 15 0
      src/main/java/com/husj/mixin/ExampleMixin.java
  22. 105 0
      src/main/java/com/husj/recipe/DisassemblerRecipes.java
  23. 113 0
      src/main/java/com/husj/screen/DisassemblerScreenHandler.java
  24. 22 0
      src/main/java/com/husj/screen/ModScreenHandlers.java
  25. 7 0
      src/main/resources/assets/husj/blockstates/disassembler.json
  26. BIN
      src/main/resources/assets/husj/icon.png
  27. 5 0
      src/main/resources/assets/husj/lang/en_us.json
  28. 5 0
      src/main/resources/assets/husj/lang/zh_cn.json
  29. 12 0
      src/main/resources/assets/husj/models/block/disassembler.json
  30. 3 0
      src/main/resources/assets/husj/models/item/disassembler.json
  31. 3 0
      src/main/resources/assets/husj/textures/block/disassembler_bottom.png.mcmeta
  32. 3 0
      src/main/resources/assets/husj/textures/block/disassembler_front.png.mcmeta
  33. 3 0
      src/main/resources/assets/husj/textures/block/disassembler_side.png.mcmeta
  34. 3 0
      src/main/resources/assets/husj/textures/block/disassembler_top.png.mcmeta
  35. 3 0
      src/main/resources/assets/husj/textures/gui/container/disassembler.png.mcmeta
  36. 23 0
      src/main/resources/data/husj/recipes/disassembler.json
  37. 41 0
      src/main/resources/fabric.mod.json
  38. 14 0
      src/main/resources/husj.mixins.json

+ 9 - 0
.gitattributes

@@ -0,0 +1,9 @@
+#
+# https://help.github.com/articles/dealing-with-line-endings/
+#
+# Linux start script should use lf
+/gradlew        text eol=lf
+
+# These are Windows script files and should use crlf
+*.bat           text eol=crlf
+

+ 40 - 0
.gitignore

@@ -0,0 +1,40 @@
+# gradle
+
+.gradle/
+build/
+out/
+classes/
+
+# eclipse
+
+*.launch
+
+# idea
+
+.idea/
+*.iml
+*.ipr
+*.iws
+
+# vscode
+
+.settings/
+.vscode/
+bin/
+.classpath
+.project
+
+# macos
+
+*.DS_Store
+
+# fabric
+
+run/
+
+# java
+
+hs_err_*.log
+replay_*.log
+*.hprof
+*.jfr

+ 121 - 0
LICENSE

@@ -0,0 +1,121 @@
+Creative Commons Legal Code
+
+CC0 1.0 Universal
+
+    CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
+    LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
+    ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+    INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
+    REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
+    PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
+    THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
+    HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer
+exclusive Copyright and Related Rights (defined below) upon the creator
+and subsequent owner(s) (each and all, an "owner") of an original work of
+authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for
+the purpose of contributing to a commons of creative, cultural and
+scientific works ("Commons") that the public can reliably and without fear
+of later claims of infringement build upon, modify, incorporate in other
+works, reuse and redistribute as freely as possible in any form whatsoever
+and for any purposes, including without limitation commercial purposes.
+These owners may contribute to the Commons to promote the ideal of a free
+culture and the further production of creative, cultural and scientific
+works, or to gain reputation or greater distribution for their Work in
+part through the use and efforts of others.
+
+For these and/or other purposes and motivations, and without any
+expectation of additional consideration or compensation, the person
+associating CC0 with a Work (the "Affirmer"), to the extent that he or she
+is an owner of Copyright and Related Rights in the Work, voluntarily
+elects to apply CC0 to the Work and publicly distribute the Work under its
+terms, with knowledge of his or her Copyright and Related Rights in the
+Work and the meaning and intended legal effect of CC0 on those rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be
+protected by copyright and related or neighboring rights ("Copyright and
+Related Rights"). Copyright and Related Rights include, but are not
+limited to, the following:
+
+  i. the right to reproduce, adapt, distribute, perform, display,
+     communicate, and translate a Work;
+ ii. moral rights retained by the original author(s) and/or performer(s);
+iii. publicity and privacy rights pertaining to a person's image or
+     likeness depicted in a Work;
+ iv. rights protecting against unfair competition in regards to a Work,
+     subject to the limitations in paragraph 4(a), below;
+  v. rights protecting the extraction, dissemination, use and reuse of data
+     in a Work;
+ vi. database rights (such as those arising under Directive 96/9/EC of the
+     European Parliament and of the Council of 11 March 1996 on the legal
+     protection of databases, and under any national implementation
+     thereof, including any amended or successor version of such
+     directive); and
+vii. other similar, equivalent or corresponding rights throughout the
+     world based on applicable law or treaty, and any national
+     implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention
+of, applicable law, Affirmer hereby overtly, fully, permanently,
+irrevocably and unconditionally waives, abandons, and surrenders all of
+Affirmer's Copyright and Related Rights and associated claims and causes
+of action, whether now known or unknown (including existing as well as
+future claims and causes of action), in the Work (i) in all territories
+worldwide, (ii) for the maximum duration provided by applicable law or
+treaty (including future time extensions), (iii) in any current or future
+medium and for any number of copies, and (iv) for any purpose whatsoever,
+including without limitation commercial, advertising or promotional
+purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
+member of the public at large and to the detriment of Affirmer's heirs and
+successors, fully intending that such Waiver shall not be subject to
+revocation, rescission, cancellation, termination, or any other legal or
+equitable action to disrupt the quiet enjoyment of the Work by the public
+as contemplated by Affirmer's express Statement of Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason
+be judged legally invalid or ineffective under applicable law, then the
+Waiver shall be preserved to the maximum extent permitted taking into
+account Affirmer's express Statement of Purpose. In addition, to the
+extent the Waiver is so judged Affirmer hereby grants to each affected
+person a royalty-free, non transferable, non sublicensable, non exclusive,
+irrevocable and unconditional license to exercise Affirmer's Copyright and
+Related Rights in the Work (i) in all territories worldwide, (ii) for the
+maximum duration provided by applicable law or treaty (including future
+time extensions), (iii) in any current or future medium and for any number
+of copies, and (iv) for any purpose whatsoever, including without
+limitation commercial, advertising or promotional purposes (the
+"License"). The License shall be deemed effective as of the date CC0 was
+applied by Affirmer to the Work. Should any part of the License for any
+reason be judged legally invalid or ineffective under applicable law, such
+partial invalidity or ineffectiveness shall not invalidate the remainder
+of the License, and in such case Affirmer hereby affirms that he or she
+will not (i) exercise any of his or her remaining Copyright and Related
+Rights in the Work or (ii) assert any associated claims and causes of
+action with respect to the Work, in either case contrary to Affirmer's
+express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
+    surrendered, licensed or otherwise affected by this document.
+ b. Affirmer offers the Work as-is and makes no representations or
+    warranties of any kind concerning the Work, express, implied,
+    statutory or otherwise, including without limitation warranties of
+    title, merchantability, fitness for a particular purpose, non
+    infringement, or the absence of latent or other defects, accuracy, or
+    the present or absence of errors, whether or not discoverable, all to
+    the greatest extent permissible under applicable law.
+ c. Affirmer disclaims responsibility for clearing rights of other persons
+    that may apply to the Work or any use thereof, including without
+    limitation any person's Copyright and Related Rights in the Work.
+    Further, Affirmer disclaims responsibility for obtaining any necessary
+    consents, permissions or other rights required for any use of the
+    Work.
+ d. Affirmer understands and acknowledges that Creative Commons is not a
+    party to this document and has no duty or obligation with respect to
+    this CC0 or use of the Work.

+ 50 - 0
README_拆解台模组.md

@@ -0,0 +1,50 @@
+# 拆解台模组 (Disassembler Mod)
+
+这是一个Minecraft Fabric模组,添加了一个拆解台功能方块,可以回收矿物制成的工具和装备。
+
+## 功能特性
+
+### 拆解台方块
+- **合成配方**: 3个铁锭 + 3个钻石 + 3个原石
+- **功能**: 将矿物工具和装备拆解为原材料
+- **工作方式**: 放入工具后自动拆解,需要时间处理
+
+### 支持的拆解物品
+
+#### 工具类
+- **钻石工具**: 钻石剑(2钻石)、钻石镐(3钻石)、钻石斧(3钻石)、钻石锹(1钻石)、钻石锄(2钻石)
+- **铁工具**: 铁剑(2铁锭)、铁镐(3铁锭)、铁斧(3铁锭)、铁锹(1铁锭)、铁锄(2铁锭)
+- **金工具**: 金剑(2金锭)、金镐(3金锭)、金斧(3金锭)、金锹(1金锭)、金锄(2金锭)
+- **石工具**: 石剑(2原石)、石镐(3原石)、石斧(3原石)、石锹(1原石)、石锄(2原石)
+
+#### 盔甲类
+- **钻石盔甲**: 头盔(5钻石)、胸甲(8钻石)、护腿(7钻石)、靴子(4钻石)
+- **铁盔甲**: 头盔(5铁锭)、胸甲(8铁锭)、护腿(7铁锭)、靴子(4铁锭)
+- **金盔甲**: 头盔(5金锭)、胸甲(8金锭)、护腿(7金锭)、靴子(4金锭)
+
+#### 下界合金装备
+- **下界合金工具**: 返还1个下界合金锭
+- **下界合金盔甲**: 返还1个下界合金锭
+
+### 特殊规则
+- **不拆解木制工具**: 木剑、木镐、木斧、木锹、木锄不会被拆解
+- **无视耐久度**: 无论工具还剩多少耐久,都返还固定数量的材料
+- **不返还非矿物部分**: 比如钻石剑只返还钻石,不返还木棍
+
+## 使用方法
+
+1. **合成拆解台**: 使用3铁锭、3钻石、3原石按照工作台配方合成
+2. **放置拆解台**: 将拆解台放置在世界中
+3. **放入工具**: 右键点击拆解台,将工具放入输入槽
+4. **等待拆解**: 拆解台会自动处理,完成后在输出槽获得材料
+
+## 技术细节
+
+- **模组ID**: `husj`
+- **Minecraft版本**: 1.21.9
+- **模组加载器**: Fabric
+- **依赖**: Fabric API
+
+## 开发信息
+
+这个模组是基于Fabric模组加载器开发的,包含了完整的方块实体、GUI界面和拆解逻辑实现。

+ 90 - 0
build.gradle

@@ -0,0 +1,90 @@
+plugins {
+	id 'net.fabricmc.fabric-loom-remap' version "${loom_version}"
+	id 'maven-publish'
+}
+
+version = project.mod_version
+group = project.maven_group
+
+base {
+	archivesName = project.archives_base_name
+}
+
+repositories {
+	// Add repositories to retrieve artifacts from in here.
+	// You should only use this when depending on other mods because
+	// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
+	// See https://docs.gradle.org/current/userguide/declaring_repositories.html
+	// for more information about repositories.
+}
+
+loom {
+	splitEnvironmentSourceSets()
+
+	mods {
+		"husj" {
+			sourceSet sourceSets.main
+			sourceSet sourceSets.client
+		}
+	}
+
+}
+
+dependencies {
+	// To change the versions see the gradle.properties file
+	minecraft "com.mojang:minecraft:${project.minecraft_version}"
+	mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
+	modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
+
+	// Fabric API. This is technically optional, but you probably want it anyway.
+	modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
+	
+}
+
+processResources {
+	inputs.property "version", project.version
+
+	filesMatching("fabric.mod.json") {
+		expand "version": inputs.properties.version
+	}
+}
+
+tasks.withType(JavaCompile).configureEach {
+	it.options.release = 21
+}
+
+java {
+	// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
+	// if it is present.
+	// If you remove this line, sources will not be generated.
+	withSourcesJar()
+
+	sourceCompatibility = JavaVersion.VERSION_21
+	targetCompatibility = JavaVersion.VERSION_21
+}
+
+jar {
+	inputs.property "archivesName", project.base.archivesName
+
+	from("LICENSE") {
+		rename { "${it}_${inputs.properties.archivesName}"}
+	}
+}
+
+// configure the maven publication
+publishing {
+	publications {
+		create("mavenJava", MavenPublication) {
+			artifactId = project.archives_base_name
+			from components.java
+		}
+	}
+
+	// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
+	repositories {
+		// Add repositories to publish to here.
+		// Notice: This block does NOT have the same function as the block in the top level.
+		// The repositories here will be used for publishing your artifact, not for
+		// retrieving dependencies.
+	}
+}

+ 21 - 0
gradle.properties

@@ -0,0 +1,21 @@
+# Done to increase the memory available to gradle.
+org.gradle.jvmargs=-Xmx1G
+org.gradle.parallel=true
+
+# IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349
+org.gradle.configuration-cache=false
+
+# Fabric Properties
+# check these on https://fabricmc.net/develop
+minecraft_version=1.21.9
+yarn_mappings=1.21.9+build.1
+loader_version=0.18.1
+loom_version=1.14-SNAPSHOT
+
+# Mod Properties
+mod_version=1.0.0
+maven_group=com.husj
+archives_base_name=husj
+
+# Dependencies
+fabric_version=0.134.0+1.21.9

BIN
gradle/wrapper/gradle-wrapper.jar


+ 7 - 0
gradle/wrapper/gradle-wrapper.properties

@@ -0,0 +1,7 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists

+ 248 - 0
gradlew

@@ -0,0 +1,248 @@
+#!/bin/sh
+
+#
+# Copyright © 2015 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+##############################################################################
+#
+#   Gradle start up script for POSIX generated by Gradle.
+#
+#   Important for running:
+#
+#   (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+#       noncompliant, but you have some other compliant shell such as ksh or
+#       bash, then to run this script, type that shell name before the whole
+#       command line, like:
+#
+#           ksh Gradle
+#
+#       Busybox and similar reduced shells will NOT work, because this script
+#       requires all of these POSIX shell features:
+#         * functions;
+#         * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+#           «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+#         * compound commands having a testable exit status, especially «case»;
+#         * various built-in commands including «command», «set», and «ulimit».
+#
+#   Important for patching:
+#
+#   (2) This script targets any POSIX shell, so it avoids extensions provided
+#       by Bash, Ksh, etc; in particular arrays are avoided.
+#
+#       The "traditional" practice of packing multiple parameters into a
+#       space-separated string is a well documented source of bugs and security
+#       problems, so this is (mostly) avoided, by progressively accumulating
+#       options in "$@", and eventually passing that to Java.
+#
+#       Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+#       and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+#       see the in-line comments for details.
+#
+#       There are tweaks for specific operating systems such as AIX, CygWin,
+#       Darwin, MinGW, and NonStop.
+#
+#   (3) This script is generated from the Groovy template
+#       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/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+    APP_HOME=${app_path%"${app_path##*/}"}  # leaves a trailing /; empty if no leading path
+    [ -h "$app_path" ]
+do
+    ls=$( ls -ld "$app_path" )
+    link=${ls#*' -> '}
+    case $link in             #(
+      /*)   app_path=$link ;; #(
+      *)    app_path=$APP_HOME$link ;;
+    esac
+done
+
+# This is normally unused
+# 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+    echo "$*"
+} >&2
+
+die () {
+    echo
+    echo "$*"
+    echo
+    exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in                #(
+  CYGWIN* )         cygwin=true  ;; #(
+  Darwin* )         darwin=true  ;; #(
+  MSYS* | MINGW* )  msys=true    ;; #(
+  NONSTOP* )        nonstop=true ;;
+esac
+
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD=$JAVA_HOME/jre/sh/java
+    else
+        JAVACMD=$JAVA_HOME/bin/java
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD=java
+    if ! command -v java >/dev/null 2>&1
+    then
+        die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+    case $MAX_FD in #(
+      max*)
+        # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+        # shellcheck disable=SC2039,SC3045
+        MAX_FD=$( ulimit -H -n ) ||
+            warn "Could not query maximum file descriptor limit"
+    esac
+    case $MAX_FD in  #(
+      '' | soft) :;; #(
+      *)
+        # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+        # shellcheck disable=SC2039,SC3045
+        ulimit -n "$MAX_FD" ||
+            warn "Could not set maximum file descriptor limit to $MAX_FD"
+    esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+#   * args from the command line
+#   * the main class name
+#   * -classpath
+#   * -D...appname settings
+#   * --module-path (only if needed)
+#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+    APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+
+    JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    for arg do
+        if
+            case $arg in                                #(
+              -*)   false ;;                            # don't mess with options #(
+              /?*)  t=${arg#/} t=/${t%%/*}              # looks like a POSIX filepath
+                    [ -e "$t" ] ;;                      #(
+              *)    false ;;
+            esac
+        then
+            arg=$( cygpath --path --ignore --mixed "$arg" )
+        fi
+        # Roll the args list around exactly as many times as the number of
+        # args, so each arg winds up back in the position where it started, but
+        # possibly modified.
+        #
+        # NB: a `for` loop captures its iteration list before it begins, so
+        # changing the positional parameters here affects neither the number of
+        # iterations, nor the values presented in `arg`.
+        shift                   # remove old arg
+        set -- "$@" "$arg"      # push replacement arg
+    done
+fi
+
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+#   * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+#     and any embedded shellness will be escaped.
+#   * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+#     treated as '${Hostname}' itself on the command line.
+
+set -- \
+        "-Dorg.gradle.appname=$APP_BASE_NAME" \
+        -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+        "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+    die "xargs is not available"
+fi
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+#   readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+#   set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+        printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+        xargs -n1 |
+        sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+        tr '\n' ' '
+    )" '"$@"'
+
+exec "$JAVACMD" "$@"

+ 93 - 0
gradlew.bat

@@ -0,0 +1,93 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem      https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@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 ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if %ERRORLEVEL% equ 0 goto execute
+
+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
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+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
+
+:execute
+@rem Setup the command line
+
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if %ERRORLEVEL% equ 0 goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 10 - 0
settings.gradle

@@ -0,0 +1,10 @@
+pluginManagement {
+	repositories {
+		maven {
+			name = 'Fabric'
+			url = 'https://maven.fabricmc.net/'
+		}
+		mavenCentral()
+		gradlePluginPortal()
+	}
+}

+ 14 - 0
src/client/java/com/husj/HusjClient.java

@@ -0,0 +1,14 @@
+package com.husj;
+
+import com.husj.client.screen.DisassemblerScreen;
+import com.husj.screen.ModScreenHandlers;
+import net.fabricmc.api.ClientModInitializer;
+import net.minecraft.client.gui.screen.ingame.HandledScreens;
+
+public class HusjClient implements ClientModInitializer {
+	@Override
+	public void onInitializeClient() {
+		// 注册拆解台屏幕
+		HandledScreens.register(ModScreenHandlers.DISASSEMBLER_SCREEN_HANDLER, DisassemblerScreen::new);
+	}
+}

+ 56 - 0
src/client/java/com/husj/client/screen/DisassemblerScreen.java

@@ -0,0 +1,56 @@
+package com.husj.client.screen;
+
+import com.husj.screen.DisassemblerScreenHandler;
+import net.minecraft.client.gui.DrawContext;
+import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.client.gui.screen.ingame.HandledScreen;
+import net.minecraft.client.render.*;
+import net.minecraft.client.render.texture.TextureManager;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.text.Text;
+import net.minecraft.util.Identifier;
+
+public class DisassemblerScreen extends HandledScreen<DisassemblerScreenHandler> {
+    private static final Identifier TEXTURE = Identifier.of("husj", "textures/gui/container/disassembler.png");
+
+    public DisassemblerScreen(DisassemblerScreenHandler handler, PlayerInventory inventory, Text title) {
+        super(handler, inventory, title);
+    }
+
+    @Override
+    protected void init() {
+        super.init();
+        titleX = (backgroundWidth - textRenderer.getWidth(title)) / 2;
+    }
+
+    @Override
+    protected void drawBackground(DrawContext context, float delta, int mouseX, int mouseY) {
+        int x = (width - backgroundWidth) / 2;
+        int y = (height - backgroundHeight) / 2;
+        
+        MatrixStack matrices = context.getMatrices();
+        TextureManager textureManager = context.getTextureManager();
+        
+        // 绑定纹理
+        textureManager.bindTexture(TEXTURE);
+        
+        // 绘制背景
+        RenderSystem.enableBlend();
+        DrawableHelper.drawTexture(matrices, x, y, 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 256);
+        
+        // 绘制进度条
+        if (handler.isCrafting()) {
+            int progress = handler.getScaledProgress();
+            DrawableHelper.drawTexture(matrices, x + 79, y + 34, 176.0F, 0.0F, progress + 1, 16, 256, 256);
+        }
+        RenderSystem.disableBlend();
+    }
+
+    @Override
+    public void render(DrawContext context, int mouseX, int mouseY, float delta) {
+        renderBackground(context, mouseX, mouseY, delta);
+        super.render(context, mouseX, mouseY, delta);
+        drawMouseoverTooltip(context, mouseX, mouseY);
+    }
+}

+ 15 - 0
src/client/java/com/husj/mixin/client/ExampleClientMixin.java

@@ -0,0 +1,15 @@
+package com.husj.mixin.client;
+
+import net.minecraft.client.MinecraftClient;
+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(MinecraftClient.class)
+public class ExampleClientMixin {
+	@Inject(at = @At("HEAD"), method = "run")
+	private void init(CallbackInfo info) {
+		// This code is injected into the start of MinecraftClient.run()V
+	}
+}

+ 11 - 0
src/client/resources/husj.client.mixins.json

@@ -0,0 +1,11 @@
+{
+	"required": true,
+	"package": "com.husj.mixin.client",
+	"compatibilityLevel": "JAVA_21",
+	"client": [
+		"ExampleClientMixin"
+	],
+	"injectors": {
+		"defaultRequire": 1
+	}
+}

+ 27 - 0
src/main/java/com/husj/Husj.java

@@ -0,0 +1,27 @@
+package com.husj;
+
+import com.husj.block.entity.DisassemblerBlockEntity;
+import net.fabricmc.api.ModInitializer;
+import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Husj implements ModInitializer {
+	public static final String MOD_ID = "husj";
+
+	// This logger is used to write text to the console and the log file.
+	// It is considered best practice to use your mod id as the logger's name.
+	// That way, it's clear which mod wrote info, warnings, and errors.
+	public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
+
+	@Override
+	public void onInitialize() {
+		// 注册方块和方块实体
+		ModBlocks.registerModBlocks();
+		
+		// 注册屏幕处理器
+		com.husj.screen.ModScreenHandlers.registerScreenHandlers();
+
+		LOGGER.info("Husj模组已加载!拆解台功能已启用。");
+	}
+}

+ 38 - 0
src/main/java/com/husj/ModBlocks.java

@@ -0,0 +1,38 @@
+package com.husj;
+
+import com.husj.block.DisassemblerBlock;
+import com.husj.block.entity.DisassemblerBlockEntity;
+import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
+import net.minecraft.block.AbstractBlock;
+import net.minecraft.block.Block;
+import net.minecraft.block.Blocks;
+import net.minecraft.block.entity.BlockEntityType;
+import net.minecraft.item.BlockItem;
+import net.minecraft.item.Item;
+import net.minecraft.registry.Registries;
+import net.minecraft.registry.Registry;
+import net.minecraft.util.Identifier;
+
+public class ModBlocks {
+    public static final Block DISASSEMBLER_BLOCK = registerBlock("disassembler",
+        new DisassemblerBlock(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).nonOpaque()));
+
+    public static final BlockEntityType<DisassemblerBlockEntity> DISASSEMBLER_BLOCK_ENTITY =
+        Registry.register(Registries.BLOCK_ENTITY_TYPE,
+            Identifier.of("husj", "disassembler_block_entity"),
+            FabricBlockEntityTypeBuilder.create(DisassemblerBlockEntity::new, DISASSEMBLER_BLOCK).build());
+
+    private static Block registerBlock(String name, Block block) {
+        registerBlockItem(name, block);
+        return Registry.register(Registries.BLOCK, Identifier.of("husj", name), block);
+    }
+
+    private static Item registerBlockItem(String name, Block block) {
+        return Registry.register(Registries.ITEM, Identifier.of("husj", name),
+            new BlockItem(block, new Item.Settings()));
+    }
+
+    public static void registerModBlocks() {
+        Husj.LOGGER.info("Registering ModBlocks for " + Husj.MOD_ID);
+    }
+}

+ 78 - 0
src/main/java/com/husj/block/DisassemblerBlock.java

@@ -0,0 +1,78 @@
+package com.husj.block;
+
+import com.husj.block.entity.DisassemblerBlockEntity;
+import com.mojang.serialization.MapCodec;
+import net.minecraft.block.*;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.block.entity.BlockEntityTicker;
+import net.minecraft.block.entity.BlockEntityType;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.screen.NamedScreenHandlerFactory;
+import net.minecraft.screen.ScreenHandlerContext;
+import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
+import net.minecraft.text.Text;
+import net.minecraft.util.ActionResult;
+import net.minecraft.util.hit.BlockHitResult;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+import org.jetbrains.annotations.Nullable;
+
+public class DisassemblerBlock extends BlockWithEntity {
+    private static final Text TITLE = Text.translatable("container.husj.disassembler");
+
+    public DisassemblerBlock(Settings settings) {
+        super(settings);
+    }
+
+    @Override
+    protected MapCodec<? extends BlockWithEntity> getCodec() {
+        return null;
+    }
+
+    @Override
+    public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
+        return new DisassemblerBlockEntity(pos, state);
+    }
+
+    @Override
+    public BlockRenderType getRenderType(BlockState state) {
+        return BlockRenderType.MODEL;
+    }
+
+    @Override
+    public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, BlockHitResult hit) {
+        if (!world.isClient()) {
+            NamedScreenHandlerFactory screenHandlerFactory = state.createScreenHandlerFactory(world, pos);
+            if (screenHandlerFactory != null) {
+                player.openHandledScreen(screenHandlerFactory);
+            }
+        }
+        return ActionResult.SUCCESS;
+    }
+
+    @Override
+    @Nullable
+    public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
+        BlockEntity blockEntity = world.getBlockEntity(pos);
+        if (blockEntity instanceof DisassemblerBlockEntity) {
+            return new SimpleNamedScreenHandlerFactory((syncId, inventory, player) -> 
+                new com.husj.screen.DisassemblerScreenHandler(syncId, inventory, ScreenHandlerContext.create(world, pos)), TITLE);
+        }
+        return null;
+    }
+
+    @Nullable
+    @Override
+    public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
+        if (world.isClient()) {
+            return null;
+        }
+        return validateTicker(type, com.husj.ModBlocks.DISASSEMBLER_BLOCK_ENTITY, DisassemblerBlockEntity::tick);
+    }
+
+    @Nullable
+    protected static <E extends BlockEntity, A extends BlockEntity> BlockEntityTicker<A> validateTicker(
+            BlockEntityType<A> givenType, BlockEntityType<E> expectedType, BlockEntityTicker<? super E> ticker) {
+        return expectedType == givenType ? (BlockEntityTicker<A>) ticker : null;
+    }
+}

+ 182 - 0
src/main/java/com/husj/block/entity/DisassemblerBlockEntity.java

@@ -0,0 +1,182 @@
+package com.husj.block.entity;
+
+import com.husj.ModBlocks;
+import com.husj.recipe.DisassemblerRecipes;
+import net.minecraft.block.Block;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.inventory.Inventories;
+import net.minecraft.inventory.SimpleInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.nbt.NbtElement;
+import net.minecraft.nbt.NbtList;
+import net.minecraft.screen.NamedScreenHandlerFactory;
+import net.minecraft.screen.PropertyDelegate;
+import net.minecraft.screen.ScreenHandler;
+import net.minecraft.text.Text;
+import net.minecraft.util.collection.DefaultedList;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+import org.jetbrains.annotations.Nullable;
+
+public class DisassemblerBlockEntity extends BlockEntity implements NamedScreenHandlerFactory, ImplementedInventory {
+    private final DefaultedList<ItemStack> inventory = DefaultedList.ofSize(2, ItemStack.EMPTY);
+    private static final int INPUT_SLOT = 0;
+    private static final int OUTPUT_SLOT = 1;
+
+    protected final PropertyDelegate propertyDelegate;
+    private int progress = 0;
+    private int maxProgress = 100;
+
+    public DisassemblerBlockEntity(BlockPos pos, BlockState state) {
+        super(ModBlocks.DISASSEMBLER_BLOCK_ENTITY, pos, state);
+        this.propertyDelegate = new PropertyDelegate() {
+            @Override
+            public int get(int index) {
+                return switch (index) {
+                    case 0 -> DisassemblerBlockEntity.this.progress;
+                    case 1 -> DisassemblerBlockEntity.this.maxProgress;
+                    default -> 0;
+                };
+            }
+
+            @Override
+            public void set(int index, int value) {
+                switch (index) {
+                    case 0 -> DisassemblerBlockEntity.this.progress = value;
+                    case 1 -> DisassemblerBlockEntity.this.maxProgress = value;
+                }
+            }
+
+            @Override
+            public int size() {
+                return 2;
+            }
+        };
+    }
+
+    @Override
+    public DefaultedList<ItemStack> getItems() {
+        return inventory;
+    }
+
+    @Override
+    public void markDirty() {
+        if (this.world != null) {
+            BlockState state = this.world.getBlockState(this.pos);
+            this.world.markDirty(this.pos);
+            this.world.updateListeners(this.pos, state, state, Block.NOTIFY_ALL);
+        }
+    }
+
+    @Override
+    public Text getDisplayName() {
+        return Text.translatable("container.husj.disassembler");
+    }
+
+    @Nullable
+    @Override
+    public ScreenHandler createMenu(int syncId, PlayerInventory playerInventory, PlayerEntity player) {
+        return new com.husj.screen.DisassemblerScreenHandler(syncId, playerInventory, this, this.propertyDelegate);
+    }
+
+    @Override
+    protected void writeNbt(NbtCompound nbt) {
+        super.writeNbt(nbt);
+        
+        // 手动保存物品栏
+        NbtList itemList = new NbtList();
+        for (int i = 0; i < inventory.size(); i++) {
+            ItemStack stack = inventory.get(i);
+            if (!stack.isEmpty()) {
+                NbtCompound itemNbt = new NbtCompound();
+                itemNbt.putByte("Slot", (byte) i);
+                stack.writeNbt(itemNbt);
+                itemList.add(itemNbt);
+            }
+        }
+        nbt.put("Items", itemList);
+        
+        nbt.putInt("disassembler.progress", progress);
+    }
+
+    @Override
+    protected void readNbt(NbtCompound nbt) {
+        super.readNbt(nbt);
+        
+        // 手动读取物品栏
+        inventory.clear();
+        NbtList itemList = nbt.getList("Items", NbtElement.COMPOUND_TYPE);
+        for (int i = 0; i < itemList.size(); i++) {
+            NbtCompound itemNbt = itemList.getCompound(i);
+            int slot = itemNbt.getByte("Slot") & 0xFF;
+            if (slot >= 0 && slot < inventory.size()) {
+                inventory.set(slot, ItemStack.fromNbt(itemNbt));
+            }
+        }
+        
+        progress = nbt.getInt("disassembler.progress");
+    }
+
+    public static void tick(World world, BlockPos pos, BlockState state, DisassemblerBlockEntity blockEntity) {
+        if (world.isClient()) {
+            return;
+        }
+
+        if (hasRecipe(blockEntity)) {
+            blockEntity.progress++;
+            blockEntity.markDirty();
+            if (blockEntity.progress >= blockEntity.maxProgress) {
+                craftItem(blockEntity);
+            }
+        } else {
+            blockEntity.resetProgress();
+            blockEntity.markDirty();
+        }
+    }
+
+    private void resetProgress() {
+        this.progress = 0;
+    }
+
+    private static boolean hasRecipe(DisassemblerBlockEntity entity) {
+        SimpleInventory inventory = new SimpleInventory(entity.size());
+        for (int i = 0; i < entity.size(); i++) {
+            inventory.setStack(i, entity.getStack(i));
+        }
+
+        // 检查输入槽是否有可拆解的工具
+        ItemStack inputStack = entity.getStack(INPUT_SLOT);
+        if (inputStack.isEmpty()) {
+            return false;
+        }
+
+        // 检查输出槽是否为空
+        ItemStack outputStack = entity.getStack(OUTPUT_SLOT);
+        if (!outputStack.isEmpty()) {
+            return false;
+        }
+
+        // 检查是否为可拆解的工具
+        return DisassemblerRecipes.hasRecipe(inputStack);
+    }
+
+    private static void craftItem(DisassemblerBlockEntity entity) {
+        SimpleInventory inventory = new SimpleInventory(entity.size());
+        for (int i = 0; i < entity.size(); i++) {
+            inventory.setStack(i, entity.getStack(i));
+        }
+
+        ItemStack inputStack = entity.getStack(INPUT_SLOT);
+        ItemStack result = DisassemblerRecipes.getRecipeResult(inputStack);
+
+        if (!result.isEmpty()) {
+            entity.setStack(OUTPUT_SLOT, new ItemStack(result.getItem(), result.getCount()));
+            entity.getStack(INPUT_SLOT).decrement(1);
+            entity.resetProgress();
+        }
+    }
+}

+ 69 - 0
src/main/java/com/husj/block/entity/ImplementedInventory.java

@@ -0,0 +1,69 @@
+package com.husj.block.entity;
+
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.inventory.Inventories;
+import net.minecraft.inventory.Inventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.collection.DefaultedList;
+
+public interface ImplementedInventory extends Inventory {
+    DefaultedList<ItemStack> getItems();
+
+    @Override
+    default int size() {
+        return getItems().size();
+    }
+
+    @Override
+    default boolean isEmpty() {
+        for (int i = 0; i < size(); i++) {
+            ItemStack stack = getStack(i);
+            if (!stack.isEmpty()) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    default ItemStack getStack(int slot) {
+        return getItems().get(slot);
+    }
+
+    @Override
+    default ItemStack removeStack(int slot, int count) {
+        ItemStack result = Inventories.splitStack(getItems(), slot, count);
+        if (!result.isEmpty()) {
+            markDirty();
+        }
+        return result;
+    }
+
+    @Override
+    default ItemStack removeStack(int slot) {
+        return Inventories.removeStack(getItems(), slot);
+    }
+
+    @Override
+    default void setStack(int slot, ItemStack stack) {
+        getItems().set(slot, stack);
+        if (stack.getCount() > getMaxCountPerStack()) {
+            stack.setCount(getMaxCountPerStack());
+        }
+    }
+
+    @Override
+    default void clear() {
+        getItems().clear();
+    }
+
+    @Override
+    default void markDirty() {
+        // 在方块实体中实现
+    }
+
+    @Override
+    default boolean canPlayerUse(PlayerEntity player) {
+        return true;
+    }
+}

+ 15 - 0
src/main/java/com/husj/mixin/ExampleMixin.java

@@ -0,0 +1,15 @@
+package com.husj.mixin;
+
+import net.minecraft.server.MinecraftServer;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(MinecraftServer.class)
+public class ExampleMixin {
+	@Inject(at = @At("HEAD"), method = "loadWorld")
+	private void init(CallbackInfo info) {
+		// This code is injected into the start of MinecraftServer.loadWorld()V
+	}
+}

+ 105 - 0
src/main/java/com/husj/recipe/DisassemblerRecipes.java

@@ -0,0 +1,105 @@
+package com.husj.recipe;
+
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.item.Items;
+import net.minecraft.registry.Registries;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class DisassemblerRecipes {
+    private static final Map<Item, ItemStack> RECIPES = new HashMap<>();
+
+    static {
+        // 钻石工具
+        registerRecipe(Items.DIAMOND_SWORD, Items.DIAMOND, 2);
+        registerRecipe(Items.DIAMOND_PICKAXE, Items.DIAMOND, 3);
+        registerRecipe(Items.DIAMOND_AXE, Items.DIAMOND, 3);
+        registerRecipe(Items.DIAMOND_SHOVEL, Items.DIAMOND, 1);
+        registerRecipe(Items.DIAMOND_HOE, Items.DIAMOND, 2);
+
+        // 铁工具
+        registerRecipe(Items.IRON_SWORD, Items.IRON_INGOT, 2);
+        registerRecipe(Items.IRON_PICKAXE, Items.IRON_INGOT, 3);
+        registerRecipe(Items.IRON_AXE, Items.IRON_INGOT, 3);
+        registerRecipe(Items.IRON_SHOVEL, Items.IRON_INGOT, 1);
+        registerRecipe(Items.IRON_HOE, Items.IRON_INGOT, 2);
+
+        // 金工具
+        registerRecipe(Items.GOLDEN_SWORD, Items.GOLD_INGOT, 2);
+        registerRecipe(Items.GOLDEN_PICKAXE, Items.GOLD_INGOT, 3);
+        registerRecipe(Items.GOLDEN_AXE, Items.GOLD_INGOT, 3);
+        registerRecipe(Items.GOLDEN_SHOVEL, Items.GOLD_INGOT, 1);
+        registerRecipe(Items.GOLDEN_HOE, Items.GOLD_INGOT, 2);
+
+        // 石工具
+        registerRecipe(Items.STONE_SWORD, Items.COBBLESTONE, 2);
+        registerRecipe(Items.STONE_PICKAXE, Items.COBBLESTONE, 3);
+        registerRecipe(Items.STONE_AXE, Items.COBBLESTONE, 3);
+        registerRecipe(Items.STONE_SHOVEL, Items.COBBLESTONE, 1);
+        registerRecipe(Items.STONE_HOE, Items.COBBLESTONE, 2);
+
+        // 钻石盔甲
+        registerRecipe(Items.DIAMOND_HELMET, Items.DIAMOND, 5);
+        registerRecipe(Items.DIAMOND_CHESTPLATE, Items.DIAMOND, 8);
+        registerRecipe(Items.DIAMOND_LEGGINGS, Items.DIAMOND, 7);
+        registerRecipe(Items.DIAMOND_BOOTS, Items.DIAMOND, 4);
+
+        // 铁盔甲
+        registerRecipe(Items.IRON_HELMET, Items.IRON_INGOT, 5);
+        registerRecipe(Items.IRON_CHESTPLATE, Items.IRON_INGOT, 8);
+        registerRecipe(Items.IRON_LEGGINGS, Items.IRON_INGOT, 7);
+        registerRecipe(Items.IRON_BOOTS, Items.IRON_INGOT, 4);
+
+        // 金盔甲
+        registerRecipe(Items.GOLDEN_HELMET, Items.GOLD_INGOT, 5);
+        registerRecipe(Items.GOLDEN_CHESTPLATE, Items.GOLD_INGOT, 8);
+        registerRecipe(Items.GOLDEN_LEGGINGS, Items.GOLD_INGOT, 7);
+        registerRecipe(Items.GOLDEN_BOOTS, Items.GOLD_INGOT, 4);
+
+        // 下界合金工具(简化版,只返还下界合金)
+        registerRecipe(Items.NETHERITE_SWORD, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_PICKAXE, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_AXE, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_SHOVEL, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_HOE, Items.NETHERITE_INGOT, 1);
+
+        // 下界合金盔甲(简化版,只返还下界合金)
+        registerRecipe(Items.NETHERITE_HELMET, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_CHESTPLATE, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_LEGGINGS, Items.NETHERITE_INGOT, 1);
+        registerRecipe(Items.NETHERITE_BOOTS, Items.NETHERITE_INGOT, 1);
+    }
+
+    private static void registerRecipe(Item tool, Item material, int count) {
+        RECIPES.put(tool, new ItemStack(material, count));
+    }
+
+    public static boolean hasRecipe(ItemStack stack) {
+        return RECIPES.containsKey(stack.getItem());
+    }
+
+    public static ItemStack getRecipeResult(ItemStack stack) {
+        ItemStack result = RECIPES.get(stack.getItem());
+        if (result != null) {
+            return result.copy();
+        }
+        return ItemStack.EMPTY;
+    }
+
+    // 检查是否为矿物工具(排除木制工具)
+    public static boolean isMineralTool(ItemStack stack) {
+        Item item = stack.getItem();
+        
+        // 排除木制工具
+        if (item == Items.WOODEN_SWORD || item == Items.WOODEN_PICKAXE || 
+            item == Items.WOODEN_AXE || item == Items.WOODEN_SHOVEL || 
+            item == Items.WOODEN_HOE) {
+            return false;
+        }
+
+        // 检查是否为已注册的工具
+        return hasRecipe(stack);
+    }
+}

+ 113 - 0
src/main/java/com/husj/screen/DisassemblerScreenHandler.java

@@ -0,0 +1,113 @@
+package com.husj.screen;
+
+import com.husj.block.entity.DisassemblerBlockEntity;
+import net.minecraft.entity.player.PlayerEntity;
+import net.minecraft.entity.player.PlayerInventory;
+import net.minecraft.inventory.Inventory;
+import net.minecraft.inventory.SimpleInventory;
+import net.minecraft.item.ItemStack;
+import net.minecraft.screen.ArrayPropertyDelegate;
+import net.minecraft.screen.PropertyDelegate;
+import net.minecraft.screen.ScreenHandler;
+import net.minecraft.screen.ScreenHandlerContext;
+import net.minecraft.screen.slot.Slot;
+
+public class DisassemblerScreenHandler extends ScreenHandler {
+    private final Inventory inventory;
+    private final PropertyDelegate propertyDelegate;
+    protected ScreenHandlerContext context;
+
+    public DisassemblerScreenHandler(int syncId, PlayerInventory playerInventory) {
+        this(syncId, playerInventory, new SimpleInventory(2), new ArrayPropertyDelegate(2));
+    }
+
+    public DisassemblerScreenHandler(int syncId, PlayerInventory playerInventory, Inventory inventory, PropertyDelegate propertyDelegate) {
+        super(ModScreenHandlers.DISASSEMBLER_SCREEN_HANDLER, syncId);
+        checkSize(inventory, 2);
+        this.inventory = inventory;
+        this.propertyDelegate = propertyDelegate;
+        this.context = ScreenHandlerContext.EMPTY;
+
+        addProperties(propertyDelegate);
+
+        // 输入槽 (0)
+        this.addSlot(new Slot(inventory, 0, 56, 35) {
+            @Override
+            public boolean canInsert(ItemStack stack) {
+                return com.husj.recipe.DisassemblerRecipes.hasRecipe(stack);
+            }
+        });
+
+        // 输出槽 (1)
+        this.addSlot(new Slot(inventory, 1, 116, 35) {
+            @Override
+            public boolean canInsert(ItemStack stack) {
+                return false;
+            }
+        });
+
+        addPlayerInventory(playerInventory);
+        addPlayerHotbar(playerInventory);
+    }
+
+    public DisassemblerScreenHandler(int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
+        this(syncId, playerInventory, new SimpleInventory(2), new ArrayPropertyDelegate(2));
+        this.context = context;
+    }
+
+    public boolean isCrafting() {
+        return propertyDelegate.get(0) > 0;
+    }
+
+    public int getScaledProgress() {
+        int progress = propertyDelegate.get(0);
+        int maxProgress = propertyDelegate.get(1);
+        int progressArrowSize = 24;
+
+        return maxProgress != 0 && progress != 0 ? progress * progressArrowSize / maxProgress : 0;
+    }
+
+    @Override
+    public ItemStack quickMove(PlayerEntity player, int invSlot) {
+        ItemStack newStack = ItemStack.EMPTY;
+        Slot slot = this.slots.get(invSlot);
+        if (slot != null && slot.hasStack()) {
+            ItemStack originalStack = slot.getStack();
+            newStack = originalStack.copy();
+            if (invSlot < this.inventory.size()) {
+                if (!this.insertItem(originalStack, this.inventory.size(), this.slots.size(), true)) {
+                    return ItemStack.EMPTY;
+                }
+            } else if (!this.insertItem(originalStack, 0, this.inventory.size(), false)) {
+                return ItemStack.EMPTY;
+            }
+
+            if (originalStack.isEmpty()) {
+                slot.setStack(ItemStack.EMPTY);
+            } else {
+                slot.markDirty();
+            }
+        }
+
+        return newStack;
+    }
+
+    @Override
+    public boolean canUse(PlayerEntity player) {
+        return this.inventory.canPlayerUse(player);
+    }
+
+    private void addPlayerInventory(PlayerInventory playerInventory) {
+        for (int i = 0; i < 3; ++i) {
+            for (int l = 0; l < 9; ++l) {
+                this.addSlot(new Slot(playerInventory, l + i * 9 + 9, 8 + l * 18, 84 + i * 18));
+            }
+        }
+    }
+
+    private void addPlayerHotbar(PlayerInventory playerInventory) {
+        for (int i = 0; i < 9; ++i) {
+            this.addSlot(new Slot(playerInventory, i, 8 + i * 18, 142));
+        }
+    }
+}

+ 22 - 0
src/main/java/com/husj/screen/ModScreenHandlers.java

@@ -0,0 +1,22 @@
+package com.husj.screen;
+
+import net.minecraft.registry.Registries;
+import net.minecraft.registry.Registry;
+import net.minecraft.screen.ScreenHandlerType;
+import net.minecraft.util.Identifier;
+
+public class ModScreenHandlers {
+    public static final ScreenHandlerType<DisassemblerScreenHandler> DISASSEMBLER_SCREEN_HANDLER = 
+        Registry.register(Registries.SCREEN_HANDLER, 
+            Identifier.of("husj", "disassembler"),
+            new ScreenHandlerType<>(new ScreenHandlerType.Factory<DisassemblerScreenHandler>() {
+                @Override
+                public DisassemblerScreenHandler create(int syncId, net.minecraft.entity.player.PlayerInventory playerInventory) {
+                    return new DisassemblerScreenHandler(syncId, playerInventory);
+                }
+            }, null));
+
+    public static void registerScreenHandlers() {
+        // 注册在Husj类中调用
+    }
+}

+ 7 - 0
src/main/resources/assets/husj/blockstates/disassembler.json

@@ -0,0 +1,7 @@
+{
+  "variants": {
+    "": {
+      "model": "husj:block/disassembler"
+    }
+  }
+}

BIN
src/main/resources/assets/husj/icon.png


+ 5 - 0
src/main/resources/assets/husj/lang/en_us.json

@@ -0,0 +1,5 @@
+{
+  "block.husj.disassembler": "Disassembler",
+  "container.husj.disassembler": "Disassembler",
+  "item.husj.disassembler": "Disassembler"
+}

+ 5 - 0
src/main/resources/assets/husj/lang/zh_cn.json

@@ -0,0 +1,5 @@
+{
+  "block.husj.disassembler": "拆解台",
+  "container.husj.disassembler": "拆解台",
+  "item.husj.disassembler": "拆解台"
+}

+ 12 - 0
src/main/resources/assets/husj/models/block/disassembler.json

@@ -0,0 +1,12 @@
+{
+  "parent": "minecraft:block/cube",
+  "textures": {
+    "particle": "husj:block/disassembler_front",
+    "north": "husj:block/disassembler_front",
+    "south": "husj:block/disassembler_side",
+    "east": "husj:block/disassembler_side",
+    "west": "husj:block/disassembler_side",
+    "up": "husj:block/disassembler_top",
+    "down": "husj:block/disassembler_bottom"
+  }
+}

+ 3 - 0
src/main/resources/assets/husj/models/item/disassembler.json

@@ -0,0 +1,3 @@
+{
+  "parent": "husj:block/disassembler"
+}

+ 3 - 0
src/main/resources/assets/husj/textures/block/disassembler_bottom.png.mcmeta

@@ -0,0 +1,3 @@
+{
+  "comment": "拆解台底部纹理,实际游戏中需要真正的纹理图片"
+}

+ 3 - 0
src/main/resources/assets/husj/textures/block/disassembler_front.png.mcmeta

@@ -0,0 +1,3 @@
+{
+  "comment": "拆解台正面纹理,实际游戏中需要真正的纹理图片"
+}

+ 3 - 0
src/main/resources/assets/husj/textures/block/disassembler_side.png.mcmeta

@@ -0,0 +1,3 @@
+{
+  "comment": "拆解台侧面纹理,实际游戏中需要真正的纹理图片"
+}

+ 3 - 0
src/main/resources/assets/husj/textures/block/disassembler_top.png.mcmeta

@@ -0,0 +1,3 @@
+{
+  "comment": "拆解台顶部纹理,实际游戏中需要真正的纹理图片"
+}

+ 3 - 0
src/main/resources/assets/husj/textures/gui/container/disassembler.png.mcmeta

@@ -0,0 +1,3 @@
+{
+  "comment": "这是一个占位符文件,实际游戏中需要真正的纹理图片"
+}

+ 23 - 0
src/main/resources/data/husj/recipes/disassembler.json

@@ -0,0 +1,23 @@
+{
+  "type": "minecraft:crafting_shaped",
+  "pattern": [
+    "III",
+    "DDD",
+    "SSS"
+  ],
+  "key": {
+    "I": {
+      "item": "minecraft:iron_ingot"
+    },
+    "D": {
+      "item": "minecraft:diamond"
+    },
+    "S": {
+      "item": "minecraft:cobblestone"
+    }
+  },
+  "result": {
+    "id": "husj:disassembler",
+    "count": 1
+  }
+}

+ 41 - 0
src/main/resources/fabric.mod.json

@@ -0,0 +1,41 @@
+{
+	"schemaVersion": 1,
+	"id": "husj",
+	"version": "${version}",
+	"name": "husj",
+	"description": "This is an example description! Tell everyone what your mod is about!",
+	"authors": [
+		"Me!"
+	],
+	"contact": {
+		"homepage": "https://fabricmc.net/",
+		"sources": "https://github.com/FabricMC/fabric-example-mod"
+	},
+	"license": "CC0-1.0",
+	"icon": "assets/husj/icon.png",
+	"environment": "*",
+	"entrypoints": {
+		"main": [
+			"com.husj.Husj"
+		],
+		"client": [
+			"com.husj.HusjClient"
+		]
+	},
+	"mixins": [
+		"husj.mixins.json",
+		{
+			"config": "husj.client.mixins.json",
+			"environment": "client"
+		}
+	],
+	"depends": {
+		"fabricloader": ">=0.18.1",
+		"minecraft": "~1.21.9",
+		"java": ">=21",
+		"fabric-api": "*"
+	},
+	"suggests": {
+		"another-mod": "*"
+	}
+}

+ 14 - 0
src/main/resources/husj.mixins.json

@@ -0,0 +1,14 @@
+{
+	"required": true,
+	"package": "com.husj.mixin",
+	"compatibilityLevel": "JAVA_21",
+	"mixins": [
+		"ExampleMixin"
+	],
+	"injectors": {
+		"defaultRequire": 1
+	},
+	"overwrites": {
+		"requireAnnotations": true
+	}
+}