Bump to MC 1.18.1

This commit is contained in:
Jonas Herzig
2021-12-10 11:30:43 +01:00
parent 2df9049e6b
commit f943d11661
9 changed files with 8 additions and 5 deletions

View File

@@ -0,0 +1,38 @@
package com.replaymod.replay.mixin;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.Vec3d;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
@Mixin(ClientPlayNetworkHandler.class)
public class Mixin_FixEntityNotTracking {
@ModifyVariable(method = { "onEntityPosition", "onEntity", "onEntityPassengersSet" }, at = @At("RETURN"), ordinal = 0)
private Entity updatePositionIfNotTracked$0(Entity entity) {
if (entity != null) {
entity.streamSelfAndPassengers().forEach(this::updatePositionIfNotTracked);
}
return entity;
}
private void updatePositionIfNotTracked(Entity entity) {
if (entity != null && entity.world instanceof ClientWorldAccessor world) {
if (!world.getEntityList().has(entity)) {
// Skip interpolation of position updates coming from server
// (See: newX in EntityLivingBase or otherPlayerMPX in EntityOtherPlayerMP)
int ticks = 0;
Vec3d prevPos;
do {
prevPos = entity.getPos();
if (entity.hasVehicle()) {
entity.tickRiding();
} else {
entity.tick();
}
} while (prevPos.squaredDistanceTo(entity.getPos()) > 0.0001 && ticks++ < 100);
}
}
}
}