-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AnvilChunkLoader to reducing allocations of MutableChunkCoordIntPair
- Loading branch information
1 parent
25e7352
commit 7489be4
Showing
2 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
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
28 changes: 28 additions & 0 deletions
28
...om/mitchej123/hodgepodge/mixins/early/minecraft/MixinAnvilChunkLoader_FixAllocations.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,28 @@ | ||
package com.mitchej123.hodgepodge.mixins.early.minecraft; | ||
|
||
import java.util.Set; | ||
|
||
import net.minecraft.world.ChunkCoordIntPair; | ||
import net.minecraft.world.chunk.storage.AnvilChunkLoader; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import com.mitchej123.hodgepodge.hax.LongChunkCoordIntPairSet; | ||
import com.mitchej123.hodgepodge.mixins.interfaces.MutableChunkCoordIntPair; | ||
|
||
@Mixin(AnvilChunkLoader.class) | ||
public class MixinAnvilChunkLoader_FixAllocations { | ||
|
||
@Shadow | ||
private Set<ChunkCoordIntPair> pendingAnvilChunksCoordinates = new LongChunkCoordIntPairSet(); | ||
|
||
private final MutableChunkCoordIntPair reusableCCIP = (MutableChunkCoordIntPair) new ChunkCoordIntPair(0, 0); | ||
|
||
@Redirect(method = "chunkExists", at = @At(value = "NEW", target = "Lnet/minecraft/world/ChunkCoordIntPair;")) | ||
private ChunkCoordIntPair chunkExistsReusable(int i, int j) { | ||
return (ChunkCoordIntPair) reusableCCIP.setChunkPos(i, j); | ||
} | ||
} |