14 Commits

Author SHA1 Message Date
f8e3c5eb84 Update rmc.mixins.json 2024-05-02 17:41:51 +08:00
4748808d79 Update README.md 2024-05-02 17:27:15 +08:00
979d816fb4 update game version to 1.20.6 2024-05-02 15:30:00 +08:00
fe97fb4edb update game version to 1.20.6 2024-05-02 15:28:26 +08:00
5eb0e7a5ab update game version to 1.20.6 2024-05-02 15:25:05 +08:00
51fcb9435c update 2024-04-14 12:25:48 +08:00
7808c64a53 update gradle 2024-03-24 09:11:21 +08:00
f5ccfd4d69 update loom 2024-03-24 09:11:05 +08:00
74a996cf84 remove kotlin dep 2024-03-24 09:04:30 +08:00
b72be0696f update 2024-03-24 09:04:21 +08:00
5601fe8afe update mod info 2024-03-24 09:04:14 +08:00
bf817ca624 fix language files 2024-03-24 09:04:04 +08:00
64b4e70773 update README.md 2024-03-24 09:03:53 +08:00
3be969730a fix 2 2023-11-21 13:11:43 +08:00
18 changed files with 62 additions and 193 deletions

View File

@@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
java:
- 17
- 21
os:
- ubuntu-latest
runs-on: ${{ matrix.os }}

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
/.idea
/build
/run
/.gradle
/.gradle
/remappedSrc

View File

@@ -4,24 +4,17 @@
<p>在游戏中添加统计信息来统计玩家挖掘数据, 可以借助计分板显示出数据</p>
<img src="https://static-flax.vercel.app/static/kotlin/made-with-kotlin.svg">
<br>
<img alt="GitHub" src="https://img.shields.io/github/license/DangoTown/RMC?logo=apache">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/DangoTown/RMC/ci.yaml">
<img alt="Kotlin Version" src="https://img.shields.io/badge/Kotlin-1.8.22-pink?logo=kotlin">
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/RTAkland/RMC/main.yml">
</div>
# 依赖
* 由于使用了`Kotlin`语言所以你需要放置`fabric-language-kotlin`在你的mods文件夹内. 点击[这里](https://github.com/FabricMC/fabric-language-kotlin/releases/latest)快速下载最新版本的`fabric-language-kotlin`
# 使用
* 默认是不会记录玩家挖掘数据的, 你需要添加一个计分板, 准则为`minecraft.custom:minecraft.rmc`的一个计分板, 以下为实例命令, 如有需要可以自行修改
* 默认是不会记录玩家挖掘数据的, 你需要添加一个计分板, 准则为`minecraft.custom:minecraft.rmc.dig`的一个计分板, 以下为实例命令, 如有需要可以自行修改
* `/scoreboard objectives add rmc minecraft.custom:minecraft.rmc {"text":"挖掘榜", "color":"yellow"}`
* `/scoreboard objectives add rmc minecraft.custom:minecraft.rmc.dig {"text":"挖掘榜", "color":"yellow"}`
* 上面的命令执行完成后所有玩家破坏任何方块都会使其加1(常规情况下破坏方块), 使用以下命令来显示出计分板

View File

@@ -1,7 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.8.22'
id 'fabric-loom' version '1.6-SNAPSHOT'
}
version = project.mod_version
@@ -17,9 +15,6 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation("net.fabricmc:fabric-language-kotlin:1.9.6+kotlin.1.8.22")
implementation 'it.unimi.dsi:fastutil:8.5.12'
}
processResources {
@@ -35,7 +30,7 @@ processResources {
}
}
def targetJavaVersion = 17
def targetJavaVersion = 21
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {

View File

@@ -3,15 +3,15 @@ org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.23
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.10
# Mod Properties
mod_version = 0.1.0
mod_version = 0.2
maven_group = cn.rtast
archives_base_name = RMC
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.90.0+1.20.2
fabric_version=0.97.8+1.20.6

Binary file not shown.

View File

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

22
gradlew vendored
View File

@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# 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
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
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.
@@ -141,7 +145,7 @@ 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=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +202,11 @@ 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 $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_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" \

20
gradlew.bat vendored
View File

@@ -43,11 +43,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 +57,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

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2023 RTAkland
* Copyright 2024 RTAkland
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,25 +14,23 @@
* limitations under the License.
*/
package cn.rtast.rmc.mixin;
package cn.rtast.rmc;
import net.fabricmc.api.ModInitializer;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.stat.StatFormatter;
import net.minecraft.stat.StatType;
import net.minecraft.stat.Stats;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
@Mixin(Stats.class)
public interface StatsAccessor {
@Invoker
static Identifier callRegister(String string, StatFormatter statFormatter) {
return null;
public class RMC implements ModInitializer {
public static final Identifier RMC_STAT_ID = new Identifier("rmc", "dig");
@Override
public void onInitialize() {
Registry.register(Registries.CUSTOM_STAT, "rmc.dig", RMC_STAT_ID);
Stats.CUSTOM.getOrCreateStat(RMC_STAT_ID);
}
@Invoker
static <T> StatType<T> callRegisterType(String string, Registry<T> registry) {
return null;
}
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright 2023 RTAkland
*
* 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
*
* http://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.
*/
package cn.rtast.rmc
import cn.rtast.rmc.mixin.StatsAccessor
import com.google.common.collect.Sets
import net.fabricmc.api.DedicatedServerModInitializer
import net.minecraft.stat.Stat
import net.minecraft.stat.StatFormatter
import net.minecraft.util.Identifier
class RMC : DedicatedServerModInitializer {
companion object {
private val stats: MutableSet<String> = Sets.newHashSet()
var RMC_STAT_ID: Identifier? = null
private fun addStat(stat: Identifier) {
stats.add(stat.toString())
}
fun registerStats() {
addStat(StatsAccessor.callRegister("rmc", StatFormatter.TIME).also { RMC_STAT_ID = it })
}
operator fun contains(stat: Stat<*>): Boolean {
return stats.contains(stat.value.toString())
}
}
override fun onInitializeServer() {
println("RMC 已加载!")
}
}

View File

@@ -25,12 +25,13 @@ import net.minecraft.world.World;
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;
@Mixin(Block.class)
public class BlockMixin {
@Inject(method = "onBreak", at = @At("HEAD"))
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfo ci) {
player.increaseStat(RMC.Companion.getRMC_STAT_ID(), 1);
public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player, CallbackInfoReturnable<BlockState> cir) {
player.increaseStat(RMC.RMC_STAT_ID, 1);
}
}

View File

@@ -1,38 +0,0 @@
/*
* Copyright 2023 RTAkland
*
* 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
*
* http://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.
*/
package cn.rtast.rmc.mixin;
import cn.rtast.rmc.RMC;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.ServerStatHandler;
import net.minecraft.stat.Stat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(ServerStatHandler.class)
public abstract class ServerStatHandlerMixin {
@Redirect(method = "sendStats", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/Object2IntMap;put(Ljava/lang/Object;I)I"), remap = false)
private int excludeCustomStats(Object2IntMap<Stat<?>> map, Object object, int value, ServerPlayerEntity player) {
if (!RMC.Companion.contains((Stat<?>) object)) {
return map.put((Stat<?>) object, value);
} else {
return map.defaultReturnValue();
}
}
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2023 RTAkland
*
* 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
*
* http://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.
*/
package cn.rtast.rmc.mixin;
import cn.rtast.rmc.RMC;
import net.minecraft.stat.Stats;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(Stats.class)
public class StatsMixin {
static {
RMC.Companion.registerStats();
}
}

View File

@@ -1,3 +1,3 @@
{
"stat.rmc.rmc_stat": "挖掘数"
"stat.rmc.dig": "Total number of blocks destroyed"
}

View File

@@ -1,3 +1,3 @@
{
"stat.rmc.rmc_stat": "Total number of blocks destroyed."
"stat.rmc.dig": "破坏方块数量"
}

View File

@@ -13,13 +13,10 @@
},
"license": "Apache-2.0",
"icon": "assets/rmc/icon.png",
"environment": "server",
"environment": "*",
"entrypoints": {
"server": [
{
"adapter": "kotlin",
"value": "cn.rtast.rmc.RMC"
}
"main": [
"cn.rtast.rmc.RMC"
]
},
"mixins": [

View File

@@ -4,12 +4,7 @@
"package": "cn.rtast.rmc.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BlockMixin",
"ServerStatHandlerMixin",
"StatsAccessor",
"StatsMixin"
],
"client": [
"BlockMixin"
],
"injectors": {
"defaultRequire": 1