mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-22 08:19:26 +00:00
Begin backporting to 1.18.2
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
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 53d0024daf6963ac4dab575666b0d6a74a39a958..e84bf61502c8c88ff1084ed14b859417736375cc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -88,6 +88,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
this.pickup = AbstractArrow.Pickup.DISALLOWED;
|
||||
this.baseDamage = 2.0D;
|
||||
this.soundEvent = this.getDefaultHitGroundSoundEvent();
|
||||
+ this.loadChunks = this.level.sakuraConfig.projectilesLoadChunksForCollisions; // Sakura - allow projectiles to load chunks for collisions
|
||||
}
|
||||
|
||||
protected AbstractArrow(EntityType<? extends AbstractArrow> type, double x, double y, double z, Level world) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||
index d1eefa6ef3e9abfe7af4d8310aa64465fa2d5463..04d45b2ddc3489c4d0764da1575cb9a373d9a490 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||
@@ -76,7 +76,14 @@ public interface BlockGetter extends LevelHeightAccessor {
|
||||
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
||||
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
|
||||
// Paper start - Prevent raytrace from loading chunks
|
||||
- BlockState iblockdata = this.getBlockStateIfLoaded(blockposition);
|
||||
+ // Sakura start - allow projectiles to load chunks for collisions
|
||||
+ final BlockState iblockdata;
|
||||
+ if (raytrace1.loadChunks()) {
|
||||
+ iblockdata = this.getBlockState(blockposition);
|
||||
+ } else {
|
||||
+ iblockdata = this.getBlockStateIfLoaded(blockposition);
|
||||
+ }
|
||||
+ // Sakura end - allow projectiles to load chunks for collisions
|
||||
if (iblockdata == null) {
|
||||
// copied the last function parameter (listed below)
|
||||
Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());
|
||||
diff --git a/src/main/java/net/minecraft/world/level/ClipContext.java b/src/main/java/net/minecraft/world/level/ClipContext.java
|
||||
index ad2c533e9a0f0e2d97620b0e16200d7eeaedeefb..b8c68b2cf534a39414474e06161d575dbd666865 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/ClipContext.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/ClipContext.java
|
||||
@@ -20,6 +20,13 @@ public class ClipContext {
|
||||
private final ClipContext.Block block;
|
||||
private final ClipContext.Fluid fluid;
|
||||
private final CollisionContext collisionContext;
|
||||
+ // Sakura start - allow projectiles to load chunks for collisions
|
||||
+ private final boolean loadChunks;
|
||||
+
|
||||
+ public boolean loadChunks() {
|
||||
+ return this.loadChunks;
|
||||
+ }
|
||||
+ // Sakura end - allow projectiles to load chunks for collisions
|
||||
|
||||
public ClipContext(Vec3 start, Vec3 end, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling, Entity entity) {
|
||||
this.from = start;
|
||||
@@ -27,6 +34,7 @@ public class ClipContext {
|
||||
this.block = shapeType;
|
||||
this.fluid = fluidHandling;
|
||||
this.collisionContext = (entity == null) ? CollisionContext.empty() : CollisionContext.of(entity); // CraftBukkit
|
||||
+ this.loadChunks = entity instanceof net.minecraft.world.entity.projectile.Projectile && entity.loadChunks; // Sakura - allow projectiles to load chunks for collisions
|
||||
}
|
||||
|
||||
public Vec3 getTo() {
|
||||
Reference in New Issue
Block a user