mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-20 15:29:33 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@9e7f6c3 Fixup and deprecate player profiles in ping event (#10880) PaperMC/Paper@5914f60 Update AbstractArrow item method implementations for 1.20.6 (#10885) PaperMC/Paper@3889ffb Fix Player#sendBlockUpdate (#10855) PaperMC/Paper@af7f0c4 Fix ItemMeta#removeEnchantments (#10886) PaperMC/Paper@43484eb Add back RecipeIterator fixes patch (#10887) PaperMC/Paper@fe7043e Configurable damage tick when blocking with shield (#10877) PaperMC/Paper@122c9d3 Fix NPE in V3808 PaperMC/Paper@e41d44f Fix `hasFiredAsync` parameter when `AsyncPlayerSendCommandsEvent` is called (#10896) PaperMC/Paper@20f5165 Backport `LivingEntity#canUseEquipmentSlot` API (#11013) PaperMC/Paper@6e71f41 Updated Upstream (CraftBukkit/Spigot)
74 lines
5.3 KiB
Diff
74 lines
5.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Mon, 2 Sep 2024 22:11:46 +0100
|
|
Subject: [PATCH] Allow projectiles to load chunks for collisions
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
index 72c48bf33a0b882e4c94f1a7c343a170b1db0f53..4cb3d683d9e103d625531dfd8065c308f04af4d6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
@@ -219,7 +219,7 @@ public abstract class AbstractArrow extends Projectile {
|
|
Vec3 vec3d2 = this.position();
|
|
|
|
vec3d1 = vec3d2.add(vec3d);
|
|
- Object object = this.level().clip(new ClipContext(vec3d2, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this));
|
|
+ Object object = this.level().clip(new ClipContext(vec3d2, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this), this.level().sakuraConfig().entity.projectilesLoadChunksForCollisions); // Sakura - allow projectiles to load chunks for collisions
|
|
|
|
if (((HitResult) object).getType() != HitResult.Type.MISS) {
|
|
vec3d1 = ((HitResult) object).getLocation();
|
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java
|
|
index 5b2728eb9243b0136d77164539f397de406215ca..948b0673441be11bae77318984079228e29e1ce6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java
|
|
@@ -46,7 +46,7 @@ public final class ProjectileUtil {
|
|
Vec3 pos, Entity entity, Predicate<Entity> predicate, Vec3 velocity, Level world, float margin, ClipContext.Block raycastShapeType
|
|
) {
|
|
Vec3 vec3 = pos.add(velocity);
|
|
- HitResult hitResult = world.clip(new ClipContext(pos, vec3, raycastShapeType, ClipContext.Fluid.NONE, entity));
|
|
+ HitResult hitResult = world.clip(new ClipContext(pos, vec3, raycastShapeType, ClipContext.Fluid.NONE, entity), world.sakuraConfig().entity.projectilesLoadChunksForCollisions); // Sakura - allow projectiles to load chunks for collisions
|
|
if (hitResult.getType() != HitResult.Type.MISS) {
|
|
vec3 = hitResult.getLocation();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 5eda4a84b51bb0fd9ca3ba4ca1666792b6e23a05..8f8b4689a462986a1d781e7d3f7a7bfcd7db2465 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -623,8 +623,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
private static final FluidState AIR_FLUIDSTATE = Fluids.EMPTY.defaultFluidState();
|
|
|
|
+ // Sakura start - allow projectiles to load chunks for collisions
|
|
private static net.minecraft.world.phys.BlockHitResult fastClip(final Vec3 from, final Vec3 to, final Level level,
|
|
final ClipContext clipContext) {
|
|
+ return fastClip(from, to, level, clipContext, false);
|
|
+ }
|
|
+ private static net.minecraft.world.phys.BlockHitResult fastClip(final Vec3 from, final Vec3 to, final Level level,
|
|
+ final ClipContext clipContext, final boolean loadChunks) {
|
|
+ // Sakura end - allow projectiles to load chunks for collisions
|
|
final double adjX = io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON * (from.x - to.x);
|
|
final double adjY = io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON * (from.y - to.y);
|
|
final double adjZ = io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON * (from.z - to.z);
|
|
@@ -687,7 +693,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
|
|
if ((chunkDiff | chunkYDiff) != 0) {
|
|
if (chunkDiff != 0) {
|
|
- LevelChunk chunk = chunkProvider.getChunkAtIfLoadedImmediately(newChunkX, newChunkZ);
|
|
+ LevelChunk chunk = loadChunks ? level.getChunk(newChunkX, newChunkZ) : chunkProvider.getChunkAtIfLoadedImmediately(newChunkX, newChunkZ); // Sakura - allow projectiles to load chunks for collisions
|
|
lastChunk = chunk == null ? null : chunk.getSections(); // diff: don't load chunks for this
|
|
}
|
|
final int sectionY = newChunkY - minSection;
|
|
@@ -758,6 +764,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
return fastClip(clipContext.getFrom(), clipContext.getTo(), this, clipContext);
|
|
}
|
|
|
|
+ // Sakura start - allow projectiles to load chunks for collisions
|
|
+ public final net.minecraft.world.phys.BlockHitResult clip(final ClipContext clipContext, final boolean loadChunks) {
|
|
+ return fastClip(clipContext.getFrom(), clipContext.getTo(), this, clipContext, loadChunks);
|
|
+ }
|
|
+ // Sakura end - allow projectiles to load chunks for collisions
|
|
+
|
|
@Override
|
|
public final boolean noCollision(final Entity entity, final AABB box, final boolean loadChunks) {
|
|
int flags = io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_ONLY;
|