Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Recommended Paper Anti-Xray settings by stonar96

Recommended Paper Anti-Xray settings by stonar96

General

Anti-Xray can be configured per world in the paper.yml configuration file. To understand how per world configuration works please read this[1] first. Note that after changing any settings for Anti-Xray you have to restart your server. Executing the /reload command (you should never do this) won't apply the settings to worlds that are already loaded.

The official documentation for the Anti-Xray settings and what they mean can be found here.

Basically Anti-Xray has two different modes. engine-mode: 1 replaces specified ores by "fake" stone, netherrack or end stone blocks depending on the world type and engine-mode: 2 randomly places specified fake ores when a chunk packet is sent to the client. The following picture[2] shows how this looks like for a player using Xray on your server.

Anti-Xray modes

engine-mode: 1 is less computationally intensive but engine-mode: 2 works better to prevent Xray. As you can see in the picture above, engine-mode: 1 isn't perfect because only ores that are completely covered by solid blocks can be hidden. This means that ores exposed to air in caves, for example, are still visible. In engine-mode: 2 fake ores obstruct the view to these ores and additionally fake air blocks can also be added.

Default settings

These are the default settings for Anti-Xray. As already mentioned above, you should take a look at the official documentation. I've added some additional info in the comments below that isn't currently there.

world-settings:
  default:
    # Other default world-settings.
    anti-xray:
      # enabled controls the on/off state for the Anti-Xray system.
      enabled: false
      # engine-mode is described above.
      engine-mode: 1
      # As of 1.15.2 build #248 chunk-edge-mode doesn't exist anymore.
      # This setting isn't necessary anymore because neighbor chunks are now usually loaded anyway.
      # Sets how the engine handles chunk edges.
      # Where 1 is not to obfuscate the edges of chunks with unloaded neighbors,
      # 2 is to not send the chunk until its neighbors are present (similar to a x-1 view distance),
      # and 3 is to load the neighbor so it can properly obfuscate the current edge (similar to an x+1 view distance).
      chunk-edge-mode: 2
      # As of 1.17 build #1 max-chunk-section-index doesn't exist anymore.
      # This setting is replaced by the max-block-height setting.
      # max-chunk-section-index controls the height the engine should operate to.
      # y = (max-chunk-section-index + 1) * 16
      # A max-chunk-section-index greater than 15 defaults to 15. A max-chunk-section-index smaller than 0 doesn't make sense.
      max-chunk-section-index: 3
      # max-block-height controls the height (y-coordinate) the engine should operate to.
      # Only integer multiples of 16 are possible values.
      # If another value is specified, it is "rounded down" to the nearest multiple of 16.
      max-block-height: 64
      # update-radius is the radius for block updates, which send the real blocks to the client when a block is broken.
      # There are only 3 valid options: 0, 1 and 2.
      # An update-radius greater than 2 defaults to 2. An update-radius smaller than 0 defaults to 0.
      # Don't use update-radius: 0 in production. This is only a test mode.
      update-radius: 2
      # Whether or not to obfuscate blocks touching lava.
      # Doesn't work well with non-stone-like ore textures.
      lava-obscures: false
      # Whether or not to enable support for the paper.antixray.bypass permission.
      # Depending on your permission plugin, this may cause performance issues.
      use-permission: false
      # In engine-mode: 1 hidden-blocks are replaced by stone, netherrack or end_stone depending on the world type.
      #                   air will be ignored in this list.
      # In engine-mode: 2 hidden-blocks are randomly placed.
      #                   tile entities such as chest or spawner will be ignored in this list.
      #                   blocks can be added multiple times to this list, those will be used accordingly more often.
      #                   an empty or invalid list or a list that only contains ignored blocks results in diamond ore being placed.
      #                   the default block states are placed.
      hidden-blocks:
      - copper_ore
      - deepslate_copper_ore
      - gold_ore
      - deepslate_gold_ore
      - iron_ore
      - deepslate_iron_ore
      - coal_ore
      - deepslate_coal_ore
      - lapis_ore
      - deepslate_lapis_ore
      - mossy_cobblestone
      - obsidian
      - chest
      - diamond_ore
      - deepslate_diamond_ore
      - redstone_ore
      - deepslate_redstone_ore
      - clay
      - emerald_ore
      - deepslate_emerald_ore
      - ender_chest
      # In engine-mode: 1 replacement-blocks are not used. Changing this list in engine-mode: 1 has no effect.
      # In engine-mode: 2 replacement-blocks and hidden-blocks are randomly replaced by hidden-blocks.
      #                   tile entities such as chest or spawner will be ignored in hidden-blocks.
      #                   tile entities can be added to replacement-blocks.
      #                   air won't be replaced regardless of where it was added.
      replacement-blocks:
      - stone
      - oak_planks
      - deepslate
    # Other default world-settings.

Recommended settings

Engine-Mode 1

world-settings:
  default:
    # Other default world-settings.
    anti-xray:
      enabled: true
      engine-mode: 1
      chunk-edge-mode: 2
      max-chunk-section-index: 3
      max-block-height: 64
      update-radius: 2
      lava-obscures: false
      use-permission: false
      hidden-blocks:
      # There's no chance to hide dungeon chests but buried treasures will be hidden.
      - chest
      - coal_ore
      - deepslate_coal_ore
      - copper_ore
      - deepslate_copper_ore
      - diamond_ore
      - deepslate_diamond_ore
      - emerald_ore
      - deepslate_emerald_ore
      - gold_ore
      - deepslate_gold_ore
      - iron_ore
      - deepslate_iron_ore
      - lapis_ore
      - deepslate_lapis_ore
      - redstone_ore
      - deepslate_redstone_ore
      replacement-blocks:
      - stone
      - oak_planks
      - deepslate
    # Other default world-settings.
  # world_nether: needs to be changed if your world is named differently.
  world_nether:
    anti-xray:
      max-chunk-section-index: 7
      max-block-height: 128
      hidden-blocks:
      - ancient_debris
      - nether_gold_ore
      - nether_quartz_ore
  # world_the_end: needs to be changed if your world is named differently.
  world_the_end:
    anti-xray:
      enabled: false

Engine-Mode 2

world-settings:
  default:
    # Other default world-settings.
    anti-xray:
      enabled: true
      engine-mode: 2
      chunk-edge-mode: 2
      max-chunk-section-index: 2
      max-block-height: 48
      update-radius: 2
      lava-obscures: false
      use-permission: false
      hidden-blocks:
      # You can add air here such that many holes are generated.
      # This works well against cave finders but may cause client FPS drops for all players.
      - air
      - copper_ore
      - deepslate_copper_ore
      - diamond_ore
      - deepslate_diamond_ore
      - emerald_ore
      - deepslate_emerald_ore
      - gold_ore
      - deepslate_gold_ore
      - iron_ore
      - deepslate_iron_ore
      - lapis_ore
      - deepslate_lapis_ore
      - mossy_cobblestone
      - redstone_ore
      - deepslate_redstone_ore
      replacement-blocks:
      # Chest is a tile entity and can't be added to hidden-blocks in engine-mode: 2.
      # But adding chest here will hide buried treasures, if max-chunk-section-index is increased.
      - chest
      - amethyst_block
      - andesite
      - budding_amethyst
      - calcite
      - deepslate
      - diorite
      - dirt
      - granite
      - gravel
      - oak_planks
      - smooth_basalt
      - stone
      - tuff
    # Other default world-settings.
  # world_nether: needs to be changed if your world is named differently.
  world_nether:
    anti-xray:
      max-chunk-section-index: 7
      max-block-height: 128
      hidden-blocks:
      # See note about air above.
      - air
      - ancient_debris
      - bone_block
      - glowstone
      - magma_block
      - nether_bricks
      - nether_gold_ore
      - nether_quartz_ore
      - polished_blackstone_bricks
      replacement-blocks:
      - basalt
      - blackstone
      - gravel
      - netherrack
      - soul_sand
      - soul_soil
  # world_the_end: needs to be changed if your world is named differently.
  world_the_end:
    anti-xray:
      enabled: false

References

[1] Unfortunately I don't know who exactly made this. It is part of this guide.

[2] This picture was made by the user Oberfail on the PaperMC Discord.

@porterporter

This comment has been minimized.

Copy link

@porterporter porterporter commented Aug 19, 2020

after adding this to the paper.yml file, the server crashes on startup. is there something i'm doing wrong?

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented Aug 23, 2020

You probably did something wrong. Here are several things you can try:

  • Make sure that you keep indents from the example.
  • Make sure that your editor doesn't insert tabs, just spaces.
  • Note that the world_nether: and world_the_end: sections have to be pasted below the default: section. So don't just copy the whole example. You have to split it up. The first part replaces the existing world-settings.default.anti-xray section and the second part is added below where the default: section ends.
  • Before (re)starting the server paste your whole paper.yml here and check if it's a valid YAML.

Here is an example paper.yml (1.16.2-r6.jar) with recommended Anti-Xray settings for engine-mode: 2. Please do not copy this file. It won't be updated with changes of this guide or updates of Paper. Of course, it doesn't include the changes you've already made and it probably doesn't match your server version. Use this as an example only, which shows where and how to paste the examples in this guide. Note that the world_nether: and world_the_end: sections don't necessarily have to be at the end of the file, but rather at the end of the default: section. This is important.

@enfuego311

This comment has been minimized.

Copy link

@enfuego311 enfuego311 commented Aug 31, 2020

I'd completely overlooked setting this up for the end. Thank you for the quick and easy guide for me to get caught up. Much appreciated!

@kevindwitama

This comment has been minimized.

Copy link

@kevindwitama kevindwitama commented Sep 8, 2020

Is max-chunk-section-index: meant to be 2 for engine-mode: 2? Should it not be set to 3 to reach y=64?
Also, am I understanding this right; if - air exists in hidden-blocks: it may cause FPS drops, therefore removing it will remove said drops right?

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented Sep 12, 2020

I'd completely overlooked setting this up for the end. Thank you for the quick and easy guide for me to get caught up. Much appreciated!

Thanks, you're welcome.

Is max-chunk-section-index: meant to be 2 for engine-mode: 2? Should it not be set to 3 to reach y=64?

Of course you can set max-chunk-section-index: to 3 (y=64). The reason I decided to set it to 2 (y=48) is that there aren't many ores to hide above anyway and that's a way to save resources.

Also, am I understanding this right; if - air exists in hidden-blocks: it may cause FPS drops, therefore removing it will remove said drops right?

Yes. But note that it may be that the said FPS drops don't even exist. I have never experienced the FPS drops myself. I have heard several times that people had problems with older client version. However, there doesn't seem to be any problems with newer versions. I'd suggest to leave air in this list and in case you ever expierence any FPS drops you can still remove it.

@dwesolowski

This comment has been minimized.

Copy link

@dwesolowski dwesolowski commented Jan 10, 2021

What setting would I use to hide chests, or can't this be done?

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented Jan 12, 2021

Anti-Xray can't place fake chests (or tile entities in general) into a chunk. This is because additional packets would be required to send tile entities. However, tile entities can be replaced by other blocks, if and only if the tile entities are not exposed to air. This means that dungeon chests can't be hidden, but buried treasures, for example, can. Both recommended settings for engine-mode: 1 and 2 cover this already. Please read the YAML comments carefully.

To replace tile entities you have to add them to hidden-blocks in engine-mode: 1 or to replacement-blocks in engine-mode: 2. Note that if you do so, the server will still send the tile entity packets of the real tile entities to the client. This can't be avoided. The client won't render the tile entities but a clever hack could bypass this easily. Also note that currently only the default block states such as chest facing north are replaced, as described above in the default settings. However, this is subject to change in the future because I'm already planning to open a pull request to fix that. Fixed.

@adelinn

This comment has been minimized.

Copy link

@adelinn adelinn commented Jan 25, 2021

Is it possible to hide caves in engine mode 1?

@Boemphie

This comment has been minimized.

Copy link

@Boemphie Boemphie commented Jan 29, 2021

It still doesnt work for me and I do not know what I am doing wrong.
image

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented Jan 29, 2021

Is it possible to hide caves in engine mode 1?

No. Anti-Xray isn't designed to do this in the first place. There is just a trick in engine-mode: 2 to make it harder to find cave ores, by adding fake air blocks.

It still doesnt work for me and I do not know what I am doing wrong.

Next time, please use a pastebin instead of posting a screenshot because it's nearly impossible to spot all mistakes, without seeing spaces or the context, where you have pasted it. The first thing I see is that the indentation of anti-xray: is wrong. It also seems wrong that the settings for the nether are directly below the default world settings. However, I can't tell that for sure because of the missing context. Please backup and reset your paper.yml, read this comment carefully and follow the instructions precisely. It also contains a link to an example paper.yml, that you can use to compare what you did.

@BareKnuckleBarry

This comment has been minimized.

Copy link

@BareKnuckleBarry BareKnuckleBarry commented Mar 2, 2021

Sorry where do I download this plugin as I'm on a shockbyte server and I don't know where to download it from

@dwesolowski

This comment has been minimized.

Copy link

@dwesolowski dwesolowski commented Mar 2, 2021

This is not a plugin, it's a feature in paper itself.

@galacticwarrior9

This comment has been minimized.

Copy link

@galacticwarrior9 galacticwarrior9 commented Apr 9, 2021

Would it not also be a good idea to add cave_air to hidden-blocks to further disrupt cave finders?

@VanillaIceAdmins

This comment has been minimized.

Copy link

@VanillaIceAdmins VanillaIceAdmins commented May 8, 2021

Not sure if I'll get a reply here, but is there any way to turn the anti-xray off for people in spectator mode? As an admin, I find it difficult to check suspicious activity in underground bases and caves with hundreds of ores obscuring my vision.

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented May 8, 2021

Would it not also be a good idea to add cave_air to hidden-blocks to further disrupt cave finders?

Of course you can, however, I wouldn't add too many blocks if it's not absolutely necessary because that also increases the packet size. Adding air doesn't mean it's 100% safe either because more clever hacks could detect those fake air blocks by distinguishing them from real caves for example. Another thing is that if you add cave_air, then I could also ask: Why not add water, lava, ...?

Not sure if I'll get a reply here, but is there any way to turn the anti-xray off for people in spectator mode? As an admin, I find it difficult to check suspicious activity in underground bases and caves with hundreds of ores obscuring my vision.

The reason why you see the fake blocks as spectator in engine-mode: 2 is the air in the hidden-blocks list. There is a permission node paper.antixray.bypass that you can set to true for admins to bypass Anti-Xray. For this you have to enable the setting use-permission in the config. You can link that permission node via contexts to spectator mode using LuckPerms for example or you create an alias for the gamemode command that additionally sets this permission. Note that the fake blocks won't dynamically appear/disappear when the permission note is set. Resending chunks (e.g. rejoining or moving away from your current location and going back) is required. I have written a plugin that can resend chunks with a command. You can also add this command to your gamemode command alias, in case you define one.

@AleSandro2

This comment has been minimized.

Copy link

@AleSandro2 AleSandro2 commented May 8, 2021

So if i remove air from the hidden-blocks list i will not see the fake blocks in spectator, but people that are using x-ray will see them, right?

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented May 8, 2021

Yes, but then Anti-Xray will be less effective against certain hacks. For example players could use hacks that only show ores exposed to air or cave finders. This is what air in hidden-blocks will prevent to a certain degree.

@Marcelektro

This comment has been minimized.

Copy link

@Marcelektro Marcelektro commented May 22, 2021

Arigatou! Helped a ton!

@DuckyBlender

This comment has been minimized.

Copy link

@DuckyBlender DuckyBlender commented Jun 5, 2021

Thanks!

@KayL9927

This comment has been minimized.

Copy link

@KayL9927 KayL9927 commented Jul 2, 2021

Hi, I copied everything but the nether anti xray still doesn't work. The overworld works perfect but the nether doesn't. I renamed the world to be the same as what is the name on mine and nothing. I can see all the ores and even the overworld ores as well. Is there a fix for this please, thanks in advance.

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented Jul 2, 2021

Hi, missing whitespaces (indentation) and wrong positioning are the most common issues that people are facing when trying to apply these settings. Indentation and correct structure is very important in YAML. Also make sure that your editor doesn't insert tabs when pasting.

Please take a look at this comment. It explains some common mistakes and also includes an example paper.yml. If that doesn't solve your problem, please join the PaperMC Discord server for further help.

@1000tree

This comment has been minimized.

Copy link

@1000tree 1000tree commented Jul 3, 2021

I copied everything(Default settings, Recommended settings - Engine-Mode 2) but the anti xray still doesn't work... T.T
Any solution?

@bluruz

This comment has been minimized.

Copy link

@bluruz bluruz commented Jul 5, 2021

Hello!

if i do it, my server going shutdown
https://pastebin.com/8sQ0twi5 (paper-1.16.5-779)

@stonar96

This comment has been minimized.

Copy link
Owner Author

@stonar96 stonar96 commented Jul 5, 2021

I copied everything(Default settings, Recommended settings - Engine-Mode 2) but the anti xray still doesn't work... T.T
Any solution?

Hello!

if i do it, my server going shutdown
https://pastebin.com/8sQ0twi5 (paper-1.16.5-779)

You will find your answers in previous comments. I have gone over this multiple times now. If that still doesn't solve your problems, please join the PaperMC Discord server for further help.

@giantfurkii

This comment has been minimized.

Copy link

@giantfurkii giantfurkii commented Sep 20, 2021

hey, When I enable the anti-xray feature in the paper file, the chunks on the server are loaded too late.
how to fix ?

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