mirror of
https://github.com/Samsuik/Sakura.git
synced 2026-01-03 22:16:38 +00:00
Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <kfian294ma4@gmail.com>
|
||||
Date: Fri, 3 May 2024 15:18:58 +0100
|
||||
Subject: [PATCH] Optimise explosions in protected regions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 03461922b9b42b4f6e9a62d1af1c1e1f6570cb09..5bf07349621d058739f12b9463bba47e9abfffd7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -353,6 +353,22 @@ public class Explosion {
|
||||
return rays;
|
||||
}
|
||||
// Sakura end - optimise paper explosions
|
||||
+ // Sakura start - optimise explosion protected regions
|
||||
+ protected final boolean isRegionUnprotected() {
|
||||
+ // optimisation: We check if a plugin has cancelled the event or cleared the blockList.
|
||||
+ // It tells us if the result was thrown away, so we can avoid the block searching logic.
|
||||
+ // As a side effect the event is called twice which may interfere with some plugins.
|
||||
+ if (this.source != null && this.level.sakuraConfig().cannons.explosion.optimiseProtectedRegions) {
|
||||
+ Location location = new Location(this.level.getWorld(), this.x, this.y, this.z);
|
||||
+ List<org.bukkit.block.Block> blocks = new ObjectArrayList<>(1);
|
||||
+ blocks.add(location.getBlock());
|
||||
+ EntityExplodeEvent event = new EntityExplodeEvent(this.source.getBukkitEntity(), location, blocks, 0.0f);
|
||||
+ return event.callEvent() && !event.blockList().isEmpty();
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Sakura end - optimise explosion protected regions
|
||||
|
||||
public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) {
|
||||
return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source));
|
||||
@@ -486,7 +502,7 @@ public class Explosion {
|
||||
|
||||
// Paper start - collision optimisations
|
||||
// Sakura start - optimise paper explosions
|
||||
- if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks()) {
|
||||
+ if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions
|
||||
this.searchForBlocks(blockCache, initialCache);
|
||||
}
|
||||
this.locateAndImpactEntities(blockCache);
|
||||
Reference in New Issue
Block a user