Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In multiplayer, a player picking up a Paradox Machine can ban that player from the server until their NBT is edited. #243

Open
James103 opened this issue Oct 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@James103
Copy link

James103 commented Oct 20, 2024

Just Dire Things version

1.4.4

Minecraft Version

1.21(.1)

(Neo)Forge Version

21.1.66

Modpack & Version

Craftoria 1.5.0 (Craftoria EU Server)

Do you have optifine or Rubidium installed?

None

Describe the issue

Picking up a Paradox Machine can ban someone from a multiplayer server due to excessive NBT data.
This occurs because a Paradox Machine can save as many blocks and entities as possible, limited only by the size of their NBT data. With enough saved blocks and entities, the NBT data of the machine block item becomes too large to fit inside the packets being sent, causing the player to be disconnected on pick up and when re-joining.

Steps to reproduce

  1. Start a dedicated server and join it.
  2. Craft and place a Paradox Machine.
  3. Set the Paradox Machine to capture a large but confined area.
  4. Spawn over a hundred entities in the area
  5. Capture the area, which will save it to the machine's NBT data.
  6. In survival mode, break the machine with a silk touch pickaxe and pick it up.
  7. Depending on the number and arrangement of blocks and entities saved, the player picking up the machine may be disconnected and unable to rejoin.

Expected behaviour

A single Paradox Machine should not be able to kick or ban a player from a multiplayer server.
This can be done by adding a limit on the amount of blocks, entities, and/or NBT data that can be captured at once.

Alternatively, the Paradox Machine can hold a UUID which references an entry in a data file or spatial storage-like dimension containing the actual captured area. This is the approach taken by mods like Refined Storage and Sophisticated Backpacks.

Screenshots

No response

Log files

No response

Additional information

Originally reported in https://discord.com/channels/570630340075454474/1297364070579835043, re-posted here as this still looks like a problem.

See also:

public void snapshotArea() {
if (level == null) return;
BlockPos machinePos = getBlockEntity().getBlockPos(); // Get the machine's position
AABB area = getAABB(machinePos); // Get the affected area
List<CompoundTag> blockDataList = new ArrayList<>();
List<CompoundTag> entityDataList = new ArrayList<>();
// Capture blocks in the area
for (BlockPos pos : findBlocksToSave()) {
BlockState blockState = level.getBlockState(pos);
if (!blockState.isAir()) {
CompoundTag blockTag = new CompoundTag();
blockTag.put("pos", NbtUtils.writeBlockPos(pos.subtract(machinePos))); // Relative position
blockTag.put("state", NbtUtils.writeBlockState(blockState)); // Block state
blockDataList.add(blockTag);
}
}
// Capture entities in the area
List<LivingEntity> entities = findEntitiesToSave(area);
for (LivingEntity entity : entities) {
CompoundTag entityTag = new CompoundTag();
CompoundTag entityData = new CompoundTag();
entity.save(entityData);
Vec3 entityRelativePos = entity.position().subtract(Vec3.atCenterOf(machinePos)); // Relative position as Vec3
entityTag.put("relativePos", NBTHelpers.vec3ToNBT(entityRelativePos)); // Save Vec3 position
entityTag.put("data", entityData);
entityDataList.add(entityTag);
}
snapshotData = new CompoundTag();
snapshotData.put("blocks", writeBlockDataList(blockDataList)); // Store blocks
snapshotData.put("entities", writeEntityDataList(entityDataList)); // Store entities
clearSnapshotCache();
markDirtyClient();
}

@James103 James103 added the bug Something isn't working label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant