mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2025-01-10 18:37:48 +01:00
9e9a295053
Upstream/An Sidestream has released updates that appears to apply and compile correctly This update has NOT been tested by YatopiaMC and as with ANY update, please do your own testing. Tuinity Changes: d41103d Updated Upstream (Paper) Purpur Changes: 4984bb7 Updated Upstream (Paper) a16a79c Updated Upstream (Paper) bd83a6b Add predicate to recipe's ExactChoice ingredient (missing NMS side) d469979 Rebuild patches 802a659 Persistent TileEntity Lore & DisplayName
69 lines
3.6 KiB
Diff
69 lines
3.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Mykyta Komarn <nkomarn@hotmail.com>
|
|
Date: Tue, 29 Sep 2020 17:27:30 -0700
|
|
Subject: [PATCH] Use faster block collision check for entity suffocation check
|
|
|
|
Improves the speed of checks by ~3,000ns per entity on average.
|
|
|
|
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java b/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
|
|
index 7ed343cfb3130446c85dab2ca04d60f91e2c94fb..194d2f177b05c594c7a27b6191860a3f89394f06 100644
|
|
--- a/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
|
|
+++ b/src/main/java/me/jellysquid/mods/lithium/common/entity/movement/ChunkAwareBlockCollisionSweeper.java
|
|
@@ -16,6 +16,7 @@ import net.minecraft.server.VoxelShape;
|
|
import net.minecraft.server.VoxelShapeCollision;
|
|
import net.minecraft.server.VoxelShapes;
|
|
|
|
+import java.util.function.BiPredicate; // Yatopia
|
|
import static me.jellysquid.mods.lithium.common.entity.LithiumEntityCollisions.EPSILON;
|
|
|
|
/**
|
|
@@ -59,6 +60,21 @@ public class ChunkAwareBlockCollisionSweeper {
|
|
private ChunkSection cachedChunkSection;
|
|
private boolean needEntityCollisionCheck;
|
|
|
|
+ // Yatopia start
|
|
+ private boolean checkSuffocation;
|
|
+ private final BiPredicate<IBlockData, BlockPosition> suffocationPredicate = new BiPredicate<IBlockData, BlockPosition>() {
|
|
+ @Override
|
|
+ public boolean test(IBlockData iBlockData, BlockPosition blockPosition) {
|
|
+ return iBlockData.o(view, blockPosition);
|
|
+ }
|
|
+ };
|
|
+
|
|
+ public ChunkAwareBlockCollisionSweeper(ICollisionAccess view, Entity entity, AxisAlignedBB box, boolean checkSuffocation) {
|
|
+ this(view, entity, box);
|
|
+ this.checkSuffocation = checkSuffocation;
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
public ChunkAwareBlockCollisionSweeper(ICollisionAccess view, Entity entity, AxisAlignedBB box) {
|
|
this.box = box;
|
|
this.shape = VoxelShapes.of(box);
|
|
@@ -206,6 +222,11 @@ public class ChunkAwareBlockCollisionSweeper {
|
|
|
|
if (canInteractWithBlock(state, edgesHit)) {
|
|
this.pos.setValues(x, y, z);
|
|
+ // Yatopia start
|
|
+ if (checkSuffocation && !suffocationPredicate.test(state, this.pos)) {
|
|
+ continue;
|
|
+ }
|
|
+ // Yatopia end
|
|
VoxelShape collisionShape = state.getCollisionShape(this.view, this.pos, this.context);
|
|
|
|
if (collisionShape != VoxelShapes.empty()) {
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 5dc87a7460667400433429567bc9eebe42a8a8fa..41ffb3b84bf7e80953d66e99564e0a66cfb9133b 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -2171,9 +2171,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
float f1 = this.size.width * 0.8F;
|
|
AxisAlignedBB axisalignedbb = AxisAlignedBB.g((double) f1, 0.10000000149011612D, (double) f1).d(this.locX(), this.getHeadY(), this.locZ());
|
|
|
|
- return this.world.b(this, axisalignedbb, (iblockdata, blockposition) -> {
|
|
- return iblockdata.o(this.world, blockposition);
|
|
- }).findAny().isPresent();
|
|
+ return new me.jellysquid.mods.lithium.common.entity.movement.ChunkAwareBlockCollisionSweeper(this.world, this, axisalignedbb, true).getNextCollidedShape() != null; // Yatopia - fast suffocation check
|
|
}
|
|
}
|
|
|