mirror of
https://github.com/Samsuik/Sakura.git
synced 2026-01-06 15:41:49 +00:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: PaperMC/Paper@a24f9b2 1.21.6 dev PaperMC/Paper@457a0a6 Bump version string and protocol version to 1.21.6 release PaperMC/Paper@245b547 Update base to 1.21.6 PaperMC/Paper@b28d77b Update Moonrise to 1.21.6 PaperMC/Paper@8318dcb Update DataConverter to 1.21.6-rc1 PaperMC/Paper@d2b1158 Set correct world access on BSL snapshots PaperMC/Paper@023e6c2 Ensure waypoints are per world PaperMC/Paper@40d5d31 Fix recursively converting JSON Text Components PaperMC/Paper@1fcc416 Implement FeatureHooks#isChunkSent for Moonrise chunk system PaperMC/Paper@e4d7178 Implement WaypointTransmitter#isChunkVisible PaperMC/Paper@8980ead Directly walk text component after converting from JSON PaperMC/Paper@5613ed6 Provide env environment variable and copy spigots sys prop for overriding default repository PaperMC/Paper@62b7f86 Avoid and discourage use of Maven Central as a CDN (#12689) PaperMC/Paper@f5534cb [ci skip] Run generators (#12691) PaperMC/Paper@4781d28 Re-add Log4j Javadocs (#12693) PaperMC/Paper@74fbcce Check type of Material in get/set stats (#12607) PaperMC/Paper@4b3f967 Improve Fix MC-44654 (#12703) PaperMC/Paper@a7dd263 Enable spigot obfuscation support (#12695) PaperMC/Paper@6a51c44 Cleanup Primed TNT Fix (#12704) PaperMC/Paper@839c6a1 Fix #11169 (#12706) PaperMC/Paper@c77d5f9 Fix MC-297591 PaperMC/Paper@219f86e Implement chunk unload delay config option PaperMC/Paper@e4eb69b Do not allow ticket level decreases to be processed asynchronously PaperMC/Paper@71b0c76 Adds support for vanilla negative explosions (#12705) PaperMC/Paper@3750927 [ci skip] Fix PermissionManager#clearPermissions() docs bad wording (#12657) PaperMC/Paper@d61a51e Add ItemType#getBurnDuration() (#12604) PaperMC/Paper@29fc853 Allow empty paths in namespaced keys (#12687) PaperMC/Paper@4419afb fix: Safely handle nanosecond overflow in ClickCallback (#12686) PaperMC/Paper@5652882 Add `isProxyEnabled` method to ServerConfiguration (#12664) PaperMC/Paper@c0dda0e Add `isForceDefaultGameMode` method (#12673) PaperMC/Paper@e714de6 Fix excess slot updates PaperMC/Paper@6d0821d [ci skip] Fix docs for Spawner class and cleanup (#12710) PaperMC/Paper@cceffe3 Release ItemType and BlockType (#12708) PaperMC/Paper@186e9e3 Relocate CommandMap#registerServerAliases() call to after lifecycle events have been run (#12601) PaperMC/Paper@5edcf6d Cleanup/command dispatching (#12713) PaperMC/Paper@803baf0 Support hidden entities in Waypoints (#12715) PaperMC/Paper@1814d8b build: publish to fill (#12717) PaperMC/Paper@e454fef Add support for private constructors in plugin main classes (#12652) PaperMC/Paper@d0e808f Move player to correct position in vehicle move packet handler PaperMC/Paper@46b4b0b Improve keepalive ping system PaperMC/Paper@38c1ddb Add and use FeatureHooks.getAllEntities PaperMC/Paper@2f083ac Ensure player entity schedulers are ticked when they are dead PaperMC/Paper@7c90c7c Optimise EntityScheduler ticking PaperMC/Paper@aa6ee44 Re-add global region scheduler tick erroneously removed in last commit PaperMC/Paper@d7510ef Fix #12722 (#12726) PaperMC/Paper@0caf75f Fix #12721 (#12725) PaperMC/Paper@bee2879 Adventure 4.23.0 (#12690) PaperMC/Paper@692e93a Fix MC-299110 PaperMC/Paper@ea10fa4 Don't mutate the position of Items for MC-4 Fix (#12702) PaperMC/Paper@aa6cd74 Remove unnecesary item check for ServerboundPlayerActionPacket RELEASE_USE_ITEM (#12668) PaperMC/Paper@c9e89f4 Expose arrow velocity in EntityShootBowEvent for mobs (#12688) PaperMC/Paper@7ec3174 Jump out of experimental phase PaperMC/Paper@4e1a255 Update try catch for command handling
166 lines
8.9 KiB
Diff
166 lines
8.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samsuik <kfian294ma4@gmail.com>
|
|
Date: Fri, 3 May 2024 15:04:31 +0100
|
|
Subject: [PATCH] Specialised Explosions
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
|
index 39cf9a8af79ce4c3f1d47eaf7cf3205199b35eb6..bad69adfbc492d851a3542dc7f77884d9f933c8a 100644
|
|
--- a/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1913,7 +1913,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type
|
|
};
|
|
Vec3 vec3 = new Vec3(x, y, z);
|
|
- ServerExplosion serverExplosion = new ServerExplosion(this, source, damageSource, damageCalculator, vec3, radius, fire, blockInteraction);
|
|
+ // Sakura start - specialised explosions
|
|
+ final ServerExplosion serverExplosion;
|
|
+ if (source instanceof net.minecraft.world.entity.item.PrimedTnt tnt) {
|
|
+ serverExplosion = new me.samsuik.sakura.explosion.TntExplosion(this, tnt, damageSource, damageCalculator, vec3, radius, fire, blockInteraction, self -> {
|
|
+ this.notifyPlayersOfExplosion(self, self.center(), smallExplosionParticles, largeExplosionParticles, explosionSound);
|
|
+ });
|
|
+ } else {
|
|
+ serverExplosion = new ServerExplosion(this, source, damageSource, damageCalculator, vec3, radius, fire, blockInteraction);
|
|
+ }
|
|
+ // Sakura end - specialised explosions
|
|
if (configurator != null) configurator.accept(serverExplosion);// Paper - Allow explosions to damage source
|
|
serverExplosion.explode();
|
|
// CraftBukkit start
|
|
@@ -1921,6 +1930,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
return serverExplosion;
|
|
}
|
|
// CraftBukkit end
|
|
+ // Sakura start - specialised explosions
|
|
+ this.notifyPlayersOfExplosion(serverExplosion, vec3, smallExplosionParticles, largeExplosionParticles, explosionSound);
|
|
+ return serverExplosion;
|
|
+ }
|
|
+
|
|
+ private void notifyPlayersOfExplosion(ServerExplosion serverExplosion, Vec3 vec3,
|
|
+ ParticleOptions smallExplosionParticles, ParticleOptions largeExplosionParticles,
|
|
+ Holder<SoundEvent> explosionSound) {
|
|
+ // Sakura end - specialised explosions
|
|
ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles;
|
|
|
|
for (ServerPlayer serverPlayer : this.players) {
|
|
@@ -1941,7 +1959,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
|
}
|
|
}
|
|
|
|
- return serverExplosion; // CraftBukkit
|
|
+ // Sakura - specialised explosions; return moved up into explode0
|
|
}
|
|
|
|
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayGameRule) {
|
|
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
index 0c8343075f5523aa200b58f2afd313d718408ac8..8986a9876f9437fd8d65f4d43df3f39a98741210 100644
|
|
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
|
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
|
@@ -79,20 +79,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
|
|
|
|
@Override
|
|
public final void respawnEntity(int count) {
|
|
- PrimedTnt tnt = new PrimedTnt(EntityType.TNT, this.level());
|
|
- tnt.updateBukkitHandle(this); // update handle for plugins
|
|
- while (count-- > 1) {
|
|
- this.setFuse(100); // Prevent unwanted explosions while ticking
|
|
-
|
|
- // Cause an explosion to affect this entity
|
|
- tnt.setPos(this.position());
|
|
- tnt.setDeltaMovement(this.getDeltaMovement());
|
|
- this.entityState().apply(this);
|
|
- tnt.explode();
|
|
- this.storeEntityState();
|
|
-
|
|
- this.tick();
|
|
- }
|
|
+ this.mergeData.count = count; // Sakura - specialised explosions
|
|
}
|
|
// Sakura end - merge cannon entities
|
|
|
|
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
|
|
index c1e6e27c8424483d5b7e2bce784463e9293b77a0..d45582bdfc3fa837c5aa95f499183b60b877b7c2 100644
|
|
--- a/net/minecraft/world/level/ServerExplosion.java
|
|
+++ b/net/minecraft/world/level/ServerExplosion.java
|
|
@@ -358,6 +358,38 @@ public class ServerExplosion implements Explosion {
|
|
return true;
|
|
}
|
|
// Sakura end - optimise explosion protected regions
|
|
+ // Sakura start - specialised explosions
|
|
+ protected final void createBlockCache() {
|
|
+ // Paper start - collision optimisations
|
|
+ this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
|
|
+ this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|
|
+ java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS);
|
|
+ this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|
|
+ this.directMappedBlockCache = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH];
|
|
+ this.mutablePos = new BlockPos.MutableBlockPos();
|
|
+ // Paper end - collision optimisations
|
|
+ }
|
|
+
|
|
+ protected final void markBlocksInCacheAsExplodable(List<BlockPos> explodedPositions) {
|
|
+ for (BlockPos blow : explodedPositions) {
|
|
+ ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cache = this.blockCache.get(blow.asLong());
|
|
+ // May be null if the blockCache is cleared then retrieved from the recent block cache
|
|
+ if (cache != null) {
|
|
+ cache.shouldExplode = null;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ protected final void clearBlockCache() {
|
|
+ // Paper start - collision optimisations
|
|
+ this.blockCache = null;
|
|
+ this.chunkPosCache = null;
|
|
+ this.chunkCache = null;
|
|
+ this.directMappedBlockCache = null;
|
|
+ this.mutablePos = null;
|
|
+ // Paper end - collision optimisations
|
|
+ }
|
|
+ // Sakura end - specialised explosions
|
|
|
|
public ServerExplosion(
|
|
ServerLevel level,
|
|
@@ -667,7 +699,10 @@ public class ServerExplosion implements Explosion {
|
|
// CraftBukkit end
|
|
entity.push(vec3);
|
|
if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback
|
|
- this.hitPlayers.put(player, vec3);
|
|
+ // Sakura start - specialised explosions; tally player velocity
|
|
+ final Vec3 explosionImpact = vec3;
|
|
+ this.hitPlayers.compute(player, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact);
|
|
+ // Sakura end - specialised explosions; tally player velocity
|
|
}
|
|
|
|
entity.onExplosionHit(this.source);
|
|
@@ -772,14 +807,7 @@ public class ServerExplosion implements Explosion {
|
|
}
|
|
|
|
public void explode() {
|
|
- // Paper start - collision optimisations
|
|
- this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
|
|
- this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|
|
- java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS);
|
|
- this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
|
|
- this.directMappedBlockCache = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH];
|
|
- this.mutablePos = new BlockPos.MutableBlockPos();
|
|
- // Paper end - collision optimisations
|
|
+ this.createBlockCache(); // Sakura - specialised explosions
|
|
this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center);
|
|
List<BlockPos> list = this.calculateExplodedPositions();
|
|
this.hurtEntities();
|
|
@@ -793,13 +821,7 @@ public class ServerExplosion implements Explosion {
|
|
if (this.fire) {
|
|
this.createFire(list);
|
|
}
|
|
- // Paper start - collision optimisations
|
|
- this.blockCache = null;
|
|
- this.chunkPosCache = null;
|
|
- this.chunkCache = null;
|
|
- this.directMappedBlockCache = null;
|
|
- this.mutablePos = null;
|
|
- // Paper end - collision optimisations
|
|
+ this.clearBlockCache(); // Sakura - specialised explosions
|
|
}
|
|
|
|
private static void addOrAppendStack(List<ServerExplosion.StackCollector> stackCollectors, ItemStack stack, BlockPos pos) {
|