-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02aebcd
commit e66c9a6
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/me/senseiwells/replay/mixin/compat/vmp/TrackedEntityMixin.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,43 @@ | ||
package me.senseiwells.replay.mixin.compat.vmp; | ||
|
||
import com.ishland.vmp.mixins.playerwatching.optimize_nearby_entity_tracking_lookups.MixinThreadedAnvilChunkStorageEntityTracker; | ||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import me.senseiwells.replay.chunk.ChunkRecordable; | ||
import me.senseiwells.replay.player.PlayerRecorders; | ||
import net.minecraft.server.level.ChunkMap; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.entity.Entity; | ||
import org.spongepowered.asm.mixin.Dynamic; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(value = ChunkMap.TrackedEntity.class, priority = 1100) | ||
public class TrackedEntityMixin { | ||
@Shadow | ||
@Final | ||
Entity entity; | ||
|
||
@Dynamic(mixin = MixinThreadedAnvilChunkStorageEntityTracker.class) | ||
@ModifyExpressionValue( | ||
method = "tryTick", | ||
at = @At( | ||
value = "INVOKE", | ||
target = "Ljava/util/Set;isEmpty()Z" | ||
), | ||
remap = false | ||
) | ||
private boolean shouldNotTick(boolean original) { | ||
if (!original) { | ||
return false; | ||
} | ||
if (!((ChunkRecordable) this).getRecorders().isEmpty()) { | ||
return false; | ||
} | ||
if (this.entity instanceof ServerPlayer player) { | ||
return !PlayerRecorders.has(player); | ||
} | ||
return true; | ||
} | ||
} |
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