Skip to content

Commit

Permalink
Split up island and event handling of certain features
Browse files Browse the repository at this point in the history
  • Loading branch information
derNiklaas committed Apr 17, 2024
1 parent 8d2fb46 commit 2367a24
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ abstract class NoxesiumMccGameStatePacketMixin {
val packet = (this as Object) as ClientboundMccGameStatePacket

// Set the map to Post Game during the Podium Phase
if(packet.stage == Constants.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.type == Constants.PARKOUR_WARRIOR) {
if (BugCreator.gameState.type == 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})")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package de.derniklaas.buildbugs.mixin
import com.noxcrew.noxesium.network.clientbound.ClientboundMccServerPacket
import de.derniklaas.buildbugs.BugCreator
import de.derniklaas.buildbugs.Constants
import de.derniklaas.buildbugs.utils.Utils
import net.fabricmc.fabric.api.networking.v1.PacketSender
import net.minecraft.client.network.ClientPlayerEntity
import org.spongepowered.asm.mixin.Mixin
Expand All @@ -19,13 +20,18 @@ abstract class NoxesiumMccServerPacketMixin {
BugCreator.handleServerStatePacket(packet, packet.type != Constants.PARKOUR_WARRIOR)

// Set default map names in PKW
if(packet.type == Constants.PARKOUR_WARRIOR) {
when(packet.subType) {
Constants.PARKOUR_WARRIOR_DAILY, Constants.PARKOUR_WARRIOR_DOJO -> {
BugCreator.updateMap("Dojo Entrance")
}
Constants.PARKOUR_WARRIOR_SURVIVOR -> {
BugCreator.updateMap("Survivor Start")
if (packet.type == 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")
}
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/de/derniklaas/buildbugs/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ object Utils {
/**
* Checks if the player is connected to a MCC related server.
*/
fun isOnMCCServer(): Boolean {
fun isOnMCCServer() = isOnEventServer() || isOnIsland()

/**
* Checks if the player is connected to the server specified in the config.
*/
fun isOnEventServer(): Boolean {
val server = MinecraftClient.getInstance().currentServerEntry ?: return false
return isOnIsland() || server.address == BuildBugsClientEntrypoint.config.eventIP
return server.address == BuildBugsClientEntrypoint.config.eventIP
}

/**
Expand Down

0 comments on commit 2367a24

Please sign in to comment.