9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-19 14:59:30 +00:00
Files
SakuraMC/sakura-server/minecraft-patches/features/0019-Collide-with-non-solid-blocks.patch
2025-08-01 11:43:36 +01:00

67 lines
4.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 26 Nov 2023 17:57:50 +0000
Subject: [PATCH] Collide with non-solid blocks
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 668f1681433d626248c49b82890aeb92b967ed3b..7414c6b4439456561f14dc0054c60fd2673ab786 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1908,6 +1908,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 - load chunks on movement
+ public static final int COLLISION_FLAG_FULL_BLOCKS = 1 << 5; // Sakura - collide with non-solid blocks
public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
@@ -1960,6 +1961,7 @@ public final class CollisionUtil {
final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0;
final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura - load chunks on movement
+ final boolean fullBlocks = (collisionFlags & COLLISION_FLAG_FULL_BLOCKS) != 0; // Sakura - collide with non-solid blocks
final ChunkSource chunkSource = world.getChunkSource();
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
@@ -2001,7 +2003,7 @@ public final class CollisionUtil {
continue;
}
- final boolean hasSpecial = ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks();
+ final boolean hasSpecial = !fullBlocks && ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); // Sakura - collide with non-solid blocks
final int sectionAdjust = !hasSpecial ? 1 : 0;
final PalettedContainer<BlockState> blocks = section.states;
@@ -2040,6 +2042,11 @@ public final class CollisionUtil {
mutablePos.set(blockX, blockY, blockZ);
if (useEntityCollisionShape) {
blockCollision = collisionShape.getCollisionShape(blockData, world, mutablePos);
+ // Sakura start - collide with non-solid blocks
+ // todo: move this logic above emptyCollisionShape and consider all blocks as a solid except scaffolding and liquids
+ } else if (fullBlocks && blockData.moonrise$getConstantContextCollisionShape() != null) {
+ blockCollision = net.minecraft.world.phys.shapes.Shapes.block();
+ // Sakura end - collide with non-solid blocks
} else if (blockCollision == null) {
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
}
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index e9f9e7b2fdd0472c50f3f9042e450f25d13b6bd9..6c76e7d25b094415ff785735a5ba508bae3f2368 100644
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -531,6 +531,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
}
+ // Sakura start - collide with non-solid blocks
+ if (this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMoving && (this.isPrimedTNT || this.isFallingBlock)) {
+ double horizontalMovementSqr = this.getDeltaMovement().horizontalDistanceSqr();
+ if (horizontalMovementSqr > Math.pow(this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMovingFasterThan, 2.0)) {
+ flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_FULL_BLOCKS;
+ }
+ }
+ // Sakura end - collide with non-solid blocks
return flags;
}
// Sakura end - load chunks on movement