update README.md
This commit is contained in:
@@ -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 已加载!")
|
||||
}
|
||||
}
|
||||
@@ -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,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 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;
|
||||
}
|
||||
|
||||
@Invoker
|
||||
static <T> StatType<T> callRegisterType(String string, Registry<T> registry) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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 +0,0 @@
|
||||
{
|
||||
"stat.rmc.rmc_stat": "挖掘数"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"stat.rmc.rmc_stat": "Total number of blocks destroyed."
|
||||
}
|
||||
Reference in New Issue
Block a user