aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/events
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/events')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt
new file mode 100644
index 000000000..41d8ea946
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt
@@ -0,0 +1,25 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.toLorenzVec
+import net.minecraft.block.state.IBlockState
+import net.minecraft.util.BlockPos
+
+class ServerBlockChangeEvent(val pos: BlockPos, val blockState: IBlockState) : LorenzEvent() {
+ val location by lazy { pos.toLorenzVec() }
+ val old by lazy { location.getBlockAt().toString().getName() }
+ val new by lazy { blockState.block.toString().getName() }
+
+ companion object {
+ val pattern = "Block\\{minecraft:(?<name>.*)}".toPattern()
+
+ private fun String.getName() = pattern.matchMatcher(this) {
+ group("name")
+ } ?: this
+
+ }
+
+}
+
+