aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMy-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com>2021-10-09 13:57:28 -0400
committerMy-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com>2021-10-09 13:57:28 -0400
commit394e02887c040c163e10e4a09c25239133a60514 (patch)
tree26440ac90f294e57249ef519b8367e0afca3ce5d /src/main
parentbfbdfe3c6ce66151633f12481d9a37c041d45025 (diff)
downloadSkytilsMod-394e02887c040c163e10e4a09c25239133a60514.tar.gz
SkytilsMod-394e02887c040c163e10e4a09c25239133a60514.tar.bz2
SkytilsMod-394e02887c040c163e10e4a09c25239133a60514.zip
yeet the dumb cache system
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java8
-rw-r--r--src/main/kotlin/skytils/skytilsmod/events/SlotChangedEvent.kt23
-rw-r--r--src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt88
-rw-r--r--src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt5
4 files changed, 45 insertions, 79 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java b/src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java
index 51ddbf1a..9203f58b 100644
--- a/src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java
+++ b/src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java
@@ -36,10 +36,4 @@ public abstract class MixinSlot {
private void markTerminalItems(CallbackInfoReturnable<ItemStack> cir) {
SlotHookKt.markTerminalItems($this, cir);
}
-
- @Inject(method = "onSlotChanged", at = @At("HEAD"))
- private void onSlotChange(CallbackInfo ci) {
- SlotHookKt.onSlotChange($this);
- }
-
-}
+} \ No newline at end of file
diff --git a/src/main/kotlin/skytils/skytilsmod/events/SlotChangedEvent.kt b/src/main/kotlin/skytils/skytilsmod/events/SlotChangedEvent.kt
deleted file mode 100644
index efd1a19a..00000000
--- a/src/main/kotlin/skytils/skytilsmod/events/SlotChangedEvent.kt
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Skytils - Hypixel Skyblock Quality of Life Mod
- * Copyright (C) 2021 Skytils
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package skytils.skytilsmod.events
-
-import net.minecraft.inventory.Slot
-
-class SlotChangedEvent(val slot: Slot) : SkytilsEvent() \ No newline at end of file
diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt
index 658e1ac6..4cd2cc35 100644
--- a/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt
+++ b/src/main/kotlin/skytils/skytilsmod/features/impl/misc/ItemFeatures.kt
@@ -32,6 +32,7 @@ import net.minecraft.init.Items
import net.minecraft.inventory.ContainerChest
import net.minecraft.item.ItemStack
import net.minecraft.network.play.server.S2APacketParticles
+import net.minecraft.network.play.server.S2FPacketSetSlot
import net.minecraft.util.EnumFacing
import net.minecraft.util.EnumParticleTypes
import net.minecraft.util.MovingObjectPosition
@@ -40,21 +41,19 @@ import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.event.entity.EntityJoinWorldEvent
import net.minecraftforge.event.entity.player.ItemTooltipEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent
-import net.minecraftforge.event.world.WorldEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import net.minecraftforge.fml.common.gameevent.TickEvent
import org.lwjgl.input.Keyboard
import skytils.skytilsmod.Skytils
import skytils.skytilsmod.Skytils.Companion.mc
import skytils.skytilsmod.core.GuiManager
-import skytils.skytilsmod.core.TickTask
import skytils.skytilsmod.core.structure.FloatPair
import skytils.skytilsmod.core.structure.GuiElement
import skytils.skytilsmod.events.GuiContainerEvent
import skytils.skytilsmod.events.GuiContainerEvent.SlotClickEvent
import skytils.skytilsmod.events.GuiRenderItemEvent
import skytils.skytilsmod.events.PacketEvent.ReceiveEvent
-import skytils.skytilsmod.events.SlotChangedEvent
import skytils.skytilsmod.features.impl.handlers.AuctionData
import skytils.skytilsmod.utils.*
import skytils.skytilsmod.utils.ItemUtil.getDisplayName
@@ -121,56 +120,21 @@ class ItemFeatures {
Blocks.oak_door,
Blocks.skull
)
+
+ var ticks = 0
}
@SubscribeEvent
- fun onWorldChange(event: WorldEvent.Load) {
- TickTask(20) {
+ fun onTick(event: TickEvent.ClientTickEvent) {
+ if (ticks % 4 == 0) {
if (mc.thePlayer != null && Utils.inSkyblock) {
for (i in 0..8) {
hotbarRarityCache[i] = ItemUtil.getRarity(mc.thePlayer.inventory.mainInventory[i])
}
}
+ ticks = 0
}
- }
-
- @SubscribeEvent
- fun onSlotChanged(event: SlotChangedEvent) {
- if (mc.thePlayer == null || (!Utils.inSkyblock && mc.thePlayer.ticksExisted > 1)) return
- val slot = event.slot
-
- if (mc.thePlayer.inventory === slot.inventory && slot.slotIndex in 0..8) {
- for (i in 0..8) {
- hotbarRarityCache[i] = ItemUtil.getRarity(mc.thePlayer.inventory.mainInventory[i])
- }
- }
-
- val item = slot.stack ?: return
- val extraAttr = getExtraAttributes(item) ?: return
- val itemId = getSkyBlockItemID(extraAttr) ?: return
-
- if (itemId == "ARROW_SWAPPER") {
- selectedArrow = getItemLore(item).find {
- it.startsWith("§aSelected: §")
- }?.substringAfter("§aSelected: ") ?: "§cUnknown"
- }
- if (Utils.equalsOneOf(itemId, "SOULFLOW_PILE", "SOULFLOW_BATTERY", "SOULFLOW_SUPERCELL")) {
- getItemLore(item).find {
- it.startsWith("§7Internalized: ")
- }?.substringAfter("§7Internalized: ")?.let { s ->
- soulflowAmount = s
- s.drop(2).filter { it.isDigit() }.toIntOrNull()?.let {
- if (Skytils.config.lowSoulflowPing > 0) {
- if (it <= Skytils.config.lowSoulflowPing && !lowSoulFlowPinged) {
- GuiManager.createTitle("§cLow Soulflow", 20)
- lowSoulFlowPinged = true
- } else if (it > Skytils.config.lowSoulflowPing) {
- lowSoulFlowPinged = false
- }
- }
- }
- }
- }
+ ticks++
}
@SubscribeEvent
@@ -405,6 +369,42 @@ class ItemFeatures {
} catch (e: ConcurrentModificationException) {
e.printStackTrace()
}
+ if (event.packet is S2FPacketSetSlot && event.packet.func_149175_c() == 0) {
+ Utils.checkThreadAndQueue {
+ if (mc.thePlayer == null || (!Utils.inSkyblock && mc.thePlayer.ticksExisted > 1)) return@checkThreadAndQueue
+ val slot = event.packet.func_149173_d()
+
+ if (slot in 0..8) {
+ hotbarRarityCache[slot] = ItemUtil.getRarity(event.packet.func_149174_e())
+ }
+ val item = event.packet.func_149174_e() ?: return@checkThreadAndQueue
+ val extraAttr = getExtraAttributes(item) ?: return@checkThreadAndQueue
+ val itemId = getSkyBlockItemID(extraAttr) ?: return@checkThreadAndQueue
+
+ if (itemId == "ARROW_SWAPPER") {
+ selectedArrow = getItemLore(item).find {
+ it.startsWith("§aSelected: §")
+ }?.substringAfter("§aSelected: ") ?: "§cUnknown"
+ }
+ if (Utils.equalsOneOf(itemId, "SOULFLOW_PILE", "SOULFLOW_BATTERY", "SOULFLOW_SUPERCELL")) {
+ getItemLore(item).find {
+ it.startsWith("§7Internalized: ")
+ }?.substringAfter("§7Internalized: ")?.let { s ->
+ soulflowAmount = s
+ s.drop(2).filter { it.isDigit() }.toIntOrNull()?.let {
+ if (Skytils.config.lowSoulflowPing > 0) {
+ if (it <= Skytils.config.lowSoulflowPing && !lowSoulFlowPinged) {
+ GuiManager.createTitle("§cLow Soulflow", 20)
+ lowSoulFlowPinged = true
+ } else if (it > Skytils.config.lowSoulflowPing) {
+ lowSoulFlowPinged = false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
@SubscribeEvent
diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt
index 5de46b32..796619dc 100644
--- a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt
+++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt
@@ -21,15 +21,10 @@ import net.minecraft.inventory.Slot
import net.minecraft.item.ItemStack
import net.minecraft.nbt.NBTTagCompound
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
-import skytils.skytilsmod.events.SlotChangedEvent
import skytils.skytilsmod.features.impl.dungeons.solvers.terminals.SelectAllColorSolver
import skytils.skytilsmod.features.impl.dungeons.solvers.terminals.StartsWithSequenceSolver
import skytils.skytilsmod.utils.Utils
-fun onSlotChange(slot: Slot) {
- SlotChangedEvent(slot).postAndCatch()
-}
-
fun markTerminalItems(slot: Slot, cir: CallbackInfoReturnable<ItemStack?>) {
if (!Utils.inSkyblock) return
val item: ItemStack = (slot.inventory.getStackInSlot(slot.slotIndex) ?: return).copy()