echo reportedly ran git add . in src/main/resources instead of src/

This commit is contained in:
amy 2024-07-22 17:27:36 +03:30
parent 1abc960bff
commit 17e10c0775
2 changed files with 15 additions and 0 deletions

View file

@ -14,6 +14,7 @@ import net.minecraft.nbt.NbtOps;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.SimpleMenuProvider; import net.minecraft.world.SimpleMenuProvider;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.PumpkinBlock;
import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -56,6 +57,9 @@ public class ComputerBlockEntity extends BlockEntity {
public AjarFileSystem getFileSystem() { public AjarFileSystem getFileSystem() {
return fileSystem; return fileSystem;
} }
public JsVm getVm() {
return jsVm;
}
@Override @Override
protected void saveAdditional(@NotNull CompoundTag pTag, HolderLookup.@NotNull Provider pRegistries) { protected void saveAdditional(@NotNull CompoundTag pTag, HolderLookup.@NotNull Provider pRegistries) {

View file

@ -25,6 +25,7 @@ public class JsVm {
this.entity = entity; this.entity = entity;
this.sandbox.inject("screen", new ScreenHelper(entity)); this.sandbox.inject("screen", new ScreenHelper(entity));
this.sandbox.inject("fs", new FileSystemHelper(entity)); this.sandbox.inject("fs", new FileSystemHelper(entity));
this.sandbox.inject("js", new Js(entity));
this.sandbox.allow(ProcessHelper.class); this.sandbox.allow(ProcessHelper.class);
} }
@ -138,6 +139,16 @@ public class JsVm {
} }
} }
public class Js {
private final ComputerBlockEntity entity;
public Js(ComputerBlockEntity entity) {this.entity = entity;}
public void run(String path){
var fs = new FileSystemHelper(entity);
entity.getVm().executeScript(fs.readFile(path), new String[0]);
}
}
public void executeScript(String source, String[] args) { public void executeScript(String source, String[] args) {
try { try {
// TODO: provide an import facility of some sort // TODO: provide an import facility of some sort