-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continuously send script data to terminal clients
- Loading branch information
1 parent
518c3c5
commit 5711456
Showing
5 changed files
with
139 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...org/cyclops/integratedscripting/network/packet/TerminalScriptingModifiedScriptPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.cyclops.integratedscripting.network.packet; | ||
|
||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraftforge.api.distmarker.Dist; | ||
import net.minecraftforge.api.distmarker.OnlyIn; | ||
import org.cyclops.cyclopscore.network.CodecField; | ||
import org.cyclops.cyclopscore.network.PacketCodec; | ||
import org.cyclops.integratedscripting.inventory.container.ContainerTerminalScripting; | ||
|
||
import java.nio.file.Path; | ||
|
||
/** | ||
* Packet for sending modified scripts between server and client. | ||
* @author rubensworks | ||
* | ||
*/ | ||
public class TerminalScriptingModifiedScriptPacket extends PacketCodec { | ||
|
||
@CodecField | ||
private int disk; | ||
@CodecField | ||
private String path; | ||
@CodecField | ||
private String script; | ||
|
||
public TerminalScriptingModifiedScriptPacket() { | ||
|
||
} | ||
|
||
public TerminalScriptingModifiedScriptPacket(int disk, Path path, String script) { | ||
this.disk = disk; | ||
this.path = path.toString(); | ||
this.script = script; | ||
} | ||
|
||
@Override | ||
public boolean isAsync() { | ||
return false; | ||
} | ||
|
||
@Override | ||
@OnlyIn(Dist.CLIENT) | ||
public void actionClient(Level world, Player player) { | ||
if(player.containerMenu instanceof ContainerTerminalScripting container) { | ||
container.setLastScript(disk, Path.of(path), script); | ||
} | ||
} | ||
|
||
@Override | ||
public void actionServer(Level world, ServerPlayer player) { | ||
if(player.containerMenu instanceof ContainerTerminalScripting container) { | ||
container.setServerScript(disk, Path.of(path), script); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters