summaryrefslogtreewikicommitdiff
path: root/bukkit/src/packet/BlockChangePacket.kt
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-03-26 23:15:33 -0400
committerFreya Murphy <freya@freyacat.org>2026-03-27 23:09:23 -0400
commitf8322cd21cde68a72b05efbad3a05b8e67c0bdd0 (patch)
treed7e60bc8fedadc8fa7ae725571cad1f398eaf6dc /bukkit/src/packet/BlockChangePacket.kt
downloadkenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.gz
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.tar.bz2
kenshinshideandseek2-f8322cd21cde68a72b05efbad3a05b8e67c0bdd0.zip
initial
Diffstat (limited to 'bukkit/src/packet/BlockChangePacket.kt')
-rw-r--r--bukkit/src/packet/BlockChangePacket.kt20
1 files changed, 20 insertions, 0 deletions
diff --git a/bukkit/src/packet/BlockChangePacket.kt b/bukkit/src/packet/BlockChangePacket.kt
new file mode 100644
index 0000000..7d11f4e
--- /dev/null
+++ b/bukkit/src/packet/BlockChangePacket.kt
@@ -0,0 +1,20 @@
+package cat.freya.khs.bukkit.packet
+
+import com.github.retrooper.packetevents.PacketEvents
+import com.github.retrooper.packetevents.util.Vector3i
+import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerBlockChange
+import io.github.retrooper.packetevents.util.SpigotConversionUtil
+import org.bukkit.Bukkit
+import org.bukkit.Location
+import org.bukkit.Material
+import org.bukkit.entity.Player as BukkitPlayer
+
+data class BlockChangePacket(val location: Location, val material: Material) {
+ fun send(player: BukkitPlayer) {
+ val blockData = Bukkit.createBlockData(material)
+ val state = SpigotConversionUtil.fromBukkitBlockData(blockData)
+ val vector = Vector3i(location.blockX, location.blockY, location.blockZ)
+ val packet = WrapperPlayServerBlockChange(vector, state)
+ PacketEvents.getAPI().playerManager.sendPacket(player, packet)
+ }
+}