Skip to content

Commit

Permalink
Update to 1.20.6
Browse files Browse the repository at this point in the history
- Temporarily disabled packet logging
  • Loading branch information
derNiklaas committed May 16, 2024
1 parent 7f5c06c commit a01ed45
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 114 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### Requirements

You need Minecraft 1.20.4 and at least [Noxesium 1.2](https://modrinth.com/mod/noxesium/version/1.2.0).
You need Minecraft 1.20.6 and at least [Noxesium 2.0.4](https://modrinth.com/mod/noxesium/version/2.0.4).

### Usage

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ tasks {
}

compileKotlin {
kotlinOptions.jvmTarget = "17"
kotlinOptions.jvmTarget = "21"
}
}

Expand Down
18 changes: 9 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
kotlin.code.style=official
archives_base_name=build-bugs
maven_group=de.derniklaas
loom_version=1.5-SNAPSHOT
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.1
fabric_kotlin_version=1.10.17+kotlin.1.9.22
fabric_api_version=0.95.4+1.20.4
mod_version=1.10.0
noxesium_version=1.2.0
adventure_version=5.12.0
loom_version=1.6-SNAPSHOT
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.11
fabric_kotlin_version=1.10.20+kotlin.1.9.24
fabric_api_version=0.97.8+1.20.6
mod_version=1.11.0
noxesium_version=2.0.4
adventure_version=5.13.0

org.gradle.jvmargs=-Xmx4000m
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ClientPlayNetworking.class)
// Temporarily disable logging of packets as networking has changed

//@Mixin(ClientPlayNetworking.class)
public class ClientPlayNetworkingMixin {
/*
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/util/Identifier;Lnet/minecraft/network/PacketByteBuf;)V")
private static void onReceive(Identifier channelName, PacketByteBuf buffer, CallbackInfo ci) {
if (!BuildBugsClientEntrypoint.Companion.getConfig().getLogOutgoingPackets()) return;
Utils.INSTANCE.sendDebugMessage("OUTBOUND: " + channelName + " -> " + buffer.readableBytes() + " bytes", true);
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(CustomPayloadS2CPacket.class)
// Temporarily disable logging of packets as networking has changed

//@Mixin(CustomPayloadS2CPacket.class)
public class CustomPayloadS2CPacketMixin {
/*
@Inject(at = @At("HEAD"), method = "readPayload")
private static void onReceive(Identifier id, PacketByteBuf buffer, CallbackInfoReturnable<CustomPayload> cir) {
if (!BuildBugsClientEntrypoint.Companion.getConfig().getLogIncomingPackets()) return;
Utils.INSTANCE.sendDebugMessage("INBOUND: " + id + " -> " + buffer.readableBytes() + " bytes", true);
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class BuildBugsClientEntrypoint : ClientModInitializer {
}

override fun onInitializeClient() {
NoxesiumPacketHandler()
BuildBugsConfig.createDefaultConfig()
val reportKeybinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
Expand All @@ -39,7 +40,7 @@ class BuildBugsClientEntrypoint : ClientModInitializer {
BugCreator.report()
}
if (bugreportKeybinding.wasPressed()) {
if(!Utils.isOnMCCServer()) {
if (!Utils.isOnMCCServer()) {
Utils.sendErrorMessage("You are not connected to a MCC related server.")
return@register
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/de/derniklaas/buildbugs/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package de.derniklaas.buildbugs
object Constants {
/* Game types */
const val LOBBY = "lobby"
const val GAME_LOBBY = "lobby-game"
const val PARKOUR_WARRIOR = "parkour-warrior"
const val HOLE_IN_THE_WALL = "hitw"
const val TO_GET_TO_THE_OTHER_SIDE = "tgttos"
Expand Down Expand Up @@ -39,5 +38,5 @@ object Constants {
const val BUG_REPORT_URL = "https://p.nox.gs/"

/* Groups */
val LOBBIES = listOf(LOBBY, GAME_LOBBY, HUB, LIMBO)
val LOBBIES = listOf(LOBBY, HUB, LIMBO)
}
60 changes: 60 additions & 0 deletions src/main/kotlin/de/derniklaas/buildbugs/NoxesiumPacketHandler.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package de.derniklaas.buildbugs

import com.noxcrew.noxesium.network.NoxesiumPackets
import com.noxcrew.noxesium.network.clientbound.ClientboundMccGameStatePacket
import com.noxcrew.noxesium.network.clientbound.ClientboundMccServerPacket
import de.derniklaas.buildbugs.utils.Utils

class NoxesiumPacketHandler {

init {
NoxesiumPackets.MCC_SERVER.addListener(this) { _, packet, _ ->
onServerPacket(packet)
}
NoxesiumPackets.MCC_GAME_STATE.addListener(this) { _, packet, _ ->
onStatePacket(packet)
}
}

private fun onServerPacket(packet: ClientboundMccServerPacket) {
BugCreator.handleServerStatePacket(packet, packet.serverType != Constants.PARKOUR_WARRIOR)

// Set default map names in PKW
if (packet.serverType == Constants.PARKOUR_WARRIOR) {
if (Utils.isOnEventServer()) {
BugCreator.updateMap("Start Area")
} else {
when (packet.subType) {
Constants.PARKOUR_WARRIOR_DAILY, Constants.PARKOUR_WARRIOR_DOJO -> {
BugCreator.updateMap("Dojo Entrance")
}

Constants.PARKOUR_WARRIOR_SURVIVOR -> {
BugCreator.updateMap("Survivor Start")
}
}
}
}
}

private fun onStatePacket(packet: ClientboundMccGameStatePacket) {
// Set the map to Post Game during the Podium Phase
if (packet.stage == Constants.PODIUM_PHASE) {
BugCreator.updateMap("Post Game")
return
}

// ignore parkour warrior updates, as they only contain "Parkour Warrior Survivor" or nothing
// also ignore the podium phase as it overwrites the map part
if (BugCreator.gameState.serverType == Constants.PARKOUR_WARRIOR && Utils.isOnIsland()) {
// Provide debug info
Utils.sendDebugMessage("Blocked GameStatePacket: (name: <green>${packet.mapName}</green>, id: ${packet.mapId}, phase: ${packet.phaseType}, stage: ${packet.stage})")

return
}

Utils.sendDebugMessage("Received GameStatePacket: (name: <green>${packet.mapName}</green>, id: ${packet.mapId}, phase: ${packet.phaseType}, stage: ${packet.stage})")
BugCreator.updateMap(packet.mapName)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
@Mixin(MinecraftClient::class)
abstract class ClearChatOnDisconnectMixin {

@Inject(at = [At("HEAD")], method = ["Lnet/minecraft/class_310;method_18096(Lnet/minecraft/class_437;)V"])
@Inject(at = [At("HEAD")], method = ["Lnet/minecraft/class_310;method_18099()V"])
fun onDisconnect(info: CallbackInfo) {
BugCreator.resetGameState()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class InGameHudMixin {
// Ignore non MCC Servers
if (!Utils.isOnMCCServer()) return
// Only check titles in Parkour Warrior
if (BugCreator.gameState.type != Constants.PARKOUR_WARRIOR) return
if (BugCreator.gameState.serverType != Constants.PARKOUR_WARRIOR) return

// Check if the first element matches the regex defined above
val start = title.content.toString()
Expand Down

This file was deleted.

This file was deleted.

16 changes: 5 additions & 11 deletions src/main/kotlin/de/derniklaas/buildbugs/utils/ServerState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import com.noxcrew.noxesium.network.clientbound.ClientboundMccServerPacket
import de.derniklaas.buildbugs.Constants

data class ServerState(
val type: String, val subType: String, val mapName: String
val serverType: String, val subType: String, val mapName: String
) {
companion object {
val UNKNOWN = ServerState("Unknown", "Unknown", "Unknown")

fun fromPacket(packet: ClientboundMccServerPacket): ServerState {
return ServerState(
packet.type, packet.subType, if (packet.type in Constants.LOBBIES) "" else "Pre Game"
packet.serverType, packet.subType, if (packet.serverType in Constants.LOBBIES) "" else "Pre Game"
)
}
}
Expand All @@ -22,14 +22,8 @@ data class ServerState(
* If it's a game lobby, it will return the game name and add "Lobby" to it.
* If it's not known, it will return the [type] and [subType]
*/
fun getFancyName(type: String = this.type): String = when (type) {
fun getFancyName(type: String = this.serverType): String = when (type) {
Constants.LOBBY -> "Lobby"
// Game Lobbies
Constants.GAME_LOBBY -> {
// realistically this will never happen, but I don't want infinite recursion
if (subType == Constants.GAME_LOBBY) "Game Lobby?"
else "${getFancyName(subType)} Lobby"
}

// Game modes
Constants.PARKOUR_WARRIOR -> "Parkour Warrior"
Expand All @@ -50,7 +44,7 @@ data class ServerState(
Constants.RAILROAD_RUSH -> "Railroad Rush"
Constants.BUILD_MART -> "Build Mart"
// Empty because map is already set to the name of the game
Constants.SANDS_OF_TIME, Constants.MELTDOWN, Constants.DODGEBOLT, Constants.LIMBO, UNKNOWN.type -> ""
Constants.SANDS_OF_TIME, Constants.MELTDOWN, Constants.DODGEBOLT, Constants.LIMBO, UNKNOWN.serverType -> ""

else -> "$type $subType"
}
Expand All @@ -61,6 +55,6 @@ data class ServerState(
fun withMapName(name: String) = copy(mapName = name)

fun miniMessageString(): String {
return "type: <green>$type</green>, subType: <green>$subType</green>, map: <green>$mapName</green>"
return "type: <green>$serverType</green>, subType: <green>$subType</green>, map: <green>$mapName</green>"
}
}
8 changes: 2 additions & 6 deletions src/main/resources/buildbugs.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@
"required": true,
"minVersion": "0.8",
"package": "de.derniklaas.buildbugs.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"mixins": [
"ChatMixin",
"ClearChatOnDisconnectMixin",
"ClientPlayNetworkingMixin",
"CustomPayloadS2CPacketMixin",
"InGameHudMixin",
"NoxesiumMccGameStatePacketMixin",
"NoxesiumMccServerPacketMixin"
"InGameHudMixin"
],
"client": [],
"injectors": {
Expand Down

0 comments on commit a01ed45

Please sign in to comment.