mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-28 11:19:08 +00:00
use the vanilla collide method when targeting vanilla mechanics
This commit is contained in:
@@ -128,7 +128,7 @@ index f6e3cc7659175b29b238f7a0ff12f96d035a7b6a..b199cc18e72bfa011f6dc3a7a9e84625
|
||||
|
||||
// Paper start
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f399a332e4 100644
|
||||
index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..218e0fbab1f545a193d818bfd4ba4df2eb4be758 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -587,6 +587,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -246,16 +246,28 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
return this.collideAxisScan(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
|
||||
} else {
|
||||
return this.collideCube(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
|
||||
@@ -1587,7 +1615,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1586,8 +1614,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
|
||||
}
|
||||
|
||||
this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER);
|
||||
- this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER);
|
||||
- return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currBoundingBox, voxelList, bbList);
|
||||
+ return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currBoundingBox, voxelList, bbList, this.mechanicsTarget); // Sakura - configure server mechanics
|
||||
+ // Sakura start - configure server mechanics
|
||||
+ final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget;
|
||||
+ if (mechanicsTarget.isServerType(me.samsuik.sakura.mechanics.ServerType.VANILLA)) {
|
||||
+ // Fallback to the slow vanilla movement method if we are targeting vanilla mechanics.
|
||||
+ // Float alignment is a bit wonky with the moonrise optimised collisions.
|
||||
+ voxelList.addAll(this.level.getEntityCollisions(this, currBoundingBox));
|
||||
+ return Entity.collideBoundingBox(this, movement, currBoundingBox, this.level, voxelList);
|
||||
+ } else {
|
||||
+ this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER);
|
||||
+ return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currBoundingBox, voxelList, bbList, this.mechanicsTarget);
|
||||
+ }
|
||||
+ // Sakura end - configure server mechanics
|
||||
}
|
||||
|
||||
private Vec3 collideAxisScan(final Vec3 movement, AABB currBoundingBox, final List<VoxelShape> voxelList, final List<AABB> bbList) {
|
||||
@@ -1595,7 +1623,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1595,7 +1633,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
double y = movement.y;
|
||||
double z = movement.z;
|
||||
|
||||
@@ -264,7 +276,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
|
||||
if (y != 0.0) {
|
||||
y = this.scanY(currBoundingBox, y, voxelList, bbList);
|
||||
@@ -1646,7 +1674,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1646,7 +1684,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
|
||||
private double scanY(final AABB currBoundingBox, double y, final List<VoxelShape> voxelList, final List<AABB> bbList) {
|
||||
final AABB scanBox = cutBoundingBoxY(currBoundingBox, y);
|
||||
@@ -278,7 +290,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
y = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performAABBCollisionsY(currBoundingBox, y, bbList);
|
||||
return ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performVoxelCollisionsY(currBoundingBox, y, voxelList);
|
||||
}
|
||||
@@ -1717,7 +1750,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1717,7 +1760,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement
|
||||
);
|
||||
potentialCollisionsBB.addAll(entityAABBs);
|
||||
@@ -287,7 +299,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
|
||||
final boolean collidedX = collided.x != movement.x;
|
||||
final boolean collidedY = collided.y != movement.y;
|
||||
@@ -1840,25 +1873,37 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1840,25 +1883,37 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
private void checkInsideBlocks(List<Entity.Movement> movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) {
|
||||
if (this.isAffectedByBlocks()) {
|
||||
LongSet set = this.visitedBlocks;
|
||||
@@ -330,7 +342,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1);
|
||||
}
|
||||
}
|
||||
@@ -1868,8 +1913,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1868,8 +1923,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
}
|
||||
|
||||
private int checkInsideBlocks(Vec3 from, Vec3 to, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet visited, int maxSteps) {
|
||||
@@ -353,7 +365,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
boolean flag1 = this.level instanceof ServerLevel serverLevel
|
||||
&& serverLevel.getServer().debugSubscribers().hasAnySubscriberFor(DebugSubscriptions.ENTITY_BLOCK_INTERSECTIONS);
|
||||
AtomicInteger atomicInteger = new AtomicInteger();
|
||||
@@ -1877,6 +1934,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1877,6 +1944,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
from,
|
||||
to,
|
||||
aabb,
|
||||
@@ -361,7 +373,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
(pos, index) -> {
|
||||
if (!this.isAlive()) {
|
||||
return false;
|
||||
@@ -1896,7 +1954,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1896,7 +1964,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
boolean flag2 = entityInsideCollisionShape == Shapes.block()
|
||||
|| this.collidedWithShapeMovingFrom(from, to, entityInsideCollisionShape.move(new Vec3(pos)).toAabbs());
|
||||
boolean flag3 = this.collidedWithFluid(blockState.getFluidState(), pos, from, to);
|
||||
@@ -370,7 +382,7 @@ index f7253b0a52f7f8eca6741e2ec64dbab3fae109e3..cc249e029be0bba5b3eaa6abc4d423f3
|
||||
if (flag2) {
|
||||
try {
|
||||
boolean flag4 = flag || aabb.intersects(pos);
|
||||
@@ -1952,6 +2010,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1952,6 +2020,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
}
|
||||
|
||||
public boolean collidedWithShapeMovingFrom(Vec3 from, Vec3 to, List<AABB> boxes) {
|
||||
|
||||
@@ -5,7 +5,7 @@ Subject: [PATCH] Configurable left shooting and adjusting limits
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 31d300e912a5892b08cc6e800039a79b4569754c..406b50d9930b787432d3fd9f9b704401e06a3948 100644
|
||||
index 2e5c14cf06f9d7a04ecde84020c6a1817bb20c1d..9ff121680336917e7a2da16ca2e5b2659cea77b7 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -614,6 +614,47 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -56,7 +56,7 @@ index 31d300e912a5892b08cc6e800039a79b4569754c..406b50d9930b787432d3fd9f9b704401
|
||||
|
||||
public Entity(EntityType<?> type, Level level) {
|
||||
this.type = type;
|
||||
@@ -1654,6 +1695,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1664,6 +1705,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
}
|
||||
|
||||
if (xSmaller && z != 0.0) {
|
||||
@@ -64,7 +64,7 @@ index 31d300e912a5892b08cc6e800039a79b4569754c..406b50d9930b787432d3fd9f9b704401
|
||||
z = this.scanZ(currBoundingBox, z, voxelList, bbList);
|
||||
if (z != 0.0) {
|
||||
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z);
|
||||
@@ -1661,6 +1703,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1671,6 +1713,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
}
|
||||
|
||||
if (x != 0.0) {
|
||||
@@ -77,7 +77,7 @@ index 31d300e912a5892b08cc6e800039a79b4569754c..406b50d9930b787432d3fd9f9b704401
|
||||
if (x != 0.0) {
|
||||
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x);
|
||||
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index 46d7f001d299ed6bb7987fe3c06c9cd1651bda80..802e890e743e85be9cc28798b12ba0e61ccabcc5 100644
|
||||
index bd19fe30448147ffa287dcea7a1571082bc2bb76..ac2c8d000e94fdf6b9cba6a22cbb84b093b3beb8 100644
|
||||
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -269,6 +269,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
|
||||
|
||||
@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise check inside blocks and traverse blocks
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 406b50d9930b787432d3fd9f9b704401e06a3948..1785811bdeee2f49e0508f21d6c93b2cb2869901 100644
|
||||
index 9ff121680336917e7a2da16ca2e5b2659cea77b7..6715f73dd05606d101f4a13d1662360bea85bbc9 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1942,6 +1942,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1952,6 +1952,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
if (this.isAffectedByBlocks()) {
|
||||
LongSet set = this.visitedBlocks;
|
||||
final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget; // Sakura - configure server mechanics
|
||||
@@ -16,7 +16,7 @@ index 406b50d9930b787432d3fd9f9b704401e06a3948..1785811bdeee2f49e0508f21d6c93b2c
|
||||
|
||||
for (Entity.Movement movement : movements) {
|
||||
Vec3 vec3 = movement.from;
|
||||
@@ -1959,7 +1960,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1969,7 +1970,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
double d = vec31.get(axis);
|
||||
if (d != 0.0) {
|
||||
Vec3 vec32 = vec3.relative(axis.getPositive(), d);
|
||||
@@ -25,7 +25,7 @@ index 406b50d9930b787432d3fd9f9b704401e06a3948..1785811bdeee2f49e0508f21d6c93b2c
|
||||
if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) {
|
||||
i -= stepsTaken;
|
||||
}
|
||||
@@ -1967,12 +1968,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1977,12 +1978,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
}
|
||||
}
|
||||
} else if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
|
||||
@@ -40,7 +40,7 @@ index 406b50d9930b787432d3fd9f9b704401e06a3948..1785811bdeee2f49e0508f21d6c93b2c
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1980,7 +1981,16 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -1990,7 +1991,16 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ index 406b50d9930b787432d3fd9f9b704401e06a3948..1785811bdeee2f49e0508f21d6c93b2c
|
||||
// Sakura start - configure server mechanics
|
||||
final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget;
|
||||
final double margin;
|
||||
@@ -2010,7 +2020,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
@@ -2020,7 +2030,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
|
||||
return false;
|
||||
} else {
|
||||
atomicInteger.set(index);
|
||||
|
||||
Reference in New Issue
Block a user