stuff
This commit is contained in:
@@ -29,7 +29,7 @@ fun neuCommand() = literal("neu") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
thenLiteral("dev") {
|
thenLiteral("dev") {
|
||||||
val sbData = thenLiteral("sbdata") {
|
thenLiteral("sbdata") {
|
||||||
thenExecute {
|
thenExecute {
|
||||||
source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.profile", SBData.profileCuteName))
|
source.sendFeedback(Text.translatable("notenoughupdates.sbinfo.profile", SBData.profileCuteName))
|
||||||
val locrawInfo = SBData.locraw
|
val locrawInfo = SBData.locraw
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package moe.nea.notenoughupdates.events
|
||||||
|
|
||||||
|
class WorldReadyEvent : NEUEvent() {
|
||||||
|
companion object : NEUEventBus<WorldReadyEvent>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package moe.nea.notenoughupdates.mixins
|
||||||
|
|
||||||
|
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 net.minecraft.client.network.ClientPlayNetworkHandler
|
||||||
|
import net.minecraft.network.packet.s2c.play.PlayerSpawnPositionS2CPacket
|
||||||
|
import moe.nea.notenoughupdates.events.WorldReadyEvent
|
||||||
|
|
||||||
|
@Mixin(ClientPlayNetworkHandler::class)
|
||||||
|
class MixinClientPlayNetworkHandler {
|
||||||
|
@Inject(method = ["onPlayerSpawnPosition"], at = [At("RETURN")])
|
||||||
|
fun onOnPlayerSpawnPosition(packet: PlayerSpawnPositionS2CPacket, ci: CallbackInfo) {
|
||||||
|
WorldReadyEvent.publish(WorldReadyEvent())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,18 +56,27 @@ object ItemCache : IReloadable {
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun brokenItemStack(neuItem: NEUItem): ItemStack {
|
||||||
|
return ItemStack(Items.PAINTING).apply {
|
||||||
|
setCustomName(Text.literal(neuItem.displayName))
|
||||||
|
appendLore(listOf(Text.translatable("notenoughupdates.repo.brokenitem", neuItem.skyblockItemId)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun NEUItem.asItemStackNow(): ItemStack {
|
private fun NEUItem.asItemStackNow(): ItemStack {
|
||||||
|
try {
|
||||||
val oldItemTag = get10809CompoundTag()
|
val oldItemTag = get10809CompoundTag()
|
||||||
val modernItemTag = oldItemTag.transformFrom10809ToModern()
|
val modernItemTag = oldItemTag.transformFrom10809ToModern()
|
||||||
?: return ItemStack(Items.PAINTING).apply {
|
?: return brokenItemStack(this)
|
||||||
setCustomName(Text.literal(this@asItemStackNow.displayName))
|
|
||||||
appendLore(listOf(Text.translatable("notenoughupdates.repo.brokenitem", skyblockItemId)))
|
|
||||||
}
|
|
||||||
val itemInstance = ItemStack.fromNbt(modernItemTag)
|
val itemInstance = ItemStack.fromNbt(modernItemTag)
|
||||||
if (itemInstance.nbt?.contains("Enchantments") == true) {
|
if (itemInstance.nbt?.contains("Enchantments") == true) {
|
||||||
itemInstance.enchantments.add(NbtCompound())
|
itemInstance.enchantments.add(NbtCompound())
|
||||||
}
|
}
|
||||||
return itemInstance
|
return itemInstance
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
return brokenItemStack(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun NEUItem.asItemStack(): ItemStack {
|
fun NEUItem.asItemStack(): ItemStack {
|
||||||
|
|||||||
@@ -1,7 +1,17 @@
|
|||||||
package moe.nea.notenoughupdates.util
|
package moe.nea.notenoughupdates.util
|
||||||
|
|
||||||
import net.minecraft.nbt.*
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import net.minecraft.nbt.AbstractNbtNumber
|
||||||
|
import net.minecraft.nbt.NbtByte
|
||||||
|
import net.minecraft.nbt.NbtCompound
|
||||||
|
import net.minecraft.nbt.NbtDouble
|
||||||
|
import net.minecraft.nbt.NbtElement
|
||||||
|
import net.minecraft.nbt.NbtFloat
|
||||||
|
import net.minecraft.nbt.NbtInt
|
||||||
|
import net.minecraft.nbt.NbtList
|
||||||
|
import net.minecraft.nbt.NbtLong
|
||||||
|
import net.minecraft.nbt.NbtShort
|
||||||
|
import net.minecraft.nbt.NbtString
|
||||||
|
|
||||||
class LegacyTagParser private constructor(string: String) {
|
class LegacyTagParser private constructor(string: String) {
|
||||||
data class TagParsingException(val baseString: String, val offset: Int, val mes0: String) :
|
data class TagParsingException(val baseString: String, val offset: Int, val mes0: String) :
|
||||||
@@ -80,7 +90,7 @@ class LegacyTagParser private constructor(string: String) {
|
|||||||
val baseTag = parseTag()
|
val baseTag = parseTag()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val digitRange = '0'..'9'
|
val digitRange = "0123456789-"
|
||||||
fun parse(string: String): NbtCompound {
|
fun parse(string: String): NbtCompound {
|
||||||
return LegacyTagParser(string).baseTag
|
return LegacyTagParser(string).baseTag
|
||||||
}
|
}
|
||||||
@@ -161,6 +171,7 @@ class LegacyTagParser private constructor(string: String) {
|
|||||||
}
|
}
|
||||||
sb.append(escaped)
|
sb.append(escaped)
|
||||||
}
|
}
|
||||||
|
|
||||||
null -> racer.error("Unfinished string")
|
null -> racer.error("Unfinished string")
|
||||||
else -> {
|
else -> {
|
||||||
sb.append(peek)
|
sb.append(peek)
|
||||||
@@ -182,7 +193,7 @@ class LegacyTagParser private constructor(string: String) {
|
|||||||
val SHORT = "([-+]?[0-9]+)[s|S]".toRegex()
|
val SHORT = "([-+]?[0-9]+)[s|S]".toRegex()
|
||||||
val INTEGER = "([-+]?[0-9]+)".toRegex()
|
val INTEGER = "([-+]?[0-9]+)".toRegex()
|
||||||
val DOUBLE_UNTYPED = "([-+]?[0-9]*\\.?[0-9]+)".toRegex()
|
val DOUBLE_UNTYPED = "([-+]?[0-9]*\\.?[0-9]+)".toRegex()
|
||||||
val ROUGH_PATTERN = "[-+]?[0-9]*\\.?[0-9]+[dDbBfFlLsS]?".toRegex()
|
val ROUGH_PATTERN = "[-+]?[0-9]*\\.?[0-9]*[dDbBfFlLsS]?".toRegex()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseNumericTag(): AbstractNbtNumber {
|
fun parseNumericTag(): AbstractNbtNumber {
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
package moe.nea.notenoughupdates.util
|
package moe.nea.notenoughupdates.util
|
||||||
|
|
||||||
import dev.architectury.event.events.client.ClientPlayerEvent
|
import java.time.Instant
|
||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.Duration.Companion.seconds
|
import kotlin.time.Duration.Companion.seconds
|
||||||
import kotlin.time.ExperimentalTime
|
import kotlin.time.ExperimentalTime
|
||||||
import kotlin.time.TimeSource
|
import kotlin.time.TimeSource
|
||||||
|
import net.minecraft.network.message.ArgumentSignatureDataMap
|
||||||
|
import net.minecraft.network.packet.c2s.play.CommandExecutionC2SPacket
|
||||||
import moe.nea.notenoughupdates.NotEnoughUpdates
|
import moe.nea.notenoughupdates.NotEnoughUpdates
|
||||||
import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent
|
import moe.nea.notenoughupdates.events.ServerChatLineReceivedEvent
|
||||||
import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent
|
import moe.nea.notenoughupdates.events.SkyblockServerUpdateEvent
|
||||||
|
import moe.nea.notenoughupdates.events.WorldReadyEvent
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
@OptIn(ExperimentalTime::class)
|
||||||
object SBData {
|
object SBData {
|
||||||
@@ -32,15 +35,15 @@ object SBData {
|
|||||||
val lLS = lastLocrawSent
|
val lLS = lastLocrawSent
|
||||||
if (tryReceiveLocraw(event.unformattedString) && lLS != null && lLS.elapsedNow() < locrawRoundtripTime) {
|
if (tryReceiveLocraw(event.unformattedString) && lLS != null && lLS.elapsedNow() < locrawRoundtripTime) {
|
||||||
lastLocrawSent = null
|
lastLocrawSent = null
|
||||||
event.cancel()
|
// event.cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientPlayerEvent.CLIENT_PLAYER_JOIN.register(ClientPlayerEvent.ClientPlayerJoin {
|
WorldReadyEvent.subscribe {
|
||||||
locraw = null
|
|
||||||
sendLocraw()
|
sendLocraw()
|
||||||
})
|
locraw = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryReceiveLocraw(unformattedString: String): Boolean = try {
|
private fun tryReceiveLocraw(unformattedString: String): Boolean = try {
|
||||||
@@ -49,14 +52,27 @@ object SBData {
|
|||||||
SkyblockServerUpdateEvent.publish(SkyblockServerUpdateEvent(lastLocraw, locraw))
|
SkyblockServerUpdateEvent.publish(SkyblockServerUpdateEvent(lastLocraw, locraw))
|
||||||
true
|
true
|
||||||
} catch (e: SerializationException) {
|
} catch (e: SerializationException) {
|
||||||
|
e.printStackTrace()
|
||||||
false
|
false
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
|
e.printStackTrace()
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendLocraw() {
|
fun sendLocraw() {
|
||||||
lastLocrawSent = TimeSource.Monotonic.markNow()
|
lastLocrawSent = TimeSource.Monotonic.markNow()
|
||||||
MC.player?.sendCommand("locraw")
|
val nh = MC.player?.networkHandler ?: return
|
||||||
|
val ack = nh.consumeAcknowledgment()
|
||||||
|
nh.sendPacket(
|
||||||
|
CommandExecutionC2SPacket(
|
||||||
|
"locraw",
|
||||||
|
Instant.now(),
|
||||||
|
0L,
|
||||||
|
ArgumentSignatureDataMap.EMPTY,
|
||||||
|
false,
|
||||||
|
ack
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ abstract class ProfileSpecificConfigHolder<S>(
|
|||||||
init {
|
init {
|
||||||
allConfigs = readValues()
|
allConfigs = readValues()
|
||||||
readValues()
|
readValues()
|
||||||
|
IConfigHolder.putConfig(this::class, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val configDirectory: Path get() = NotEnoughUpdates.CONFIG_DIR.resolve("profiles")
|
private val configDirectory: Path get() = NotEnoughUpdates.CONFIG_DIR.resolve("profiles")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"package": "moe.nea.notenoughupdates.mixins",
|
"package": "moe.nea.notenoughupdates.mixins",
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"client": [
|
"client": [
|
||||||
|
"MixinClientPlayNetworkHandler",
|
||||||
"MixinMessageHandler",
|
"MixinMessageHandler",
|
||||||
"MixinMinecraft",
|
"MixinMinecraft",
|
||||||
"MixinWorldRenderer"
|
"MixinWorldRenderer"
|
||||||
|
|||||||
Reference in New Issue
Block a user