mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-27 02:39:06 +00:00
73 lines
4.5 KiB
Diff
73 lines
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
|
Date: Sun, 26 Nov 2023 17:57:50 +0000
|
|
Subject: [PATCH] Treat all collidable blocks as full while moving fast
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
|
index 8014ebfb391825c31d9d1b39f5304a7e76b1ee44..e6c1fffa1281c302b5201c1a6826f10df8a0e382 100644
|
|
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
|
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
|
|
@@ -1592,6 +1592,7 @@ public final class CollisionUtil {
|
|
public static final int COLLISION_FLAG_CHECK_BORDER = 1 << 2;
|
|
public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3;
|
|
public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura
|
|
+ public static final int COLLISION_FLAG_FULL_BLOCKS = 1 << 5; // Sakura
|
|
|
|
public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
|
|
final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
|
|
@@ -1643,6 +1644,7 @@ public final class CollisionUtil {
|
|
|
|
final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0;
|
|
final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura
|
|
+ final boolean fullBlocks = (collisionFlags & COLLISION_FLAG_FULL_BLOCKS) != 0; // Sakura
|
|
final ServerChunkCache chunkSource = (ServerChunkCache)world.getChunkSource();
|
|
|
|
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
|
@@ -1684,7 +1686,7 @@ public final class CollisionUtil {
|
|
continue;
|
|
}
|
|
|
|
- final boolean hasSpecial = section.getSpecialCollidingBlocks() != 0;
|
|
+ final boolean hasSpecial = !fullBlocks && section.getSpecialCollidingBlocks() != 0; // Sakura
|
|
final int sectionAdjust = !hasSpecial ? 1 : 0;
|
|
|
|
final PalettedContainer<BlockState> blocks = section.states;
|
|
@@ -1718,12 +1720,15 @@ public final class CollisionUtil {
|
|
}
|
|
|
|
if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) {
|
|
+ // Sakura start - if flag is set treat all block as full
|
|
VoxelShape blockCollision = blockData.getConstantCollisionShape();
|
|
-
|
|
- if (blockCollision == null) {
|
|
+ if (fullBlocks && blockCollision != null) {
|
|
+ blockCollision = Shapes.block();
|
|
+ } else if (blockCollision == null) {
|
|
mutablePos.set(blockX, blockY, blockZ);
|
|
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
|
|
}
|
|
+ // Sakura end
|
|
|
|
AABB singleAABB = blockCollision.getSingleAABBRepresentation();
|
|
if (singleAABB != null) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index b336fe34b8d3e54dd300509812a6c4886105b299..b7f14516d3bb1356de709d528eca3aee1bb212ff 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -582,6 +582,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
|
flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
|
|
}
|
|
|
|
+ if (this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMoving && (this.isPrimedTNT || this.isFallingBlock)) {
|
|
+ this.syncDeltaMovement();
|
|
+ double horizontalMovementSqr = this.movementX*this.movementX + this.movementZ*this.movementZ;
|
|
+ if (horizontalMovementSqr > Math.pow(this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMovingFasterThan, 2.0)) {
|
|
+ flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_FULL_BLOCKS;
|
|
+ }
|
|
+ }
|
|
+
|
|
return flags;
|
|
}
|
|
// Sakura end - load chunks on cannon entity movement
|