Compare commits
7 Commits
v0.1.1-fix
...
v0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 7808c64a53 | |||
| f5ccfd4d69 | |||
| 74a996cf84 | |||
| b72be0696f | |||
| 5601fe8afe | |||
| bf817ca624 | |||
| 64b4e70773 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/.idea
|
||||
/build
|
||||
/run
|
||||
/.gradle
|
||||
/.gradle
|
||||
/remappedSrc
|
||||
11
README.md
11
README.md
@@ -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">
|
||||
</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(常规情况下破坏方块), 使用以下命令来显示出计分板
|
||||
|
||||
|
||||
11
build.gradle
11
build.gradle
@@ -1,7 +1,6 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.2-SNAPSHOT'
|
||||
id 'fabric-loom' version '1.5-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.8.22'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
@@ -11,20 +10,12 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
embed
|
||||
compile.extendsFrom(embed)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
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")
|
||||
|
||||
embed(api("it.unimi.dsi:fastutil:8.5.12"))
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
@@ -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.4
|
||||
yarn_mappings=1.20.4+build.3
|
||||
loader_version=0.15.7
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 0.1.1-fix2
|
||||
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.96.11+1.20.4
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
22
gradlew
vendored
22
gradlew
vendored
@@ -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" \
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 已加载!")
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
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);
|
||||
player.increaseStat(RMC.RMC_STAT_ID, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"stat.rmc.rmc_stat": "挖掘数"
|
||||
"stat.rmc.dig": "Total number of blocks destroyed"
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"stat.rmc.rmc_stat": "Total number of blocks destroyed."
|
||||
"stat.rmc.dig": "破坏方块数量"
|
||||
}
|
||||
@@ -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": [
|
||||
|
||||
@@ -4,12 +4,7 @@
|
||||
"package": "cn.rtast.rmc.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"BlockMixin",
|
||||
"ServerStatHandlerMixin",
|
||||
"StatsAccessor",
|
||||
"StatsMixin"
|
||||
],
|
||||
"client": [
|
||||
"BlockMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
||||
Reference in New Issue
Block a user