diff --git a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java index 93a9d0113..1f831574f 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/computer/blocks/CommandComputerBlockEntity.java @@ -20,28 +20,24 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; -import java.util.HashMap; -import java.util.Map; +import java.util.ArrayList; +import java.util.List; public class CommandComputerBlockEntity extends ComputerBlockEntity { public class CommandReceiver implements CommandSource { - private final Map output = new HashMap<>(); + private final List output = new ArrayList<>(); public void clearOutput() { output.clear(); } - public Map getOutput() { - return output; - } - - public Map copyOutput() { - return new HashMap<>(output); + public List copyOutput() { + return new ArrayList<>(output); } @Override public void sendSystemMessage(Component textComponent) { - output.put(output.size() + 1, textComponent.getString()); + output.add(textComponent.getString()); } @Override diff --git a/projects/common/src/main/java/dan200/computercraft/shared/util/NBTUtil.java b/projects/common/src/main/java/dan200/computercraft/shared/util/NBTUtil.java index bad2223cb..96cdc6194 100644 --- a/projects/common/src/main/java/dan200/computercraft/shared/util/NBTUtil.java +++ b/projects/common/src/main/java/dan200/computercraft/shared/util/NBTUtil.java @@ -19,9 +19,7 @@ import java.io.IOException; import java.io.OutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public final class NBTUtil { private static final Logger LOG = LoggerFactory.getLogger(NBTUtil.class); @@ -149,20 +147,20 @@ public final class NBTUtil { } case Tag.TAG_LIST: { var list = (ListTag) tag; - Map map = new HashMap<>(list.size()); - for (var i = 0; i < list.size(); i++) map.put(i, toLua(list.get(i))); + List map = new ArrayList<>(list.size()); + for (var value : list) map.add(toLua(value)); return map; } case Tag.TAG_BYTE_ARRAY: { var array = ((ByteArrayTag) tag).getAsByteArray(); - Map map = new HashMap<>(array.length); - for (var i = 0; i < array.length; i++) map.put(i + 1, array[i]); + List map = new ArrayList<>(array.length); + for (var b : array) map.add(b); return map; } case Tag.TAG_INT_ARRAY: { var array = ((IntArrayTag) tag).getAsIntArray(); - Map map = new HashMap<>(array.length); - for (var i = 0; i < array.length; i++) map.put(i + 1, array[i]); + List map = new ArrayList<>(array.length); + for (var j : array) map.add(j); return map; }