update
This commit is contained in:
@@ -17,31 +17,36 @@ package cn.rtast.rminecounter
|
|||||||
|
|
||||||
import cn.rtast.rminecounter.mixins.StatsAccessor
|
import cn.rtast.rminecounter.mixins.StatsAccessor
|
||||||
import com.google.common.collect.Sets
|
import com.google.common.collect.Sets
|
||||||
|
import net.fabricmc.api.ModInitializer
|
||||||
import net.minecraft.entity.player.PlayerEntity
|
import net.minecraft.entity.player.PlayerEntity
|
||||||
import net.minecraft.stat.Stat
|
import net.minecraft.stat.Stat
|
||||||
import net.minecraft.stat.StatFormatter
|
import net.minecraft.stat.StatFormatter
|
||||||
import net.minecraft.util.Identifier
|
import net.minecraft.util.Identifier
|
||||||
|
|
||||||
|
|
||||||
object RMineCounter {
|
object RMineCounter : ModInitializer {
|
||||||
|
|
||||||
private var RMCC: Identifier? = null
|
private var RMC: Identifier? = null
|
||||||
|
|
||||||
private val stats: MutableSet<String> = Sets.newHashSet()
|
private val stats: MutableSet<String> = Sets.newHashSet()
|
||||||
|
|
||||||
private fun addStat(stat: Identifier) {
|
private fun addStat(stat: Identifier) {
|
||||||
this.stats.add(stat.toString())
|
stats.add(stat.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun registerStats() {
|
fun registerStats() {
|
||||||
this.addStat(StatsAccessor.callRegister("rmc", StatFormatter.DEFAULT).also { this.RMCC = it })
|
addStat(StatsAccessor.callRegister("rmc", StatFormatter.DEFAULT).also { RMC = it })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPlayerMineFinish(player: PlayerEntity) {
|
fun onPlayerMineFinish(player: PlayerEntity) {
|
||||||
player.increaseStat(this.RMCC, 1)
|
player.increaseStat(RMC, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun contains(stat: Stat<*>): Boolean {
|
operator fun contains(stat: Stat<*>): Boolean {
|
||||||
return this.stats.contains(stat.value.toString())
|
return stats.contains(stat.value.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInitialize() {
|
||||||
|
println("RMC 已加载!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,12 @@
|
|||||||
"icon": "assets/rminecounter/icon.png",
|
"icon": "assets/rminecounter/icon.png",
|
||||||
"environment": "*",
|
"environment": "*",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": []
|
"main": [
|
||||||
|
{
|
||||||
|
"adapter": "kotlin",
|
||||||
|
"value": "cn.rtast.rminecounter.RMineCounter"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"rminecounter.mixins.json"
|
"rminecounter.mixins.json"
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"compatibilityLevel": "JAVA_17",
|
"compatibilityLevel": "JAVA_17",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"BlockMixin",
|
"BlockMixin",
|
||||||
|
"ServerPlayNetworkHandlerAccessor",
|
||||||
"ServerStatHandlerMixin",
|
"ServerStatHandlerMixin",
|
||||||
"StatsAccessor",
|
"StatsAccessor",
|
||||||
"StatsMixin"
|
"StatsMixin"
|
||||||
|
|||||||
Reference in New Issue
Block a user