44import net .minecraft .client .renderer .chunk .RenderChunkRegion ;
55import net .minecraft .core .BlockPos ;
66import net .minecraft .world .level .block .state .BlockState ;
7+ import org .embeddedt .modernfix .annotation .ClientOnlyMixin ;
78import org .embeddedt .modernfix .util .blockpos .SectionBlockPosIterator ;
89import org .spongepowered .asm .mixin .Mixin ;
910import org .spongepowered .asm .mixin .injection .At ;
1011import org .spongepowered .asm .mixin .injection .Redirect ;
1112
1213@ Mixin (targets = { "net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk$RebuildTask" }, priority = 2000 )
14+ @ ClientOnlyMixin
1315public class RebuildTaskMixin {
1416 /**
1517 * @author embeddedt
1618 * @reason Use a much faster iterator implementation than vanilla's Guava-based one.
1719 */
18- @ Redirect (method = "compile" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/core/BlockPos;betweenClosed(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)Ljava/lang/Iterable;" ))
20+ @ Redirect (method = "compile" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/core/BlockPos;betweenClosed(Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/BlockPos;)Ljava/lang/Iterable;" ), require = 0 )
1921 private Iterable <BlockPos > fastBetweenClosed (BlockPos firstPos , BlockPos secondPos ) {
2022 return () -> new SectionBlockPosIterator (firstPos );
2123 }
@@ -24,7 +26,7 @@ private Iterable<BlockPos> fastBetweenClosed(BlockPos firstPos, BlockPos secondP
2426 * @author embeddedt
2527 * @reason RenderChunkRegion.getBlockState is expensive, avoid calling it multiple times for the same position
2628 */
27- @ Redirect (method = "compile" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/chunk/RenderChunkRegion;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;" , ordinal = 1 ))
29+ @ Redirect (method = "compile" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/renderer/chunk/RenderChunkRegion;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;" , ordinal = 1 ), require = 0 )
2830 private BlockState useExistingBlockState (RenderChunkRegion instance , BlockPos pos , @ Local (ordinal = 0 ) BlockState state ) {
2931 return state ;
3032 }
0 commit comments