Skip to content

Extended View Distance - #335

Open
Dueris wants to merge 4 commits into
mainfrom
dev/extended-view
Open

Dueris wants to merge 4 commits into
mainfrom
dev/extended-view

Conversation

@Dueris

@Dueris Dueris commented Sep 12, 2026

Copy link
Copy Markdown
Member

This will be made into a base patch soon, but I need to extract the per-world-distance system too, since this is based somewhat on that system.

This adds a new "fake chunk" system to Canvas, sending out fake chunks to extend the view distance of the client without actually loading any chunks on the server. One caveat is that this only reads already generated chunks from disk, and does not generate new chunks, meaning this will only really be beneficial for servers that are pre-generated.

This needs some production testing, and a few more things need to be done, but the base implementation is done. This also has builtin "hollowing" of chunks to try and set as much of the chunk to air as possible to try and reduce bandwidth as much as possible. At the time of creating this PR bandwidth for these chunks seems to be cut anywhere between 35-65%, and hopefully it will be a bit better later.

Comment thread canvas-server/minecraft-patches/features/0003-Extended-View-Distance.patch Outdated

@R00tB33rMan R00tB33rMan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw region NBT is parsed without chunkMap.upgradeChunkTag first, unlike ChunkLoadTask.runOffMain, so chunks saved under an older data version render wrong or throw. (Currently uncertain)

+ private static final Predicate<BlockState> IS_ORE = (state) ->
+ state.is(BlockTags.COPPER_ORES)
+ || state.is(BlockTags.IRON_ORES)
+ || state.is(BlockTags.GOLD_ORES)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few notes that we'll need to likely tackle:
OLD_ORES (which includes nether gold ore) is replaced with STONE in the nether while ancient debris gets the netherrack special case, also that emerald ore, deepslate emerald ore and nether quartz ore are not in IS_ORE, given fake packets skip anti-xray entirely, and that the "bottom half is truncated" assumption in clearOres only holds when hollowChunks is on, so hideOres alone puts stone specks into deepslate

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something I want to improve in general via a customizable map of sorts in the config to let servers configure their own block "hide" or "replace" mechanics.

@Dueris

Dueris commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

Raw region NBT is parsed without chunkMap.upgradeChunkTag first, unlike ChunkLoadTask.runOffMain, so chunks saved under an older data version render wrong or throw. (Currently uncertain)

You are correct. Fixed.

@Cubicake

Copy link
Copy Markdown

Will there be a way to detect fake chunks from the plugin-side? I do a lot of chunk packet modifying in my plugin and I think it'd be better to skip that logic for fake chunks given that the more authoritative chunk packet will be sent if the player gets close.

@Dueris

Dueris commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

You could check the VVChunkCache of the world to see if the fake chunk is present in the cache. I plan to do a lot more "hollowing" and generic culling of the chunk in general though. What sort of thing r u needing for your plugin

@Cubicake

Copy link
Copy Markdown

What sort of thing r u needing for your plugin

Just some sort of lightweight way to flag it as a fake chunk so I can bypass my expensive logic for it. Preferably it'd be one of

  1. Data attached to the chunk
    a. Admittedly this would be hacky
  2. Some sort of player-netty-thread local data store I can query with chunk coordinates and receive whether it is a real, fake, or unloaded chunk for that player
  3. Some sort of event that fires on the player's netty thread so I can make my own version of option 2

@Dueris

Dueris commented Sep 13, 2026

Copy link
Copy Markdown
Member Author

Do u have access to the NMS object instance of the packet in your plugin? ClientboundLevelChunkWithLightPacket

@Cubicake

Copy link
Copy Markdown

I'm using packetevents so unfortunately not currently. If you decide to store the flag on the NMS object though, I could add a canvas-specific path to access it and check for the flag then implement option 2 myself, so if that's the easiest way then it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants