Skip to content

Commit

Permalink
Merge branch 'hannibal002:beta' into optimal-speed-without-ranchers
Browse files Browse the repository at this point in the history
  • Loading branch information
Obsidianninja11 authored Nov 1, 2024
2 parents 140a1a7 + 50fedee commit e19edc7
Show file tree
Hide file tree
Showing 15 changed files with 242 additions and 93 deletions.
17 changes: 16 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import kotlin.io.path.outputStream
plugins {
idea
java
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.gradleup.shadow") version "8.3.4"
id("gg.essential.loom")
id("dev.deftu.gradle.preprocess")
kotlin("jvm")
Expand Down Expand Up @@ -277,6 +277,21 @@ if (target == ProjectTarget.MAIN) {
}
}

fun includeBuildPaths(buildPathsFile: File, sourceSet: Provider<SourceSet>) {
if (buildPathsFile.exists()) {
sourceSet.get().apply {
val buildPaths = buildPathsFile.readText().lineSequence()
.map { it.substringBefore("#").trim() }
.filter { it.isNotBlank() }
.toSet()
kotlin.include(buildPaths)
java.include(buildPaths)
}
}
}
includeBuildPaths(file("buildpaths.txt"), sourceSets.main)
includeBuildPaths(file("buildpaths-test.txt"), sourceSets.test)

tasks.withType<KotlinCompile> {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(target.minecraftVersion.formattedJavaLanguageVersion))
}
Expand Down
1 change: 1 addition & 0 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- remove all unused parts
The title of your PR should be descriptive and concise. It should be in the format of `Type: Description`. For example, `Feature: Add new command` or `Fix: Bug in command`. If there are multiple types of changes these can be separated by a plus. For example, `Feature + Fix: Add new command and fix bug in command`.
Commonly used labels are Improvement, Backend, Feature and Fix.
## PR Reviews
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ object ChatFilter {
private val annoyingSpamPatterns = listOf(
"§7Your Implosion hit (.*) for §r§c(.*) §r§7damage.".toPattern(),
"§7Your Molten Wave hit (.*) for §r§c(.*) §r§7damage.".toPattern(),
"§7Your Spirit Sceptre hit (.*) for §r§c(.*) §r§7damage.".toPattern(),
"§cYou need a tool with a §r§aBreaking Power §r§cof §r§6(\\d)§r§c to mine (.*)§r§c! Speak to §r§dFragilis §r§cby the entrance to the Crystal Hollows to learn more!".toPattern(),
)
private val annoyingSpamMessages = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ object SkyBlockKickDuration {
/**
* REGEX-TEST: §cYou were kicked while joining that server!
* REGEX-TEST: §cA kick occurred in your connection, so you were put in the SkyBlock lobby!
* REGEX-TEST: §cAn exception occurred in your connection, so you were put in the SkyBlock Lobby!
*/
@Suppress("MaxLineLength")
private val kickPattern by patternGroup.pattern(
"kicked",
"§c(?:You were kicked while joining that server!|A kick occurred in your connection, so you were put in the SkyBlock lobby!)",
"§c(?:You were kicked while joining that server!|An? (?:kick|exception) occurred in your connection, so you were put in the SkyBlock [lL]obby!)",
)

/**
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/at/hannibal2/skyhanni/utils/TabListData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,12 @@ object TabListData {
}

private fun readTabList(): List<String>? {
val thePlayer = Minecraft.getMinecraft()?.thePlayer ?: return null
val thePlayer = Minecraft.getMinecraft().thePlayer ?: return null
//#if MC<1.16
val players = playerOrdering.sortedCopy(thePlayer.sendQueue.playerInfoMap)
//#else
//$$ val players = playerOrdering.sortedCopy(thePlayer.connection.onlinePlayers)
//#endif
val result = mutableListOf<String>()
tabListGuard = true
for (info in players) {
Expand Down
53 changes: 53 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/compat/TextCompat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package at.hannibal2.skyhanni.utils.compat

import net.minecraft.util.IChatComponent
//#if MC > 1.16
//$$ import net.minecraft.ChatFormatting
//$$ import net.minecraft.network.chat.TextColor
//#endif
//#if MC > 1.20
//$$ import net.minecraft.text.MutableText
//$$ import net.minecraft.text.PlainTextContent
//#endif

fun IChatComponent.getDirectlyContainedText() =
//#if MC < 1.16
this.unformattedTextForChat
//#elseif MC < 1.20
//$$ this.contents
//#else
//$$ (this.content as? PlainTextContent)?.string().orEmpty()
//#endif

fun IChatComponent.getFormattedTextCompat() =
//#if MC < 1.16
this.formattedText
//#else
//$$run {
//$$ val sb = StringBuilder()
//$$ for (component in iterator()) {
//$$ sb.append(component.style.color?.toChatFormatting()?.toString() ?: "§r")
//$$ sb.append(component.getDirectlyContainedText())
//$$ sb.append("§r")
//$$ }
//$$ sb.toString()
//$$}
//$$
//$$private val textColorLUT = ChatFormatting.entries
//$$ .mapNotNull { formatting -> formatting.color?.let { it to formatting } }
//$$ .toMap()
//$$
//$$fun TextColor.toChatFormatting(): ChatFormatting? {
//$$ return textColorLUT[this.value]
//$$}
//$$
//$$fun Component.iterator(): Sequence<Component> {
//$$ return sequenceOf(this) + siblings.asSequence().flatMap { it.iterator() } // TODO: in theory we want to properly inherit styles here
//$$}
//#endif

//#if MC > 1.20
//$$fun MutableText.withColor(formatting: Formatting): Text {
//$$ return this.styled { it.withColor(formatting) }
//$$}
//#endif
23 changes: 2 additions & 21 deletions src/main/java/at/hannibal2/skyhanni/utils/compat/World.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import net.minecraft.entity.Entity
import net.minecraft.entity.item.EntityArmorStand
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.potion.Potion
import net.minecraft.util.IChatComponent

fun WorldClient.getLoadedPlayers(): List<EntityPlayer> =
//#if MC < 1.14
Expand All @@ -15,18 +14,17 @@ fun WorldClient.getLoadedPlayers(): List<EntityPlayer> =
//$$ this.players()
//#endif


fun Entity.getNameAsString(): String =
this.name
//#if MC >= 1.14
//$$ .getString()
//$$ .string
//#endif

fun EntityArmorStand.getArmorOrFullInventory() =
//#if MC < 1.12
this.inventory
//#else
//$$ this.getArmorInventoryList()
//$$ this.armorInventoryList
//#endif

fun Minecraft.isOnMainThread() =
Expand All @@ -36,21 +34,6 @@ fun Minecraft.isOnMainThread() =
//$$ this.isSameThread
//#endif

fun IChatComponent.getFormattedTextCompat() =
//#if MC < 1.16
this.formattedText
//#else
//$$ run {
//$$ val sb = StringBuilder()
//$$ for (component in iterator()) {
//$$ sb.append(component.style.formattingCode)
//$$ sb.append(component.unformattedComponentText)
//$$ sb.append("§r")
//$$ }
//$$ sb.toString()
//$$ }
//#endif

object Effects {
val invisibility =
//#if MC <1.12
Expand All @@ -59,5 +42,3 @@ object Effects {
//$$ net.minecraft.init.PotionTypes.INVISIBILITY
//#endif
}


2 changes: 2 additions & 0 deletions versions/1.21/buildpaths-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
at/hannibal2/skyhanni/utils/compat/TextCompat.kt
TestLegacyColorFormat.kt
1 change: 1 addition & 0 deletions versions/1.21/buildpaths.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
at/hannibal2/skyhanni/utils/compat/TextCompat.kt
22 changes: 22 additions & 0 deletions versions/1.21/src/test/kotlin/TestLegacyColorFormat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import net.minecraft.text.Text
import net.minecraft.util.Formatting
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
import at.hannibal2.skyhanni.utils.compat.*

class TestLegacyColorFormat {
@Test
fun testLegacyColorFormatString() {
val text = Text.literal("")
.append(Text.literal("[").withColor(Formatting.DARK_GRAY))
.append(Text.literal("302").withColor(Formatting.BLUE))
.append(Text.literal("] ").withColor(Formatting.DARK_GRAY))
.append(Text.literal("").withColor(Formatting.GOLD))
.append(Text.literal("[MVP").withColor(Formatting.AQUA))
.append(Text.literal("+").withColor(Formatting.LIGHT_PURPLE))
.append(Text.literal("] lrg89").withColor(Formatting.AQUA))
.append(Text.literal(": test").withColor(Formatting.WHITE))
Assertions.assertEquals("§r§r§8[§r§9302§r§8] §r§6♫ §r§b[MVP§r§d+§r§b] lrg89§r§f: test§r", text.getFormattedTextCompat())
}

}
24 changes: 14 additions & 10 deletions versions/mapping-1.12.2-1.8.9.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@

net.minecraft.client.renderer.entity.RenderLivingBase net.minecraft.client.renderer.entity.RendererLivingEntity

net.minecraft.client.renderer.BufferBuilder net.minecraft.client.renderer.WorldRenderer
net.minecraft.client.renderer.RenderItem net.minecraft.client.renderer.entity.RenderItem

net.minecraft.client.renderer.block.model.IBakedModel net.minecraft.client.resources.model.IBakedModel

net.minecraft.client.renderer.entity.RenderLivingBase net.minecraft.client.renderer.entity.RendererLivingEntity

net.minecraft.entity.player.EntityPlayer getHeldItemMainhand() getHeldItem()

Expand Down Expand Up @@ -47,7 +50,6 @@ net.minecraft.network.play.server.SPacketPlayerListHeaderFooter net.minecraft.ne
net.minecraft.network.play.server.SPacketPlayerListItem net.minecraft.network.play.server.S38PacketPlayerListItem
net.minecraft.network.play.server.SPacketSetSlot net.minecraft.network.play.server.S2FPacketSetSlot
net.minecraft.network.play.server.SPacketSoundEffect net.minecraft.network.play.server.S29PacketSoundEffect
net.minecraft.network.play.server.SPacketSoundEffect net.minecraft.network.play.server.S29PacketSoundEffect
net.minecraft.network.play.server.SPacketSpawnMob net.minecraft.network.play.server.S0FPacketSpawnMob
net.minecraft.network.play.server.SPacketSpawnObject net.minecraft.network.play.server.S0EPacketSpawnObject
net.minecraft.network.play.server.SPacketSpawnPlayer net.minecraft.network.play.server.S0CPacketSpawnPlayer
Expand All @@ -62,18 +64,20 @@ net.minecraft.util.math.AxisAlignedBB net.minecraft.util.AxisAlignedBB
net.minecraft.util.math.BlockPos net.minecraft.util.BlockPos
net.minecraft.util.math.MathHelper net.minecraft.util.MathHelper
net.minecraft.util.math.RayTraceResult net.minecraft.util.MovingObjectPosition
net.minecraft.util.math.RayTraceResult$Type net.minecraft.util.math.RayTraceResult$MovingObjectType
net.minecraft.util.math.Rotations net.minecraft.util.Rotations
net.minecraft.util.math.Vec3d net.minecraft.util.Vec3
net.minecraft.util.math.Vec3d net.minecraft.util.Vec3

net.minecraft.util.math.RayTraceResult$Type net.minecraft.util.math.RayTraceResult$MovingObjectType

net.minecraft.util.text.ITextComponent net.minecraft.util.IChatComponent
net.minecraft.util.text.Style net.minecraft.util.ChatStyle
net.minecraft.util.text.TextComponentString net.minecraft.util.ChatComponentText
net.minecraft.util.text.TextComponentTranslation net.minecraft.util.ChatComponentTranslation
net.minecraft.util.text.Style net.minecraft.util.ChatStyle
net.minecraft.util.text.Style getHoverEvent() getChatHoverEvent()
net.minecraft.util.text.Style getClickEvent() getChatClickEvent()
net.minecraft.util.text.TextFormatting net.minecraft.util.EnumChatFormatting
net.minecraft.util.text.ITextComponent net.minecraft.util.IChatComponent
net.minecraft.util.text.event.HoverEvent net.minecraft.event.HoverEvent

net.minecraft.util.text.Style getClickEvent() getChatClickEvent()
net.minecraft.util.text.Style getHoverEvent() getChatHoverEvent()

net.minecraft.util.text.event.ClickEvent net.minecraft.event.ClickEvent
net.minecraft.util.text.event.HoverEvent net.minecraft.event.HoverEvent

4 changes: 3 additions & 1 deletion versions/mapping-1.16.5-1.16.5-forge.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
net.fabricmc.api.Environment net.minecraftforge.api.distmarker.OnlyIn

net.fabricmc.api.EnvType net.minecraftforge.api.distmarker.Dist
net.fabricmc.api.Environment net.minecraftforge.api.distmarker.OnlyIn

Loading

0 comments on commit e19edc7

Please sign in to comment.