diff --git a/html/mainPage/script.js b/html/mainPage/script.js
index b3ae8d6..b9e9b07 100644
--- a/html/mainPage/script.js
+++ b/html/mainPage/script.js
@@ -266,6 +266,17 @@ ipcRenderer.on('copyPacketData', (event, arg) => {
ipcRenderer.send('copyToClipboard', data)
})
+ipcRenderer.on('copyTeleportCommand', (event, arg) => {
+ const ipcMessage = JSON.parse(arg)
+ let data = allPackets[ipcMessage.id].data
+ data = '/tp @p ' + ((data.flags & 0x01) ? '~' : '') + data.x
+ + ((data.flags & 0x02) ? ' ~' : ' ') + data.y
+ + ((data.flags & 0x04) ? ' ~' : ' ') + data.z
+ + ((data.flags & 0x08) ? ' ~' : ' ') + data.yaw
+ + ((data.flags & 0x10) ? ' ~' : ' ') + data.pitch
+ ipcRenderer.send('copyToClipboard', data)
+})
+
window.closeDialog = function () { // window. stops standardjs from complaining
// dialogOpen = false
document.getElementById('dialog-overlay').className = 'dialog-overlay'
diff --git a/src/index.js b/src/index.js
index 7b59183..49760ba 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,7 +18,7 @@ const osDataFolder = app.getPath('appData')
const dataFolder = setupDataFolder.setup(osDataFolder, resourcesPath)
function makeMenu (direction, text, id) {
- return Menu.buildFromTemplate([
+ let menuData = [
{
icon: resourcesPath + `icons/${direction}.png`,
label: text,
@@ -55,7 +55,23 @@ function makeMenu (direction, text, id) {
}))
}
}
- ])
+ ]
+
+ if (text.split(' ')[1] === 'position' && direction === 'clientbound') {
+ menuData.splice(3, 0,
+ {
+ label: 'Copy teleport as command',
+ click: () => {
+ BrowserWindow.getAllWindows()[0].send('copyTeleportCommand', JSON.stringify({
+ // Packet ID from link URL
+ id: id
+ }))
+ }
+ }
+ )
+ }
+
+ return Menu.buildFromTemplate(menuData)
}
function createWindow () {