9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-22 16:29:16 +00:00
Files
SakuraMC/patches/server/0018-Optimise-explosions-in-protected-regions.patch
Samsuik 021078518d Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@20ec622 use correct types for preloading CraftRegistry
PaperMC/Paper@627cc64 Adjust HAProxy's existance to log for console masters (#11433)
PaperMC/Paper@01c4820 Call EntityDropItemEvent when a container item drops its contents (#11441)
PaperMC/Paper@9c76642 Deprecate for removal Block#isValidTool (#11439)
PaperMC/Paper@dd6d184 Remove redundant fillUsableCommands call (#11425)
PaperMC/Paper@f33611c fix ItemStack#removeEnchantments creating non-stackable items (#11442)
PaperMC/Paper@8f56db8 Add enchantWithLevels with tag specification (#11438)
PaperMC/Paper@b7ab22d Fix console completions on invalid commands (#7603)
PaperMC/Paper@41bc31b Update paperweight to 1.7.3 (#11445)
PaperMC/Paper@e17eb6b Improve entity effect API (#11444)
PaperMC/Paper@7b03141 Add startingBrewTime (#11406)
PaperMC/Paper@355b1cb Add API for explosions to damage the explosion cause (#11180)
PaperMC/Paper@6d7a438 Call bucket events for cauldrons (#7486)
PaperMC/Paper@f9c7f2a Begin switching to JSpecify annotations (#11448)
PaperMC/Paper@e3c8a8e Add PlayerInsertLecternBookEvent [1.20 port] (#7305)
PaperMC/Paper@b410fe8 Configurable per-world void damage offset/damage(#11436)
PaperMC/Paper@ea00be3 Do not NPE on uuid resolution in player profile (#11449)
PaperMC/Paper@ba3c29b Finish converting all events to jspecify annotations
PaperMC/Paper@e7e1ab5 Finish converting most of the undeprecated api to jspecify
PaperMC/Paper@69ffbec Fix hex color check
PaperMC/Paper@709f0f2 Use components properly in ProfileWhitelistVerifyEvent (#11456)
PaperMC/Paper@fb76840 [ci skip] Add section on nullability annotations (#11461)
2024-10-02 19:14:24 +01:00

43 lines
2.4 KiB
Diff

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 d8baaed4ae55c079bdfd684b6d942923dfbbbcd1..220d97947df493d1ab825e6637ca648e0b186d18 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -354,6 +354,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 = CraftEventFactory.callEntityExplodeEvent(this.source, blocks, 0.0f, this.blockInteraction);
+ return !event.isCancelled() && !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));
@@ -487,7 +503,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);