Logic data instruction (#9935)

* Logic `data` instruction

* Rename to `clientdata` & reliable option

* frog

Co-authored-by: Anuken <arnukren@gmail.com>

---------

Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
Redstonneur1256
2024-06-16 15:29:35 +02:00
committed by GitHub
parent 2e460bf483
commit 58dbc5104f
4 changed files with 85 additions and 0 deletions

View File

@@ -41,6 +41,7 @@ public class LExecutor{
maxDisplayBuffer = 1024,
maxTextBuffer = 400;
public LInstruction[] instructions = {};
/** Non-constant variables used for network sync */
public LVar[] vars = {};
@@ -1761,6 +1762,31 @@ public class LExecutor{
}
}
public static class ClientDataI implements LInstruction{
public LVar channel, value, reliable;
public ClientDataI(LVar channel, LVar value, LVar reliable){
this.channel = channel;
this.value = value;
this.reliable = reliable;
}
public ClientDataI() {
}
@Override
public void run(LExecutor exec) {
if(channel.obj() instanceof String c){
Object v = value.isobj ? value.objval : value.numval;
if(reliable.bool()){
Call.clientLogicDataReliable(c, v);
}else{
Call.clientLogicDataUnreliable(c, v);
}
}
}
}
public static class GetFlagI implements LInstruction{
public LVar result, flag;