diff options
| author | CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> | 2024-10-22 21:12:20 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-22 21:12:20 +1100 |
| commit | 3ec6a29f79c4f4c437b2dd4dec34dca12ea0924f (patch) | |
| tree | 61326fb17f02239c8781c34c17d25061e63523d3 /src/main/java | |
| parent | 65613e99af5595b4ee4b03de477ad327c96e1d01 (diff) | |
| download | SkyHanni-3ec6a29f79c4f4c437b2dd4dec34dca12ea0924f.tar.gz SkyHanni-3ec6a29f79c4f4c437b2dd4dec34dca12ea0924f.tar.bz2 SkyHanni-3ec6a29f79c4f4c437b2dd4dec34dca12ea0924f.zip | |
Backend: Start preprocessing mappings (#2776)
Diffstat (limited to 'src/main/java')
12 files changed, 29 insertions, 17 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt index 1cef0be01..678fa4e33 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt @@ -20,7 +20,11 @@ object ActionBarData { @SubscribeEvent(receiveCanceled = true) fun onChatReceive(event: ClientChatReceivedEvent) { + //#if MC<1.12 if (event.type.toInt() != 2) return + //#else + //$$ if (event.type.id.toInt() != 2) return + //#endif val original = event.message val message = LorenzUtils.stripVanillaMessage(original.formattedText) diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 878056192..9564df15a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -118,7 +118,11 @@ object ChatManager { @SubscribeEvent(receiveCanceled = true) fun onChatReceive(event: ClientChatReceivedEvent) { + //#if MC<1.12 if (event.type.toInt() == 2) return + //#else + //$$ if (event.type.id.toInt() == 2) return + //#endif val original = event.message val message = LorenzUtils.stripVanillaMessage(original.formattedText) diff --git a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt index 1abe31736..58c5703bd 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/FriendAPI.kt @@ -153,7 +153,8 @@ object FriendAPI { } private fun readName(chatStyle: ChatStyle): String? { - for (component in chatStyle.chatHoverEvent.value.siblings) { + val hoverEventSiblings = chatStyle.chatHoverEvent?.value?.siblings ?: return null + for (component in hoverEventSiblings) { val rawName = component.unformattedText rawNamePattern.matchMatcher(rawName) { return group("name").cleanPlayerName() diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt index e934e0027..9d22200a4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLividFinder.kt @@ -85,7 +85,7 @@ object DungeonLividFinder { posZ - 0.5, posX + 0.5, posY, - posZ + 0.5 + posZ + 0.5, ) } val world = Minecraft.getMinecraft().theWorld @@ -96,7 +96,7 @@ object DungeonLividFinder { lividEntity = newLivid RenderLivingEntityHelper.setEntityColorWithNoHurtTime( newLivid, - color.toColor().withAlpha(30) + color.toColor().withAlpha(30), ) { shouldHighlight() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt index eb3c7a24a..1ca3f8acf 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/InquisitorWaypointShare.kt @@ -241,7 +241,11 @@ object InquisitorWaypointShare { val messageComponent = packet.chatComponent val message = messageComponent.formattedText.stripHypixelMessage() + //#if MC<1.12 if (packet.type.toInt() != 0) return + //#else + //$$ if (packet.type.id.toInt() != 0) return + //#endif partyInquisitorCheckerPattern.matchMatcher(message) { if (detectFromChat()) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt index 78e6063ee..12b3e9495 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemPickupLog.kt @@ -147,7 +147,7 @@ object ItemPickupLog { itemList.clear() val inventoryItems = InventoryUtils.getItemsInOwnInventory().toMutableList() - val cursorItem = Minecraft.getMinecraft().thePlayer.inventory?.itemStack + val cursorItem = Minecraft.getMinecraft().thePlayer?.inventory?.itemStack if (cursorItem != null) { val hash = cursorItem.hash() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt index 4642124b7..6ab97193f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/DelayedRun.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.test.command.ErrorManager import at.hannibal2.skyhanni.utils.CollectionUtils.drainTo +import at.hannibal2.skyhanni.utils.compat.isOnMainThread import net.minecraft.client.Minecraft import java.util.concurrent.ConcurrentLinkedQueue import java.util.concurrent.Executor @@ -41,7 +42,7 @@ object DelayedRun { @JvmField val onThread = Executor { val mc = Minecraft.getMinecraft() - if (mc.isCallingFromMinecraftThread) { + if (mc.isOnMainThread()) { it.run() } else { Minecraft.getMinecraft().addScheduledTask(it) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index 15dc807bb..3284881ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -185,7 +185,7 @@ object EntityUtils { }?.asSequence().orEmpty() fun getAllTileEntities(): Sequence<TileEntity> = Minecraft.getMinecraft()?.theWorld?.loadedTileEntityList?.let { - if (Minecraft.getMinecraft().isCallingFromMinecraftThread) it else it.toMutableList() + if (Minecraft.getMinecraft().isOnMainThread()) it else it.toMutableList() }?.asSequence()?.filterNotNull().orEmpty() fun Entity.canBeSeen(viewDistance: Number = 150.0) = getLorenzVec().up(0.5).canBeSeen(viewDistance) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt index d7d3bc997..2209cbdb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/InventoryUtils.kt @@ -54,7 +54,7 @@ object InventoryUtils { // TODO use this instead of getItemsInOwnInventory() for many cases, e.g. vermin tracker, diana spade, etc fun getItemsInHotbar() = - getItemsInOwnInventoryWithNull()?.sliceArray(0..8)?.filterNotNull().orEmpty() + getItemsInOwnInventoryWithNull()?.slice(0..8)?.filterNotNull().orEmpty() fun containsInLowerInventory(predicate: (ItemStack) -> Boolean): Boolean = countItemsInLowerInventory(predicate) > 0 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index b06d84f50..9a2e6857e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -171,16 +171,15 @@ object ItemUtils { fun ItemStack.hasEnchantments() = getEnchantments()?.isNotEmpty() ?: false fun ItemStack.removeEnchants(): ItemStack = apply { - val tag = tagCompound ?: NBTTagCompound() - tag.removeTag("ench") - tag.removeTag("StoredEnchantments") - tagCompound = tag + val tempTag = tagCompound ?: NBTTagCompound() + tempTag.removeTag("ench") + tempTag.removeTag("StoredEnchantments") + tagCompound = tempTag } fun ItemStack.getSkullTexture(): String? { if (item != Items.skull) return null - if (tagCompound == null) return null - val nbt = tagCompound + val nbt = tagCompound ?: return null if (!nbt.hasKey("SkullOwner")) return null return nbt.getCompoundTag("SkullOwner").getCompoundTag("Properties").getTagList("textures", Constants.NBT.TAG_COMPOUND) .getCompoundTagAt(0).getString("Value") @@ -188,8 +187,7 @@ object ItemUtils { fun ItemStack.getSkullOwner(): String? { if (item != Items.skull) return null - if (tagCompound == null) return null - val nbt = tagCompound + val nbt = tagCompound ?: return null if (!nbt.hasKey("SkullOwner")) return null return nbt.getCompoundTag("SkullOwner").getString("Id") } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt index d80fe5913..a2e32adaa 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/StringUtils.kt @@ -419,7 +419,7 @@ object StringUtils { private fun addComponent(foundCommands: MutableList<IChatComponent>, message: IChatComponent) { val clickEvent = message.chatStyle.chatClickEvent if (clickEvent != null) { - if (foundCommands.size == 1 && foundCommands[0].chatStyle.chatClickEvent.value == clickEvent.value) { + if (foundCommands.size == 1 && foundCommands[0].chatStyle.chatClickEvent?.value == clickEvent.value) { return } foundCommands.add(message) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/compat/SkyhanniBaseScreen.kt b/src/main/java/at/hannibal2/skyhanni/utils/compat/SkyhanniBaseScreen.kt index 11327f15d..17752b0b4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/compat/SkyhanniBaseScreen.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/compat/SkyhanniBaseScreen.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.utils.compat import net.minecraft.client.gui.GuiScreen abstract class SkyhanniBaseScreen : GuiScreen( - //#if MC > 1.12 + //#if MC > 1.12.2 //$$ net.minecraft.network.chat.TextComponent.EMPTY //#endif ) |
