Collision Spike

- Reduced false positives for train/player collisions during lag spikes
This commit is contained in:
simibubi 2022-09-25 20:41:12 +02:00
parent 1f06034b47
commit 95a23f7433
2 changed files with 11 additions and 1 deletions

View File

@ -32,6 +32,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis; import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection; import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource; import net.minecraft.sounds.SoundSource;
@ -373,6 +374,13 @@ public class ContraptionCollider {
return entityMotion; return entityMotion;
if (!entity.isOnGround()) if (!entity.isOnGround())
return entityMotion; return entityMotion;
CompoundTag persistentData = entity.getPersistentData();
if (persistentData.contains("ContraptionGrounded")) {
persistentData.remove("ContraptionGrounded");
return entityMotion;
}
if (cce.collidingEntities.containsKey(entity)) if (cce.collidingEntities.containsKey(entity))
return entityMotion; return entityMotion;
if (entity instanceof ItemEntity) if (entity instanceof ItemEntity)

View File

@ -141,6 +141,8 @@ public abstract class EntityContraptionInteractionMixin extends CapabilityProvid
return; return;
self.setOnGround(true); self.setOnGround(true);
self.getPersistentData()
.putBoolean("ContraptionGrounded", true);
} }
@Inject(method = { "spawnSprintParticle" }, at = @At(value = "TAIL")) @Inject(method = { "spawnSprintParticle" }, at = @At(value = "TAIL"))