Revert "call me the abuser the way i be absuing nea"

This reverts commit db4031f568.
This commit is contained in:
amy 2024-07-25 13:31:50 +03:30
parent db4031f568
commit bea1953ce8
2 changed files with 12 additions and 19 deletions

View file

@ -14,13 +14,16 @@ import net.minecraft.nbt.NbtOps;
import net.minecraft.network.chat.Component;
import net.minecraft.world.SimpleMenuProvider;
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.state.BlockState;
import org.apache.commons.io.IOUtils;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ComputerBlockEntity extends BlockEntity {
public ComputerBlockEntity(BlockPos pPos, BlockState pBlockState) {
@ -37,7 +40,7 @@ public class ComputerBlockEntity extends BlockEntity {
.fieldOf("screen")
.setPartial(() -> ComputerTerminal.ofSize(20, 30));
JsVm jsVm = new JsVm(this);
private char[] chars = new char[screen.dimensions().columns() * screen.dimensions().rows()];
private List<String> lines = new ArrayList<>();
@Override
protected void loadAdditional(@NotNull CompoundTag pTag, @NotNull HolderLookup.Provider pRegistries) {
@ -67,17 +70,6 @@ public class ComputerBlockEntity extends BlockEntity {
builder.build((CompoundTag) null).resultOrPartial(Ajar.LOGGER::error)
.ifPresent(it -> pTag.merge((CompoundTag) it));
}
public void setScreenString(ComputerTerminal.Dimensions startingPos, String value){
var bytes = value.toCharArray();
System.arraycopy(chars, startingPos.rows() * screen.dimensions().columns() + startingPos.columns(), bytes, 0, Math.min(bytes.length, screen.dimensions().columns() - startingPos.columns()));
}
public void setScreenChar(ComputerTerminal.Dimensions dimensions, char value){
chars[dimensions.rows() * screen.dimensions().columns() + dimensions.rows()] = value;
}
public char getScreenChar(ComputerTerminal.Dimensions dimensions){
return chars[dimensions.rows() * screen.dimensions().columns() + dimensions.rows()];
}
public void openMenu(Player pPlayer) {
pPlayer.openMenu(new SimpleMenuProvider(
@ -95,13 +87,13 @@ public class ComputerBlockEntity extends BlockEntity {
}
public void executeCommand(String line) {
setScreenChar(new ComputerTerminal.Dimensions(0,0), '$');
lines.add("$ " + line);
if (line.equals("small")) {
screen = ComputerTerminal.ofSize(10, 20);
setScreenString(new ComputerTerminal.Dimensions(0,0), "Made small!");
lines.add("Made small!");
} else if (line.equals("big")) {
screen = ComputerTerminal.ofSize(20, 30);
setScreenString(new ComputerTerminal.Dimensions(0,0), "Made big!");
lines.add("Made big!");
} else if (line.startsWith("resetfs")) {
var root = fileSystem.root().listing();
var directory = (AjarDirectory) root.compute("bin", (ignored, old) ->
@ -132,12 +124,12 @@ public class ComputerBlockEntity extends BlockEntity {
public ComputerScreenUpdate getSyncPacket(int windowId) {
return new ComputerScreenUpdate(windowId,
chars,
lines,
screen.dimensions().rows(),
screen.dimensions().columns());
}
public void addLine(ComputerTerminal.Dimensions dimensions, String line) {
setScreenString(dimensions, line);
public void addLine(String line) {
lines.add(line);
}
}

View file

@ -10,10 +10,11 @@ import net.neoforged.neoforge.network.handling.IPayloadContext;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public record ComputerScreenUpdate(
int windowId,
char[] lines,
List<String> lines,
int rows,
int columns
) implements CustomPacketPayload {