Improve CubicPlayerManager and add support for third party modded cubic world generators#46
Improve CubicPlayerManager and add support for third party modded cubic world generators#46RecursivePineapple wants to merge 15 commits into
Conversation
DarkShadow44
left a comment
There was a problem hiding this comment.
A bunch of questions and some points that could need improvement. Please don't resolve those, leave that for me.
| } | ||
|
|
||
| @ModifyVariable(method = "generate", at = @At("LOAD"), ordinal = 1, argsOnly = true) | ||
| public int fixHeight(int value, @Local(argsOnly = true) World world, @Local(argsOnly = true, ordinal = 0) int x, |
There was a problem hiding this comment.
Do we really need to inject that at every load? At least that's what it currently does. TBH, I can't really follow this mixin's logic.
There was a problem hiding this comment.
Yeah that's one of its issues. I couldn't figure out how to modify the variable at the head.
|
|
||
| void updateLightBetween(Chunk column, int localX, int y1, int y2, int localZ); | ||
|
|
||
| default void onSendCubes(Iterable<? extends ICube> cubes) { |
There was a problem hiding this comment.
Can't we remove the whole method? It's currently unused.
| args = "array=get", | ||
| target = "Lnet/minecraft/world/chunk/Chunk;storageArrays:[Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;")) | ||
| private ExtendedBlockStorage init_getStorage(ExtendedBlockStorage[] ebs, int y) { | ||
| return ebs[y - (this.isColumn ? 0 : blockToCube(((IMinMaxHeight) worldObj).getMinHeight()))]; |
There was a problem hiding this comment.
Why exactly can we remove that?
There was a problem hiding this comment.
The ebs array normally starts at y=0. It seems like modern CC shifts the ebses down as new cubes are added, which is kinda odd because all code that I've seen that interacts with the array expects it to have 16 indices. This is better compat-wise.
There was a problem hiding this comment.
Then the entire mixin can be removed, shouldn't do anything anymore right?
| args = "array=get", | ||
| target = "Lnet/minecraft/world/chunk/Chunk;storageArrays:[Lnet/minecraft/world/chunk/storage/ExtendedBlockStorage;")) | ||
| private ExtendedBlockStorage getBlock_getStorage(ExtendedBlockStorage[] ebs, int y) { | ||
| return isColumn ? getEBS_CubicChunks(y) : ebs[y]; |
There was a problem hiding this comment.
Why can we remove this?
There was a problem hiding this comment.
Everything should route through the same code either way, this is just for simplification from what I can see. I don't remember the specifics, all of these changes were really finicky.
| * double-ticking is avoided by checking this lastTicked field instead of deduplication by putting them all into a | ||
| * Set. | ||
| */ | ||
| private long lastTicked = Long.MIN_VALUE; |
There was a problem hiding this comment.
This is now unused. Is this correct or do we still need to workaround whatever issue this tried to prevent?
| } | ||
|
|
||
| public static int getLocalAddress(int localX, int localZ) { | ||
| return (Bits.packUnsignedToInt(localX, 4, 0) | Bits.packUnsignedToInt(localZ, 4, 4)); |
There was a problem hiding this comment.
Shouldn't this also get the & 0xF treatment for consistency?
| cubesToUnload.add(new CubePos(cubeX, cubeY, cubeZ)); | ||
| } | ||
| } | ||
| public WorldVisibilityChange findChanged(CubePos oldPos, CubePos newPos, int oldHorizonalView, int oldVerticalView, |
There was a problem hiding this comment.
oldHorizonalView -> oldHorizontalView
| } | ||
|
|
||
| public void registerCallback(CubeLoaderCallback callback) { | ||
| if (callback != null) this.callbacks.add(callback); |
There was a problem hiding this comment.
Why drop those checks?
| if (columnData.syncedCubeCount <= 0) { | ||
| syncedColumns.remove(pos.getX(), pos.getZ()); | ||
|
|
||
| if (player.isWatchingColumn(pos.getX(), pos.getZ())) { |
There was a problem hiding this comment.
While were at it, can we add
MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(
new ChunkCoordIntPair(pos.getX(), pos.getZ()), player.player));
here? Similar for Watch event. This makes FMP work (at least until you reload the chunk)
Code changes
ICubicWorldProviderinterface, which is used by third party mods to make their dimensions cubic.CubeStackBlockView).Testing done
asprof -d 30 -f profile.html -e alloc GradleStartcommand will make a profile that shows allocations, but asprof only works on linux.See Also
Weird water gradients
Stress test
https://discord.com/channels/181078474394566657/1415607665375313961/1492890103457255564