blob: 0e996e1579116af80361289e4e653276be7b694d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package com.ambientaddons.features.dungeon
import AmbientAddons.Companion.config
import AmbientAddons.Companion.mc
import com.ambientaddons.events.ReceivePacketEvent
import com.ambientaddons.utils.Area
import com.ambientaddons.utils.SBLocation
import net.minecraft.network.play.client.C0DPacketCloseWindow
import net.minecraft.network.play.server.S2DPacketOpenWindow
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object CloseChest {
@SubscribeEvent
fun onOpenWindow(event: ReceivePacketEvent) {
if (!config.closeSecretChests || SBLocation.area != Area.Dungeon) return
if (event.packet !is S2DPacketOpenWindow) return
if (event.packet.windowTitle.unformattedText == "Chest") {
mc.netHandler.networkManager.sendPacket(C0DPacketCloseWindow(event.packet.windowId))
event.isCanceled = true
}
}
}
|