Skip to content

Commit

Permalink
fix a bug where items were placed onto armor slots
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Jan 8, 2022
1 parent 73d38dc commit d13acce
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class MixinGuiContainer extends GuiScreen {
@Unique
private final GuiContainerHook hook = new GuiContainerHook(this);

@Inject(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;closeScreen()V", shift = At.Shift.BEFORE))
@Inject(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;closeScreen()V", shift = At.Shift.BEFORE), cancellable = true)
private void closeWindowPressed(CallbackInfo ci) {
hook.closeWindowPressed(ci);
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/kotlin/skytils/skytilsmod/Skytils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ class Skytils {
Utils.inDungeons = Utils.inSkyblock && ScoreboardUtil.sidebarLines.any {
(it.contains("The Catacombs") && !it.contains("Queue")) || it.contains("Dungeon Cleared:")
}
if (deobfEnvironment) {
if (DevTools.toggles.getOrDefault("forcehypixel", false)) Utils.isOnHypixel = true
if (DevTools.toggles.getOrDefault("forceskyblock", false)) Utils.inSkyblock = true
if (DevTools.toggles.getOrDefault("forcedungeons", false)) Utils.inDungeons = true
}
if (DevTools.getToggle("sprint"))
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSprint.keyCode, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container:
val partialTicks: Float
) : GuiContainerEvent(gui, container)

@Cancelable
data class CloseWindowEvent(override val gui: GuiContainer, override val container: Container) :
GuiContainerEvent(gui, container)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ class ProtectItems {
val item = mc.thePlayer.inventory.itemStack
val extraAttr = ItemUtil.getExtraAttributes(item)
if (ItemProtectStrategy.isAnyWorth(item, extraAttr, ItemProtectStrategy.ProtectType.USERCLOSEWINDOW)) {
notifyStopped(null, "dropping")
for (slot in event.container.inventorySlots) {
if (slot.inventory !== mc.thePlayer.inventory || slot.hasStack) continue
if (slot.inventory !== mc.thePlayer.inventory || slot.hasStack || !slot.isItemValid(item)) continue
mc.playerController.windowClick(event.container.windowId, slot.slotNumber, 0, 0, mc.thePlayer)
break
notifyStopped(null, "dropping")
return
}
notifyStopped(null, "closing the window on")
event.isCanceled = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GuiContainerHook(guiAny: Any) {
}

fun closeWindowPressed(ci: CallbackInfo) {
CloseWindowEvent(gui, gui.inventorySlots).postAndCatch()
if (CloseWindowEvent(gui, gui.inventorySlots).postAndCatch()) ci.cancel()
}

fun backgroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float, ci: CallbackInfo) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/skytils/skytilsmod/utils/DevTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package skytils.skytilsmod.utils
import gg.essential.universal.UChat

object DevTools {
private val toggles = HashMap<String, Boolean>()
val toggles = HashMap<String, Boolean>()
var allToggle = false
private set

Expand Down

0 comments on commit d13acce

Please sign in to comment.