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

Paper Changes:
PaperMC/Paper@52a0590 Updated Upstream (Bukkit/CraftBukkit) (#11543)
PaperMC/Paper@5c0930d Fix fix recipe iterator patch
PaperMC/Paper@1de0130 re-add a dispense fix patch
PaperMC/Paper@16d7d73 bunch more general fixes
PaperMC/Paper@a5d7426 Correctly support RecipeChoice.empty (#11550)
PaperMC/Paper@85c870e Correct update cursor (#11554)
PaperMC/Paper@d19be64 Fix NPE with spark when CraftServer is not init yet (#11558)
PaperMC/Paper@92131ad Decrease dead entity teleport warning (#11559)
PaperMC/Paper@a6df4c8 Handle corrupt light data gracefully
PaperMC/Paper@ce0a041 [ci skip] Rebuild patches
PaperMC/Paper@c6aa61e Updated Upstream (Bukkit/CraftBukkit/Spigot) (#11561)
PaperMC/Paper@93b435d [ci skip] better instructions for patch apply conflict (#11568)
PaperMC/Paper@42a1901 Correctly adopt upstream item EAR fix (#11582)
PaperMC/Paper@fcb6c72 Correctly pass velocity native compressor (#11509)
PaperMC/Paper@99f4bb2 Fix infinite fireworks (#11592) (#11594)
2024-11-08 19:55:18 +00:00

69 lines
5.0 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 613d2d90571546a482ba493fae5cbc7c69dd8f08..72b135bbd5eed8e3f94f815a7b7ee827a2f9a8e6 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1933,6 +1933,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,
@@ -1984,6 +1985,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) {
@@ -2023,7 +2025,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;
@@ -2059,7 +2061,12 @@ public final class CollisionUtil {
VoxelShape blockCollision = ((CollisionBlockState)blockData).moonrise$getConstantContextCollisionShape();
if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) {
- if (blockCollision == null) {
+ // 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
+ if (fullBlocks && blockData.moonrise$getConstantContextCollisionShape() != null) {
+ blockCollision = net.minecraft.world.phys.shapes.Shapes.block();
+ } else if (blockCollision == null) {
+ // Sakura end - treat solid blocks as full when moving fast
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 fce41d825a35700deaa0475aef85fa6e6b431790..2c84608aba2bfb610a7f2898e45f9a047691b3f4 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -626,6 +626,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