9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-31 04:36:39 +00:00
Files
SakuraMC/patches/server/0044-Treat-solid-blocks-as-full-when-moving-fast.patch
Samsuik 877990205f Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@eef40b7 Configurable Entity Despawn Time (#11454)
PaperMC/Paper@edabff8 Correctly damage tick wolf after armor block (#11653)
PaperMC/Paper@6051dac Painting variant registry modification API (#11648)
PaperMC/Paper@bb32b05 Call ProjectileHitEvent for entity hits (#11652)
PaperMC/Paper@bf8405f [ci skip] Rebuild patches
2024-11-24 17:57:49 +00:00

67 lines
4.8 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 solid blocks as full when moving fast
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 27b7be52f7617a6ecd1ff7e967604424f40027bc..417b18e1179f962e218f63679785e487ba606477 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1935,6 +1935,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 - treat solid blocks as full when moving fast
public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
@@ -1987,6 +1988,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 - treat solid blocks as full when moving fast
final ChunkSource chunkSource = world.getChunkSource();
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
@@ -2026,7 +2028,7 @@ public final class CollisionUtil {
continue;
}
- final boolean hasSpecial = ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks();
+ final boolean hasSpecial = !fullBlocks && ((BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); // Sakura - treat solid blocks as full when moving fast
final int sectionAdjust = !hasSpecial ? 1 : 0;
final PalettedContainer<BlockState> blocks = section.states;
@@ -2065,6 +2067,11 @@ public final class CollisionUtil {
if (useEntityCollisionShape) {
mutablePos.set(blockX, blockY, blockZ);
blockCollision = collisionShape.getCollisionShape(blockData, world, mutablePos);
+ // Sakura start - treat solid blocks as full when moving fast
+ // 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 - treat solid blocks as full when moving fast
} else if (blockCollision == null) {
mutablePos.set(blockX, blockY, blockZ);
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0e479e1960b3f054bf8991f5d429b37500319c4a..7a07be8dfabde5ab99c354bc7aef29fcf551c9e1 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -627,6 +627,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
}
+ // Sakura start - treat solid blocks as full when moving fast
+ 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 - treat solid blocks as full when moving fast
return flags;
}
// Sakura end - load chunks on movement