Topic category: Help with modding (Java Edition)
Hey so I am making a land claiming system and I wanna have a way to detect the actual chunks its protecting so I can do a No Man's Land protective "skirt" around the claimed chunks
If there is a way to detect chunks then please let me know!
I know I said it below in the reply section, but to fix my own errors and provide much needed links, ill post my solution here!
WARNING: This solution requires the ArrayLists plugin found here: https://mcreator.net/plugin/65659/arraylists
Array = [0, 16, 32, 48, 64, …, 37500]
Set xD = x MOD 16
If xD =/= 0
- xChunk = (x - xD) / 16
- xChunk = x / 16
Set zD = z MOD 16
If zD =/= 0
- zChunk = (z - zD) / 16
- zChunk = z / 16
Say "This is Chunk [" + Array[xChunk] + ", " + Array[zChunk] + "]."
Q1: Why stop at 375000?
A1: That is the default world border (6,000,000) divided by 16
Q2: How does this work?
A2: I was testing and found out that chunks start at the North West corner (where X and Z are divisible from 16) and ran with that. Basically, it gets the location, doing MOD reveals how many blocks they are away from being divisible by 16, they move there, and then reference the array to get a chunk-based X and Z! It sounds complex but its just simple math using MOD.