Skip to content

Commit

Permalink
Update to 1.21.4 (#3)
Browse files Browse the repository at this point in the history
- Updates the mod to 1.21.4
- Remove Fish Spot detection
  - This was never really intended to become part of the mod, plus somewhat recent rule changes made it more annoying to deal with fishing related features, so this is the path that needs the least upkeep from my end.
- Removed unused files and config options
- Moved from yarn mappings to official mappings
  • Loading branch information
derNiklaas authored Feb 14, 2025
1 parent 1d082c8 commit f8024f4
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 195 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
### Requirements

You need Minecraft 1.21.1 and at least [Noxesium 2.3.1](https://modrinth.com/mod/noxesium/version/2.3.1).
You need Minecraft 1.21.4 and at least [Noxesium 2.5.0](https://modrinth.com/mod/noxesium/version/2.5.0).

### Usage

This mod adds the ``/buildbug`` command and three hotkeys, the first hotkey (default ``U``) is used to quickly gather
This mod adds the ``/buildbug`` command and two hotkeys, the first hotkey (default ``U``) is used to quickly gather
information about your location.
The second hotkey (default ``I``) is used to quickly generate a /bugreport.
The third hotkey (default ``J``) is used to copy a fishing spot (including its perks) to the clipboard.

- ``/buildbug`` - Prints out location information, same as the hotkey.
- ``/buildbug config clipboard <true/false>`` (default: ``false``) - If set to true, automatically copies
Expand Down
20 changes: 12 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id("fabric-loom")
`maven-publish`
java
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.21"
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.21"
}

group = property("maven_group")!!
Expand All @@ -27,22 +27,26 @@ repositories {
includeGroup("maven.modrinth")
}
}

maven("https://maven.noxcrew.com/public")
maven("https://maven.enginehub.org/repo/")
maven("https://maven.terraformersmc.com/")
}

dependencies {
minecraft("com.mojang:minecraft:${property("minecraft_version")}")
mappings("net.fabricmc:yarn:${property("yarn_mappings")}:v2")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${property("loader_version")}")

include(modImplementation("net.fabricmc:fabric-language-kotlin:${property("fabric_kotlin_version")}")!!)
include(implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")!!)
modImplementation("net.fabricmc:fabric-language-kotlin:${property("fabric_kotlin_version")}")!!
include(implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")!!)
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("fabric_api_version")}")
modCompileOnly("maven.modrinth:noxesium:${property("noxesium_version")}")
modCompileOnly("com.noxcrew.noxesium:fabric:${property("noxesium_version")}")
modImplementation(include("net.kyori:adventure-platform-fabric:${property("adventure_version")}")!!)
modImplementation(include("org.incendo:cloud-fabric:${property("cloud_version")}")!!)
modImplementation(include("org.incendo:cloud-annotations:2.0.0-rc.2")!!)
modImplementation(include("org.incendo:cloud-kotlin-coroutines-annotations:2.0.0-rc.2")!!)
modImplementation(include("org.incendo:cloud-kotlin-extensions:2.0.0-rc.2")!!)
modImplementation(include("org.incendo:cloud-annotations:2.0.0")!!)
modImplementation(include("org.incendo:cloud-kotlin-coroutines-annotations:2.0.0")!!)
modImplementation(include("org.incendo:cloud-kotlin-extensions:2.0.0")!!)
}

tasks {
Expand Down
19 changes: 9 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
kotlin.code.style=official
archives_base_name=build-bugs
maven_group=de.derniklaas
loom_version=1.7-SNAPSHOT
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.5
fabric_kotlin_version=1.11.0+kotlin.2.0.0
fabric_api_version=0.105.0+1.21.1
mod_version=1.14.1
noxesium_version=2.3.1
adventure_version=5.14.1
cloud_version=2.0.0-beta.7
loom_version=1.9-SNAPSHOT
minecraft_version=1.21.4
loader_version=0.16.9
fabric_kotlin_version=1.13.1+kotlin.2.1.10
fabric_api_version=0.116.1+1.21.4
mod_version=1.15.0
noxesium_version=2.5.0
adventure_version=6.1.0
cloud_version=2.0.0-beta.9

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.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

This file was deleted.

This file was deleted.

76 changes: 9 additions & 67 deletions src/main/kotlin/de/derniklaas/buildbugs/BugCreator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@ package de.derniklaas.buildbugs
import com.noxcrew.noxesium.network.clientbound.ClientboundMccServerPacket
import de.derniklaas.buildbugs.utils.ServerState
import de.derniklaas.buildbugs.utils.Utils
import net.minecraft.client.MinecraftClient
import net.minecraft.client.util.Clipboard
import net.minecraft.entity.decoration.DisplayEntity
import net.minecraft.util.math.BlockPos
import net.minecraft.util.math.Box
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.font.TextFieldHelper
import net.minecraft.client.multiplayer.ServerData
import net.minecraft.core.BlockPos

object BugCreator {

var gameState: ServerState = ServerState.UNKNOWN
private set
private val clipboard: Clipboard = Clipboard()

/**
* Gathers information to more easily create a build bug report.
*/
fun report() {
val client = MinecraftClient.getInstance()
val server = client.currentServerEntry ?: return
val client = Minecraft.getInstance()
val server = client.currentServer ?: return
val player = client.player ?: return

// Check if the player is connected to a server
if (server.isLocal) {
if (server.type() == ServerData.Type.LAN) {
Utils.sendErrorMessage("You are not connected to a server.")
return
}
Expand All @@ -37,7 +35,7 @@ object BugCreator {

// Get the "area" of the player
val area = gameState.getFancyName()
val blockPos = player.blockPos
val blockPos = player.blockPosition()
val map = gameState.mapName

val minecraftMessage = getCopyMessage(area, map, blockPos).trim()
Expand All @@ -55,62 +53,6 @@ object BugCreator {
}
}

fun shareFishingSpot() {
val client = MinecraftClient.getInstance()
val server = client.currentServerEntry ?: return
val player = client.player ?: return

// Check if the player is connected to a server
if (server.isLocal) {
Utils.sendErrorMessage("You are not connected to a server.")
return
}

// Check if the player is connected to a MCC related server
if (!Utils.isOnMCCServer()) {
Utils.sendErrorMessage("You are not connected to a MCC related server.")
return
}

// Get the "area" of the player
val area = gameState.getFancyName()
val map = gameState.mapName

val fishHook = player.fishHook
if (fishHook == null) {
Utils.sendErrorMessage("You are not fishing.")
return
}
val blockPos = fishHook.blockPos

val box = Box.of(blockPos.toCenterPos(), 6.0, 6.0, 6.0)
val entities = player.world.getOtherEntities(null, box) { entity ->
entity is DisplayEntity.TextDisplayEntity
}

if (entities.isNotEmpty()) {
val textDisplay = entities.first() as DisplayEntity.TextDisplayEntity
val text = textDisplay.data!!.text.asTruncatedString(Int.MAX_VALUE)

val perks = text.split("\n").filter { it.contains("+") }.map { "+" + it.split("+")[1] }.joinToString(", ")
if (perks.isNotEmpty()) {
val minecraftMessage = getCopyMessage(area, map, blockPos).trim() + " $perks"
Utils.sendMiniMessage(
"<click:copy_to_clipboard:'${
minecraftMessage.replace(
"'", "\\\'"
)
}'>$minecraftMessage <yellow><bold>[CLICK TO COPY]</bold></yellow></click>", true
)
if (BuildBugsClientEntrypoint.config.copyToClipboard) {
setClipboard(minecraftMessage)
}
return
}
}
Utils.sendErrorMessage("Could not find a fishing spot.")
}

/**
* Updates [gameState] when a new packet is received.
*/
Expand Down Expand Up @@ -146,7 +88,7 @@ object BugCreator {
* Sets the content of the Clipboard to [text].
*/
fun setClipboard(text: String) {
clipboard.setClipboard(MinecraftClient.getInstance().window.handle, text)
TextFieldHelper.setClipboardContents(Minecraft.getInstance(), text)
Utils.sendMiniMessage("<i>Copied </i>${if (BuildBugsClientEntrypoint.config.debugMode) "<green>${text.trim()}</green> " else ""}<i>to clipboard.</i>")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.derniklaas.buildbugs

import com.mojang.blaze3d.platform.InputConstants
import com.noxcrew.noxesium.NoxesiumFabricMod
import de.derniklaas.buildbugs.utils.Utils
import io.leangen.geantyref.TypeToken
import net.fabricmc.api.ClientModInitializer
Expand All @@ -8,8 +10,7 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.fabricmc.loader.api.FabricLoader
import net.fabricmc.loader.api.Version
import net.minecraft.client.option.KeyBinding
import net.minecraft.client.util.InputUtil
import net.minecraft.client.KeyMapping
import org.incendo.cloud.annotations.AnnotationParser
import org.incendo.cloud.execution.ExecutionCoordinator
import org.incendo.cloud.fabric.FabricClientCommandManager
Expand All @@ -24,45 +25,46 @@ class BuildBugsClientEntrypoint : ClientModInitializer {
}

override fun onInitializeClient() {
NoxesiumFabricMod.initialize()
NoxesiumPacketHandler()
val manager = FabricClientCommandManager.createNative(ExecutionCoordinator.asyncCoordinator())
val annotationParser = AnnotationParser(manager, TypeToken.get(FabricClientCommandSource::class.java))
annotationParser.parse(BuildBugsCommand())
BuildBugsConfig.createDefaultConfig()
val reportKeybinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.buildbugs.report", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_U, "category.buildbugs"
KeyMapping(
"key.buildbugs.report", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_U, "category.buildbugs"
)
)
val bugreportKeybinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.buildbugs.bugreport", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_I, "category.buildbugs"
KeyMapping(
"key.buildbugs.bugreport", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_I, "category.buildbugs"
)
)

val shareFishingSpotKeybinding = KeyBindingHelper.registerKeyBinding(
KeyBinding(
"key.buildbugs.share_fishing_spot",
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_J,
"category.buildbugs"
)
)
// ensure only executed once
var clickedReportKeybind = false
var clickedBugreportKeybind = false

ClientTickEvents.END_CLIENT_TICK.register {
if (reportKeybinding.wasPressed()) {
if (reportKeybinding.isDown) {
if (clickedReportKeybind) return@register
clickedReportKeybind = true
BugCreator.report()
} else if (clickedReportKeybind) {
clickedReportKeybind = false
}
if (shareFishingSpotKeybinding.wasPressed()) {
BugCreator.shareFishingSpot()
}
if (bugreportKeybinding.wasPressed()) {
if (bugreportKeybinding.isDown) {
if (clickedBugreportKeybind) return@register
clickedBugreportKeybind = true
if (!Utils.isOnMCCServer()) {
Utils.sendErrorMessage("You are not connected to a MCC related server.")
return@register
}
val player = it.player ?: return@register
player.networkHandler.sendCommand("bugreport Generated using BuildBugs Mod - contact on discord: derniklaas")
player.connection.sendCommand("bugreport Generated using BuildBugs Mod - contact on discord: derniklaas")
} else if (clickedBugreportKeybind) {
clickedBugreportKeybind = false
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/de/derniklaas/buildbugs/BuildBugsCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class BuildBugsCommand {
}

@Command("buildbug force_state <game> <type>")
fun force_state_full(
fun force_state_minimum(
context: CommandContext<*>,
@Argument("game", suggestions = "gameSuggestions") game: String,
@Argument("type") type: String
Expand All @@ -78,6 +78,7 @@ class BuildBugsCommand {
BugCreator.forceGameState(game, type, Constants.UNKNOWN)
}

@Command("buildbug")
fun report(context: CommandContext<*>) {
BugCreator.report()
}
Expand Down
14 changes: 1 addition & 13 deletions src/main/kotlin/de/derniklaas/buildbugs/BuildBugsConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ data class BuildBugsConfig(
var version: Int = 3,
var debugMode: Boolean = false,
var copyToClipboard: Boolean = false,
var eventIP: String = "example.com",
var logIncomingPackets: Boolean = false,
var logOutgoingPackets: Boolean = false
var eventIP: String = "example.com"
) {
companion object {
private val DEFAULT = BuildBugsConfig()
Expand Down Expand Up @@ -71,16 +69,6 @@ data class BuildBugsConfig(
saveConfig()
}

fun setLoggingForIncomingPackets(newValue: Boolean) {
logIncomingPackets = newValue
saveConfig()
}

fun setLoggingForOutgoingPackets(newValue: Boolean) {
logOutgoingPackets = newValue
saveConfig()
}

/**
* Saves the config file to disk.
*/
Expand Down
Loading

0 comments on commit f8024f4

Please sign in to comment.