From e260cc308bdda1383689d26db082d7d63764098d Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Sun, 15 Dec 2024 18:43:04 +0800 Subject: [PATCH] notice to inform you that you are wrong --- blocks/World.js | 4 ++-- functions.js | 36 +++++++++++++++++++++++------------- serialise.js | 6 +++++- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/blocks/World.js b/blocks/World.js index 925c726..d195096 100644 --- a/blocks/World.js +++ b/blocks/World.js @@ -12,7 +12,7 @@ const world_explosion = { .appendField('Fire:'); this.appendValueInput('SMOKE') .setCheck('Boolean') - .appendField('Particles:'); + .appendField('Break Blocks:'); this.setInputsInline(false) this.setPreviousStatement(true, null); this.setNextStatement(true, null); @@ -46,7 +46,7 @@ const world_command = { this.setInputsInline(false) this.setPreviousStatement(true, null); this.setNextStatement(true, null); - this.setTooltip(''); + this.setTooltip('NOTICE: @selectors do NOT work'); this.setHelpUrl(''); this.setColour(195); }, diff --git a/functions.js b/functions.js index 2a4779a..d66ce81 100644 --- a/functions.js +++ b/functions.js @@ -33,20 +33,30 @@ FUNCTIONS["execute_command"] = { code: function () { function EFB2__defineExecCmdGlobal() { globalThis.efb2__executeCommand = function efb2__executeCommand($world, $blockpos, commandStr) { - var fakeEntity = (new new ModAPI.reflect.getClassByName("Entity").class); - fakeEntity.$setPosition($blockpos.$x, $blockpos.$y, $blockpos.$z); - var vector = ModAPI.reflect.getClassByName("Vec3").constructors[0]($blockpos.$x, $blockpos.$y, $blockpos.$z); - var cmd = Object.assign((new new ModAPI.reflect.getClassByName("CommandBlockLogic").class), { - $func_145751_f: ()=>{return 1}, - $updateCommand: ()=>{}, - $func_145757_a: ()=>{}, - $getPosition: ()=>{return $blockpos}, - $getPositionVector: ()=>{return vector}, - $getEntityWorld: ()=>{return $world}, - $getCommandSenderEntity: ()=>{return fakeEntity} - }); + if ($world.$isRemote) { + return; + } + function x() { + ModAPI.reflect.getSuper(ModAPI.reflect.getClassByName("CommandBlockLogic"))(this); + } + ModAPI.reflect.prototypeStack(ModAPI.reflect.getClassByName("CommandBlockLogic"), x); + var vector = ModAPI.reflect.getClassByName("Vec3").constructors[0]($blockpos.$x + 0.5, $blockpos.$y + 0.5, $blockpos.$z + 0.5); + x.prototype.$getEntityWorld = ()=>{return $world}; + x.prototype.$getCommandSenderEntity = ()=>{return null}; + x.prototype.$updateCommand = ()=>{}; + x.prototype.$func_145757_a = ()=>{}; + x.prototype.$getPosition = ()=>{return $blockpos}; + x.prototype.$getPositionVector = ()=>{return vector}; + x.prototype.$func_145751_f = ()=>{return 0}; + var cmd = new x(); cmd.$setCommand(ModAPI.util.str(commandStr)); - cmd.$trigger($world); + + try { + debugger; + cmd.$trigger($world); + } catch (error) { + console.error(error); + } } } ModAPI.dedicatedServer.appendCode(EFB2__defineExecCmdGlobal); diff --git a/serialise.js b/serialise.js index d7ba0df..1cf326a 100644 --- a/serialise.js +++ b/serialise.js @@ -9,7 +9,11 @@ function serialise() { } function deserialise(data) { var data = JSON.parse(data); - Blockly.serialization.workspaces.load(data.blockly || {}, workspace); + try { + Blockly.serialization.workspaces.load(data.blockly || {}, workspace); + } catch (error) { + + } globalThis.state = data; reloadUI(); }