-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experimental: Optimize chunk iteration
Also refactor chunk related packages
- Loading branch information
Showing
32 changed files
with
136 additions
and
69 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ishland/vmp/common/chunk/iteration/ITickableChunkSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.ishland.vmp.common.chunk.iteration; | ||
|
||
import net.minecraft.server.world.ChunkHolder; | ||
|
||
public interface ITickableChunkSource { | ||
|
||
Iterable<ChunkHolder> vmp$tickableChunksIterator(); | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/ishland/vmp/common/chunk/loading/IEntityPortalInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.ishland.vmp.common.chunk.loading; | ||
|
||
public interface IEntityPortalInterface { | ||
|
||
// default CompletionStage<TeleportTarget> getTeleportTargetAtAsync(ServerWorld destination) { | ||
// throw new AbstractMethodError(); | ||
// } | ||
|
||
} |
3 changes: 1 addition & 2 deletions
3
...common/chunkloading/IPOIAsyncPreload.java → ...ommon/chunk/loading/IPOIAsyncPreload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s_on_player_login/AsyncChunkLoadUtil.java → ...s_on_player_login/AsyncChunkLoadUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ks_on_player_login/IAsyncChunkPlayer.java → ...ks_on_player_login/IAsyncChunkPlayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java/com/ishland/vmp/common/chunk/loading/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.ishland.vmp.common.chunk.loading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.ishland.vmp.common.chunk; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/main/java/com/ishland/vmp/common/chunkloading/IEntityPortalInterface.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/main/java/com/ishland/vmp/common/chunkloading/package-info.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
src/main/java/com/ishland/vmp/common/chunkwatching/AreaPlayerChunkWatchingManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/com/ishland/vmp/mixins/chunk/iteration/MixinServerChunkManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ishland.vmp.mixins.chunk.iteration; | ||
|
||
import com.ishland.vmp.common.chunk.iteration.ITickableChunkSource; | ||
import net.minecraft.server.world.ChunkHolder; | ||
import net.minecraft.server.world.ServerChunkManager; | ||
import net.minecraft.server.world.ThreadedAnvilChunkStorage; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(ServerChunkManager.class) | ||
public class MixinServerChunkManager { | ||
|
||
@Redirect(method = "tickChunks", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ThreadedAnvilChunkStorage;entryIterator()Ljava/lang/Iterable;")) | ||
private Iterable<ChunkHolder> redirectVisibleChunks(ThreadedAnvilChunkStorage instance) { | ||
return ((ITickableChunkSource) instance).vmp$tickableChunksIterator(); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/ishland/vmp/mixins/chunk/iteration/MixinThreadedAnvilChunkStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.ishland.vmp.mixins.chunk.iteration; | ||
|
||
import com.ishland.vmp.common.chunk.iteration.ITickableChunkSource; | ||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; | ||
import net.minecraft.server.world.ChunkHolder; | ||
import net.minecraft.server.world.ThreadedAnvilChunkStorage; | ||
import net.minecraft.util.math.ChunkPos; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(ThreadedAnvilChunkStorage.class) | ||
public class MixinThreadedAnvilChunkStorage implements ITickableChunkSource { | ||
|
||
@Shadow @Final private Long2ObjectLinkedOpenHashMap<ChunkHolder> currentChunkHolders; | ||
|
||
@Unique | ||
private Long2ObjectLinkedOpenHashMap<ChunkHolder> vmp$tickingChunks = new Long2ObjectLinkedOpenHashMap<>(); | ||
|
||
@Inject(method = "<init>", at = @At("RETURN")) | ||
private void onInit(CallbackInfo ci) { | ||
this.vmp$tickingChunks = new Long2ObjectLinkedOpenHashMap<>(); | ||
} | ||
|
||
@Inject(method = "onChunkStatusChange", at = @At("HEAD")) | ||
private void listenChunkStatusChange(ChunkPos chunkPos, ChunkHolder.LevelType levelType, CallbackInfo ci) { | ||
final ChunkHolder chunkHolder = this.currentChunkHolders.get(chunkPos.toLong()); | ||
if (chunkHolder == null) return; | ||
if (chunkHolder.getLevelType().isAfter(ChunkHolder.LevelType.TICKING)) { | ||
this.vmp$tickingChunks.put(chunkPos.toLong(), chunkHolder); | ||
} else { | ||
this.vmp$tickingChunks.remove(chunkPos.toLong()); | ||
} | ||
} | ||
|
||
@Override | ||
public Iterable<ChunkHolder> vmp$tickableChunksIterator() { | ||
return this.vmp$tickingChunks.values(); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...kloading/MixinPointOfInterestStorage.java → .../loading/MixinPointOfInterestStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ins/chunkloading/MixinTeleportTarget.java → ...ns/chunk/loading/MixinTeleportTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...k_on_player_login/MixinPlayerManager.java → ...k_on_player_login/MixinPlayerManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
..._login/MixinServerPlayNetworkHandler.java → ..._login/MixinServerPlayNetworkHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...player_login/MixinServerPlayerEntity.java → ...player_login/MixinServerPlayerEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...commands/MixinCommandFunctionManager.java → ...commands/MixinCommandFunctionManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...oading/commands/MixinTeleportCommand.java → ...oading/commands/MixinTeleportCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java/com/ishland/vmp/mixins/chunk/loading/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.ishland.vmp.mixins.chunk.loading; |
9 changes: 4 additions & 5 deletions
9
...ins/chunkloading/portals/MixinEntity.java → ...ns/chunk/loading/portals/MixinEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.ishland.vmp.mixins.chunk; |
2 changes: 1 addition & 1 deletion
2
...nding/MixinThreadedAnvilChunkStorage.java → ...nding/MixinThreadedAnvilChunkStorage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...t/MixinNoTickChunkSendingInterceptor.java → ...t/MixinNoTickChunkSendingInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/main/java/com/ishland/vmp/mixins/chunk/sending/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package com.ishland.vmp.mixins.chunk.sending; |
1 change: 0 additions & 1 deletion
1
src/main/java/com/ishland/vmp/mixins/chunkloading/package-info.java
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/main/java/com/ishland/vmp/mixins/chunksending/package-info.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters