9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-19 14:59:30 +00:00

Updated Upstream (Paper 1.21.9)

Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@7e70636 Initial 1.21.9 update (squashed)
PaperMC/Paper@0a28816 Add Server#getRespawnWorld and Server#setRespawnWorld(World)
PaperMC/Paper@b67fa6d move todos txt content into tracking issue
PaperMC/Paper@68f26a1 Drop no-longer-needed packet diffs
PaperMC/Paper@f9434d2 Use pitch when setting spawn position with Location
PaperMC/Paper@810b3c6 Deprecate the Conversation API (for removal), Metadata API, and PlayerSpawnLocationEvent (for removal)
PaperMC/Paper@1870261 Update Moonrise to 1.21.9-pre1
PaperMC/Paper@1141058 Shift feature patch #s for Moonrise being first
PaperMC/Paper@510aa9b Update 'Optimize Network Manager and add advanced packet support'
PaperMC/Paper@89cc24a Update 'Allow Saving of Oversized Chunks'
PaperMC/Paper@bcd75d8 Update EAR 2.0 patch and enable oldPaperCommit for better 3-way merges
PaperMC/Paper@6b44820 Update 'Use Velocity compression and cipher natives'
PaperMC/Paper@87f3e2f Update 'Optimize GoalSelector Goal.Flag Set operations'
PaperMC/Paper@5323486 Update 'Optimize Voxel Shape Merging'
PaperMC/Paper@5aac8b4 Update 'Handle Oversized block entities in chunks'
PaperMC/Paper@f0b3d62 Update 'optimize dirt and snow spreading' and drop 'Optimise getChunkAt calls for loaded chunks' patch to code replaced by Moonrise
PaperMC/Paper@92f822d Update 'Optimize Bit Operations by inlining', 'Remove streams from hot code'
PaperMC/Paper@98e745a Update 'Optimize Pathfinder - Remove Streams / Optimized collections'
PaperMC/Paper@49e49d0 Update 'Fix entity tracker desync when new players are added to the tracker'
PaperMC/Paper@87e0525 Update alternate redstone impls
PaperMC/Paper@35e973d Update 'Improve exact choice recipe ingredients', 'Only write chunk data to disk if it serializes without throwing'
PaperMC/Paper@181f9bb Update 'Entity load/save limit per chunk', 'Attempt to recalculate regionfile header if it is corrupt'
PaperMC/Paper@b31ca18 Update 'Incremental chunk and player saving', 'Optimise general POI access'
PaperMC/Paper@9b69cc5 Add some more Mannequin API
PaperMC/Paper@8bb12cb Fix compile
PaperMC/Paper@e3aca92 Replace ConcurrentUtil's Validate with Objects
PaperMC/Paper@9a626dd Rewrite ticket counter system
PaperMC/Paper@65250cb Drop "Optimize Collision to not load chunks"
PaperMC/Paper@55d56d9 Apply "Flush regionfiles on save configuration option"
PaperMC/Paper@920e8d3 Apply "Optimise collision checking in player move packet handling"
PaperMC/Paper@ec492d3 Apply "Improve keepalive ping system"
PaperMC/Paper@8f65947 Apply "Optimise EntityScheduler ticking"
PaperMC/Paper@086b4fd Apply "Optional per player mob spawns"
PaperMC/Paper@2f4211e Apply "Improve cancelling PreCreatureSpawnEvent with per player mob spawns"
PaperMC/Paper@b6d9557 Apply "Optimize Hoppers"
PaperMC/Paper@388e693 update generator
PaperMC/Paper@a3c89a8 add javadocs for new api
PaperMC/Paper@fcc763a Call BlockRedstoneEvent for the shelf
PaperMC/Paper@03eb18b replace requireNonNull by checkArgument and deprecate MCUtil#toLocation
PaperMC/Paper@6b7bf01 bump built-in datapack version
PaperMC/Paper@2779a53 deprecate #lanterns material tag in favour of vanilla tag
PaperMC/Paper@6f9957e Mannequin#createDefaultProfile -> Mannequin#defaultProfile
PaperMC/Paper@24874e5 Also rename Mannequin profile getter/setters for consistency
PaperMC/Paper@bc2ae10 Fix default respawn dimension being null for new worlds
PaperMC/Paper@eb42158 Use 0.0.4 release of ConcurrentUtil
PaperMC/Paper@bb01745 1.21.9-pre2
PaperMC/Paper@0249204 1.21.9-pre2 feature patches
PaperMC/Paper@9360ba4 Identifying comments for MinecraftServer
PaperMC/Paper@5d3aa53 Some diff improvements in prepare spawn task
PaperMC/Paper@22ad451 Move some stuff to ATs
PaperMC/Paper@0ea15c9 Drop no longer applicable ATs
PaperMC/Paper@cf78f2a bump api-version/datapack format and add a copper torch tag
PaperMC/Paper@60cb0df generate ClientOption enums and mark CraftBlockData impl as null marked
PaperMC/Paper@4025289 Add pre2 to api version
PaperMC/Paper@f2cb073 Set build channel to alpha
PaperMC/Paper@90b29c4 Port most of the anti-xray patch
PaperMC/Paper@4a8e88d Disable oldPaperCommit to fix CI build
PaperMC/Paper@121ac2e Port the last Anti-XRay hunk
PaperMC/Paper@f43641f Use ConcurrentUtil 0.0.5
PaperMC/Paper@1f79388 fix end portal teleportation
PaperMC/Paper@2efb400 [ci skip] Adjust spawn location event docs
PaperMC/Paper@cb9fc05 simplify overloads
PaperMC/Paper@25ecc59 Enable Anti-Xray
PaperMC/Paper@4d7185f Add AsyncPlayerSpawnLocationEvent#isNewPlayer (#13081)
PaperMC/Paper@dc474a8 Fixup vanilla code for Anti-Xray changes
PaperMC/Paper@0e23b02 Add back null check for chunkPacketBlockController
PaperMC/Paper@e6f1483 Update to 1.21.9-pre3
PaperMC/Paper@44259ea Add ResolvableProfile.SkinPatch (#13091)
PaperMC/Paper@634f51e Update to 1.21.9-pre4
PaperMC/Paper@fada3a7 Update DataConverter to 1.21.9-pre4
PaperMC/Paper@037179f Update Starlight stored version
PaperMC/Paper@6b0b29a Update publishing endpoint
PaperMC/Paper@f6fabc5 Call EntityChangeBlockEvent for copper golem statue changes (#13090)
PaperMC/Paper@1d6ee7d Update adventure
PaperMC/Paper@404e49f Update to 1.21.9-rc1
PaperMC/Paper@4055274 Fix empty SkinPatch initialization and swapped dynamic/static heuristic in ResolvableProfile build method
PaperMC/Paper@51fe7aa Fixed modern forwarding support (#13098)
PaperMC/Paper@5613a35 fix PlayerGameModeChangeEvent#cancelMessage
PaperMC/Paper@673abf4 use PlayerShieldDisableEvent#getCooldown
PaperMC/Paper@3a0dc7f Fix a couple PlayerProfile mutability issues
PaperMC/Paper@e97fb40 Remove parallel generation config option
PaperMC/Paper@c3a60b8 Use ThreadLocal for Starlight and ticket level propagator cache
PaperMC/Paper@e16b369 Resize propagator queues less aggressively
This commit is contained in:
Samsuik
2025-09-27 15:39:58 +01:00
parent f6f596821d
commit 40897f76f7
86 changed files with 807 additions and 722 deletions

View File

@@ -19,7 +19,6 @@ protected-f net.minecraft.world.level.ServerExplosion center
public net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket chunkData public net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket chunkData
public net.minecraft.server.level.ServerLevel entityTickList public net.minecraft.server.level.ServerLevel entityTickList
public net.minecraft.world.entity.Entity addMovementThisTick(Lnet/minecraft/world/entity/Entity$Movement;)V public net.minecraft.world.entity.Entity addMovementThisTick(Lnet/minecraft/world/entity/Entity$Movement;)V
public net.minecraft.world.entity.Entity axisStepOrder(Lnet/minecraft/world/phys/Vec3;)Ljava/lang/Iterable;
public net.minecraft.world.entity.Entity stuckSpeedMultiplier public net.minecraft.world.entity.Entity stuckSpeedMultiplier
public net.minecraft.world.entity.Entity$Movement public net.minecraft.world.entity.Entity$Movement
public net.minecraft.world.level.Level neighborUpdater public net.minecraft.world.level.Level neighborUpdater

View File

@@ -3,7 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins { plugins {
java java
id("io.papermc.paperweight.patcher") version "2.0.0-beta.17" id("io.papermc.paperweight.patcher") version "2.0.0-beta.18"
} }
paperweight { paperweight {

View File

@@ -1,8 +1,8 @@
group=me.samsuik.sakura group=me.samsuik.sakura
version=1.21.8-R0.1-SNAPSHOT version=1.21.9-rc1-R0.1-SNAPSHOT
mcVersion=1.21.8 mcVersion=1.21.9-rc1
paperRef=29c8822d90899c89d2689338e81a98f690bcba12 paperRef=e16b369f6e8cbd3c4cc29970b6eb11d2b9da06df
org.gradle.jvmargs=-Xmx2G org.gradle.jvmargs=-Xmx2G
org.gradle.vfs.watch=false org.gradle.vfs.watch=false

View File

@@ -45,7 +45,7 @@
options.use() options.use()
options.isDocFilesSubDirs = true options.isDocFilesSubDirs = true
options.links( options.links(
@@ -199,11 +_,11 @@ @@ -201,11 +_,11 @@
} }
// workaround for https://github.com/gradle/gradle/issues/4046 // workaround for https://github.com/gradle/gradle/issues/4046

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Client Visibility Settings API
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 7f48e073173094fdee63efa0eea1cbfc4e06ba7d..8f53905e57e0905c7f75f9a457cdb9c0a7bcfafe 100644 index bf8a7c425ebc8cf1546b5f891092ec317b298f3c..756336415e4e18b7871556bf1fe4ec7690ea4047 100644
--- a/src/main/java/org/bukkit/entity/Player.java --- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java
@@ -70,6 +70,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @@ -71,6 +71,14 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
void setTrackingRangeModifier(final double modifier); void setTrackingRangeModifier(final double modifier);
// Sakura end - entity tracking range modifier // Sakura end - entity tracking range modifier

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -128,6 +_,20 @@ @@ -127,6 +_,20 @@
// Paper end // Paper end
} }

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/World.java --- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java
@@ -4387,6 +_,11 @@ @@ -4556,6 +_,11 @@
void setSendViewDistance(int viewDistance); void setSendViewDistance(int viewDistance);
// Paper end - view distance api // Paper end - view distance api

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/entity/Player.java --- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java
@@ -65,6 +_,12 @@ @@ -66,6 +_,12 @@
@NullMarked @NullMarked
public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper

View File

@@ -24,6 +24,7 @@ public final class MechanicVersion {
public static final short v1_21_2 = MinecraftVersionEncoding.v1xy(21, 2); public static final short v1_21_2 = MinecraftVersionEncoding.v1xy(21, 2);
public static final short v1_21_5 = MinecraftVersionEncoding.v1xy(21, 5); public static final short v1_21_5 = MinecraftVersionEncoding.v1xy(21, 5);
public static final short v1_21_6 = MinecraftVersionEncoding.v1xy(21, 6); public static final short v1_21_6 = MinecraftVersionEncoding.v1xy(21, 6);
public static final short v1_21_9 = MinecraftVersionEncoding.v1xy(21, 9);
public static String name(final short version) { public static String name(final short version) {
if (version == LATEST) { if (version == LATEST) {

View File

@@ -7,7 +7,7 @@
+val serverBrand = rootProject.name +val serverBrand = rootProject.name
dependencies { dependencies {
mache("io.papermc:mache:1.21.8+build.2") mache("io.papermc:mache:1.21.9-rc1+build.1")
@@ -26,6 +_,17 @@ @@ -26,6 +_,17 @@
minecraftVersion = providers.gradleProperty("mcVersion") minecraftVersion = providers.gradleProperty("mcVersion")
gitFilePatches = false gitFilePatches = false
@@ -24,7 +24,7 @@
+ activeFork = fork + activeFork = fork
+ +
spigot { spigot {
enabled = true enabled = false
buildDataRef = "436eac9815c211be1a2a6ca0702615f995e81c44" buildDataRef = "436eac9815c211be1a2a6ca0702615f995e81c44"
@@ -107,7 +_,20 @@ @@ -107,7 +_,20 @@
} }
@@ -54,7 +54,7 @@
dependencies { dependencies {
- implementation(project(":paper-api")) - implementation(project(":paper-api"))
+ implementation(project(":$serverBrand-api")) + implementation(project(":$serverBrand-api"))
implementation("ca.spottedleaf:concurrentutil:0.0.3") implementation("ca.spottedleaf:concurrentutil:0.0.5")
implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+
implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21
@@ -207,7 +_,7 @@ @@ -207,7 +_,7 @@

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Track block changes and level tick scheduler
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
index 4dabb2a689d4bceb054e819e2fd53420e95a283d..65bd8e94d7d7b815a2c8fe2a6fd1fa1ad9e60bc6 100644 index a90e5cb4d989f38f7011a6ddd8c539a67e51494c..b2b8c9a651bab91491b4306dbb9d5a818e06869d 100644
--- a/net/minecraft/server/MinecraftServer.java --- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java
@@ -1750,6 +1750,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1687,6 +1687,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
profilerFiller.pop(); profilerFiller.pop();
profilerFiller.pop(); profilerFiller.pop();
serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions serverLevel.explosionDensityCache.clear(); // Paper - Optimize explosions
@@ -17,10 +17,10 @@ index 4dabb2a689d4bceb054e819e2fd53420e95a283d..65bd8e94d7d7b815a2c8fe2a6fd1fa1a
this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index b0b5d32b374a3ff32dc9f6757361ee4ace962a46..44e4c907801b934c188cf67bf3c75023a52a948f 100644 index 24f43dd7d3ffa060409c96882c0416f59dc571cc..4b2ea3c99bcd5452840b26c2ba607a4f034ba367 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -824,6 +824,10 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -829,6 +829,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z); return chunk != null ? chunk.getNoiseBiome(x, y, z) : this.getUncachedNoiseBiome(x, y, z);
} }
// Paper end - optimise random ticking // Paper end - optimise random ticking
@@ -32,10 +32,10 @@ index b0b5d32b374a3ff32dc9f6757361ee4ace962a46..44e4c907801b934c188cf67bf3c75023
protected Level( protected Level(
WritableLevelData levelData, WritableLevelData levelData,
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a5ecb85c7 100644 index 4dcec2e8a3120a3dfa078e8cf6857ba99ca01a2d..4a274798077c4ee0a504a784449a1aef1d89d325 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java --- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -129,6 +129,21 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -136,6 +136,21 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
return this.getBlockStateFinal(x, y, z); return this.getBlockStateFinal(x, y, z);
} }
// Paper end - get block chunk optimisation // Paper end - get block chunk optimisation
@@ -57,7 +57,7 @@ index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a
public LevelChunk(Level level, ChunkPos pos) { public LevelChunk(Level level, ChunkPos pos) {
this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null);
@@ -166,6 +181,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -173,6 +188,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
this.debug = !empty && this.level.isDebug(); this.debug = !empty && this.level.isDebug();
this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE; this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE;
// Paper end - get block chunk optimisation // Paper end - get block chunk optimisation
@@ -65,7 +65,7 @@ index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a
} }
public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) {
@@ -414,6 +430,11 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -421,6 +437,12 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
if (!section.getBlockState(i, i1, i2).is(block)) { if (!section.getBlockState(i, i1, i2).is(block)) {
return null; return null;
} else { } else {
@@ -74,6 +74,7 @@ index 75578e6ed7233a03d9b6cd3c6d3997f1c6148392..a39077ba4e1e40462ee9a96ce6f3871a
+ this.blockChange(pos, state, blockState); + this.blockChange(pos, state, blockState);
+ } + }
+ // Sakura end - track block changes and tick scheduler + // Sakura end - track block changes and tick scheduler
if (!this.level.isClientSide && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. +
if (!this.level.isClientSide() && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled.
state.onPlace(this.level, pos, blockState, flag1); state.onPlace(this.level, pos, blockState, flag1);
} }

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Client Visibility Settings
diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
index 9f6d7c5dc0e591488a8a3763d8a1f1b3671d5299..0f5383dcec940db15205afbb65f1f8aa5899edf4 100644 index 6987eeace609fbfba967922e558e09268e0f6d44..e45e2d6094620d761b624bfaf5dfbbed4d559858 100644
--- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
+++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
@@ -31,7 +31,7 @@ public class ClientboundLevelChunkPacketData { @@ -31,7 +31,7 @@ public class ClientboundLevelChunkPacketData {
@@ -36,7 +36,7 @@ index 9f6d7c5dc0e591488a8a3763d8a1f1b3671d5299..0f5383dcec940db15205afbb65f1f8aa
final CompoundTag tag; final CompoundTag tag;
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08fa3b5d68 100644 index 88035581d220dd3653fa2d30102e59e9a9340002..f9dfbf11a39573e839153fd5d72bcf9019540359 100644
--- a/net/minecraft/server/level/ChunkMap.java --- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java
@@ -173,6 +173,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -173,6 +173,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -47,7 +47,7 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08
public ChunkMap( public ChunkMap(
ServerLevel level, ServerLevel level,
@@ -237,6 +238,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -235,6 +236,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
); );
this.setServerViewDistance(serverViewDistance); this.setServerViewDistance(serverViewDistance);
this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, null, this::setChunkUnsaved); // Paper - rewrite chunk system this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, null, this::setChunkUnsaved); // Paper - rewrite chunk system
@@ -58,7 +58,7 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08
} }
private void setChunkUnsaved(ChunkPos chunkPos) { private void setChunkUnsaved(ChunkPos chunkPos) {
@@ -1016,6 +1021,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1024,6 +1029,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
tracker.serverEntity.sendChanges(); tracker.serverEntity.sendChanges();
} }
} }
@@ -67,7 +67,7 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
@@ -1226,6 +1233,32 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1263,6 +1270,32 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return !this.seenBy.isEmpty(); return !this.seenBy.isEmpty();
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
@@ -99,8 +99,8 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08
+ // Sakura end - client visibility settings; entity visibility + // Sakura end - client visibility settings; entity visibility
public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper
@@ -1304,6 +1337,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1347,6 +1380,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
} }
flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z); flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
// Paper end - Configurable entity tracking range by Y // Paper end - Configurable entity tracking range by Y
@@ -109,10 +109,10 @@ index 68865b05cdb0704ed463a1765deec383eb20cf41..e164d7fbda422dbcffd753c3373b1c08
if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
flag = false; flag = false;
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 03a157f6c96b0f39effa24ae278eeac689c83ee8..2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7 100644 index 1b1e2cb3f97de8bce9a88709e3fe02f7c44c77b6..9a963308d5b1a896b0dfe6a47f7d257a173719c5 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -564,6 +564,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -584,6 +584,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.playerTickingChunks.remove((LevelChunk)chunkHolder.getCurrentChunk()); this.playerTickingChunks.remove((LevelChunk)chunkHolder.getCurrentChunk());
} }
// Paper end - chunk tick iteration // Paper end - chunk tick iteration
@@ -135,7 +135,7 @@ index 03a157f6c96b0f39effa24ae278eeac689c83ee8..2a7c057ccfeb5dbe6b14ff660c0bb342
public ServerLevel( public ServerLevel(
MinecraftServer server, MinecraftServer server,
@@ -675,6 +691,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -692,6 +708,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.chunkDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.ChunkDataController((ServerLevel)(Object)this, this.chunkTaskScheduler); this.chunkDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.ChunkDataController((ServerLevel)(Object)this, this.chunkTaskScheduler);
// Paper end - rewrite chunk system // Paper end - rewrite chunk system
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
@@ -143,31 +143,33 @@ index 03a157f6c96b0f39effa24ae278eeac689c83ee8..2a7c057ccfeb5dbe6b14ff660c0bb342
} }
// Paper start // Paper start
@@ -1898,7 +1915,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1931,7 +1948,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
for (ServerPlayer serverPlayer : this.players) { for (ServerPlayer serverPlayer : this.players) {
if (serverPlayer.distanceToSqr(vec3) < 4096.0) { if (serverPlayer.distanceToSqr(vec3) < 4096.0) {
Optional<Vec3> optional = Optional.ofNullable(serverExplosion.getHitPlayers().get(serverPlayer)); Optional<Vec3> optional = Optional.ofNullable(serverExplosion.getHitPlayers().get(serverPlayer));
- serverPlayer.connection.send(new ClientboundExplodePacket(vec3, optional, particleOptions, explosionSound)); - serverPlayer.connection.send(new ClientboundExplodePacket(vec3, radius, i, optional, particleOptions, explosionSound, blockParticles));
+ // Sakura start - client visibility settings; let players toggle explosion particles + // Sakura start - client visibility settings; let players toggle explosion particles
+ ParticleOptions particle = particleOptions; + ParticleOptions particle = particleOptions;
+ Vec3 position = vec3; + Vec3 position = vec3;
+ // In 1.22 and later this should be replaced with sending the motion through a PlayerPositionPacket.
+ // The problem here is SetEntityMotion is capped to 3.9 b/pt and the only other alternate mean was
+ // implemented in 1.21.3. I believe it's best to just wait on this issue and deal with this hack.
+ if (!this.checkExplosionVisibility(vec3, serverPlayer)) { + if (!this.checkExplosionVisibility(vec3, serverPlayer)) {
+ position = new Vec3(0.0, -1024.0, 0.0); + // todo: send knockback through PlayerPositionPacket
+ particle = net.minecraft.core.particles.ParticleTypes.SMOKE; + if (this.paperConfig().environment.disableExplosionKnockback) {
+ continue;
+ } else {
+ position = new Vec3(0.0, -1024.0, 0.0);
+ particle = net.minecraft.core.particles.ParticleTypes.SMOKE;
+ }
+ } + }
+ serverPlayer.connection.send(new ClientboundExplodePacket(position, optional, particle, explosionSound)); + serverPlayer.connection.send(new ClientboundExplodePacket(position, radius, i, optional, particle, explosionSound, blockParticles));
+ // Sakura end - client visibility settings; let players toggle explosion particles + // Sakura end - client visibility settings; let players toggle explosion particles
} }
} }
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index b1a0ab0958fffbd24d4e79c6840c5d7539a42142..34730f5750f335d10f04ebb557cca510a6a8adbd 100644 index 637d60f082ca7aac689f9e7dc940e8c16d414445..24921be00af8df2314e54373c7014b6831940204 100644
--- a/net/minecraft/server/level/ServerPlayer.java --- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java
@@ -460,6 +460,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc @@ -473,6 +473,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
return this.viewDistanceHolder; return this.viewDistanceHolder;
} }
// Paper end - rewrite chunk system // Paper end - rewrite chunk system
@@ -176,10 +178,10 @@ index b1a0ab0958fffbd24d4e79c6840c5d7539a42142..34730f5750f335d10f04ebb557cca510
public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) {
super(level, gameProfile); super(level, gameProfile);
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index f02800e4e941b05bde6f0d5fac76e2b6ec5b9832..4a84792f9cf17cf2b50638ce6de05dc6f40b311f 100644 index c6db2c96db96453daaf49779f588f75f7c3d3d60..fd08d04c13a4064c658e0aad436b48831316129b 100644
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -57,6 +57,60 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -58,6 +58,60 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
public @Nullable String playerBrand; public @Nullable String playerBrand;
public final java.util.Set<String> pluginMessagerChannels; public final java.util.Set<String> pluginMessagerChannels;
// Paper end - retain certain values // Paper end - retain certain values
@@ -240,9 +242,9 @@ index f02800e4e941b05bde6f0d5fac76e2b6ec5b9832..4a84792f9cf17cf2b50638ce6de05dc6
public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) { public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) {
this.server = server; this.server = server;
@@ -317,6 +371,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -318,6 +372,12 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
} else if (packet instanceof net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket defaultSpawnPositionPacket && this instanceof ServerGamePacketListenerImpl serverGamePacketListener) { } else if (packet instanceof net.minecraft.network.protocol.game.ClientboundSetDefaultSpawnPositionPacket defaultSpawnPositionPacket && this instanceof ServerGamePacketListenerImpl serverGamePacketListener) {
serverGamePacketListener.player.compassTarget = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(defaultSpawnPositionPacket.getPos(), serverGamePacketListener.getCraftPlayer().getWorld()); serverGamePacketListener.player.compassTarget = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(defaultSpawnPositionPacket.respawnData().pos(), serverGamePacketListener.getPlayer().level());
} }
+ // Sakura start - client visibility settings + // Sakura start - client visibility settings
+ final net.minecraft.server.level.ServerPlayer player = this.getPlayer(); + final net.minecraft.server.level.ServerPlayer player = this.getPlayer();
@@ -254,10 +256,10 @@ index f02800e4e941b05bde6f0d5fac76e2b6ec5b9832..4a84792f9cf17cf2b50638ce6de05dc6
if (packet.isTerminal()) { if (packet.isTerminal()) {
this.close(); this.close();
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ca13dd72f173be6714965c506f2d48dcd3c9e569..21134883bea2553a870ef0df32c47430aa056cef 100644 index 11d55309f3030399386b4deeab58d5f760b3574d..57934cb30c7704f7ff10d25a47df894fabd4687a 100644
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3205,6 +3205,7 @@ public class ServerGamePacketListenerImpl @@ -3215,6 +3215,7 @@ public class ServerGamePacketListenerImpl
event.setCancelled(cancelled); event.setCancelled(cancelled);
net.minecraft.world.inventory.AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 net.minecraft.world.inventory.AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224
@@ -266,10 +268,10 @@ index ca13dd72f173be6714965c506f2d48dcd3c9e569..21134883bea2553a870ef0df32c47430
if (this.player.containerMenu != oldContainer) { if (this.player.containerMenu != oldContainer) {
this.player.containerMenu.resumeRemoteUpdates(); this.player.containerMenu.resumeRemoteUpdates();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index b06d701b280d58240503a0c95c2c98fa002faa16..96988c6993360cf90c8872a1371d91e897c56582 100644 index 40983aa59d0d8ee7e725c3daf2049a8a9d775d70..8d64020b4c4d5f86ab692db05f40e79b9c42ee68 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -533,6 +533,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -535,6 +535,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api
@@ -281,7 +283,7 @@ index b06d701b280d58240503a0c95c2c98fa002faa16..96988c6993360cf90c8872a1371d91e8
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index e035e87278e02c5a234ec9fa79c009706a189561..fff6985d35ff9b37b2829b7d0639a13e150ad697 100644 index 31e0739bc20096fa368f2b22bb45034a6fe1fe43..c7a930caa2264c9465baf61a0ed8a188119f28c8 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -79,6 +79,7 @@ public class FallingBlockEntity extends Entity { @@ -79,6 +79,7 @@ public class FallingBlockEntity extends Entity {
@@ -293,7 +295,7 @@ index e035e87278e02c5a234ec9fa79c009706a189561..fff6985d35ff9b37b2829b7d0639a13e
public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) { public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index f153f25a4a61a84d842ab33225c4618d464c4116..d9e2a6e02b51cd42f1226a9fb62d0b205e693eba 100644 index df5b6c6c06fc594c3d51e59bab59a625ac1e4bae..4d0bc49ce0868d7a5a1870be4e19eb08f3f31482 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -63,6 +63,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -63,6 +63,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Load Chunks on Movement
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 01cd38bba2deb6cf65c82b4e4ec352a2998fd339..c9bafad13e831f7254f397629f07d3c92fc2a8bb 100644 index 2082b7506a403ed6815076cbd0d3b7eecd7225a0..82dac4fbaf3572391dad61356ba5351b725194ff 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1885,6 +1885,7 @@ public final class CollisionUtil { @@ -1885,6 +1885,7 @@ public final class CollisionUtil {
@@ -50,22 +50,22 @@ index 01cd38bba2deb6cf65c82b4e4ec352a2998fd339..c9bafad13e831f7254f397629f07d3c9
// bound y // bound y
diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java
index 6a7dae136691fb2476633fa12897424daa6bb5b3..372fceb03ee24f0d9c0dc970824f3b637068385a 100644 index e3a4b57f374bbe9792d86e60da1a115abcc9cd66..c22a4c45da0a4c3f6c043d40b6a9a9cd50a64667 100644
--- a/net/minecraft/server/level/TicketType.java --- a/net/minecraft/server/level/TicketType.java
+++ b/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java
@@ -56,6 +56,7 @@ public final class TicketType<T> implements ca.spottedleaf.moonrise.patches.chun @@ -62,6 +62,7 @@ public final class TicketType<T> implements ca.spottedleaf.moonrise.patches.chun
public static final TicketType PLUGIN_TICKET = register("plugin_ticket", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); static { ((TicketType<org.bukkit.plugin.Plugin>)PLUGIN_TICKET).moonrise$setIdentifierComparator((org.bukkit.plugin.Plugin p1, org.bukkit.plugin.Plugin p2) -> p1.getName().compareTo(p2.getName())); } // Paper // Paper - rewrite chunk system public static final TicketType PLUGIN_TICKET = register("plugin_ticket", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper
public static final TicketType FUTURE_AWAIT = register("future_await", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper public static final TicketType FUTURE_AWAIT = register("future_await", NO_TIMEOUT, FLAG_LOADING | FLAG_SIMULATION); // Paper
public static final TicketType CHUNK_LOAD = register("chunk_load", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING); // Paper - moonrise public static final TicketType CHUNK_LOAD = register("chunk_load", NO_TIMEOUT, FLAG_LOADING); // Paper - moonrise
+ public static final TicketType ENTITY_MOVEMENT = register("entity_movement", 200L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Sakura - load chunks on movement + public static final TicketType ENTITY_MOVEMENT = register("entity_movement", 200L, FLAG_LOADING | FLAG_SIMULATION); // Sakura - load chunks on movement
public static TicketType register(String name, long timeout, boolean persist, TicketType.TicketUse use) { private static TicketType register(String name, long timeout, int flags) {
return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, persist, use)); return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, flags));
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b99eaec25 100644 index 8d64020b4c4d5f86ab692db05f40e79b9c42ee68..245997396ebb84c69ee056d83b02fcbc06cea4d2 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -537,6 +537,19 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -539,6 +539,19 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
public boolean isPrimedTNT; public boolean isPrimedTNT;
public boolean isFallingBlock; public boolean isFallingBlock;
// Sakura end - client visibility settings // Sakura end - client visibility settings
@@ -85,7 +85,7 @@ index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
@@ -1520,7 +1533,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1537,7 +1550,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder( ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.getCollisionsForBlocksOrWorldBorder(
this.level, (Entity)(Object)this, initialCollisionBox, potentialCollisionsVoxel, potentialCollisionsBB, this.level, (Entity)(Object)this, initialCollisionBox, potentialCollisionsVoxel, potentialCollisionsBB,
@@ -94,7 +94,7 @@ index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b
); );
potentialCollisionsBB.addAll(entityAABBs); potentialCollisionsBB.addAll(entityAABBs);
final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB); final Vec3 collided = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.performCollisions(movement, currentBox, potentialCollisionsVoxel, potentialCollisionsBB);
@@ -5183,13 +5196,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -5248,13 +5261,14 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@Override @Override
public boolean shouldBeSaved() { public boolean shouldBeSaved() {
return (this.removalReason == null || this.removalReason.shouldSave()) return (this.removalReason == null || this.removalReason.shouldSave())
@@ -111,7 +111,7 @@ index 96988c6993360cf90c8872a1371d91e897c56582..77c06f9304a895e70a695be5afbaea7b
public boolean mayInteract(ServerLevel level, BlockPos pos) { public boolean mayInteract(ServerLevel level, BlockPos pos) {
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index fff6985d35ff9b37b2829b7d0639a13e150ad697..4b9a75c677b8f553a103438c3c7813f46d64d26a 100644 index c7a930caa2264c9465baf61a0ed8a188119f28c8..44f04d0a6b1a47fa152f955a22cc8b8f1d2b3348 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -80,6 +80,7 @@ public class FallingBlockEntity extends Entity { @@ -80,6 +80,7 @@ public class FallingBlockEntity extends Entity {
@@ -123,7 +123,7 @@ index fff6985d35ff9b37b2829b7d0639a13e150ad697..4b9a75c677b8f553a103438c3c7813f4
public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) { public FallingBlockEntity(Level level, double x, double y, double z, BlockState state) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index d9e2a6e02b51cd42f1226a9fb62d0b205e693eba..ea017a4162d54bd7e02b801216d83e51010ef618 100644 index 4d0bc49ce0868d7a5a1870be4e19eb08f3f31482..2572c0fe5fc6bd2f389569cdaa907a8b5203f5b4 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -64,6 +64,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -64,6 +64,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -135,10 +135,10 @@ index d9e2a6e02b51cd42f1226a9fb62d0b205e693eba..ea017a4162d54bd7e02b801216d83e51
public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) { public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) {
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
index 182c14b660f8860bed627eed4e01fd4002153e9a..164e080fbfc4ebff99479497030294e06b658bdc 100644 index 9889485b15501c1adf1a73bb4603d3477860482d..833048754d7f60ad7f528f38c7d34804e1bf5ee1 100644
--- a/net/minecraft/world/level/chunk/ChunkAccess.java --- a/net/minecraft/world/level/chunk/ChunkAccess.java
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java
@@ -139,6 +139,15 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @@ -137,6 +137,15 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
private final int minSection; private final int minSection;
private final int maxSection; private final int maxSection;
// Paper end - get block chunk optimisation // Paper end - get block chunk optimisation

View File

@@ -123,10 +123,10 @@ index f1ab0e66e7d464f7f31a7a360528ed97cdda0aa0..4aed59c3038cb4af7e454a0dd8455488
public DataItem(EntityDataAccessor<T> accessor, T value) { public DataItem(EntityDataAccessor<T> accessor, T value) {
this.accessor = accessor; this.accessor = accessor;
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
index e96d4dee14c05f2fa329bfb1588ec795d4e3d730..ba9393e474ae213316c693d73ef2641e69eae8cc 100644 index 638432a2e6506d3db6a25c068a33eeafb13cf0d6..c386288e808e97c938f1909d81ebfa0032dec2a6 100644
--- a/net/minecraft/server/level/ServerEntity.java --- a/net/minecraft/server/level/ServerEntity.java
+++ b/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java
@@ -148,7 +148,7 @@ public class ServerEntity { @@ -136,7 +136,7 @@ public class ServerEntity {
this.sendDirtyEntityData(); this.sendDirtyEntityData();
} }
@@ -135,28 +135,28 @@ index e96d4dee14c05f2fa329bfb1588ec795d4e3d730..ba9393e474ae213316c693d73ef2641e
byte b = Mth.packDegrees(this.entity.getYRot()); byte b = Mth.packDegrees(this.entity.getYRot());
byte b1 = Mth.packDegrees(this.entity.getXRot()); byte b1 = Mth.packDegrees(this.entity.getXRot());
boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1; boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1;
@@ -411,7 +411,15 @@ public class ServerEntity { @@ -392,7 +392,15 @@ public class ServerEntity {
List<SynchedEntityData.DataValue<?>> list = entityData.packDirty(); List<SynchedEntityData.DataValue<?>> list = entityData.packDirty();
if (list != null) { if (list != null) {
this.trackedDataValues = entityData.getNonDefaultValues(); this.trackedDataValues = entityData.getNonDefaultValues();
- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); - this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
+ // Slice start - packet obfuscation and reduction + // Slice start - packet obfuscation and reduction
+ if (!(this.entity instanceof ServerPlayer)) { + if (!(this.entity instanceof ServerPlayer)) {
+ list = entityData.packForeignDirty(list); + list = entityData.packForeignDirty(list);
+ } + }
+ +
+ if (list != null) { + if (list != null) {
+ this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); + this.synchronizer.sendToTrackingPlayersAndSelf(new ClientboundSetEntityDataPacket(this.entity.getId(), list));
+ } + }
+ // Slice end - packet obfuscation and reduction + // Slice end - packet obfuscation and reduction
} }
if (this.entity instanceof LivingEntity) { if (this.entity instanceof LivingEntity) {
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 77c06f9304a895e70a695be5afbaea7b99eaec25..a13f7613115f08461ed6852fd35bc19f4923063d 100644 index 245997396ebb84c69ee056d83b02fcbc06cea4d2..eb157e848ea97ea11bbf233d473e6a62a23bf32f 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -3637,7 +3637,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -3703,7 +3703,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
return; return;
} }
@@ -166,7 +166,7 @@ index 77c06f9304a895e70a695be5afbaea7b99eaec25..a13f7613115f08461ed6852fd35bc19f
} }
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index 4b9a75c677b8f553a103438c3c7813f46d64d26a..d35183f10362952c0c38061ccdedc1a578c91c2d 100644 index 44f04d0a6b1a47fa152f955a22cc8b8f1d2b3348..59aa539b7d830de48ff582b0da6fa17796b8c4b8 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -144,7 +144,7 @@ public class FallingBlockEntity extends Entity { @@ -144,7 +144,7 @@ public class FallingBlockEntity extends Entity {
@@ -179,7 +179,7 @@ index 4b9a75c677b8f553a103438c3c7813f46d64d26a..d35183f10362952c0c38061ccdedc1a5
public BlockPos getStartPos() { public BlockPos getStartPos() {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index ea017a4162d54bd7e02b801216d83e51010ef618..b53baca84c9022a700fbc1150264fc805af6a61e 100644 index 2572c0fe5fc6bd2f389569cdaa907a8b5203f5b4..6797e16f973b11d168906dfce240c70db25bc6f0 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -228,7 +228,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -228,7 +228,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -196,10 +196,10 @@ index ea017a4162d54bd7e02b801216d83e51010ef618..b53baca84c9022a700fbc1150264fc80
public int getFuse() { public int getFuse() {
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index fbb58d0dc50d1e6d90d51379acbf6822674efc46..17723bdf3f3d3c8637dee01f8f4a15b2d741e52d 100644 index 0a72140f396ab1c03a064020b6e081108a98b06e..92a8bdbf74a35afcd76eabee0869426440a69b7a 100644
--- a/net/minecraft/world/entity/player/Player.java --- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java
@@ -701,7 +701,7 @@ public abstract class Player extends LivingEntity { @@ -573,7 +573,7 @@ public abstract class Player extends Avatar implements ContainerUser {
public void increaseScore(int score) { public void increaseScore(int score) {
int score1 = this.getScore(); int score1 = this.getScore();

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Add redstone implementation api
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index ddd70576d1551d77cbefb9d63bbbaf94b569b074..a9db955a90e0b44d3c85e39f2f7ae9ea4f68a316 100644 index 8268ac128d0a2dfb9eee9a46630862bdd04a747e..7390a21f7c6991d3fb62fda9e88bc9212159177b 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java --- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -275,7 +275,7 @@ public class RedStoneWireBlock extends Block { @@ -275,7 +275,7 @@ public class RedStoneWireBlock extends Block {
@@ -19,7 +19,7 @@ index ddd70576d1551d77cbefb9d63bbbaf94b569b074..a9db955a90e0b44d3c85e39f2f7ae9ea
// to find the direction of information flow // to find the direction of information flow
@@ -348,7 +348,7 @@ public class RedStoneWireBlock extends Block { @@ -348,7 +348,7 @@ public class RedStoneWireBlock extends Block {
protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) {
if (!oldState.is(state.getBlock()) && !level.isClientSide) { if (!oldState.is(state.getBlock()) && !level.isClientSide()) {
// Paper start - optimize redstone - replace call to updatePowerStrength // Paper start - optimize redstone - replace call to updatePowerStrength
- if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { - if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {
+ if (level.localConfig().at(pos).paperRedstoneImplementation() == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura - redstone implementation api + if (level.localConfig().at(pos).paperRedstoneImplementation() == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura - redstone implementation api
@@ -36,7 +36,7 @@ index ddd70576d1551d77cbefb9d63bbbaf94b569b074..a9db955a90e0b44d3c85e39f2f7ae9ea
} else { } else {
this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft
@@ -401,7 +401,7 @@ public class RedStoneWireBlock extends Block { @@ -401,7 +401,7 @@ public class RedStoneWireBlock extends Block {
if (!level.isClientSide) { if (!level.isClientSide()) {
// Paper start - optimize redstone (Alternate Current) // Paper start - optimize redstone (Alternate Current)
// Alternate Current handles breaking of redstone wires in the WireHandler. // Alternate Current handles breaking of redstone wires in the WireHandler.
- if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { - if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) {

View File

@@ -40,10 +40,10 @@ index b2bcfb3557a0326fd7ec1059f95d6da4568dfd80..8df264c86ab14f4e7aa9918a3341ef35
if (this.count == 0) { if (this.count == 0) {
return; return;
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index f99a254d140f96feab9436b7799eec4804500033..0b3abcd143e7f81d5feaf75f74ce19a6915be7be 100644 index 6626dd51bba3bbc979f0e641243ce864f88925ca..a3e47902098331ce1dfcbb96909e4a8cd5d7da78 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -86,7 +86,7 @@ public class ServerExplosion implements Explosion { @@ -88,7 +88,7 @@ public class ServerExplosion implements Explosion {
} }
} }
@@ -52,7 +52,7 @@ index f99a254d140f96feab9436b7799eec4804500033..0b3abcd143e7f81d5feaf75f74ce19a6
} }
private static final int CHUNK_CACHE_SHIFT = 2; private static final int CHUNK_CACHE_SHIFT = 2;
@@ -398,6 +398,12 @@ public class ServerExplosion implements Explosion { @@ -400,6 +400,12 @@ public class ServerExplosion implements Explosion {
initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true);
} }
@@ -65,110 +65,10 @@ index f99a254d140f96feab9436b7799eec4804500033..0b3abcd143e7f81d5feaf75f74ce19a6
// only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of // only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of
// a 16x16x16 cube // a 16x16x16 cube
// we can cache the rays and their normals as well, so that we eliminate the excess iterations / checks and // we can cache the rays and their normals as well, so that we eliminate the excess iterations / checks and
@@ -476,16 +482,62 @@ public class ServerExplosion implements Explosion { @@ -558,7 +564,7 @@ public class ServerExplosion implements Explosion {
// Paper end - collision optimisations
}
+ // Sakura start - optimise paper explosions
+ protected final AABB getExplosionBounds(final float impactRadius) {
+ final int minX = Mth.floor(this.center.x - impactRadius - 1.0);
+ final int maxX = Mth.floor(this.center.x + impactRadius + 1.0);
+ final int minY = Mth.floor(this.center.y - impactRadius - 1.0);
+ final int maxY = Mth.floor(this.center.y + impactRadius + 1.0);
+ final int minZ = Mth.floor(this.center.z - impactRadius - 1.0);
+ final int maxZ = Mth.floor(this.center.z + impactRadius + 1.0);
+ return new AABB(minX, minY, minZ, maxX, maxY, maxZ);
+ }
+
private void hurtEntities() {
- float f = this.radius * 2.0F;
- int floor = Mth.floor(this.center.x - f - 1.0);
- int floor1 = Mth.floor(this.center.x + f + 1.0);
- int floor2 = Mth.floor(this.center.y - f - 1.0);
- int floor3 = Mth.floor(this.center.y + f + 1.0);
- int floor4 = Mth.floor(this.center.z - f - 1.0);
- int floor5 = Mth.floor(this.center.z + f + 1.0);
- List <Entity> list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
- for (Entity entity : list) { // Paper - used in loop
+ final float impactRadius = this.radius * 2.0F;
+
+ final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this.level);
+ final int maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this.level);
+
+ final int minChunkX = Mth.floor(this.center.x - impactRadius) >> 4;
+ final int maxChunkX = Mth.floor(this.center.x + impactRadius) >> 4;
+ final int minChunkY = Mth.clamp(Mth.floor(this.center.y - impactRadius) >> 4, minSection, maxSection);
+ final int maxChunkY = Mth.clamp(Mth.floor(this.center.y + impactRadius) >> 4, minSection, maxSection);
+ final int minChunkZ = Mth.floor(this.center.z - impactRadius) >> 4;
+ final int maxChunkZ = Mth.floor(this.center.z + impactRadius) >> 4;
+
+ final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup = this.level.moonrise$getEntityLookup();
+ for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) {
+ for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) {
+ final ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices chunk = entityLookup.getChunk(chunkX, chunkZ);
+ if (chunk == null) {
+ continue; // empty slice
+ }
+
+ for (int chunkY = minChunkY; chunkY <= maxChunkY; ++chunkY) {
+ this.impactEntities(impactRadius, chunk.getSectionEntities(chunkY));
+ }
+ }
+ }
+ }
+
+ protected final void impactEntities(final float impactRadius, final Entity[] entities) {
+ for (int index = 0; index < entities.length; index++) {
+ final Entity entity = entities[index];
+ if (entity == null) break; // end of entity slice
+
+ this.impactEntity(impactRadius, entity);
+
+ // Entities can be removed from the world mid-explosion.
+ if (entity != entities[index]) {
+ index--;
+ }
+ }
+ }
+
+ protected final void impactEntity(final float f, final Entity entity) {
+ if (entity.isAlive() && !entity.isSpectator() && (!this.excludeSourceFromDamage || entity != this.source)) { // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ // Sakura end - optimise paper explosions
if (!entity.ignoreExplosion(this)) {
double d = Math.sqrt(entity.distanceToSqr(this.center)) / f;
if (d <= 1.0) {
@@ -510,15 +562,16 @@ public class ServerExplosion implements Explosion {
// - Damaging EnderDragon does nothing
// - EnderDragon hitbox always covers the other parts and is therefore always present
if (entity instanceof EnderDragonPart) {
- continue;
+ return; // Sakura - optimise paper explosions
}
entity.lastDamageCancelled = false;
if (entity instanceof EnderDragon) {
+ final AABB bounds = this.getExplosionBounds(f); // Sakura - optimise paper explosions
for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) {
// Calculate damage separately for each EntityComplexPart
- if (list.contains(dragonPart)) {
+ if (dragonPart.getBoundingBox().intersects(bounds)) { // Sakura - optimise paper explosions
dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1));
}
}
@@ -527,7 +580,7 @@ public class ServerExplosion implements Explosion {
}
if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled
- continue;
+ return; // Sakura - optimise paper explosions
}
// CraftBukkit end
}
@@ -570,7 +623,7 @@ public class ServerExplosion implements Explosion {
// CraftBukkit start // CraftBukkit start
Location location = CraftLocation.toBukkit(this.center, this.level.getWorld()); Location location = CraftLocation.toBukkit(this.center, this.level);
- List<org.bukkit.block.Block> blockList = new ObjectArrayList<>(); - List<org.bukkit.block.Block> blockList = new ObjectArrayList<>();
+ List<org.bukkit.block.Block> blockList = new ObjectArrayList<>(fire ? ObjectArrayList.DEFAULT_INITIAL_CAPACITY : blocks.size()); // Sakura - optimise paper explosions + List<org.bukkit.block.Block> blockList = new ObjectArrayList<>(fire ? ObjectArrayList.DEFAULT_INITIAL_CAPACITY : blocks.size()); // Sakura - optimise paper explosions
for (int i1 = blocks.size() - 1; i1 >= 0; i1--) { for (int i1 = blocks.size() - 1; i1 >= 0; i1--) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Store Entity Data/State
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index a13f7613115f08461ed6852fd35bc19f4923063d..815f92176821bf4117952450e97bd5b044c78b58 100644 index eb157e848ea97ea11bbf233d473e6a62a23bf32f..127479da921c2679e19f13e71cc04be8a310b459 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -550,6 +550,21 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -552,6 +552,21 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return flags; return flags;
} }
// Sakura end - load chunks on movement // Sakura end - load chunks on movement
@@ -31,14 +31,14 @@ index a13f7613115f08461ed6852fd35bc19f4923063d..815f92176821bf4117952450e97bd5b0
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 44e4c907801b934c188cf67bf3c75023a52a948f..4ff7fdc9a75e7d31170385016bf8ea75c45719a1 100644 index 4b2ea3c99bcd5452840b26c2ba607a4f034ba367..5f49990b13ac7fdd4366585d976d50bd3ae183cb 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -1498,6 +1498,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -1448,6 +1448,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public <T extends Entity> void guardEntityTick(Consumer<T> consumerEntity, T entity) { public <T extends Entity> void guardEntityTick(Consumer<T> action, T entity) {
try { try {
+ entity.storeEntityState(); // Sakura - store entity data/state + entity.storeEntityState(); // Sakura - store entity data/state
consumerEntity.accept(entity); action.accept(entity);
} catch (Throwable var6) { } catch (Throwable var6) {
// Paper start - Prevent block entity and entity crashes // Paper start - Prevent block entity and entity crashes

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Merge Cannon Entities
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e09715f79e 100644 index bc714079924b4a724a6f1aa7ccfa53884a9e4fa9..259faa131f4aec7db565c78c38aa058d20ef3d28 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -692,6 +692,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -709,6 +709,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
// Paper end - rewrite chunk system // Paper end - rewrite chunk system
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
@@ -16,7 +16,7 @@ index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e0
} }
// Paper start // Paper start
@@ -806,6 +807,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -827,6 +828,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
} }
io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR
@@ -24,7 +24,7 @@ index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e0
this.entityTickList this.entityTickList
.forEach( .forEach(
entity -> { entity -> {
@@ -824,6 +826,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -845,6 +847,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
entity.stopRiding(); entity.stopRiding();
} }
@@ -41,10 +41,10 @@ index 2a7c057ccfeb5dbe6b14ff660c0bb342571d88e7..496e23c110cbb3b60a6565e1903545e0
this.guardEntityTick(this::tickNonPassenger, entity); this.guardEntityTick(this::tickNonPassenger, entity);
profilerFiller.pop(); profilerFiller.pop();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 815f92176821bf4117952450e97bd5b044c78b58..bf46bb5b61f4ec6f23aacec41426d0ffe5a265fb 100644 index 127479da921c2679e19f13e71cc04be8a310b459..4ce3d09d30996fb2c13afe799bb31d910ce666ba 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -565,6 +565,27 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -567,6 +567,27 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return to.entityState() != null && to.entityState().comparePositionAndMotion(this); return to.entityState() != null && to.entityState().comparePositionAndMotion(this);
} }
// Sakura end - store entity data/state // Sakura end - store entity data/state
@@ -72,7 +72,7 @@ index 815f92176821bf4117952450e97bd5b044c78b58..bf46bb5b61f4ec6f23aacec41426d0ff
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
@@ -5176,6 +5197,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -5241,6 +5262,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
if (this.removalReason != Entity.RemovalReason.UNLOADED_TO_CHUNK) { this.getPassengers().forEach(Entity::stopRiding); } // Paper - rewrite chunk system if (this.removalReason != Entity.RemovalReason.UNLOADED_TO_CHUNK) { this.getPassengers().forEach(Entity::stopRiding); } // Paper - rewrite chunk system
this.levelCallback.onRemove(removalReason); this.levelCallback.onRemove(removalReason);
this.onRemoval(removalReason); this.onRemoval(removalReason);
@@ -85,7 +85,7 @@ index 815f92176821bf4117952450e97bd5b044c78b58..bf46bb5b61f4ec6f23aacec41426d0ff
if (!(this instanceof ServerPlayer) && removalReason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) { if (!(this instanceof ServerPlayer) && removalReason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
// Players need to be special cased, because they are regularly removed from the world // Players need to be special cased, because they are regularly removed from the world
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410668e42bd 100644 index 59aa539b7d830de48ff582b0da6fa17796b8c4b8..af7dd04ecbf9e8b35357da421fb156aee61261b5 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -53,7 +53,7 @@ import net.minecraft.world.phys.HitResult; @@ -53,7 +53,7 @@ import net.minecraft.world.phys.HitResult;
@@ -167,9 +167,9 @@ index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410
// CraftBukkit end // CraftBukkit end
+ if (this.tryToRespawnEntity()) return; // Sakura - merge cannon entities + if (this.tryToRespawnEntity()) return; // Sakura - merge cannon entities
if (this.level().setBlock(blockPos, this.blockState, 3)) { if (this.level().setBlock(blockPos, this.blockState, 3)) {
((ServerLevel)this.level()) serverLevel.getChunkSource()
.getChunkSource() .chunkMap
@@ -346,6 +398,11 @@ public class FallingBlockEntity extends Entity { @@ -345,6 +397,11 @@ public class FallingBlockEntity extends Entity {
output.putBoolean("CancelDrop", this.cancelDrop); output.putBoolean("CancelDrop", this.cancelDrop);
if (!this.autoExpire) output.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API if (!this.autoExpire) output.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API
@@ -181,7 +181,7 @@ index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410
} }
@Override @Override
@@ -360,6 +417,7 @@ public class FallingBlockEntity extends Entity { @@ -359,6 +416,7 @@ public class FallingBlockEntity extends Entity {
this.blockData = input.read("TileEntityData", CompoundTag.CODEC).map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks this.blockData = input.read("TileEntityData", CompoundTag.CODEC).map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks
this.cancelDrop = input.getBooleanOr("CancelDrop", false); this.cancelDrop = input.getBooleanOr("CancelDrop", false);
this.autoExpire = input.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API this.autoExpire = input.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API
@@ -190,7 +190,7 @@ index d35183f10362952c0c38061ccdedc1a578c91c2d..8ea534e6f49b787f5445093203f41410
public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) { public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) {
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index b53baca84c9022a700fbc1150264fc805af6a61e..95d57f9aea21860ff886a27cc5641d7c96882f34 100644 index 6797e16f973b11d168906dfce240c70db25bc6f0..8a36e0ce4792e7152905256dde7746fd09d42729 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -34,7 +34,7 @@ import org.bukkit.event.entity.EntityRemoveEvent; @@ -34,7 +34,7 @@ import org.bukkit.event.entity.EntityRemoveEvent;
@@ -256,7 +256,7 @@ index b53baca84c9022a700fbc1150264fc805af6a61e..95d57f9aea21860ff886a27cc5641d7c
// CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
//this.discard(); //this.discard();
+ this.tryToRespawnEntity(); // Sakura - merge cannon entities + this.tryToRespawnEntity(); // Sakura - merge cannon entities
if (!this.level().isClientSide) { if (!this.level().isClientSide()) {
this.explode(); this.explode();
} }
@@ -203,6 +241,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { @@ -203,6 +241,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -280,10 +280,10 @@ index b53baca84c9022a700fbc1150264fc805af6a61e..95d57f9aea21860ff886a27cc5641d7c
@Nullable @Nullable
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 4ff7fdc9a75e7d31170385016bf8ea75c45719a1..7b9e61b2286d18f55a365eebda1fe2128023bec9 100644 index 5f49990b13ac7fdd4366585d976d50bd3ae183cb..93ff0fdaee21ac493833640b5f620f9bec1a69c8 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -828,6 +828,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -833,6 +833,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public final me.samsuik.sakura.listener.LevelTickScheduler levelTickScheduler = new me.samsuik.sakura.listener.LevelTickScheduler(this); public final me.samsuik.sakura.listener.LevelTickScheduler levelTickScheduler = new me.samsuik.sakura.listener.LevelTickScheduler(this);
public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this); public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this);
// Sakura end - track block changes and tick scheduler // Sakura end - track block changes and tick scheduler
@@ -292,7 +292,7 @@ index 4ff7fdc9a75e7d31170385016bf8ea75c45719a1..7b9e61b2286d18f55a365eebda1fe212
protected Level( protected Level(
WritableLevelData levelData, WritableLevelData levelData,
diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java
index 42ee3f32fe44c1f0680c994a69201f7bd7792673..79593698d532a41c3f75c00b3452b6f0aa092845 100644 index fe9b5cf6fb8d8221b98836148e95aa857241181d..f9c1c5a7f0602c225d18005e7161384cc1d3c604 100644
--- a/net/minecraft/world/level/block/BasePressurePlateBlock.java --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java
+++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java
@@ -92,7 +92,7 @@ public abstract class BasePressurePlateBlock extends Block { @@ -92,7 +92,7 @@ public abstract class BasePressurePlateBlock extends Block {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Replace explosion density cache
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 496e23c110cbb3b60a6565e1903545e09715f79e..a73395c1ec0f36019de553c39199957032e316c4 100644 index 259faa131f4aec7db565c78c38aa058d20ef3d28..efdf41c42320ac9defd5d0eb206df5aaed012363 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -693,6 +693,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -710,6 +710,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit
this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities
@@ -17,10 +17,10 @@ index 496e23c110cbb3b60a6565e1903545e09715f79e..a73395c1ec0f36019de553c391999570
// Paper start // Paper start
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 7b9e61b2286d18f55a365eebda1fe2128023bec9..7a30a227a417ecf9f16ce97d53b238935e652d68 100644 index 93ff0fdaee21ac493833640b5f620f9bec1a69c8..e807aafed0295d8db7ba0782bb1e462561e9e1ec 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -829,6 +829,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -834,6 +834,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this); public final me.samsuik.sakura.listener.BlockChangeTracker blockChangeTracker = new me.samsuik.sakura.listener.BlockChangeTracker(this);
// Sakura end - track block changes and tick scheduler // Sakura end - track block changes and tick scheduler
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
@@ -29,10 +29,10 @@ index 7b9e61b2286d18f55a365eebda1fe2128023bec9..7a30a227a417ecf9f16ce97d53b23893
protected Level( protected Level(
WritableLevelData levelData, WritableLevelData levelData,
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002dcd28343b 100644 index a3e47902098331ce1dfcbb96909e4a8cd5d7da78..39a4f8ffb7c0e61d94c4384c4a3f77550fefe16f 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -294,7 +294,12 @@ public class ServerExplosion implements Explosion { @@ -296,7 +296,12 @@ public class ServerExplosion implements Explosion {
Math.fma(dz, diffZ, offZ) Math.fma(dz, diffZ, offZ)
); );
@@ -46,7 +46,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d
++missedRays; ++missedRays;
} }
} }
@@ -352,8 +357,16 @@ public class ServerExplosion implements Explosion { @@ -354,8 +359,16 @@ public class ServerExplosion implements Explosion {
double d9 = Mth.lerp(d6, boundingBox.minY, boundingBox.maxY); double d9 = Mth.lerp(d6, boundingBox.minY, boundingBox.maxY);
double d10 = Mth.lerp(d7, boundingBox.minZ, boundingBox.maxZ); double d10 = Mth.lerp(d7, boundingBox.minZ, boundingBox.maxZ);
Vec3 vec3 = new Vec3(d8 + d3, d9, d10 + d4); Vec3 vec3 = new Vec3(d8 + d3, d9, d10 + d4);
@@ -65,7 +65,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d
i++; i++;
} }
@@ -656,6 +669,11 @@ public class ServerExplosion implements Explosion { @@ -597,6 +610,11 @@ public class ServerExplosion implements Explosion {
return; return;
} }
// CraftBukkit end // CraftBukkit end
@@ -77,7 +77,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d
for (BlockPos blockPos : blocks) { for (BlockPos blockPos : blocks) {
// CraftBukkit start - TNTPrimeEvent // CraftBukkit start - TNTPrimeEvent
@@ -822,14 +840,12 @@ public class ServerExplosion implements Explosion { @@ -765,14 +783,12 @@ public class ServerExplosion implements Explosion {
// Paper start - Optimize explosions // Paper start - Optimize explosions
protected float getBlockDensity(Vec3 vec3d, Entity entity) { protected float getBlockDensity(Vec3 vec3d, Entity entity) {
@@ -98,7 +98,7 @@ index cc6ee993470a274cdad124b4a7befb016d9a2b6e..fde0528e00939972adc2f48b1456002d
return blockDensity; return blockDensity;
diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java
index 79593698d532a41c3f75c00b3452b6f0aa092845..2ea14093ba70d6e0e7407c18fb0570f5a15d8c2a 100644 index f9c1c5a7f0602c225d18005e7161384cc1d3c604..a43dfc0ebd28d42d4334021ac7255e496f78c6b7 100644
--- a/net/minecraft/world/level/block/BasePressurePlateBlock.java --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java
+++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java
@@ -107,6 +107,11 @@ public abstract class BasePressurePlateBlock extends Block { @@ -107,6 +107,11 @@ public abstract class BasePressurePlateBlock extends Block {
@@ -130,7 +130,7 @@ index 8a3a8b0fdf9545a41501dc992c6982d9c8ce7b66..5e2576a8b90de8a829c6136cc384f3fe
notifyNeighbors(block, level, blockPosx, opposite); notifyNeighbors(block, level, blockPosx, opposite);
emitState(level, blockPosx, flag2, flag3, flag, flag1); emitState(level, blockPosx, flag2, flag3, flag, flag1);
diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java
index 84f3073444ae9e11e5d11224d6af6474ced925e2..cc0ce70aa363a5ba64c5f7eda579cd00fbb6cd4c 100644 index f87d0bd3d65155fbc206a0dae8de67a9184436f3..da90795ce9d4589ee9a4b5ab10f3af59c772547b 100644
--- a/net/minecraft/world/phys/AABB.java --- a/net/minecraft/world/phys/AABB.java
+++ b/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java
@@ -19,6 +19,30 @@ public class AABB { @@ -19,6 +19,30 @@ public class AABB {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise explosions in protected regions
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index c3c90cc17c4f1ebcaddffea4087929e3708aa22f..000e1ffcebd6f529133af1edbed6da80b9848e75 100644 index 39a4f8ffb7c0e61d94c4384c4a3f77550fefe16f..17aaa7cd99f9a0f1d1c31c72bea2973eeb71e600 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -309,6 +309,22 @@ public class ServerExplosion implements Explosion { @@ -311,6 +311,22 @@ public class ServerExplosion implements Explosion {
return (float)missedRays / (float)totalRays; return (float)missedRays / (float)totalRays;
} }
// Paper end - collisions optimisations // Paper end - collisions optimisations
@@ -31,7 +31,7 @@ index c3c90cc17c4f1ebcaddffea4087929e3708aa22f..000e1ffcebd6f529133af1edbed6da80
public ServerExplosion( public ServerExplosion(
ServerLevel level, ServerLevel level,
@@ -416,6 +432,11 @@ public class ServerExplosion implements Explosion { @@ -418,6 +434,11 @@ public class ServerExplosion implements Explosion {
return ret; return ret;
} }
// Sakura end - optimise paper explosions // Sakura end - optimise paper explosions

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Specialised Explosions
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 8c4b4cb9e98b8c0334bb7e247e67206bd57c3de2..573b1695abde0d89d5702a60a84919167ef4baab 100644 index efdf41c42320ac9defd5d0eb206df5aaed012363..733c5d7419cae21300d40fb13979dd40ecdd6810 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -1914,7 +1914,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1947,7 +1947,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type case STANDARD -> Explosion.BlockInteraction.DESTROY; // CraftBukkit - handle custom explosion type
}; };
Vec3 vec3 = new Vec3(x, y, z); Vec3 vec3 = new Vec3(x, y, z);
@@ -16,47 +16,55 @@ index 8c4b4cb9e98b8c0334bb7e247e67206bd57c3de2..573b1695abde0d89d5702a60a8491916
+ // Sakura start - specialised explosions + // Sakura start - specialised explosions
+ final ServerExplosion serverExplosion; + final ServerExplosion serverExplosion;
+ if (source instanceof net.minecraft.world.entity.item.PrimedTnt tnt) { + 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 -> { + serverExplosion = new me.samsuik.sakura.explosion.TntExplosion(this, tnt, damageSource, damageCalculator, vec3, radius, fire, blockInteraction);
+ this.notifyPlayersOfExplosion(self, self.center(), smallExplosionParticles, largeExplosionParticles, explosionSound);
+ });
+ } else { + } else {
+ serverExplosion = new ServerExplosion(this, source, damageSource, damageCalculator, vec3, radius, fire, blockInteraction); + serverExplosion = new ServerExplosion(this, source, damageSource, damageCalculator, vec3, radius, fire, blockInteraction);
+ } + }
+ // Sakura end - specialised explosions + // Sakura end - specialised explosions
if (configurator != null) configurator.accept(serverExplosion);// Paper - Allow explosions to damage source if (configurator != null) configurator.accept(serverExplosion);// Paper - Allow explosions to damage source
serverExplosion.explode(); int i = serverExplosion.explode();
// CraftBukkit start // CraftBukkit start
@@ -1922,6 +1931,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1955,6 +1962,29 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
return serverExplosion; return serverExplosion;
} }
// CraftBukkit end // CraftBukkit end
+ // Sakura start - specialised explosions + // Sakura start - specialised explosions
+ this.notifyPlayersOfExplosion(serverExplosion, vec3, smallExplosionParticles, largeExplosionParticles, explosionSound); + if (serverExplosion instanceof me.samsuik.sakura.explosion.SpecialisedExplosion<?> specialisedExplosion) {
+ me.samsuik.sakura.explosion.ExplosionToSend explosionToSend;
+ while ((explosionToSend = specialisedExplosion.getExplosionsToSend().poll()) != null) {
+ this.notifyPlayersOfExplosion(serverExplosion, explosionToSend.position(), radius, explosionToSend.blocksDestroyed(), smallExplosionParticles, largeExplosionParticles, explosionSound, blockParticles);
+ }
+ }
+
+ this.notifyPlayersOfExplosion(serverExplosion, vec3, radius, i, smallExplosionParticles, largeExplosionParticles, explosionSound, blockParticles);
+ return serverExplosion; + return serverExplosion;
+ } + }
+ +
+ private void notifyPlayersOfExplosion( + private void notifyPlayersOfExplosion(
+ final ServerExplosion serverExplosion, + final ServerExplosion serverExplosion,
+ final Vec3 vec3, + final Vec3 vec3,
+ final float radius,
+ final int i,
+ final ParticleOptions smallExplosionParticles, + final ParticleOptions smallExplosionParticles,
+ final ParticleOptions largeExplosionParticles, + final ParticleOptions largeExplosionParticles,
+ final Holder<SoundEvent> explosionSound + final Holder<SoundEvent> explosionSound,
+ final WeightedList<ExplosionParticleInfo> blockParticles
+ ) { + ) {
+ // Sakura end - specialised explosions + // Sakura end - specialised explosions
ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles;
for (ServerPlayer serverPlayer : this.players) { for (ServerPlayer serverPlayer : this.players) {
@@ -1942,7 +1964,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1977,7 +2007,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
} }
} }
- return serverExplosion; // CraftBukkit - return serverExplosion; // CraftBukkit
+ // Sakura - specialised explosions; return moved up into explode0 + serverExplosion.getHitPlayers().clear(); // Sakura - specialised explosions
} }
private Explosion.BlockInteraction getDestroyType(GameRules.Key<GameRules.BooleanValue> decayGameRule) { 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 diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index 95d57f9aea21860ff886a27cc5641d7c96882f34..45a528169a57ecc287ae4f527d1d98b597a48f04 100644 index 8a36e0ce4792e7152905256dde7746fd09d42729..b349149592b09512b573911e95fd13915ba698cd 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/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 @@ -79,20 +79,7 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -82,10 +90,10 @@ index 95d57f9aea21860ff886a27cc5641d7c96882f34..45a528169a57ecc287ae4f527d1d98b5
// Sakura end - merge cannon entities // Sakura end - merge cannon entities
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8d3da0292 100644 index 17aaa7cd99f9a0f1d1c31c72bea2973eeb71e600..0f95ffa2551289cb74d0210673b942ca90be74d3 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -325,6 +325,38 @@ public class ServerExplosion implements Explosion { @@ -327,6 +327,38 @@ public class ServerExplosion implements Explosion {
return true; return true;
} }
// Sakura end - optimise explosion protected regions // Sakura end - optimise explosion protected regions
@@ -101,16 +109,6 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8
+ // Paper end - collision optimisations + // Paper end - collision optimisations
+ } + }
+ +
+ protected final void markBlocksInCacheAsExplodable(final List<BlockPos> explodedPositions) {
+ for (final BlockPos blow : explodedPositions) {
+ final 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() { + protected final void clearBlockCache() {
+ // Paper start - collision optimisations + // Paper start - collision optimisations
+ this.blockCache = null; + this.blockCache = null;
@@ -120,26 +118,92 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8
+ this.mutablePos = null; + this.mutablePos = null;
+ // Paper end - collision optimisations + // Paper end - collision optimisations
+ } + }
+
+ protected final void markBlocksInCacheAsExplodable(final List<BlockPos> explodedPositions) {
+ for (final BlockPos explodedPos : explodedPositions) {
+ final ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache cache = this.blockCache.get(explodedPos.asLong());
+ // May be null if the blockCache is cleared then retrieved from the recent block cache
+ if (cache != null) {
+ cache.shouldExplode = null;
+ }
+ }
+ }
+ // Sakura end - specialised explosions + // Sakura end - specialised explosions
public ServerExplosion( public ServerExplosion(
ServerLevel level, ServerLevel level,
@@ -641,7 +673,10 @@ public class ServerExplosion implements Explosion { @@ -520,14 +552,25 @@ public class ServerExplosion implements Explosion {
// CraftBukkit end
entity.push(vec3); private void hurtEntities() {
if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback float f = this.radius * 2.0F;
- this.hitPlayers.put(player, vec3); + // Sakura start - specialised explosions
+ // Sakura start - specialised explosions; tally player velocity + for (final Entity entity : this.level.getEntities(null, this.getExplosionBounds(f))) {
+ final Vec3 explosionImpact = vec3; + this.impactEntity(f, entity);
+ this.hitPlayers.compute(player, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact); + }
+ // Sakura end - specialised explosions; tally player velocity + }
+
+ private AABB getExplosionBounds(final float f) {
int floor = Mth.floor(this.center.x - f - 1.0);
int floor1 = Mth.floor(this.center.x + f + 1.0);
int floor2 = Mth.floor(this.center.y - f - 1.0);
int floor3 = Mth.floor(this.center.y + f + 1.0);
int floor4 = Mth.floor(this.center.z - f - 1.0);
int floor5 = Mth.floor(this.center.z + f + 1.0);
- List <Entity> list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
- for (Entity entity : list) { // Paper - used in loop
+ return new AABB(floor, floor2, floor4, floor1, floor3, floor5);
+ }
+
+ protected final void impactEntity(final float f, final Entity entity) {
+ if (entity.isAlive() && !entity.isSpectator() && (!this.excludeSourceFromDamage || entity != this.source)) { // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source
+ // Sakura end - specialised explosions
if (!entity.ignoreExplosion(this)) {
double d = Math.sqrt(entity.distanceToSqr(this.center)) / f;
if (!(d > 1.0)) {
@@ -546,15 +589,16 @@ public class ServerExplosion implements Explosion {
// - Damaging EnderDragon does nothing
// - EnderDragon hitbox always covers the other parts and is therefore always present
if (entity instanceof EnderDragonPart) {
- continue;
+ return; // Sakura - specialised explosions
} }
entity.onExplosionHit(this.source); entity.lastDamageCancelled = false;
@@ -746,14 +781,7 @@ public class ServerExplosion implements Explosion {
if (entity instanceof EnderDragon) {
+ final AABB explosionBounds = this.getExplosionBounds(f); // Sakura - specialised explosions
for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) {
// Calculate damage separately for each EntityComplexPart
- if (list.contains(dragonPart)) {
+ if (explosionBounds.intersects(dragonPart.getBoundingBox())) { // Sakura - specialised explosions
dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1));
}
}
@@ -563,7 +607,7 @@ public class ServerExplosion implements Explosion {
}
if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled
- continue;
+ return; // Sakura - specialised explosions
}
// CraftBukkit end
}
@@ -583,7 +627,10 @@ public class ServerExplosion implements Explosion {
if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) {
projectile.setOwner(this.damageSource.getEntity());
} else 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, vec32);
+ // Sakura start - specialised explosions; tally player velocity
+ final Vec3 explosionImpact = vec32;
+ this.hitPlayers.compute(player, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact);
+ // Sakura end - specialised explosions; tally player velocity
}
entity.onExplosionHit(this.source);
@@ -687,14 +734,7 @@ public class ServerExplosion implements Explosion {
} }
public void explode() { public int explode() {
- // Paper start - collision optimisations - // Paper start - collision optimisations
- this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(); - this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
- this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; - this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
@@ -152,10 +216,10 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8
this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center);
List<BlockPos> list = this.calculateExplodedPositions(); List<BlockPos> list = this.calculateExplodedPositions();
this.hurtEntities(); this.hurtEntities();
@@ -767,13 +795,7 @@ public class ServerExplosion implements Explosion { @@ -709,13 +749,7 @@ public class ServerExplosion implements Explosion {
if (this.fire) {
this.createFire(list); this.createFire(list);
} }
- // Paper start - collision optimisations - // Paper start - collision optimisations
- this.blockCache = null; - this.blockCache = null;
- this.chunkPosCache = null; - this.chunkPosCache = null;
@@ -164,6 +228,6 @@ index 000e1ffcebd6f529133af1edbed6da80b9848e75..d2b33fb06ce9a806466208d7afd65fa8
- this.mutablePos = null; - this.mutablePos = null;
- // Paper end - collision optimisations - // Paper end - collision optimisations
+ this.clearBlockCache(); // Sakura - specialised explosions + this.clearBlockCache(); // Sakura - specialised explosions
return list.size();
} }
private static void addOrAppendStack(List<ServerExplosion.StackCollector> stackCollectors, ItemStack stack, BlockPos pos) {

View File

@@ -5,24 +5,24 @@ Subject: [PATCH] Optimise cannon entity movement
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index bf46bb5b61f4ec6f23aacec41426d0ffe5a265fb..eaa57560a20841a2b218ff2fd9059f82339a678c 100644 index 4ce3d09d30996fb2c13afe799bb31d910ce666ba..0c20de0f6af0385a7849cb9b0be86049784d59ae 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -1190,7 +1190,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1200,7 +1200,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
Vec3 vec3 = this.collide(movement); Vec3 vec3 = this.collide(movement);
double d = vec3.lengthSqr(); double d = vec3.lengthSqr();
if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) { if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) {
- if (this.fallDistance != 0.0 && d >= 1.0) { - if (this.fallDistance != 0.0 && d >= 1.0) {
+ if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement + if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement
double min = Math.min(vec3.length(), 8.0);
Vec3 vec31 = this.position().add(vec3.normalize().scale(min));
BlockHitResult blockHitResult = this.level() BlockHitResult blockHitResult = this.level()
.clip( @@ -1555,6 +1555,132 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
new ClipContext(this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this) return list.isEmpty() ? distance : -Shapes.collide(Direction.Axis.Y, boundingBox, list, -distance);
@@ -1538,6 +1538,132 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return distance;
} }
+ // Sakura start - optimise cannon entity movement + // Sakura start - optimise cannon entity movement
+ protected final Vec3 sakura_collide(final Vec3 movement) { + protected final Vec3 sakura$collide(final Vec3 movement) {
+ if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) { + if (movement.x == 0.0 && movement.y == 0.0 && movement.z == 0.0) {
+ return movement; + return movement;
+ } + }
@@ -151,7 +151,7 @@ index bf46bb5b61f4ec6f23aacec41426d0ffe5a265fb..eaa57560a20841a2b218ff2fd9059f82
protected Vec3 collide(Vec3 movement) { protected Vec3 collide(Vec3 movement) {
final boolean xZero = movement.x == 0.0; final boolean xZero = movement.x == 0.0;
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index 8ea534e6f49b787f5445093203f41410668e42bd..f7807b56bf935e1686ac893c0752e92e1115ffbe 100644 index af7dd04ecbf9e8b35357da421fb156aee61261b5..0344ba2a6d063a4ee5d6f9a8985ae8ca8c5816ce 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -124,6 +124,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -124,6 +124,12 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
@@ -161,14 +161,14 @@ index 8ea534e6f49b787f5445093203f41410668e42bd..f7807b56bf935e1686ac893c0752e92e
+ // Sakura start - optimise cannon entity movement + // Sakura start - optimise cannon entity movement
+ @Override + @Override
+ protected final Vec3 collide(final Vec3 movement) { + protected final Vec3 collide(final Vec3 movement) {
+ return this.sakura_collide(movement); + return this.sakura$collide(movement);
+ } + }
+ // Sakura end - optimise cannon entity movement + // Sakura end - optimise cannon entity movement
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) { public FallingBlockEntity(EntityType<? extends FallingBlockEntity> entityType, Level level) {
super(entityType, level); super(entityType, level);
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index 45a528169a57ecc287ae4f527d1d98b597a48f04..e476d500df5e197f87863d9fdb61065af68778dd 100644 index b349149592b09512b573911e95fd13915ba698cd..05003798585d98406cd1affb89403b9f955bacdc 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -82,6 +82,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -82,6 +82,12 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
@@ -178,7 +178,7 @@ index 45a528169a57ecc287ae4f527d1d98b597a48f04..e476d500df5e197f87863d9fdb61065a
+ // Sakura start - optimise cannon entity movement + // Sakura start - optimise cannon entity movement
+ @Override + @Override
+ protected final net.minecraft.world.phys.Vec3 collide(final net.minecraft.world.phys.Vec3 movement) { + protected final net.minecraft.world.phys.Vec3 collide(final net.minecraft.world.phys.Vec3 movement) {
+ return this.sakura_collide(movement); + return this.sakura$collide(movement);
+ } + }
+ // Sakura end - optimise cannon entity movement + // Sakura end - optimise cannon entity movement

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Add maxSearch to getEntities
diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
index bd2055bc89c5672b514f1f7b1ad320a2fba7cbe2..7678696aa2fa74358a374a501a6b7f76f4805945 100644 index 8df264c86ab14f4e7aa9918a3341ef35ffaa5290..9d90db0c55df85ac26c91b42fb9e72baad940e8f 100644
--- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
+++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java
@@ -336,7 +336,14 @@ public final class ChunkEntitySlices { @@ -336,7 +336,14 @@ public final class ChunkEntitySlices {
@@ -83,10 +83,10 @@ index 2d24d03bbdb5ee0d862cbfff2219f58afffafe12..1bf06038d51efcc103fad23670686c30
} }
} }
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index c24f09cf9959310353bd0fc5a5ff7498c6ea47a0..ca5e2ec53590b731aedf33dfd69e728992f52b91 100644 index e807aafed0295d8db7ba0782bb1e462561e9e1ec..af39222e08bc7957ac40ea9fd6aae517e7cee45a 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -1772,10 +1772,18 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -1728,10 +1728,18 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE); this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE);
} }
@@ -106,7 +106,7 @@ index c24f09cf9959310353bd0fc5a5ff7498c6ea47a0..ca5e2ec53590b731aedf33dfd69e7289
Profiler.get().incrementCounter("getEntities"); Profiler.get().incrementCounter("getEntities");
if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) { if (entityTypeTest instanceof net.minecraft.world.entity.EntityType<T> byType) {
@@ -1792,7 +1800,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -1748,7 +1756,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
if (entityTypeTest == null) { if (entityTypeTest == null) {
if (maxCount != Integer.MAX_VALUE) { if (maxCount != Integer.MAX_VALUE) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Use maxEntityCollision limit for entity retrieval
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
index 6a28431c6a586adb6cd3e6d38e419fbaf8cafff7..5d4e0efabd61e848db8e0e309cdfd7adaa38b0ce 100644 index 987e73ec724a435231bccc449ce77ad021aa0903..849b012b87d25bdc4bcbe7edf5a5a6be2de1d35d 100644
--- a/net/minecraft/world/entity/LivingEntity.java --- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java
@@ -3752,7 +3752,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @@ -3784,7 +3784,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin
return; return;
} }
// Paper end - don't run getEntities if we're not going to use its result // Paper end - don't run getEntities if we're not going to use its result

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Explosion Durable Blocks
diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java
index 6db566adf2d0df1d26221eda04aa01738df6d3d2..23c135a6355e920535734e946e5bd4d06f7f33b7 100644 index dceb2b683064bbf4286c3fe71e0fd0c5a644cb07..40b76310d311a8d4cbe028d575f9220f55e70da2 100644
--- a/net/minecraft/world/item/BlockItem.java --- a/net/minecraft/world/item/BlockItem.java
+++ b/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java
@@ -38,8 +38,30 @@ public class BlockItem extends Item { @@ -37,8 +37,30 @@ public class BlockItem extends Item {
this.block = block; this.block = block;
} }
@@ -40,10 +40,10 @@ index 6db566adf2d0df1d26221eda04aa01738df6d3d2..23c135a6355e920535734e946e5bd4d0
return !interactionResult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE) return !interactionResult.consumesAction() && context.getItemInHand().has(DataComponents.CONSUMABLE)
? super.use(context.getLevel(), context.getPlayer(), context.getHand()) ? super.use(context.getLevel(), context.getPlayer(), context.getHand())
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index a99273ac64a223cc0a728137abca9331e79a546b..f41caed876beff43778e6138ac444f6e2608883d 100644 index af39222e08bc7957ac40ea9fd6aae517e7cee45a..1da42c11174bb7eae9a827a17a57d5e7f1d80f09 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -830,6 +830,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -835,6 +835,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Sakura end - track block changes and tick scheduler // Sakura end - track block changes and tick scheduler
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(this); // Sakura - optimise explosion density cache public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(this); // Sakura - optimise explosion density cache
@@ -52,10 +52,10 @@ index a99273ac64a223cc0a728137abca9331e79a546b..f41caed876beff43778e6138ac444f6e
protected Level( protected Level(
WritableLevelData levelData, WritableLevelData levelData,
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 88192b561c2a071f583d16d1de926917108a8f45..d12473581f5285aff5867e8bebfe34ccbdb1285f 100644 index 0f95ffa2551289cb74d0210673b942ca90be74d3..976ebf4c62d1cc96f2e147c2240a5886d6b022ed 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -131,7 +131,7 @@ public class ServerExplosion implements Explosion { @@ -133,7 +133,7 @@ public class ServerExplosion implements Explosion {
BlockState blockState = ((ca.spottedleaf.moonrise.patches.getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z); BlockState blockState = ((ca.spottedleaf.moonrise.patches.getblock.GetBlockChunk)chunk).moonrise$getBlock(x, y, z);
FluidState fluidState = blockState.getFluidState(); FluidState fluidState = blockState.getFluidState();
@@ -64,8 +64,8 @@ index 88192b561c2a071f583d16d1de926917108a8f45..d12473581f5285aff5867e8bebfe34cc
ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache( ret = new ca.spottedleaf.moonrise.patches.collisions.ExplosionBlockCache(
key, pos, blockState, fluidState, key, pos, blockState, fluidState,
@@ -357,6 +357,20 @@ public class ServerExplosion implements Explosion { @@ -359,6 +359,20 @@ public class ServerExplosion implements Explosion {
// Paper end - collision optimisations }
} }
// Sakura end - specialised explosions // Sakura end - specialised explosions
+ // Sakura start - explosion durable blocks + // Sakura start - explosion durable blocks
@@ -85,7 +85,7 @@ index 88192b561c2a071f583d16d1de926917108a8f45..d12473581f5285aff5867e8bebfe34cc
public ServerExplosion( public ServerExplosion(
ServerLevel level, ServerLevel level,
@@ -744,6 +758,14 @@ public class ServerExplosion implements Explosion { @@ -697,6 +711,14 @@ public class ServerExplosion implements Explosion {
} }
} }
// CraftBukkit end // CraftBukkit end

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Destroy Waterlogged Blocks
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index f8933e198a250f2184fb64bb987575b441ae8a32..f79e8f48a1f9a6964e1449c099df39076615dd88 100644 index 976ebf4c62d1cc96f2e147c2240a5886d6b022ed..16575c1222b28f7809db39d320848153e3b97044 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -366,6 +366,11 @@ public class ServerExplosion implements Explosion { @@ -368,6 +368,11 @@ public class ServerExplosion implements Explosion {
if (material != null && material.replaceBlastResistance() && pos.getY() > this.level.getMinY()) { if (material != null && material.replaceBlastResistance() && pos.getY() > this.level.getMinY()) {
return Optional.of(material.resistance()); return Optional.of(material.resistance());
} }

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Configure cannon physics
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 5cc6fe6984d59a94c037b2c327a5d72b5a2a740d..82689f3a737a80c1c3fd5c46aa271e70fc7b8866 100644 index 82dac4fbaf3572391dad61356ba5351b725194ff..0f0f1cb55bc167071e84ec998469001374995e8f 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1774,6 +1774,13 @@ public final class CollisionUtil { @@ -1774,6 +1774,13 @@ public final class CollisionUtil {
@@ -64,10 +64,10 @@ index 5cc6fe6984d59a94c037b2c327a5d72b5a2a740d..82689f3a737a80c1c3fd5c46aa271e70
if (xSmaller && z != 0.0) { if (xSmaller && z != 0.0) {
z = performAABBCollisionsZ(axisalignedbb, z, aabbs); z = performAABBCollisionsZ(axisalignedbb, z, aabbs);
diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java diff --git a/net/minecraft/core/dispenser/DispenseItemBehavior.java b/net/minecraft/core/dispenser/DispenseItemBehavior.java
index ca02c4c71a0a5a1a0ae8bbb40f0b1b7eac64e6fd..476b1330455cb30a582147bcf95d4f199ade3c6f 100644 index 703a75c7c6cd05a95afb630973250898dbc7223d..1531f0c275814e1346fef34dc06ea97643de382c 100644
--- a/net/minecraft/core/dispenser/DispenseItemBehavior.java --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java
+++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java
@@ -462,6 +462,14 @@ public interface DispenseItemBehavior { @@ -471,6 +471,14 @@ public interface DispenseItemBehavior {
} }
} }
@@ -83,18 +83,10 @@ index ca02c4c71a0a5a1a0ae8bbb40f0b1b7eac64e6fd..476b1330455cb30a582147bcf95d4f19
// CraftBukkit end // CraftBukkit end
serverLevel.addFreshEntity(primedTnt); serverLevel.addFreshEntity(primedTnt);
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb913990a820838 100644 index 0c20de0f6af0385a7849cb9b0be86049784d59ae..87948a1f3ff9b9e5ac2de8e4eb033e31a6818a2e 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -2,7 +2,6 @@ package net.minecraft.world.entity; @@ -588,6 +588,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import com.google.common.collect.ImmutableList.Builder;
import com.mojang.logging.LogUtils;
import com.mojang.serialization.Codec;
@@ -586,6 +585,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
} }
} }
// Sakura end - merge cannon entities // Sakura end - merge cannon entities
@@ -108,7 +100,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
@@ -1110,7 +1116,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1116,7 +1123,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) { protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) {
@@ -117,9 +109,9 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
AABB boundingBox = this.getBoundingBox(); AABB boundingBox = this.getBoundingBox();
AABB aabb = new AABB(boundingBox.minX, boundingBox.minY - 1.0E-6, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ); AABB aabb = new AABB(boundingBox.minX, boundingBox.minY - 1.0E-6, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
Optional<BlockPos> optional = this.level.findSupportingBlock(this, aabb); Optional<BlockPos> optional = this.level.findSupportingBlock(this, aabb);
@@ -1160,7 +1166,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1170,7 +1177,10 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
if (this.noPhysics) { this.verticalCollisionBelow = false;
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); this.minorHorizontalCollision = false;
} else { } else {
- if (type == MoverType.PISTON) { - if (type == MoverType.PISTON) {
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
@@ -127,41 +119,50 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
+ if (type == MoverType.PISTON && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_11)) { + if (type == MoverType.PISTON && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_11)) {
+ // Sakura end - configure server mechanics + // Sakura end - configure server mechanics
// Paper start - EAR 2 // Paper start - EAR 2
this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); this.activatedTick = Math.max(this.activatedTick, net.minecraft.server.MinecraftServer.currentTick + 20);
this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); this.activatedImmunityTick = Math.max(this.activatedImmunityTick, net.minecraft.server.MinecraftServer.currentTick + 20);
@@ -1189,8 +1198,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1199,10 +1209,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
movement = this.maybeBackOffFromEdge(movement, type); movement = this.maybeBackOffFromEdge(movement, type);
Vec3 vec3 = this.collide(movement); Vec3 vec3 = this.collide(movement);
double d = vec3.lengthSqr(); double d = vec3.lengthSqr();
- if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) { - if (d > 1.0E-7 || movement.lengthSqr() - d < 1.0E-7) {
- if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement - if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock) { // Sakura - optimise cannon entity movement
- double min = Math.min(vec3.length(), 8.0);
- Vec3 vec31 = this.position().add(vec3.normalize().scale(min));
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
+ if (me.samsuik.sakura.mechanics.EntityBehaviour.canMoveEntity(d, movement, mechanicsTarget)) { + if (me.samsuik.sakura.mechanics.EntityBehaviour.canMoveEntity(d, movement, mechanicsTarget)) {
+ if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_18_2)) { // Sakura - optimise cannon entity movement + if (this.fallDistance != 0.0 && d >= 1.0 && !this.isFallingBlock && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_18_2)) { // Sakura - optimise cannon entity movement
+ final Vec3 vec31;
+ if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) {
+ double min = Math.min(Math.sqrt(d), 8.0);
+ vec31 = this.position().add(vec3.normalize().scale(min));
+ } else {
+ vec31 = this.position().add(vec3);
+ }
+ // Sakura end - configure server mechanics + // Sakura end - configure server mechanics
BlockHitResult blockHitResult = this.level() BlockHitResult blockHitResult = this.level()
.clip( .clip(new ClipContext(this.position(), vec31, ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
new ClipContext(this.position(), this.position().add(vec3), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this) if (blockHitResult.getType() != HitResult.Type.MISS) {
@@ -1201,9 +1212,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1211,9 +1228,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
Vec3 vec31 = this.position(); Vec3 vec32 = this.position();
- Vec3 vec32 = vec31.add(vec3); - Vec3 vec33 = vec32.add(vec3);
- this.addMovementThisTick(new Entity.Movement(vec31, vec32, true)); - this.addMovementThisTick(new Entity.Movement(vec32, vec33, movement));
- this.setPos(vec32); - this.setPos(vec33);
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
+ if (mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_6)) { + if (mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_6)) {
+ me.samsuik.sakura.mechanics.EntityBehaviour.changeEntityPosition(this, vec31, vec3, mechanicsTarget); + me.samsuik.sakura.mechanics.EntityBehaviour.changeEntityPosition(this, vec32, vec3, mechanicsTarget);
+ } else { + } else {
+ Vec3 vec32 = vec31.add(vec3); + Vec3 vec33 = vec32.add(vec3);
+ this.addMovementThisTick(new Entity.Movement(vec31, vec32, true)); + this.addMovementThisTick(new Entity.Movement(vec32, vec33, movement));
+ this.setPos(vec32); + this.setPos(vec33);
+ } + }
+ // Sakura end - configure server mechanics + // Sakura end - configure server mechanics
} }
profilerFiller.pop(); profilerFiller.pop();
@@ -1234,6 +1251,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1244,6 +1267,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} else { } else {
if (this.horizontalCollision) { if (this.horizontalCollision) {
Vec3 deltaMovement = this.getDeltaMovement(); Vec3 deltaMovement = this.getDeltaMovement();
@@ -173,7 +174,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
this.setDeltaMovement(flag ? 0.0 : deltaMovement.x, deltaMovement.y, flag1 ? 0.0 : deltaMovement.z); this.setDeltaMovement(flag ? 0.0 : deltaMovement.x, deltaMovement.y, flag1 ? 0.0 : deltaMovement.z);
} }
@@ -1568,7 +1590,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1585,7 +1613,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER); this.collectCollisions(bb, voxelList, bbList, ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER);
@@ -182,7 +183,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
} }
private Vec3 collideAxisScan(final Vec3 movement, AABB currBoundingBox, final List<VoxelShape> voxelList, final List<AABB> bbList) { private Vec3 collideAxisScan(final Vec3 movement, AABB currBoundingBox, final List<VoxelShape> voxelList, final List<AABB> bbList) {
@@ -1576,7 +1598,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1593,7 +1621,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
double y = movement.y; double y = movement.y;
double z = movement.z; double z = movement.z;
@@ -191,7 +192,7 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
if (y != 0.0) { if (y != 0.0) {
y = this.scanY(currBoundingBox, y, voxelList, bbList); y = this.scanY(currBoundingBox, y, voxelList, bbList);
@@ -1698,7 +1720,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1715,7 +1743,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), null // Sakura - load chunks on movement
); );
potentialCollisionsBB.addAll(entityAABBs); potentialCollisionsBB.addAll(entityAABBs);
@@ -200,11 +201,54 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
final boolean collidedX = collided.x != movement.x; final boolean collidedX = collided.x != movement.x;
final boolean collidedY = collided.y != movement.y; final boolean collidedY = collided.y != movement.y;
@@ -1843,11 +1865,22 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1838,25 +1866,37 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
private void checkInsideBlocks(List<Entity.Movement> movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) {
if (this.isAffectedByBlocks()) {
LongSet set = this.visitedBlocks;
+ final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget; // Sakura - configure server mechanics
for (Entity.Movement movement : movements) {
Vec3 vec3 = movement.from;
Vec3 vec31 = movement.to().subtract(movement.from());
int i = 16;
- if (movement.axisDependentOriginalMovement().isPresent() && vec31.lengthSqr() > 0.0) {
- for (Direction.Axis axis : Direction.axisStepOrder(movement.axisDependentOriginalMovement().get())) {
+ // Sakura start - configure server mechanics
+ final Optional<Vec3> axisDependentMovement = movement.axisDependentOriginalMovement();
+ if (axisDependentMovement.isPresent() && vec31.lengthSqr() > 0.0 && mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_5)) {
+ final Vec3 stepOrderVec = mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)
+ ? axisDependentMovement.get()
+ : vec31;
+
+ // The axis order here may differ from the order during movement in versions below 1.21.9
+ for (Direction.Axis axis : Direction.axisStepOrder(stepOrderVec)) {
double d = vec31.get(axis);
if (d != 0.0) {
Vec3 vec32 = vec3.relative(axis.getPositive(), d);
- i -= this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i);
+ final int stepsTaken = this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i);
+ if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) {
+ i -= stepsTaken;
+ }
vec3 = vec32;
}
}
- } else {
+ } else if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
i -= this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, 16);
}
- if (i <= 0) {
+ if (i <= 0 || mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
+ // Sakura end - configure server mechanics
this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1);
}
}
@@ -1866,7 +1906,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) { private int checkInsideBlocks(Vec3 from, Vec3 to, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet visited, int maxSteps) {
- AABB aabb = this.makeBoundingBox(vec31).deflate(1.0E-5F); - AABB aabb = this.makeBoundingBox(to).deflate(1.0E-5F);
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
+ final double margin; + final double margin;
+ if (this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { + if (this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
@@ -214,22 +258,25 @@ index eaa57560a20841a2b218ff2fd9059f82339a678c..098b5a8cfe1ce37f5c1ed51c2bb91399
+ } else { + } else {
+ margin = 0.001; + margin = 0.001;
+ } + }
+ AABB aabb = this.makeBoundingBox(vec31).deflate(margin); + AABB aabb = this.makeBoundingBox(to).deflate(margin);
+ // Sakura end - configure server mechanics + // Sakura end - configure server mechanics
BlockGetter.forEachBlockIntersectedBetween( boolean flag = this.level instanceof ServerLevel serverLevel
vec3, && serverLevel.getServer().debugSubscribers().hasAnySubscriberFor(DebugSubscriptions.ENTITY_BLOCK_INTERSECTIONS);
vec31, AtomicInteger atomicInteger = new AtomicInteger();
@@ -1874,6 +1924,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
from,
to,
aabb, aabb,
+ this.mechanicsTarget, // Sakura - configure server mechanics + this.mechanicsTarget, // Sakura - configure server mechanics
(pos, index) -> { (pos, index) -> {
if (!this.isAlive()) { if (!this.isAlive()) {
return false; return false;
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index f7807b56bf935e1686ac893c0752e92e1115ffbe..297310605e3ed4dbd3db40ff3cddb8eee6f3f508 100644 index 0344ba2a6d063a4ee5d6f9a8985ae8ca8c5816ce..02dc6c5965354047fc05ad3d3293c7f6277f50cd 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -130,6 +130,25 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -130,6 +130,25 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
return this.sakura_collide(movement); return this.sakura$collide(movement);
} }
// Sakura end - optimise cannon entity movement // Sakura end - optimise cannon entity movement
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
@@ -333,7 +380,7 @@ index f7807b56bf935e1686ac893c0752e92e1115ffbe..297310605e3ed4dbd3db40ff3cddb8ee
if (!this.cancelDrop) { if (!this.cancelDrop) {
boolean canBeReplaced = blockState.canBeReplaced( boolean canBeReplaced = blockState.canBeReplaced(
new DirectionalPlaceContext(this.level(), blockPos, Direction.DOWN, ItemStack.EMPTY, Direction.UP) new DirectionalPlaceContext(this.level(), blockPos, Direction.DOWN, ItemStack.EMPTY, Direction.UP)
@@ -350,7 +395,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -349,7 +394,14 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti
} }
} }
@@ -350,11 +397,11 @@ index f7807b56bf935e1686ac893c0752e92e1115ffbe..297310605e3ed4dbd3db40ff3cddb8ee
} }
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
index e476d500df5e197f87863d9fdb61065af68778dd..135e1174115a7ed90245be47bd998833ddbe7d68 100644 index 05003798585d98406cd1affb89403b9f955bacdc..cb2241e99f4b3bee099ff1eea566beb9bd80c57d 100644
--- a/net/minecraft/world/entity/item/PrimedTnt.java --- a/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java
@@ -88,6 +88,23 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak @@ -88,6 +88,23 @@ public class PrimedTnt extends Entity implements TraceableEntity, me.samsuik.sak
return this.sakura_collide(movement); return this.sakura$collide(movement);
} }
// Sakura end - optimise cannon entity movement // Sakura end - optimise cannon entity movement
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
@@ -458,10 +505,19 @@ index e476d500df5e197f87863d9fdb61065af68778dd..135e1174115a7ed90245be47bd998833
// Paper end - Option to prevent TNT from moving in water // Paper end - Option to prevent TNT from moving in water
} }
diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java
index 2146efa860d8323a88f3ad365c0cdb66de42154a..b6ddb1ad889a115daeba64321d38b236033f62ff 100644 index 41c036324499d4e408030d1e19f78468b6b3d8a6..ba2e7efe147b26bea5d73eac1f4b2fe6ee4bd5c2 100644
--- a/net/minecraft/world/level/BlockGetter.java --- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java
@@ -213,8 +213,20 @@ public interface BlockGetter extends LevelHeightAccessor { @@ -8,6 +8,8 @@ import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+
+import me.samsuik.sakura.mechanics.MechanicVersion;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
@@ -212,8 +214,23 @@ public interface BlockGetter extends LevelHeightAccessor {
} }
static boolean forEachBlockIntersectedBetween(Vec3 from, Vec3 to, AABB boundingBox, BlockGetter.BlockStepVisitor visitor) { static boolean forEachBlockIntersectedBetween(Vec3 from, Vec3 to, AABB boundingBox, BlockGetter.BlockStepVisitor visitor) {
@@ -477,17 +533,20 @@ index 2146efa860d8323a88f3ad365c0cdb66de42154a..b6ddb1ad889a115daeba64321d38b236
+ final BlockGetter.BlockStepVisitor visitor + final BlockGetter.BlockStepVisitor visitor
+ ) { + ) {
Vec3 vec3 = to.subtract(from); Vec3 vec3 = to.subtract(from);
- if (vec3.lengthSqr() < Mth.square(0.99999F)) { - if (vec3.lengthSqr() < Mth.square(1.0E-5F)) {
+ if (vec3.lengthSqr() < Mth.square(0.99999F) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { + final double margin = mechanicsTarget != null && mechanicsTarget.atLeast(MechanicVersion.v1_21_9)
+ ? 1.0E-5F
+ : 0.99999F;
+ if (vec3.lengthSqr() < Mth.square(margin) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
+ // Sakura end - configure server mechanics + // Sakura end - configure server mechanics
for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) { for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) {
if (!visitor.visit(blockPos, 0)) { if (!visitor.visit(blockPos, 0)) {
return false; return false;
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5f9b58963 100644 index 16575c1222b28f7809db39d320848153e3b97044..a24e728476a64e49f2e5139fc103e19d5650d6e1 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -376,6 +376,17 @@ public class ServerExplosion implements Explosion { @@ -378,6 +378,17 @@ public class ServerExplosion implements Explosion {
return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
} }
// Sakura end - explosion durable blocks // Sakura end - explosion durable blocks
@@ -505,7 +564,7 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5
public ServerExplosion( public ServerExplosion(
ServerLevel level, ServerLevel level,
@@ -400,6 +411,7 @@ public class ServerExplosion implements Explosion { @@ -402,6 +413,7 @@ public class ServerExplosion implements Explosion {
this.yield = Double.isFinite(this.yield) ? this.yield : 0; // Paper - Don't allow infinite default yields this.yield = Double.isFinite(this.yield) ? this.yield : 0; // Paper - Don't allow infinite default yields
// Paper end - add yield // Paper end - add yield
this.consistentExplosionRadius = level.localConfig().at(this.center).consistentExplosionRadius; // Sakura - consistent explosion radius this.consistentExplosionRadius = level.localConfig().at(this.center).consistentExplosionRadius; // Sakura - consistent explosion radius
@@ -513,7 +572,7 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5
} }
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -429,8 +441,15 @@ public class ServerExplosion implements Explosion { @@ -431,8 +443,15 @@ public class ServerExplosion implements Explosion {
final float density = entity.level().densityCache.getKnownDensity(vec3); final float density = entity.level().densityCache.getKnownDensity(vec3);
if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK; hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK;
@@ -530,7 +589,7 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5
} }
if (hitResult == HitResult.Type.MISS) { if (hitResult == HitResult.Type.MISS) {
// Sakura end - replace density cache // Sakura end - replace density cache
@@ -528,6 +547,15 @@ public class ServerExplosion implements Explosion { @@ -530,6 +549,15 @@ public class ServerExplosion implements Explosion {
} }
if (cachedBlock.outOfWorld) { if (cachedBlock.outOfWorld) {
@@ -546,20 +605,36 @@ index e6ca200bf17e097f65204d7cead78306573e4782..41a9da18ec229f9e489de2ac3af9d9e5
break; break;
} }
final BlockState iblockdata = cachedBlock.blockState; final BlockState iblockdata = cachedBlock.blockState;
@@ -630,6 +658,12 @@ public class ServerExplosion implements Explosion { @@ -594,7 +622,27 @@ public class ServerExplosion implements Explosion {
double d2 = (entity instanceof PrimedTnt ? entity.getY() : entity.getEyeY()) - this.center.y; double d = Math.sqrt(entity.distanceToSqr(this.center)) / f;
double d3 = entity.getZ() - this.center.z; if (!(d > 1.0)) {
double squareRoot = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3); Vec3 vec3 = entity instanceof PrimedTnt ? entity.position() : entity.getEyePosition();
- Vec3 vec31 = vec3.subtract(this.center).normalize();
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
+ final double dirX = vec3.x - this.center.x;
+ final double dirY = vec3.y - this.center.y;
+ final double dirZ = vec3.z - this.center.z;
+ double magnitude = Math.sqrt(dirX * dirX + dirY * dirY + dirZ * dirZ);
+
+ if (this.mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_17)) { + if (this.mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_17)) {
+ d = (float) d; + d = (float) d;
+ squareRoot = (float) squareRoot; + magnitude = (float) magnitude;
+ }
+
+ final Vec3 vec31;
+ if (magnitude < 1.0e-5f && this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) {
+ vec31 = Vec3.ZERO;
+ } else {
+ final double normalisedX = dirX / magnitude;
+ final double normalisedY = dirY / magnitude;
+ final double normalisedZ = dirZ / magnitude;
+ vec31 = new Vec3(normalisedX, normalisedY, normalisedZ);
+ } + }
+ // Sakura end - configure server mechanics + // Sakura end - configure server mechanics
if (squareRoot != 0.0) { boolean shouldDamageEntity = this.damageCalculator.shouldDamageEntity(this, entity);
d1 /= squareRoot; float knockbackMultiplier = this.damageCalculator.getKnockbackMultiplier(entity);
d2 /= squareRoot; float f1 = !shouldDamageEntity && knockbackMultiplier == 0.0F ? 0.0F : this.getBlockDensity(this.center, entity); // Paper - Optimize explosions
@@ -913,7 +947,7 @@ public class ServerExplosion implements Explosion { @@ -868,7 +916,7 @@ public class ServerExplosion implements Explosion {
// Sakura start - replace density cache // Sakura start - replace density cache
float blockDensity = this.level.densityCache.getBlockDensity(vec3d, entity); float blockDensity = this.level.densityCache.getBlockDensity(vec3d, entity);
if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) {
@@ -596,7 +671,7 @@ index 4fa238d1cd6b19f16c0d0a8a9a913e9e42debbed..96a02601636cdf7cf6e360fc933e5764
protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if (isFree(level.getBlockState(pos.below())) && pos.getY() >= level.getMinY()) { if (isFree(level.getBlockState(pos.below())) && pos.getY() >= level.getMinY()) {
diff --git a/net/minecraft/world/level/block/FenceGateBlock.java b/net/minecraft/world/level/block/FenceGateBlock.java diff --git a/net/minecraft/world/level/block/FenceGateBlock.java b/net/minecraft/world/level/block/FenceGateBlock.java
index a5e686b90e532e3b656fca411936499c2b2020c7..4e689171f7c3344442d7827e6d2aa1dea46a61a2 100644 index 0c6ae65fc58d63a0b80f3bc1ffa0c9a1bb33de83..f291dc3b3f3e3b8da221f42580ed26c4b8f569a7 100644
--- a/net/minecraft/world/level/block/FenceGateBlock.java --- a/net/minecraft/world/level/block/FenceGateBlock.java
+++ b/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java
@@ -210,8 +210,15 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { @@ -210,8 +210,15 @@ public class FenceGateBlock extends HorizontalDirectionalBlock {
@@ -618,7 +693,7 @@ index a5e686b90e532e3b656fca411936499c2b2020c7..4e689171f7c3344442d7827e6d2aa1de
level.playSound( level.playSound(
null, null,
diff --git a/net/minecraft/world/level/block/HoneyBlock.java b/net/minecraft/world/level/block/HoneyBlock.java diff --git a/net/minecraft/world/level/block/HoneyBlock.java b/net/minecraft/world/level/block/HoneyBlock.java
index a98c308c5febd458d6489174b94898cd4b9bae69..3b0afe1fdfa6f992903acf8fc56a4031d08083a1 100644 index c15cd4d68e3168d63dba10122a74abe9a884f80d..6da4f87a7ce49f3ad86ca456a9aba66e2a5d1439 100644
--- a/net/minecraft/world/level/block/HoneyBlock.java --- a/net/minecraft/world/level/block/HoneyBlock.java
+++ b/net/minecraft/world/level/block/HoneyBlock.java +++ b/net/minecraft/world/level/block/HoneyBlock.java
@@ -71,11 +71,19 @@ public class HoneyBlock extends HalfTransparentBlock { @@ -71,11 +71,19 @@ public class HoneyBlock extends HalfTransparentBlock {
@@ -703,10 +778,10 @@ index f9c305de60a323b450a26c9d7de50a824492cf5a..c4987294763a82f5f065f726d48fa61d
} }
diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java
index 4dbbfa34c085fd9777de5b4a6bf48dedfe8603b8..1bf1f20235ee2d1395c94648c3d5deedf3b31bab 100644 index 0b1ec05fcd799536c8d7393bb42dc4b2f46ca48b..5968a30d21367b882501bbb70029b9e0069cca9f 100644
--- a/net/minecraft/world/level/block/LiquidBlock.java --- a/net/minecraft/world/level/block/LiquidBlock.java
+++ b/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java
@@ -195,7 +195,14 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -199,7 +199,14 @@ public class LiquidBlock extends Block implements BucketPickup {
} }
// Sakura end - configure fluid ticking outside the world border // Sakura end - configure fluid ticking outside the world border
if (level.getFluidState(blockPos).is(FluidTags.WATER)) { if (level.getFluidState(blockPos).is(FluidTags.WATER)) {
@@ -723,7 +798,7 @@ index 4dbbfa34c085fd9777de5b4a6bf48dedfe8603b8..1bf1f20235ee2d1395c94648c3d5deed
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), 3)) { if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), 3)) {
this.fizz(level, pos); this.fizz(level, pos);
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index a9db955a90e0b44d3c85e39f2f7ae9ea4f68a316..9dbd97607866f8bd356044318ab670bcc794074f 100644 index 7390a21f7c6991d3fb62fda9e88bc9212159177b..497cc0156cbd87e591f1f50090fc5fe055b71916 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java --- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -542,7 +542,7 @@ public class RedStoneWireBlock extends Block { @@ -542,7 +542,7 @@ public class RedStoneWireBlock extends Block {
@@ -768,7 +843,7 @@ index 3b3047aa1198754e64913634f76fdc015c1fe07d..4e88020dc0036145281f86b7f5eaf462
} }
diff --git a/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/net/minecraft/world/level/block/piston/MovingPistonBlock.java diff --git a/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/net/minecraft/world/level/block/piston/MovingPistonBlock.java
index 05bbc2e59384702439548a988e128a85f1adbe82..2f7d86b4d50ce4a3da6c1c4d2006c173bde66d86 100644 index 16f14dffcbca21e0c6d369d557ab6c036523b8bd..f459cee5a4d0eafccc525c246964acc9272429f5 100644
--- a/net/minecraft/world/level/block/piston/MovingPistonBlock.java --- a/net/minecraft/world/level/block/piston/MovingPistonBlock.java
+++ b/net/minecraft/world/level/block/piston/MovingPistonBlock.java +++ b/net/minecraft/world/level/block/piston/MovingPistonBlock.java
@@ -100,6 +100,16 @@ public class MovingPistonBlock extends BaseEntityBlock { @@ -100,6 +100,16 @@ public class MovingPistonBlock extends BaseEntityBlock {
@@ -789,7 +864,7 @@ index 05bbc2e59384702439548a988e128a85f1adbe82..2f7d86b4d50ce4a3da6c1c4d2006c173
} }
diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index c372c9f828f52af0d31cc9d20c00359fdb2a610a..c890eb98a3f480e3f269ff56a81f280e7b7c100c 100644 index 384eb75c644489fecd78fff904612ebe1e3e1706..87bc3222c33a00a46c5fdff792ca11f8248a61cd 100644
--- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -122,6 +122,11 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -122,6 +122,11 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -805,7 +880,7 @@ index c372c9f828f52af0d31cc9d20c00359fdb2a610a..c890eb98a3f480e3f269ff56a81f280e
} }
} }
diff --git a/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/net/minecraft/world/level/block/piston/PistonHeadBlock.java diff --git a/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/net/minecraft/world/level/block/piston/PistonHeadBlock.java
index 6c789e56f21f01252c21786cfeb48d88485b5636..b325c24be64a3484d1084abc515599e77b535bed 100644 index 72e39ceeca8d684569c4250263b41034362f8abd..0f723f8eb814931f949b1a467b79266e9a6e7f9e 100644
--- a/net/minecraft/world/level/block/piston/PistonHeadBlock.java --- a/net/minecraft/world/level/block/piston/PistonHeadBlock.java
+++ b/net/minecraft/world/level/block/piston/PistonHeadBlock.java +++ b/net/minecraft/world/level/block/piston/PistonHeadBlock.java
@@ -3,6 +3,8 @@ package net.minecraft.world.level.block.piston; @@ -3,6 +3,8 @@ package net.minecraft.world.level.block.piston;
@@ -841,7 +916,7 @@ index 6c789e56f21f01252c21786cfeb48d88485b5636..b325c24be64a3484d1084abc515599e7
} }
diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index b5a17b441f046a8f2efd1b776a4620b55d99a854..dd20beab7f2ae2c804e00f822dfd6cc01aa635e1 100644 index 4c4dbd7ade2b8836064242bb43eeb871cac023ce..c1afb74f19ad627b02bed2e3ffec67b877625c9f 100644
--- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -64,6 +64,163 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -64,6 +64,163 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -1041,7 +1116,7 @@ index b5a17b441f046a8f2efd1b776a4620b55d99a854..dd20beab7f2ae2c804e00f822dfd6cc0
blockEntity.lastTicked = level.getGameTime(); blockEntity.lastTicked = level.getGameTime();
blockEntity.progressO = blockEntity.progress; blockEntity.progressO = blockEntity.progress;
if (blockEntity.progressO >= 1.0F) { if (blockEntity.progressO >= 1.0F) {
if (level.isClientSide && blockEntity.deathTicks < 5) { if (level.isClientSide() && blockEntity.deathTicks < 5) {
blockEntity.deathTicks++; blockEntity.deathTicks++;
} else { } else {
+ // Sakura start - configure server mechanics + // Sakura start - configure server mechanics
@@ -1081,10 +1156,10 @@ index b5a17b441f046a8f2efd1b776a4620b55d99a854..dd20beab7f2ae2c804e00f822dfd6cc0
} }
diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java
index 86401ba95530d10ee505d124dcbaaad6e0b800e9..1166ecc7e938341a65cbabb592fc998593afe835 100644 index c8e427907c17ae6ac6c4dbe6abe74955c8030ead..f7209a487a48e434fde91daa39466de16ead03f2 100644
--- a/net/minecraft/world/level/material/LavaFluid.java --- a/net/minecraft/world/level/material/LavaFluid.java
+++ b/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java
@@ -184,6 +184,11 @@ public abstract class LavaFluid extends FlowingFluid { @@ -185,6 +185,11 @@ public abstract class LavaFluid extends FlowingFluid {
@Override @Override
public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) { public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Allow explosions to destroy lava
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index e79de0fc3102c107d2c49e1b084b65d5c667e6e3..3e4e09b886dea6642dbe86c52c5a475baad11734 100644 index a24e728476a64e49f2e5139fc103e19d5650d6e1..8317c1d8ede33a1de115c5597a439f30284c8b86 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -371,6 +371,11 @@ public class ServerExplosion implements Explosion { @@ -373,6 +373,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(ZERO_RESISTANCE); return Optional.of(ZERO_RESISTANCE);
} }
// Sakura end - destroy water logged blocks // Sakura end - destroy water logged blocks
@@ -21,10 +21,10 @@ index e79de0fc3102c107d2c49e1b084b65d5c667e6e3..3e4e09b886dea6642dbe86c52c5a475b
return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState);
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index 834e27ef2f7b342b074ff9e1e390e02f3ca1c399..fed11ed5ab97826915710b66395d1bdc926935b0 100644 index dff1c4fa389d5168bd9ec1aff4c7e4bc63c4110e..7ee94845b69139f7c419b9d6ee24ba1db0e69975 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java --- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -201,7 +201,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -200,7 +200,7 @@ public abstract class BlockBehaviour implements FeatureElement {
state.getDrops(builder).forEach(stack -> dropConsumer.accept(stack, pos)); state.getDrops(builder).forEach(stack -> dropConsumer.accept(stack, pos));
} }

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Collide with non-solid blocks
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 96009170f6ec0febc577867be3ee77433471c919..17940de16399033575c2c8031cdf1092f7b39ea2 100644 index 0f0f1cb55bc167071e84ec998469001374995e8f..54d561e1b4069df7115457accb0763fa7586dddc 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1905,6 +1905,7 @@ public final class CollisionUtil { @@ -1905,6 +1905,7 @@ public final class CollisionUtil {
@@ -46,10 +46,10 @@ index 96009170f6ec0febc577867be3ee77433471c919..17940de16399033575c2c8031cdf1092
blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape); blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
} }
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 098b5a8cfe1ce37f5c1ed51c2bb913990a820838..2107fb073fc6bee12a80652c08cdc82e2fe495f8 100644 index 87948a1f3ff9b9e5ac2de8e4eb033e31a6818a2e..6d1edbfd851737d19ce0a3ffa4914c6beecaa440 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -546,6 +546,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -549,6 +549,14 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET; flags |= ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
} }

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Reduce entity tracker player updates
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
index e164d7fbda422dbcffd753c3373b1c08fa3b5d68..98512bdd9cae7f4070587386382c0615074b122d 100644 index f9dfbf11a39573e839153fd5d72bcf9019540359..747885dd0e8aaefecf600ebef33bb2e136f65290 100644
--- a/net/minecraft/server/level/ChunkMap.java --- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java
@@ -1015,7 +1015,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1023,7 +1023,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
if (tracker == null) { if (tracker == null) {
continue; continue;
} }
@@ -21,7 +21,7 @@ index e164d7fbda422dbcffd753c3373b1c08fa3b5d68..98512bdd9cae7f4070587386382c0615
if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$hasPlayers() if (((ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerTrackedEntity)tracker).moonrise$hasPlayers()
|| ((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)entity).moonrise$getChunkStatus().isOrAfter(FullChunkStatus.ENTITY_TICKING)) { || ((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)entity).moonrise$getChunkStatus().isOrAfter(FullChunkStatus.ENTITY_TICKING)) {
tracker.serverEntity.sendChanges(); tracker.serverEntity.sendChanges();
@@ -1259,12 +1263,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @@ -1296,12 +1300,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
return state != me.samsuik.sakura.player.visibility.VisibilityState.OFF; return state != me.samsuik.sakura.player.visibility.VisibilityState.OFF;
} }
// Sakura end - client visibility settings; entity visibility // Sakura end - client visibility settings; entity visibility
@@ -41,7 +41,7 @@ index e164d7fbda422dbcffd753c3373b1c08fa3b5d68..98512bdd9cae7f4070587386382c0615
+ // Sakura start - reduce entity tracker player updates + // Sakura start - reduce entity tracker player updates
public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) {
this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this, this.seenBy); // Paper
this.entity = entity; this.entity = entity;
this.range = range; this.range = range;
this.lastSectionPos = SectionPos.of(entity); this.lastSectionPos = SectionPos.of(entity);

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Legacy lava block formation
diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java
index 1bf1f20235ee2d1395c94648c3d5deedf3b31bab..7346bde5612d2d521390102fe8d7c82904b8df06 100644 index 5968a30d21367b882501bbb70029b9e0069cca9f..6fee4284d61afa39685bbcd2c6e72a41c5b1cc50 100644
--- a/net/minecraft/world/level/block/LiquidBlock.java --- a/net/minecraft/world/level/block/LiquidBlock.java
+++ b/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java
@@ -198,7 +198,14 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -202,7 +202,14 @@ public class LiquidBlock extends Block implements BucketPickup {
// Sakura start - configure server mechanics // Sakura start - configure server mechanics
final FluidState fluidState = state.getFluidState(); final FluidState fluidState = state.getFluidState();
final Block block = fluidState.isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; final Block block = fluidState.isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE;
@@ -25,10 +25,10 @@ index 1bf1f20235ee2d1395c94648c3d5deedf3b31bab..7346bde5612d2d521390102fe8d7c829
return true; return true;
} }
diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java
index 1166ecc7e938341a65cbabb592fc998593afe835..a0666fc38f4df2293b3888224c0b85652af803bf 100644 index f7209a487a48e434fde91daa39466de16ead03f2..5edf09ff8aca309882b635706354be1dcec12764 100644
--- a/net/minecraft/world/level/material/LavaFluid.java --- a/net/minecraft/world/level/material/LavaFluid.java
+++ b/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java
@@ -184,9 +184,16 @@ public abstract class LavaFluid extends FlowingFluid { @@ -185,9 +185,16 @@ public abstract class LavaFluid extends FlowingFluid {
@Override @Override
public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) { public boolean canBeReplacedWith(FluidState fluidState, BlockGetter blockReader, BlockPos pos, Fluid fluid, Direction direction) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add entity travel distance limits
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 573b1695abde0d89d5702a60a84919167ef4baab..29e1683741241f4f1e578041371a116170f2d1d2 100644 index 733c5d7419cae21300d40fb13979dd40ecdd6810..aca28d1e2530d239b0e2b55f75c6d0e398841ea1 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -1304,6 +1304,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -1336,6 +1336,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2 final boolean isActive = io.papermc.paper.entity.activation.ActivationRange.checkIfActive(entity); // Paper - EAR 2
if (isActive) { // Paper - EAR 2 if (isActive) { // Paper - EAR 2
entity.tick(); entity.tick();
@@ -21,10 +21,10 @@ index 573b1695abde0d89d5702a60a84919167ef4baab..29e1683741241f4f1e578041371a1161
} else {entity.inactiveTick();} // Paper - EAR 2 } else {entity.inactiveTick();} // Paper - EAR 2
profilerFiller.pop(); profilerFiller.pop();
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 528d45eb5ff968ef14c3ff74a0c3bdb58ab21b86..b39b2cd2f4b85535bea19752ca1ecd334531b86c 100644 index 6d1edbfd851737d19ce0a3ffa4914c6beecaa440..4ceffc9f043ef3c3063e8dc2b4cda753ad4d8059 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -600,6 +600,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -603,6 +603,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return this.mechanicsTarget; return this.mechanicsTarget;
} }
// Sakura end - configure server mechanics // Sakura end - configure server mechanics
@@ -43,7 +43,7 @@ index 528d45eb5ff968ef14c3ff74a0c3bdb58ab21b86..b39b2cd2f4b85535bea19752ca1ecd33
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
@@ -629,6 +641,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -632,6 +644,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
this.setPos(0.0, 0.0, 0.0); this.setPos(0.0, 0.0, 0.0);
this.eyeHeight = this.dimensions.eyeHeight(); this.eyeHeight = this.dimensions.eyeHeight();
this.despawnTime = level == null || type == EntityType.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit this.despawnTime = level == null || type == EntityType.PLAYER ? -1 : level.paperConfig().entities.spawning.despawnTime.getOrDefault(type, io.papermc.paper.configuration.type.number.IntOr.Disabled.DISABLED).or(-1); // Paper - entity despawn time limit

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Protect scaffolding from creepers
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 3e4e09b886dea6642dbe86c52c5a475baad11734..4b937ba2568a08d45541199964b3b46638f76785 100644 index 8317c1d8ede33a1de115c5597a439f30284c8b86..a185d44ef797663d5007c9084117ca6933ba46be 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -376,6 +376,11 @@ public class ServerExplosion implements Explosion { @@ -378,6 +378,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(ZERO_RESISTANCE); return Optional.of(ZERO_RESISTANCE);
} }
// Sakura end - allow explosions to destroy lava // Sakura end - allow explosions to destroy lava

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configurable left shooting and adjusting limits
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247d27957be 100644 index 4ceffc9f043ef3c3063e8dc2b4cda753ad4d8059..5a8fdf9af5b64d2e365151c178b2fbe4468f9a2a 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -612,6 +612,47 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -615,6 +615,47 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
return Math.max(x, z) >= this.travelDistanceLimit; return Math.max(x, z) >= this.travelDistanceLimit;
} }
// Sakura end - entity travel distance limits // Sakura end - entity travel distance limits
@@ -56,7 +56,7 @@ index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
@@ -1629,6 +1670,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1652,6 +1693,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
if (xSmaller && z != 0.0) { if (xSmaller && z != 0.0) {
@@ -64,7 +64,7 @@ index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247
z = this.scanZ(currBoundingBox, z, voxelList, bbList); z = this.scanZ(currBoundingBox, z, voxelList, bbList);
if (z != 0.0) { if (z != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z); currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetZ(currBoundingBox, z);
@@ -1636,6 +1678,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1659,6 +1701,11 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
if (x != 0.0) { if (x != 0.0) {
@@ -77,7 +77,7 @@ index b39b2cd2f4b85535bea19752ca1ecd334531b86c..0810ca0de7035bc913c63f8c26ccd247
if (x != 0.0) { if (x != 0.0) {
currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x); currBoundingBox = ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.offsetX(currBoundingBox, x);
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
index 297310605e3ed4dbd3db40ff3cddb8eee6f3f508..f21b9e47fc35e00b9d4d8664e4bf1b9a188878a4 100644 index 02dc6c5965354047fc05ad3d3293c7f6277f50cd..1dc2976daac6e0621a3cf573d7e1e673ba5934a3 100644
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java --- a/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -269,6 +269,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti @@ -269,6 +269,7 @@ public class FallingBlockEntity extends Entity implements me.samsuik.sakura.enti

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise hopper ticking
diff --git a/net/minecraft/world/CompoundContainer.java b/net/minecraft/world/CompoundContainer.java diff --git a/net/minecraft/world/CompoundContainer.java b/net/minecraft/world/CompoundContainer.java
index 0e9beb7f74e527a95bff064631e6d591f5775ce5..2408e385989f19ae9591495bd9ee5af411a1e412 100644 index 8eb989a811924fb6d2bc5150d7279d9d59bc3400..759ba8cc85101e8f22e8cb58cf74fe91d4226e54 100644
--- a/net/minecraft/world/CompoundContainer.java --- a/net/minecraft/world/CompoundContainer.java
+++ b/net/minecraft/world/CompoundContainer.java +++ b/net/minecraft/world/CompoundContainer.java
@@ -53,6 +53,15 @@ public class CompoundContainer implements Container { @@ -54,6 +54,15 @@ public class CompoundContainer implements Container {
return this.container1.getLocation(); // TODO: right? return this.container1.getLocation(); // TODO: right?
} }
// CraftBukkit end // CraftBukkit end
@@ -25,10 +25,10 @@ index 0e9beb7f74e527a95bff064631e6d591f5775ce5..2408e385989f19ae9591495bd9ee5af4
public CompoundContainer(Container container1, Container container2) { public CompoundContainer(Container container1, Container container2) {
this.container1 = container1; this.container1 = container1;
diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java
index b382665cc125b8b5c0938e5e55984e4bf91d37ff..7a62a5c61474b5b0ffc581c55d35d3327c7831b6 100644 index 8e6f097b4d17aaaf8eccc16e11ce2bd01ad63322..4baa578a2d277676647ca60487a104f8a09ad5c9 100644
--- a/net/minecraft/world/Container.java --- a/net/minecraft/world/Container.java
+++ b/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java
@@ -14,6 +14,12 @@ import net.minecraft.world.level.block.entity.BlockEntity; @@ -16,6 +16,12 @@ import net.minecraft.world.level.block.entity.BlockEntity;
public interface Container extends Clearable, Iterable<ItemStack> { public interface Container extends Clearable, Iterable<ItemStack> {
float DEFAULT_DISTANCE_BUFFER = 4.0F; float DEFAULT_DISTANCE_BUFFER = 4.0F;
@@ -42,10 +42,10 @@ index b382665cc125b8b5c0938e5e55984e4bf91d37ff..7a62a5c61474b5b0ffc581c55d35d332
boolean isEmpty(); boolean isEmpty();
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index d4b2f81aebc888e6fe041537b71ac52d8dc8b4e7..92b3a69b2f87f44cb0c797d5986d501a649f4fe4 100644 index 1da42c11174bb7eae9a827a17a57d5e7f1d80f09..7aa5ffc32835fab4a91db464d9112785475a67e9 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -1483,7 +1483,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -1434,7 +1434,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
// Spigot end // Spigot end
if (tickingBlockEntity.isRemoved()) { if (tickingBlockEntity.isRemoved()) {
toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
@@ -55,7 +55,7 @@ index d4b2f81aebc888e6fe041537b71ac52d8dc8b4e7..92b3a69b2f87f44cb0c797d5986d501a
// Paper start - rewrite chunk system // Paper start - rewrite chunk system
if ((++tickedEntities & 7) == 0) { if ((++tickedEntities & 7) == 0) {
diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java
index 46a27f60ba407dacdac190b5e292ab3f1db5a078..ec05bb86803d878867b46e437cc73a39f155b9fc 100644 index c6bec5967f7792ad3b65c0c69fdafd36194d8823..ad097818384adab7fe4d9e83e2295d20f531a5e3 100644
--- a/net/minecraft/world/level/block/HopperBlock.java --- a/net/minecraft/world/level/block/HopperBlock.java
+++ b/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java
@@ -121,6 +121,12 @@ public class HopperBlock extends BaseEntityBlock { @@ -121,6 +121,12 @@ public class HopperBlock extends BaseEntityBlock {
@@ -72,10 +72,10 @@ index 46a27f60ba407dacdac190b5e292ab3f1db5a078..ec05bb86803d878867b46e437cc73a39
} }
} }
diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java
index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4be6d5902 100644 index 39691f6ff8dc08c7d4ebff0612cb9777d809c6ed..037534185be3afd434f0a19f4a4e6de43e947ca0 100644
--- a/net/minecraft/world/level/block/entity/BlockEntity.java --- a/net/minecraft/world/level/block/entity/BlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java
@@ -50,6 +50,60 @@ public abstract class BlockEntity { @@ -52,6 +52,60 @@ public abstract class BlockEntity implements DebugValueSource {
private BlockState blockState; private BlockState blockState;
private DataComponentMap components = DataComponentMap.EMPTY; private DataComponentMap components = DataComponentMap.EMPTY;
@@ -136,7 +136,7 @@ index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4
public BlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState) { public BlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState blockState) {
this.type = type; this.type = type;
this.worldPosition = pos.immutable(); this.worldPosition = pos.immutable();
@@ -229,11 +283,22 @@ public abstract class BlockEntity { @@ -231,11 +285,22 @@ public abstract class BlockEntity implements DebugValueSource {
public void setChanged() { public void setChanged() {
if (this.level != null) { if (this.level != null) {
if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers
@@ -160,7 +160,7 @@ index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4
level.blockEntityChanged(pos); level.blockEntityChanged(pos);
if (!state.isAir()) { if (!state.isAir()) {
level.updateNeighbourForOutputSignal(pos, state.getBlock()); level.updateNeighbourForOutputSignal(pos, state.getBlock());
@@ -263,6 +328,7 @@ public abstract class BlockEntity { @@ -265,6 +330,7 @@ public abstract class BlockEntity implements DebugValueSource {
public void setRemoved() { public void setRemoved() {
this.remove = true; this.remove = true;
@@ -169,7 +169,7 @@ index 5986825d6a381eeb445dd424dd127864aa703163..72ed4c5b9f07be9d7149cd7f99622ec4
public void clearRemoved() { public void clearRemoved() {
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17e7ccd163 100644 index 28348e3881c3c8591053a01b193fb2a956f79726..c12dd06bf9e4cd2f9dc3ace5e1089283fce385fe 100644
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -28,7 +28,7 @@ import net.minecraft.world.level.storage.ValueInput; @@ -28,7 +28,7 @@ import net.minecraft.world.level.storage.ValueInput;
@@ -181,7 +181,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17
public static final int MOVE_ITEM_SPEED = 8; public static final int MOVE_ITEM_SPEED = 8;
public static final int HOPPER_CONTAINER_SIZE = 5; public static final int HOPPER_CONTAINER_SIZE = 5;
private static final int[][] CACHED_SLOTS = new int[54][]; private static final int[][] CACHED_SLOTS = new int[54][];
@@ -71,6 +71,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -72,6 +72,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
this.maxStack = size; this.maxStack = size;
} }
// CraftBukkit end // CraftBukkit end
@@ -240,7 +240,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17
public HopperBlockEntity(BlockPos pos, BlockState blockState) { public HopperBlockEntity(BlockPos pos, BlockState blockState) {
super(BlockEntityType.HOPPER, pos, blockState); super(BlockEntityType.HOPPER, pos, blockState);
@@ -200,6 +252,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -201,6 +253,12 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
setChanged(level, pos, state); setChanged(level, pos, state);
return true; return true;
} }
@@ -253,7 +253,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17
} }
return false; return false;
@@ -417,7 +475,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -418,7 +476,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
// Paper end - Perf: Optimize Hoppers // Paper end - Perf: Optimize Hoppers
private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) { private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) {
@@ -262,7 +262,7 @@ index 01ed25d1f895d94485b5fecd98476534cbb26930..6ccd350a5cbe87e5cf9e66c230aced17
if (attachedContainer == null) { if (attachedContainer == null) {
return false; return false;
} else { } else {
@@ -530,7 +588,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -531,7 +589,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
public static boolean suckInItems(Level level, Hopper hopper) { public static boolean suckInItems(Level level, Hopper hopper) {
BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ()); BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ());
BlockState blockState = level.getBlockState(blockPos); BlockState blockState = level.getBlockState(blockPos);
@@ -287,10 +287,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..a0d247aa883553708c4b921582324255
+ // Sakura end - optimise hopper ticking + // Sakura end - optimise hopper ticking
} }
diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java
index a39077ba4e1e40462ee9a96ce6f3871a5ecb85c7..6edccc2452c30a56ad393ba72ba2de487078f316 100644 index 4a274798077c4ee0a504a784449a1aef1d89d325..4e84ead78c91b3453f2549b010de4aa8691967ba 100644
--- a/net/minecraft/world/level/chunk/LevelChunk.java --- a/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java
@@ -987,6 +987,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -1022,6 +1022,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
return BlockEntityType.getKey(this.blockEntity.getType()).toString(); return BlockEntityType.getKey(this.blockEntity.getType()).toString();
} }
@@ -304,7 +304,7 @@ index a39077ba4e1e40462ee9a96ce6f3871a5ecb85c7..6edccc2452c30a56ad393ba72ba2de48
@Override @Override
public String toString() { public String toString() {
return "Level ticker for " + this.getType() + "@" + this.getPos(); return "Level ticker for " + this.getType() + "@" + this.getPos();
@@ -1035,6 +1042,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @@ -1070,6 +1077,13 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot
return this.ticker.getType(); return this.ticker.getType();
} }

View File

@@ -5,55 +5,63 @@ Subject: [PATCH] Optimise check inside blocks and traverse blocks
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
index 0810ca0de7035bc913c63f8c26ccd247d27957be..5c772c05908f59b0f3d8636492685c3b853bcb47 100644 index 5a8fdf9af5b64d2e365151c178b2fbe4468f9a2a..bc6e2cd985f28a79c843efe93e8b847a3adb7756 100644
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -1910,6 +1910,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1935,6 +1935,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
private void checkInsideBlocks(List<Entity.Movement> movements, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector) {
if (this.isAffectedByBlocks()) { if (this.isAffectedByBlocks()) {
LongSet set = this.visitedBlocks; LongSet set = this.visitedBlocks;
final me.samsuik.sakura.mechanics.MinecraftMechanicsTarget mechanicsTarget = this.mechanicsTarget; // Sakura - configure server mechanics
+ final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache = new net.minecraft.world.level.chunk.ChunkAccess[4]; // Sakura - optimise check inside blocks + final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache = new net.minecraft.world.level.chunk.ChunkAccess[4]; // Sakura - optimise check inside blocks
for (Entity.Movement movement : movements) { for (Entity.Movement movement : movements) {
Vec3 vec3 = movement.from; Vec3 vec3 = movement.from;
@@ -1919,12 +1920,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1952,7 +1953,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
double d = vec31.get(axis); double d = vec31.get(axis);
if (d != 0.0) { if (d != 0.0) {
Vec3 vec32 = vec3.relative(axis.getPositive(), d); Vec3 vec32 = vec3.relative(axis.getPositive(), d);
- this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set); - final int stepsTaken = this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i);
+ this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, chunkCache); // Sakura - optimise check inside blocks + final int stepsTaken = this.checkInsideBlocks(vec3, vec32, stepBasedCollector, set, i, chunkCache); // Sakura - optimise check inside blocks
vec3 = vec32; if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_9)) {
i -= stepsTaken;
}
@@ -1960,12 +1961,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
} }
} else { } else if (mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
- this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set); - i -= this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, 16);
+ this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, chunkCache); // Sakura - optimise check inside blocks + i -= this.checkInsideBlocks(movement.from(), movement.to(), stepBasedCollector, set, 16, chunkCache); // Sakura - optimise check inside blocks
}
if (i <= 0 || mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
// Sakura end - configure server mechanics
- this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1);
+ this.checkInsideBlocks(movement.to(), movement.to(), stepBasedCollector, set, 1, chunkCache); // Sakura - optimise check inside blocks
} }
} }
@@ -1932,8 +1933,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -1973,7 +1974,16 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
} }
} }
- private void checkInsideBlocks(Vec3 vec3, Vec3 vec31, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet set) { - private int checkInsideBlocks(Vec3 from, Vec3 to, InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, LongSet visited, int maxSteps) {
- // Sakura start - configure server mechanics
+ // Sakura start - optimise check inside blocks + // Sakura start - optimise check inside blocks
+ private void checkInsideBlocks( + private int checkInsideBlocks(
+ final Vec3 vec3, + final Vec3 from,
+ final Vec3 vec31, + final Vec3 to,
+ final InsideBlockEffectApplier.StepBasedCollector stepBasedCollector, + final InsideBlockEffectApplier.StepBasedCollector stepBasedCollector,
+ final LongSet set, + final LongSet visited,
+ final int maxSteps,
+ final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache + final net.minecraft.world.level.chunk.ChunkAccess[] chunkCache
+ ) { + ) {
+ // Sakura end - optimise check inside blocks + // Sakura end - optimise check inside blocks
+ // Sakura start - configure cannon physics // Sakura start - configure server mechanics
final double margin; final double margin;
if (this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { if (this.mechanicsTarget.atLeast(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
margin = 1.0e-5f; @@ -2000,7 +2010,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name
@@ -1953,7 +1962,20 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
if (!this.isAlive()) {
return false; return false;
} else { } else {
atomicInteger.set(index);
- BlockState blockState = this.level().getBlockState(pos); - BlockState blockState = this.level().getBlockState(pos);
+ // Sakura start - optimise check inside blocks + // Sakura start - optimise check inside blocks
+ final int chunkX = pos.getX() >> 4; + final int chunkX = pos.getX() >> 4;
@@ -70,22 +78,22 @@ index 0810ca0de7035bc913c63f8c26ccd247d27957be..5c772c05908f59b0f3d8636492685c3b
+ final BlockState blockState = chunk.getBlockState(pos); + final BlockState blockState = chunk.getBlockState(pos);
+ // Sakura end - optimise check inside blocks + // Sakura end - optimise check inside blocks
if (blockState.isAir()) { if (blockState.isAir()) {
this.debugBlockIntersection(pos, false, false); if (flag) {
return true; this.debugBlockIntersection((ServerLevel)this.level(), pos.immutable(), false, false);
diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java diff --git a/net/minecraft/world/level/BlockGetter.java b/net/minecraft/world/level/BlockGetter.java
index b6ddb1ad889a115daeba64321d38b236033f62ff..0d8dda4e914e7570d08f595fd20e5f45e366cd0d 100644 index ba2e7efe147b26bea5d73eac1f4b2fe6ee4bd5c2..b9ed6671edc98fe7a4bb30fdd25a6629e852da4f 100644
--- a/net/minecraft/world/level/BlockGetter.java --- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java
@@ -227,7 +227,7 @@ public interface BlockGetter extends LevelHeightAccessor { @@ -231,7 +231,7 @@ public interface BlockGetter extends LevelHeightAccessor {
Vec3 vec3 = to.subtract(from); : 0.99999F;
if (vec3.lengthSqr() < Mth.square(0.99999F) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) { if (vec3.lengthSqr() < Mth.square(margin) || mechanicsTarget != null && mechanicsTarget.before(me.samsuik.sakura.mechanics.MechanicVersion.v1_21_2)) {
// Sakura end - configure server mechanics // Sakura end - configure server mechanics
- for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) { - for (BlockPos blockPos : BlockPos.betweenClosed(boundingBox)) {
+ for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks + for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks
if (!visitor.visit(blockPos, 0)) { if (!visitor.visit(blockPos, 0)) {
return false; return false;
} }
@@ -235,6 +235,20 @@ public interface BlockGetter extends LevelHeightAccessor { @@ -239,9 +239,22 @@ public interface BlockGetter extends LevelHeightAccessor {
return true; return true;
} else { } else {
@@ -94,9 +102,8 @@ index b6ddb1ad889a115daeba64321d38b236033f62ff..0d8dda4e914e7570d08f595fd20e5f45
+ final boolean yZero = vec3.y() == 0.0; + final boolean yZero = vec3.y() == 0.0;
+ final boolean zZero = vec3.z() == 0.0; + final boolean zZero = vec3.z() == 0.0;
+ if (xZero && yZero || yZero && zZero || xZero && zZero) { + if (xZero && yZero || yZero && zZero || xZero && zZero) {
+ int blockIndex = 0;
+ for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.traverseArea(vec3, boundingBox)) { + for (final BlockPos blockPos : me.samsuik.sakura.utils.BlockPosIterator.traverseArea(vec3, boundingBox)) {
+ if (!visitor.visit(blockPos, blockIndex++)) { + if (!visitor.visit(blockPos, 0)) {
+ return false; + return false;
+ } + }
+ } + }
@@ -104,14 +111,18 @@ index b6ddb1ad889a115daeba64321d38b236033f62ff..0d8dda4e914e7570d08f595fd20e5f45
+ } + }
+ // Sakura end - optimise check inside blocks + // Sakura end - optimise check inside blocks
LongSet set = new LongOpenHashSet(); LongSet set = new LongOpenHashSet();
Vec3 minPosition = boundingBox.getMinPosition();
Vec3 vec31 = minPosition.subtract(vec3); - for (BlockPos blockPos1 : BlockPos.betweenCornersInDirection(boundingBox.move(vec3.scale(-1.0)), vec3)) {
@@ -242,7 +256,7 @@ public interface BlockGetter extends LevelHeightAccessor { + for (final BlockPos blockPos1 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox.move(vec3.scale(-1.0)))) { // Sakura - optimise check inside blocks
if (!visitor.visit(blockPos1, 0)) {
return false;
}
@@ -253,7 +266,7 @@ public interface BlockGetter extends LevelHeightAccessor {
if (i < 0) { if (i < 0) {
return false; return false;
} else { } else {
- for (BlockPos blockPos1 : BlockPos.betweenClosed(boundingBox)) { - for (BlockPos blockPos2 : BlockPos.betweenCornersInDirection(boundingBox, vec3)) {
+ for (final BlockPos blockPos1 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks + for (final BlockPos blockPos2 : me.samsuik.sakura.utils.BlockPosIterator.iterable(boundingBox)) { // Sakura - optimise check inside blocks
if (!set.contains(blockPos1.asLong()) && !visitor.visit(blockPos1, i + 1)) { if (set.add(blockPos2.asLong()) && !visitor.visit(blockPos2, i + 1)) {
return false; return false;
} }

View File

@@ -33,10 +33,10 @@ index ff747a1ecdf3c888bca0d69de4f85dcd810b6139..d90f6aa4557b5863eba6a206226f763c
} }
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
index 8a046ad7590bd358d416f4aa21a3c173d0931d2a..cdcc64da3481ea8ab4bc680fef775bc193e65c41 100644 index aca28d1e2530d239b0e2b55f75c6d0e398841ea1..ed50677f6b0445ac1c7246697c5f8d949bb59437 100644
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -694,6 +694,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @@ -711,6 +711,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings this.levelTickScheduler.repeatingTask(this.explosionPositions::clear, 0); // Sakura - client visibility settings
this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities this.levelTickScheduler.repeatingTask(this.mergeHandler::expire, 200); // Sakura - merge cannon entities
this.levelTickScheduler.repeatingTask(this.densityCache::expire, 0); // Sakura - explosion density cache this.levelTickScheduler.repeatingTask(this.densityCache::expire, 0); // Sakura - explosion density cache
@@ -45,10 +45,10 @@ index 8a046ad7590bd358d416f4aa21a3c173d0931d2a..cdcc64da3481ea8ab4bc680fef775bc1
// Paper start // Paper start
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 38baa1b6c846fd1f8cdbe9faf5e38300dade87e9..307542eff210e8824f651ca42e15b00c22df98fc 100644 index 7aa5ffc32835fab4a91db464d9112785475a67e9..6804055e9344eb2ea0b2dd6318231963376791c2 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -831,6 +831,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -836,6 +836,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities public final me.samsuik.sakura.entity.merge.EntityMergeHandler mergeHandler = new me.samsuik.sakura.entity.merge.EntityMergeHandler(); // Sakura - merge cannon entities
public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(this); // Sakura - optimise explosion density cache public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(this); // Sakura - optimise explosion density cache
public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks
@@ -57,7 +57,7 @@ index 38baa1b6c846fd1f8cdbe9faf5e38300dade87e9..307542eff210e8824f651ca42e15b00c
protected Level( protected Level(
WritableLevelData levelData, WritableLevelData levelData,
diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java
index 9dbd97607866f8bd356044318ab670bcc794074f..cc0abc586908631747ceb1c920e7c3cb3f7828dd 100644 index 497cc0156cbd87e591f1f50090fc5fe055b71916..b124e28cefac098d42fef55b699f4db398dfa1ba 100644
--- a/net/minecraft/world/level/block/RedStoneWireBlock.java --- a/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -306,6 +306,12 @@ public class RedStoneWireBlock extends Block { @@ -306,6 +306,12 @@ public class RedStoneWireBlock extends Block {
@@ -85,8 +85,8 @@ index 9dbd97607866f8bd356044318ab670bcc794074f..cc0abc586908631747ceb1c920e7c3cb
@Override @Override
protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) {
- if (!level.isClientSide) { - if (!level.isClientSide()) {
+ if (!level.isClientSide && !level.redstoneWireCache.isApplyingCache()) { // Sakura - cache vanilla and eigencraft wires; ignore redstone updates when applying from cache + if (!level.isClientSide() && !level.redstoneWireCache.isApplyingCache()) { // Sakura - cache vanilla and eigencraft wires; ignore redstone updates when applying from cache
// Paper start - optimize redstone (Alternate Current) // Paper start - optimize redstone (Alternate Current)
// Alternate Current handles breaking of redstone wires in the WireHandler. // Alternate Current handles breaking of redstone wires in the WireHandler.
if (level.localConfig().at(pos).paperRedstoneImplementation() == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura - redstone implementation api if (level.localConfig().at(pos).paperRedstoneImplementation() == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura - redstone implementation api
@@ -108,10 +108,10 @@ index 9dbd97607866f8bd356044318ab670bcc794074f..cc0abc586908631747ceb1c920e7c3cb
: powerValue; : powerValue;
} }
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251d54244ed 100644 index 7ee94845b69139f7c419b9d6ee24ba1db0e69975..d90389c515255df8273a69c652ba524135928482 100644
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java --- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -521,6 +521,13 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -524,6 +524,13 @@ public abstract class BlockBehaviour implements FeatureElement {
return this.constantCollisionShape; return this.constantCollisionShape;
} }
// Paper end - optimise collisions // Paper end - optimise collisions
@@ -125,7 +125,7 @@ index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251
protected BlockStateBase(Block owner, Reference2ObjectArrayMap<Property<?>, Comparable<?>> values, MapCodec<BlockState> propertiesCodec) { protected BlockStateBase(Block owner, Reference2ObjectArrayMap<Property<?>, Comparable<?>> values, MapCodec<BlockState> propertiesCodec) {
super(owner, values, propertiesCodec); super(owner, values, propertiesCodec);
@@ -635,6 +642,7 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -638,6 +645,7 @@ public abstract class BlockBehaviour implements FeatureElement {
} }
} }
// Paper end - optimise collisions // Paper end - optimise collisions
@@ -134,10 +134,10 @@ index fed11ed5ab97826915710b66395d1bdc926935b0..d6131c5ec6a4229291f7cecb9cec9251
public Block getBlock() { public Block getBlock() {
diff --git a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java diff --git a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
index 028eae2f9a459b60e92f3344091083aa93b54485..9fbf679b54088f89ac4ba727ccb645d645f01bd7 100644 index 879be2d05ef0fcfb8fab0c9f4e5bf66d7fce730b..c995827a4adad2279e98ede5e977aa2775349eec 100644
--- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java --- a/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
+++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java +++ b/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java
@@ -26,6 +26,13 @@ public class CollectingNeighborUpdater implements NeighborUpdater { @@ -29,6 +29,13 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
this.maxChainedNeighborUpdates = maxChainedNeighborUpdates; this.maxChainedNeighborUpdates = maxChainedNeighborUpdates;
} }
@@ -148,10 +148,10 @@ index 028eae2f9a459b60e92f3344091083aa93b54485..9fbf679b54088f89ac4ba727ccb645d6
+ } + }
+ // Sakura end - cache vanilla and eigencraft wires + // Sakura end - cache vanilla and eigencraft wires
+ +
@Override public void setDebugListener(@Nullable Consumer<BlockPos> debugListener) {
public void shapeUpdate(Direction direction, BlockState state, BlockPos pos, BlockPos neighborPos, int flags, int recursionLevel) { this.debugListener = debugListener;
this.addAndRun(pos, new CollectingNeighborUpdater.ShapeUpdate(direction, state, pos.immutable(), neighborPos.immutable(), flags, recursionLevel)); }
@@ -83,6 +90,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater { @@ -93,6 +100,7 @@ public class CollectingNeighborUpdater implements NeighborUpdater {
} }
} }
} finally { } finally {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configure breaking blocks outside the world border
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 963bcb84fc48ae81e07a7a19074af17d302ac890..73c8f19826ca39ba344c9590d4420e0a25103d4d 100644 index a185d44ef797663d5007c9084117ca6933ba46be..a252e8565b4b8e7f80477611b91f995706008753 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -517,6 +517,11 @@ public class ServerExplosion implements Explosion { @@ -519,6 +519,11 @@ public class ServerExplosion implements Explosion {
return ret; return ret;
} }
// Sakura end - optimise protected explosions // Sakura end - optimise protected explosions

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Optimise block counting for cannon entities
diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
index 17940de16399033575c2c8031cdf1092f7b39ea2..884ea2f49afc43c09af9c0b42d34f417bd14ec9e 100644 index 54d561e1b4069df7115457accb0763fa7586dddc..29f66ef8355a95b2869988187bf74536343f2ec8 100644
--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java --- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java
@@ -1941,6 +1941,7 @@ public final class CollisionUtil { @@ -1941,6 +1941,7 @@ public final class CollisionUtil {
@@ -42,10 +42,10 @@ index 17940de16399033575c2c8031cdf1092f7b39ea2..884ea2f49afc43c09af9c0b42d34f417
for (int currY = minYIterate; currY <= maxYIterate; ++currY) { for (int currY = minYIterate; currY <= maxYIterate; ++currY) {
final int blockY = currY | (currChunkY << 4); final int blockY = currY | (currChunkY << 4);
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 307542eff210e8824f651ca42e15b00c22df98fc..c3cc64d75338e5fd58db074284cb10b5f778f007 100644 index 6804055e9344eb2ea0b2dd6318231963376791c2..3a3d22835df907a85c38cd178c1db9d96554b8e0 100644
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -616,6 +616,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -621,6 +621,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
BlockPos selected = null; BlockPos selected = null;
double selectedDistance = Double.MAX_VALUE; double selectedDistance = Double.MAX_VALUE;
final Vec3 entityPos = entity.position(); final Vec3 entityPos = entity.position();
@@ -53,7 +53,7 @@ index 307542eff210e8824f651ca42e15b00c22df98fc..c3cc64d75338e5fd58db074284cb10b5
// special cases: // special cases:
if (minBlockY > maxBlockY) { if (minBlockY > maxBlockY) {
@@ -658,15 +659,19 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl @@ -663,15 +664,19 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
final boolean hasSpecial = ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks(); final boolean hasSpecial = ((ca.spottedleaf.moonrise.patches.block_counting.BlockCountingChunkSection)section).moonrise$hasSpecialCollidingBlocks();
final int sectionAdjust = !hasSpecial ? 1 : 0; final int sectionAdjust = !hasSpecial ? 1 : 0;
@@ -79,10 +79,10 @@ index 307542eff210e8824f651ca42e15b00c22df98fc..c3cc64d75338e5fd58db074284cb10b5
for (int currY = minYIterate; currY <= maxYIterate; ++currY) { for (int currY = minYIterate; currY <= maxYIterate; ++currY) {
final int blockY = currY | (currChunkY << 4); final int blockY = currY | (currChunkY << 4);
diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java
index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086be9e0dfa 100644 index 029d224557613b46f015785a5bbffe49a6f39ec6..a13771119488202fa0ad27121616f82553be968c 100644
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java --- a/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -47,6 +47,13 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ @@ -43,6 +43,13 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
return this.tickingBlocks; return this.tickingBlocks;
} }
// Paper end - block counting // Paper end - block counting
@@ -96,13 +96,13 @@ index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086
private LevelChunkSection(LevelChunkSection section) { private LevelChunkSection(LevelChunkSection section) {
this.nonEmptyBlockCount = section.nonEmptyBlockCount; this.nonEmptyBlockCount = section.nonEmptyBlockCount;
@@ -117,6 +124,18 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ @@ -113,6 +120,18 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
} }
} }
+ // Sakura start - optimise block counting for cannon entities + // Sakura start - optimise block counting for cannon entities
+ final boolean isMovingPistonOld = oldState.is(Blocks.MOVING_PISTON); + final boolean isMovingPistonOld = oldState.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON);
+ final boolean isMovingPistonNew = newState.is(Blocks.MOVING_PISTON); + final boolean isMovingPistonNew = newState.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON);
+ if (isMovingPistonOld != isMovingPistonNew) { + if (isMovingPistonOld != isMovingPistonNew) {
+ if (isMovingPistonOld) { + if (isMovingPistonOld) {
+ --this.movingPistonBlocks; + --this.movingPistonBlocks;
@@ -115,7 +115,7 @@ index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086
final boolean oldTicking = oldState.isRandomlyTicking(); final boolean oldTicking = oldState.isRandomlyTicking();
final boolean newTicking = newState.isRandomlyTicking(); final boolean newTicking = newState.isRandomlyTicking();
if (oldTicking != newTicking) { if (oldTicking != newTicking) {
@@ -192,6 +211,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ @@ -188,6 +207,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
this.tickingBlockCount = (short)0; this.tickingBlockCount = (short)0;
this.tickingFluidCount = (short)0; this.tickingFluidCount = (short)0;
this.specialCollidingBlocks = (short)0; this.specialCollidingBlocks = (short)0;
@@ -123,12 +123,12 @@ index 598e22c085e55be7a35ca6d73b8bc9f465bb6e33..ea193b58a9e49a1c33f0191285a58086
this.tickingBlocks.clear(); this.tickingBlocks.clear();
if (this.maybeHas((final BlockState state) -> !state.isAir())) { if (this.maybeHas((final BlockState state) -> !state.isAir())) {
@@ -220,6 +240,12 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ @@ -216,6 +236,12 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_
continue; continue;
} }
+ // Sakura start - optimise block counting for cannon entities + // Sakura start - optimise block counting for cannon entities
+ if (state.is(Blocks.MOVING_PISTON)) { + if (state.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON)) {
+ this.movingPistonBlocks += (short) paletteCount; + this.movingPistonBlocks += (short) paletteCount;
+ } + }
+ // Sakura end - optimise block counting for cannon entities + // Sakura end - optimise block counting for cannon entities

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Protect blocks above a configured Y-level from explosions
diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java
index 3b2498ab4f3da5aea22931532901a540ffb03e73..b5c50214830bd04d916850de6920a651b94e8463 100644 index a252e8565b4b8e7f80477611b91f995706008753..5d3cfeb3256d1173e1d16f05c501d99503bb6bde 100644
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -381,6 +381,11 @@ public class ServerExplosion implements Explosion { @@ -383,6 +383,11 @@ public class ServerExplosion implements Explosion {
return Optional.of(net.minecraft.world.level.block.Blocks.BARRIER.getExplosionResistance()); return Optional.of(net.minecraft.world.level.block.Blocks.BARRIER.getExplosionResistance());
} }
// Sakura end - protect scaffolding from creepers // Sakura end - protect scaffolding from creepers

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/MinecraftServer.java --- a/net/minecraft/server/MinecraftServer.java
+++ b/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java
@@ -300,6 +_,7 @@ @@ -307,6 +_,7 @@
public volatile boolean abnormalExit; // Paper - Improved watchdog support public volatile boolean abnormalExit; // Paper - Improved watchdog support
public volatile Thread shutdownThread; // Paper - Improved watchdog support public volatile Thread shutdownThread; // Paper - Improved watchdog support
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations; // Paper - add paper configuration files
@@ -8,7 +8,7 @@
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
@@ -319,6 +_,17 @@ @@ -326,6 +_,17 @@
thread.start(); thread.start();
return minecraftServer; return minecraftServer;
} }
@@ -26,10 +26,10 @@
// Paper start - rewrite chunk system // Paper start - rewrite chunk system
private volatile Throwable chunkSystemCrash; private volatile Throwable chunkSystemCrash;
@@ -471,6 +_,10 @@ @@ -476,6 +_,10 @@
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this)); Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
// CraftBukkit end // CraftBukkit end
this.paperConfigurations = services.paperConfigurations(); // Paper - add paper configuration files this.paperConfigurations = services.paper().configurations(); // Paper - add paper configuration files
+ // Sakura start - sakura configuration files + // Sakura start - sakura configuration files
+ final java.nio.file.Path sakuraConfigDirPath = ((java.io.File) options.valueOf("sakura-settings-directory")).toPath(); + final java.nio.file.Path sakuraConfigDirPath = ((java.io.File) options.valueOf("sakura-settings-directory")).toPath();
+ this.sakuraConfigurations = me.samsuik.sakura.configuration.SakuraConfigurations.setup(sakuraConfigDirPath); + this.sakuraConfigurations = me.samsuik.sakura.configuration.SakuraConfigurations.setup(sakuraConfigDirPath);
@@ -37,7 +37,7 @@
} }
private void readScoreboard(DimensionDataStorage dataStorage) { private void readScoreboard(DimensionDataStorage dataStorage) {
@@ -1223,6 +_,7 @@ @@ -1155,6 +_,7 @@
if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) { if (++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0) {
final long diff = currentTime - tickSection; final long diff = currentTime - tickSection;
final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP); final java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
@@ -45,7 +45,7 @@
tps1.add(currentTps, diff); tps1.add(currentTps, diff);
tps5.add(currentTps, diff); tps5.add(currentTps, diff);
tps15.add(currentTps, diff); tps15.add(currentTps, diff);
@@ -1260,6 +_,7 @@ @@ -1192,6 +_,7 @@
// Paper end - rewrite chunk system // Paper end - rewrite chunk system
this.tickFrame.end(); this.tickFrame.end();
profilerFiller.popPush("nextTickWait"); profilerFiller.popPush("nextTickWait");

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/dedicated/DedicatedServer.java --- a/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java
@@ -184,6 +_,11 @@ @@ -277,6 +_,11 @@
this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now
@@ -10,5 +10,5 @@
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this); + me.samsuik.sakura.command.SakuraCommands.registerCommands(this);
+ // Sakura end - sakura configuration files + // Sakura end - sakura configuration files
this.setPvpAllowed(properties.pvp); // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading
this.setFlightAllowed(properties.allowFlight); LOGGER.info("Default game type: {}", properties.gameMode.get());

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/server/level/ChunkMap.java --- a/net/minecraft/server/level/ChunkMap.java
+++ b/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java
@@ -134,7 +_,7 @@ @@ -134,7 +_,7 @@
public final AtomicInteger tickingGenerated = new AtomicInteger(); // Paper - public public final ChunkMap.DistanceManager distanceManager;
private final String storageName; private final String storageName;
private final PlayerMap playerMap = new PlayerMap(); private final PlayerMap playerMap = new PlayerMap();
- public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = new Int2ObjectOpenHashMap<>(); - public final Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = new Int2ObjectOpenHashMap<>();
@@ -9,7 +9,7 @@
private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap(); private final Long2ByteMap chunkTypeCache = new Long2ByteOpenHashMap();
// Paper - rewrite chunk system // Paper - rewrite chunk system
public int serverViewDistance; public int serverViewDistance;
@@ -1287,7 +_,10 @@ @@ -1330,7 +_,10 @@
double vec3_dz = player.getZ() - this.entity.getZ(); double vec3_dz = player.getZ() - this.entity.getZ();
// Paper end - remove allocation of Vec3D here // Paper end - remove allocation of Vec3D here
int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player); int playerViewDistance = ChunkMap.this.getPlayerViewDistance(player);

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/server/level/ServerLevel.java --- a/net/minecraft/server/level/ServerLevel.java
+++ b/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java
@@ -583,7 +_,7 @@ @@ -602,7 +_,7 @@
org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit
) { ) {
// CraftBukkit start // CraftBukkit start
- super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor - super(levelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(storageSource.levelDirectory.path(), levelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), levelData.getGameRules())), dispatcher); // Paper - create paper world configsAsync-Anti-Xray: Pass executor
+ super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), () -> server.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), server.registryAccess())), dispatcher); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor + super(levelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(storageSource.levelDirectory.path(), levelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), levelData.getGameRules())), () -> server.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(storageSource.levelDirectory.path(), levelData.getLevelName(), dimension.location(), server.registryAccess())), dispatcher); // Sakura - sakura configuration files // Paper - create paper world configs; Async-Anti-Xray: Pass executor
this.pvpMode = server.isPvpAllowed(); this.levelStorageAccess = storageSource;
this.levelStorageAccess = levelStorageAccess;
this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile());
this.levelLoadListener = new net.minecraft.server.level.progress.LoggingLevelLoadListener(false, this);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/server/level/ServerPlayer.java --- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java
@@ -296,7 +_,7 @@ @@ -307,7 +_,7 @@
// Paper start - Sync offhand slot in menus // Paper start - Sync offhand slot in menus
@Override @Override
public void sendOffHandSlotChange() { public void sendOffHandSlotChange() {
@@ -9,7 +9,7 @@
} }
// Paper end - Sync offhand slot in menus // Paper end - Sync offhand slot in menus
@@ -429,6 +_,7 @@ @@ -442,6 +_,7 @@
public boolean isRealPlayer; // Paper public boolean isRealPlayer; // Paper
public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent
public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java --- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java
@@ -532,6 +_,7 @@ @@ -534,6 +_,7 @@
} }
} }
// Paper end - optimise entity tracker // Paper end - optimise entity tracker
@@ -8,7 +8,7 @@
public Entity(EntityType<?> entityType, Level level) { public Entity(EntityType<?> entityType, Level level) {
this.type = entityType; this.type = entityType;
@@ -4227,7 +_,7 @@ @@ -4301,7 +_,7 @@
} }
public boolean isPushedByFluid() { public boolean isPushedByFluid() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/LivingEntity.java --- a/net/minecraft/world/entity/LivingEntity.java
+++ b/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java
@@ -287,6 +_,43 @@ @@ -288,6 +_,43 @@
public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API
public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; // Paper - Make shield blocking delay configurable public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; // Paper - Make shield blocking delay configurable
// CraftBukkit end // CraftBukkit end
@@ -44,7 +44,7 @@
protected LivingEntity(EntityType<? extends LivingEntity> entityType, Level level) { protected LivingEntity(EntityType<? extends LivingEntity> entityType, Level level) {
super(entityType, level); super(entityType, level);
@@ -1513,7 +_,7 @@ @@ -1521,7 +_,7 @@
} }
// Paper end - Check distance in entity interactions // Paper end - Check distance in entity interactions
@@ -53,7 +53,7 @@
if (!flag) { if (!flag) {
this.indicateDamage(d, d1); this.indicateDamage(d, d1);
} }
@@ -1615,6 +_,11 @@ @@ -1623,6 +_,11 @@
if (itemBlockingWith == null) { if (itemBlockingWith == null) {
return false; return false;
} else { } else {
@@ -65,7 +65,7 @@
BlocksAttacks blocksAttacks = itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS); BlocksAttacks blocksAttacks = itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS);
if (blocksAttacks != null && !blocksAttacks.bypassedBy().map(damageSource::is).orElse(false)) { if (blocksAttacks != null && !blocksAttacks.bypassedBy().map(damageSource::is).orElse(false)) {
if (damageSource.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.getPierceLevel() > 0) { if (damageSource.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.getPierceLevel() > 0) {
@@ -1641,6 +_,12 @@ @@ -1649,6 +_,12 @@
acos = (float) Math.PI; acos = (float) Math.PI;
} }
@@ -78,7 +78,7 @@
BlocksAttacks blocksAttacks = this.getItemBlockingWith().get(DataComponents.BLOCKS_ATTACKS); BlocksAttacks blocksAttacks = this.getItemBlockingWith().get(DataComponents.BLOCKS_ATTACKS);
return blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); return blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos);
} }
@@ -1708,7 +_,7 @@ @@ -1716,7 +_,7 @@
} }
protected void blockedByItem(LivingEntity entity) { protected void blockedByItem(LivingEntity entity) {
@@ -87,7 +87,7 @@
} }
private boolean checkTotemDeathProtection(DamageSource damageSource) { private boolean checkTotemDeathProtection(DamageSource damageSource) {
@@ -1865,6 +_,12 @@ @@ -1873,6 +_,12 @@
// Paper start // Paper start
if (this.dead) { // Paper if (this.dead) { // Paper
@@ -100,7 +100,7 @@
this.level().broadcastEntityEvent(this, (byte)3); this.level().broadcastEntityEvent(this, (byte)3);
this.setPose(Pose.DYING); this.setPose(Pose.DYING);
@@ -2038,7 +_,7 @@ @@ -2070,7 +_,7 @@
} }
public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events public void knockback(double strength, double x, double z, @Nullable Entity attacker, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause eventCause) { // Paper - knockback events
@@ -109,7 +109,7 @@
if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0 if (true || !(strength <= 0.0)) { // CraftBukkit - Call event even when force is 0
// this.hasImpulse = true; // CraftBukkit - Move down // this.hasImpulse = true; // CraftBukkit - Move down
Vec3 deltaMovement = this.getDeltaMovement(); Vec3 deltaMovement = this.getDeltaMovement();
@@ -2049,10 +_,18 @@ @@ -2081,10 +_,18 @@
} }
Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength);
@@ -129,7 +129,7 @@
deltaMovement.z / 2.0 - vec3.z deltaMovement.z / 2.0 - vec3.z
); );
Vec3 diff = finalVelocity.subtract(deltaMovement); Vec3 diff = finalVelocity.subtract(deltaMovement);
@@ -2197,8 +_,14 @@ @@ -2229,8 +_,14 @@
} }
} }
@@ -145,7 +145,7 @@
return 0; return 0;
} else { } else {
double d = this.calculateFallPower(fallDistance); double d = this.calculateFallPower(fallDistance);
@@ -2256,9 +_,21 @@ @@ -2288,9 +_,21 @@
protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) {
if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) {
// this.hurtArmor(damageSource, damageAmount); // CraftBukkit - actuallyHurt(DamageSource, float, EntityDamageEvent) for damage handling // this.hurtArmor(damageSource, damageAmount); // CraftBukkit - actuallyHurt(DamageSource, float, EntityDamageEvent) for damage handling
@@ -167,7 +167,7 @@
} }
return damageAmount; return damageAmount;
@@ -2438,6 +_,12 @@ @@ -2470,6 +_,12 @@
armorDamage += (float) event.getDamage(DamageModifier.BLOCKING); armorDamage += (float) event.getDamage(DamageModifier.BLOCKING);
armorDamage += (float) event.getDamage(DamageModifier.FREEZING); armorDamage += (float) event.getDamage(DamageModifier.FREEZING);
armorDamage += (float) event.getDamage(DamageModifier.HARD_HAT); armorDamage += (float) event.getDamage(DamageModifier.HARD_HAT);
@@ -180,7 +180,7 @@
this.hurtArmor(damageSource, armorDamage); this.hurtArmor(damageSource, armorDamage);
} }
@@ -3384,6 +_,11 @@ @@ -3416,6 +_,11 @@
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
EnchantmentHelper.runLocationChangedEffects(serverLevel, itemBySlot, this, equipmentSlot1); EnchantmentHelper.runLocationChangedEffects(serverLevel, itemBySlot, this, equipmentSlot1);
} }
@@ -192,7 +192,7 @@
} }
} }
@@ -3584,7 +_,7 @@ @@ -3616,7 +_,7 @@
} }
} }
// Paper end - Add EntityMoveEvent // Paper end - Add EntityMoveEvent
@@ -201,7 +201,7 @@
this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F);
} }
} }
@@ -4173,6 +_,13 @@ @@ -4200,6 +_,13 @@
if (!this.isUsingItem()) { if (!this.isUsingItem()) {
return null; return null;
} else { } else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Mob.java --- a/net/minecraft/world/entity/Mob.java
+++ b/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java
@@ -746,7 +_,7 @@ @@ -757,7 +_,7 @@
protected final void serverAiStep() { protected final void serverAiStep() {
this.noActionTime++; this.noActionTime++;
// Paper start - Allow nerfed mobs to jump and float // Paper start - Allow nerfed mobs to jump and float

View File

@@ -67,7 +67,7 @@
if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED)
&& this.level().getFluidState(blockPos).getType() == Fluids.WATER) { && this.level().getFluidState(blockPos).getType() == Fluids.WATER) {
this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
@@ -247,6 +_,10 @@ @@ -246,6 +_,10 @@
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
this.callOnBrokenAfterFall(block, blockPos); this.callOnBrokenAfterFall(block, blockPos);
this.spawnAtLocation(serverLevel, block); this.spawnAtLocation(serverLevel, block);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/item/ItemEntity.java --- a/net/minecraft/world/entity/item/ItemEntity.java
+++ b/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java
@@ -368,6 +_,13 @@ @@ -359,6 +_,13 @@
@Override @Override
public boolean ignoreExplosion(Explosion explosion) { public boolean ignoreExplosion(Explosion explosion) {

View File

@@ -3,7 +3,7 @@
@@ -75,7 +_,28 @@ @@ -75,7 +_,28 @@
this.yo = y; this.yo = y;
this.zo = z; this.zo = z;
this.owner = owner != null ? new EntityReference<>(owner) : null; this.owner = EntityReference.of(owner);
- } - }
+ // Sakura start - configure cannon mechanics + // Sakura start - configure cannon mechanics
+ switch (level.sakuraConfig().cannons.mechanics.tntSpread) { + switch (level.sakuraConfig().cannons.mechanics.tntSpread) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/Creeper.java --- a/net/minecraft/world/entity/monster/Creeper.java
+++ b/net/minecraft/world/entity/monster/Creeper.java +++ b/net/minecraft/world/entity/monster/Creeper.java
@@ -247,7 +_,12 @@ @@ -250,7 +_,12 @@
if (!event.isCancelled()) { if (!event.isCancelled()) {
// CraftBukkit end // CraftBukkit end
this.dead = true; this.dead = true;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/player/Player.java --- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java
@@ -219,6 +_,7 @@ @@ -180,6 +_,7 @@
private int currentImpulseContextResetGraceTime = 0; private int currentImpulseContextResetGraceTime = 0;
public boolean affectsSpawning = true; // Paper - Affects Spawning API public boolean affectsSpawning = true; // Paper - Affects Spawning API
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
@@ -8,17 +8,27 @@
// CraftBukkit start // CraftBukkit start
public boolean fauxSleeping; public boolean fauxSleeping;
@@ -229,6 +_,18 @@ @@ -190,6 +_,28 @@
return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity(); return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity();
} }
// CraftBukkit end // CraftBukkit end
+ // Sakura start - player poses shrink collision box
+ @Override
+ public net.minecraft.world.entity.EntityDimensions getDefaultDimensions(final Pose pose) {
+ final net.minecraft.world.entity.EntityDimensions dimensions = super.getDefaultDimensions(pose);
+ if (!this.level().sakuraConfig().players.posesShrinkCollisionBox && dimensions.height() != Avatar.STANDING_DIMENSIONS.height()) {
+ return STANDING_DIMENSIONS;
+ }
+ return dimensions;
+ }
+ // Sakura end - player poses shrink collision box
+ // Sakura start - prevent players glitching through blocks + // Sakura start - prevent players glitching through blocks
+ public final boolean isInsideAnyCollision() { + public final boolean isInsideAnyCollision() {
+ return this.insideAnyCollisionAt(this.level(), this.position()); + return this.insideAnyCollisionAt(this.level(), this.position());
+ } + }
+ +
+ public final boolean insideAnyCollisionAt(final Level level, final Vec3 position) { + public final boolean insideAnyCollisionAt(final Level level, final Vec3 position) {
+ final EntityDimensions entityDimensions = this.getDimensions(Pose.STANDING); + final net.minecraft.world.entity.EntityDimensions entityDimensions = this.getDimensions(Pose.STANDING);
+ final AABB entityBB = entityDimensions.makeBoundingBox(position); + final AABB entityBB = entityDimensions.makeBoundingBox(position);
+ return !level.noCollision(this, entityBB.deflate(1.0e-7)) + return !level.noCollision(this, entityBB.deflate(1.0e-7))
+ || !level.getWorldBorder().isWithinBounds(entityBB); + || !level.getWorldBorder().isWithinBounds(entityBB);
@@ -27,7 +37,7 @@
public Player(Level level, GameProfile gameProfile) { public Player(Level level, GameProfile gameProfile) {
super(EntityType.PLAYER, level); super(EntityType.PLAYER, level);
@@ -866,6 +_,10 @@ @@ -718,6 +_,10 @@
public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) { public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) {
if (super.isInvulnerableTo(level, damageSource)) { if (super.isInvulnerableTo(level, damageSource)) {
return true; return true;
@@ -38,7 +48,7 @@
} else if (damageSource.is(DamageTypeTags.IS_DROWNING)) { } else if (damageSource.is(DamageTypeTags.IS_DROWNING)) {
return !level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE); return !level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE);
} else if (damageSource.is(DamageTypeTags.IS_FALL)) { } else if (damageSource.is(DamageTypeTags.IS_FALL)) {
@@ -1182,13 +_,19 @@ @@ -1030,13 +_,19 @@
if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable.
{ {
// Paper end - PlayerAttackEntityEvent // Paper end - PlayerAttackEntityEvent
@@ -59,17 +69,17 @@
// this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt // this.resetAttackStrengthTicker(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) if (target.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE)
&& target instanceof Projectile projectile) { && target instanceof Projectile projectile) {
@@ -1206,7 +_,7 @@ @@ -1054,7 +_,7 @@
if (f > 0.0F || f1 > 0.0F) { if (f > 0.0F || f1 > 0.0F) {
boolean flag = attackStrengthScale > 0.9F; boolean flag = attackStrengthScale > 0.9F;
boolean flag1; boolean flag1;
- if (this.isSprinting() && flag) { - if (this.isSprinting() && flag) {
+ if (this.isSprinting() && (!this.level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura - configure entity knockback + if (this.isSprinting() && (!this.level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura - configure entity knockback
this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
flag1 = true; flag1 = true;
} else { } else {
@@ -1222,7 +_,7 @@ @@ -1070,7 +_,7 @@
&& !this.hasEffect(MobEffects.BLINDNESS) && !this.isMobilityRestricted()
&& !this.isPassenger() && !this.isPassenger()
&& target instanceof LivingEntity && target instanceof LivingEntity
- && !this.isSprinting(); - && !this.isSprinting();
@@ -77,7 +87,7 @@
flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits
if (flag2) { if (flag2) {
damageSource = damageSource.critical(); // Paper - critical damage API damageSource = damageSource.critical(); // Paper - critical damage API
@@ -1249,7 +_,21 @@ @@ -1097,7 +_,21 @@
if (flag4) { if (flag4) {
float f4 = this.getKnockback(target, damageSource) + (flag1 ? 1.0F : 0.0F); float f4 = this.getKnockback(target, damageSource) + (flag1 ? 1.0F : 0.0F);
if (f4 > 0.0F) { if (f4 > 0.0F) {
@@ -100,7 +110,7 @@
livingEntity1.knockback( livingEntity1.knockback(
f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0))
, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK // Paper - knockback events
@@ -1271,7 +_,7 @@ @@ -1119,7 +_,7 @@
// Paper end - Configurable sprint interruption on attack // Paper end - Configurable sprint interruption on attack
} }
@@ -109,7 +119,7 @@
float f5 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f; float f5 = 1.0F + (float)this.getAttributeValue(Attributes.SWEEPING_DAMAGE_RATIO) * f;
for (LivingEntity livingEntity2 : this.level() for (LivingEntity livingEntity2 : this.level()
@@ -1287,7 +_,7 @@ @@ -1135,7 +_,7 @@
if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) { if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) {
// Paper end - Only apply knockback if the event is not cancelled // Paper end - Only apply knockback if the event is not cancelled
livingEntity2.knockback( livingEntity2.knockback(
@@ -118,7 +128,7 @@
, this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events
); );
EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity2, damageSource); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity2, damageSource);
@@ -1375,7 +_,7 @@ @@ -1223,7 +_,7 @@
if (target instanceof LivingEntity) { if (target instanceof LivingEntity) {
float f7 = f3 - ((LivingEntity)target).getHealth(); float f7 = f3 - ((LivingEntity)target).getHealth();
this.awardStat(Stats.DAMAGE_DEALT, Math.round(f7 * 10.0F)); this.awardStat(Stats.DAMAGE_DEALT, Math.round(f7 * 10.0F));
@@ -127,7 +137,7 @@
int i = (int)(f7 * 0.5); int i = (int)(f7 * 0.5);
((ServerLevel)this.level()) ((ServerLevel)this.level())
.sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5), target.getZ(), i, 0.1, 0.0, 0.1, 0.2); .sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5), target.getZ(), i, 0.1, 0.0, 0.1, 0.2);
@@ -1764,6 +_,11 @@ @@ -1616,6 +_,11 @@
// Paper start - send while respecting visibility // Paper start - send while respecting visibility
private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) { private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) {
@@ -139,18 +149,3 @@
fromEntity.level().playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity itself fromEntity.level().playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity itself
if (fromEntity instanceof ServerPlayer serverPlayer) { if (fromEntity instanceof ServerPlayer serverPlayer) {
serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundSoundPacket(net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(soundEffect), soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong())); serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundSoundPacket(net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(soundEffect), soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong()));
@@ -2118,7 +_,13 @@
@Override
public EntityDimensions getDefaultDimensions(Pose pose) {
- return POSES.getOrDefault(pose, STANDING_DIMENSIONS);
+ // Sakura start - player poses shrink collision box
+ final EntityDimensions dimensions = POSES.getOrDefault(pose, STANDING_DIMENSIONS);
+ if (!this.level().sakuraConfig().players.posesShrinkCollisionBox && dimensions.height() == STANDING_DIMENSIONS.height()) {
+ return STANDING_DIMENSIONS;
+ }
+ return dimensions;
+ // Sakura end - player poses shrink collision box
}
@Override

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java --- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java
+++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java +++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java
@@ -39,6 +_,26 @@ @@ -39,6 +_,25 @@
super(entityType, x, y, z, level, item); super(entityType, x, y, z, level, item);
} }
@@ -18,9 +18,8 @@
+ } + }
+ +
+ @Override + @Override
+ protected boolean checkLeftOwner() { // may be overridden by plugins + protected final boolean breakInsideOwner() {
+ return this.level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5 + return this.level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5;
+ || super.checkLeftOwner();
+ } + }
+ // Sakura end - configure potion mechanics + // Sakura end - configure potion mechanics
+ +

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/projectile/FishingHook.java --- a/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java
@@ -298,6 +_,12 @@ @@ -302,6 +_,12 @@
if (!this.level().isClientSide) { if (!this.level().isClientSide()) {
this.setHookedEntity(result.getEntity()); this.setHookedEntity(result.getEntity());
} }
+ // Sakura start - configure entity knockback + // Sakura start - configure entity knockback
@@ -13,7 +13,7 @@
} }
@Override @Override
@@ -599,7 +_,7 @@ @@ -603,7 +_,7 @@
public void pullEntity(Entity entity) { public void pullEntity(Entity entity) {
Entity owner = this.getOwner(); Entity owner = this.getOwner();

View File

@@ -0,0 +1,24 @@
--- a/net/minecraft/world/entity/projectile/Projectile.java
+++ b/net/minecraft/world/entity/projectile/Projectile.java
@@ -51,6 +_,12 @@
super(entityType, level);
}
+ // Sakura start - configure potion mechanics
+ protected boolean breakInsideOwner() {
+ return false;
+ }
+ // Sakura end - configure potion mechanics
+
protected void setOwner(@Nullable EntityReference<Entity> owner) {
this.owner = owner;
this.refreshProjectileSource(false); // Paper
@@ -401,7 +_,7 @@
}
}
// Paper end - Cancel hit for vanished entities
- return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(target);
+ return owner == null || this.leftOwner || this.breakInsideOwner() || !owner.isPassengerOfSameVehicle(target); // Sakura - configure potion mechanics
}
}

View File

@@ -16,7 +16,7 @@
@Override @Override
public Item getDefaultItem() { public Item getDefaultItem() {
return Items.ENDER_PEARL; return Items.ENDER_PEARL;
@@ -118,6 +_,15 @@ @@ -103,6 +_,15 @@
if (owner != null && isAllowedToTeleportOwner(owner, serverLevel)) { if (owner != null && isAllowedToTeleportOwner(owner, serverLevel)) {
Vec3 vec3 = this.oldPosition(); Vec3 vec3 = this.oldPosition();
if (owner instanceof ServerPlayer serverPlayer) { if (owner instanceof ServerPlayer serverPlayer) {

View File

@@ -8,4 +8,4 @@
+ if (!level.noCollision(boat, boat.getBoundingBox()) || !level.getWorldBorder().isWithinBounds(boat.getBoundingBox())) { // Sakura - fix placing boats outside the world border + if (!level.noCollision(boat, boat.getBoundingBox()) || !level.getWorldBorder().isWithinBounds(boat.getBoundingBox())) { // Sakura - fix placing boats outside the world border
return InteractionResult.FAIL; return InteractionResult.FAIL;
} else { } else {
if (!level.isClientSide) { if (!level.isClientSide()) {

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java
@@ -147,7 +_,7 @@ @@ -147,7 +_,7 @@
// CraftBukkit end // CraftBukkit end
if (!flag) { if (!flag2) {
return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemstack, hand); // CraftBukkit return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemstack, hand); // CraftBukkit
- } else if (level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { - } else if (level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) {
+ } else if (!level.sakuraConfig().environment.allowWaterInTheNether && level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { // Sakura - allow water in the nether + } else if (!level.sakuraConfig().environment.allowWaterInTheNether && level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { // Sakura - allow water in the nether

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/Item.java --- a/net/minecraft/world/item/Item.java
+++ b/net/minecraft/world/item/Item.java +++ b/net/minecraft/world/item/Item.java
@@ -131,6 +_,11 @@ @@ -134,6 +_,11 @@
} }
} }

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/ItemStack.java --- a/net/minecraft/world/item/ItemStack.java
+++ b/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java
@@ -822,6 +_,15 @@ @@ -823,6 +_,15 @@
} }
} }

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/Items.java --- a/net/minecraft/world/item/Items.java
+++ b/net/minecraft/world/item/Items.java +++ b/net/minecraft/world/item/Items.java
@@ -1158,32 +_,32 @@ @@ -1207,7 +_,7 @@
public static final Item GOLD_INGOT = registerItem("gold_ingot", new Item.Properties().trimMaterial(TrimMaterials.GOLD)); public static final Item GOLD_INGOT = registerItem("gold_ingot", new Item.Properties().trimMaterial(TrimMaterials.GOLD));
public static final Item NETHERITE_INGOT = registerItem("netherite_ingot", new Item.Properties().fireResistant().trimMaterial(TrimMaterials.NETHERITE)); public static final Item NETHERITE_INGOT = registerItem("netherite_ingot", new Item.Properties().fireResistant().trimMaterial(TrimMaterials.NETHERITE));
public static final Item NETHERITE_SCRAP = registerItem("netherite_scrap", new Item.Properties().fireResistant()); public static final Item NETHERITE_SCRAP = registerItem("netherite_scrap", new Item.Properties().fireResistant());
@@ -9,7 +9,10 @@
public static final Item WOODEN_SHOVEL = registerItem("wooden_shovel", properties -> new ShovelItem(ToolMaterial.WOOD, 1.5F, -3.0F, properties)); public static final Item WOODEN_SHOVEL = registerItem("wooden_shovel", properties -> new ShovelItem(ToolMaterial.WOOD, 1.5F, -3.0F, properties));
public static final Item WOODEN_PICKAXE = registerItem("wooden_pickaxe", new Item.Properties().pickaxe(ToolMaterial.WOOD, 1.0F, -2.8F)); public static final Item WOODEN_PICKAXE = registerItem("wooden_pickaxe", new Item.Properties().pickaxe(ToolMaterial.WOOD, 1.0F, -2.8F));
public static final Item WOODEN_AXE = registerItem("wooden_axe", properties -> new AxeItem(ToolMaterial.WOOD, 6.0F, -3.2F, properties)); public static final Item WOODEN_AXE = registerItem("wooden_axe", properties -> new AxeItem(ToolMaterial.WOOD, 6.0F, -3.2F, properties));
public static final Item WOODEN_HOE = registerItem("wooden_hoe", properties -> new HoeItem(ToolMaterial.WOOD, 0.0F, -3.0F, properties)); @@ -1217,27 +_,27 @@
public static final Item COPPER_PICKAXE = registerItem("copper_pickaxe", new Item.Properties().pickaxe(ToolMaterial.COPPER, 1.0F, -2.8F));
public static final Item COPPER_AXE = registerItem("copper_axe", properties -> new AxeItem(ToolMaterial.COPPER, 7.0F, -3.2F, properties));
public static final Item COPPER_HOE = registerItem("copper_hoe", properties -> new HoeItem(ToolMaterial.COPPER, -1.0F, -2.0F, properties));
- public static final Item STONE_SWORD = registerItem("stone_sword", new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F)); - public static final Item STONE_SWORD = registerItem("stone_sword", new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F));
+ public static final Item STONE_SWORD = registerItem("stone_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F)); // Sakura - allow blocking with swords + public static final Item STONE_SWORD = registerItem("stone_sword", me.samsuik.sakura.player.item.BlockableSwordItem::new, new Item.Properties().sword(ToolMaterial.STONE, 3.0F, -2.4F)); // Sakura - allow blocking with swords
public static final Item STONE_SHOVEL = registerItem("stone_shovel", properties -> new ShovelItem(ToolMaterial.STONE, 1.5F, -3.0F, properties)); public static final Item STONE_SHOVEL = registerItem("stone_shovel", properties -> new ShovelItem(ToolMaterial.STONE, 1.5F, -3.0F, properties));
@@ -39,7 +42,7 @@
public static final Item NETHERITE_SHOVEL = registerItem( public static final Item NETHERITE_SHOVEL = registerItem(
"netherite_shovel", properties -> new ShovelItem(ToolMaterial.NETHERITE, 1.5F, -3.0F, properties), new Item.Properties().fireResistant() "netherite_shovel", properties -> new ShovelItem(ToolMaterial.NETHERITE, 1.5F, -3.0F, properties), new Item.Properties().fireResistant()
); );
@@ -1261,6 +_,7 @@ @@ -1321,6 +_,7 @@
public static final Item GOLDEN_APPLE = registerItem("golden_apple", new Item.Properties().food(Foods.GOLDEN_APPLE, Consumables.GOLDEN_APPLE)); public static final Item GOLDEN_APPLE = registerItem("golden_apple", new Item.Properties().food(Foods.GOLDEN_APPLE, Consumables.GOLDEN_APPLE));
public static final Item ENCHANTED_GOLDEN_APPLE = registerItem( public static final Item ENCHANTED_GOLDEN_APPLE = registerItem(
"enchanted_golden_apple", "enchanted_golden_apple",
@@ -47,7 +50,7 @@
new Item.Properties() new Item.Properties()
.rarity(Rarity.RARE) .rarity(Rarity.RARE)
.food(Foods.ENCHANTED_GOLDEN_APPLE, Consumables.ENCHANTED_GOLDEN_APPLE) .food(Foods.ENCHANTED_GOLDEN_APPLE, Consumables.ENCHANTED_GOLDEN_APPLE)
@@ -1362,12 +_,12 @@ @@ -1422,12 +_,12 @@
(block, properties) -> new HangingSignItem(block, Blocks.WARPED_WALL_HANGING_SIGN, properties), (block, properties) -> new HangingSignItem(block, Blocks.WARPED_WALL_HANGING_SIGN, properties),
new Item.Properties().stacksTo(16) new Item.Properties().stacksTo(16)
); );
@@ -63,7 +66,7 @@
); );
public static final Item POWDER_SNOW_BUCKET = registerItem( public static final Item POWDER_SNOW_BUCKET = registerItem(
"powder_snow_bucket", "powder_snow_bucket",
@@ -1378,6 +_,7 @@ @@ -1438,6 +_,7 @@
public static final Item LEATHER = registerItem("leather"); public static final Item LEATHER = registerItem("leather");
public static final Item MILK_BUCKET = registerItem( public static final Item MILK_BUCKET = registerItem(
"milk_bucket", "milk_bucket",

View File

@@ -1,50 +1,23 @@
--- a/net/minecraft/world/item/SpawnEggItem.java --- a/net/minecraft/world/item/SpawnEggItem.java
+++ b/net/minecraft/world/item/SpawnEggItem.java +++ b/net/minecraft/world/item/SpawnEggItem.java
@@ -13,6 +_,7 @@ @@ -14,6 +_,7 @@
import net.minecraft.core.registries.Registries; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.stats.Stats; import net.minecraft.stats.Stats;
import net.minecraft.world.Difficulty;
+import net.minecraft.util.Mth; +import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.AgeableMob; import net.minecraft.world.entity.AgeableMob;
@@ -71,16 +_,21 @@ @@ -98,6 +_,12 @@
} } else if (!type.isAllowedInPeaceful(stack.get(DataComponents.ENTITY_DATA).getUnsafe()) && level.getDifficulty() == Difficulty.PEACEFUL) { // Paper - check peaceful override
return InteractionResult.FAIL;
EntityType<?> type = this.getType(level.registryAccess(), itemInHand); } else {
+ // Sakura start - prevent placing spawn eggs inside blocks + // Sakura start - prevent placing spawn eggs inside blocks
+ if (level.sakuraConfig().players.preventPlacingSpawnEggsInsideBlocks && !level.noCollision(type.getSpawnAABB(blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5))) { + if (level.sakuraConfig().players.preventPlacingSpawnEggsInsideBlocks && !level.noCollision(type.getSpawnAABB(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5))) {
+ return InteractionResult.PASS; + return InteractionResult.PASS;
+ } + }
+ // Sakura end - prevent placing spawn eggs inside blocks + // Sakura end - prevent placing spawn eggs inside blocks
+ +
if (type.spawn( if (type.spawn((ServerLevel)level, stack, source, pos, EntitySpawnReason.SPAWN_ITEM_USE, shouldOffsetY, shouldOffsetYMore) != null) {
- (ServerLevel)level, stack.consume(1, source);
- itemInHand, level.gameEvent(source, GameEvent.ENTITY_PLACE, pos);
- context.getPlayer(),
- blockPos,
- EntitySpawnReason.SPAWN_ITEM_USE,
- true,
- !Objects.equals(clickedPos, blockPos) && clickedFace == Direction.UP
- )
- != null) {
+ (ServerLevel)level,
+ itemInHand,
+ context.getPlayer(),
+ blockPos,
+ EntitySpawnReason.SPAWN_ITEM_USE,
+ true,
+ !Objects.equals(clickedPos, blockPos) && clickedFace == Direction.UP
+ ) != null) {
itemInHand.shrink(1);
level.gameEvent(context.getPlayer(), GameEvent.ENTITY_PLACE, clickedPos);
}
@@ -103,7 +_,7 @@
} else if (level.mayInteract(player, blockPos) && player.mayUseItemAt(blockPos, playerPovHitResult.getDirection(), itemInHand)) {
EntityType<?> type = this.getType(serverLevel.registryAccess(), itemInHand);
Entity entity = type.spawn(serverLevel, itemInHand, player, blockPos, EntitySpawnReason.SPAWN_ITEM_USE, false, false);
- if (entity == null) {
+ if (entity == null || level.sakuraConfig().players.preventPlacingSpawnEggsInsideBlocks && !level.noCollision(null, entity.getBoundingBox())) { // Sakura - prevent placing spawn eggs inside blocks
return InteractionResult.PASS;
} else {
itemInHand.consume(1, player);

View File

@@ -22,7 +22,7 @@
tickDelay = serverLevel.paperConfig().tickRates.mobSpawner; tickDelay = serverLevel.paperConfig().tickRates.mobSpawner;
if (tickDelay == -1) { return; } // If disabled if (tickDelay == -1) { return; } // If disabled
// Paper end - Configurable mob spawner tick rate // Paper end - Configurable mob spawner tick rate
- if (this.isNearPlayer(serverLevel, pos)) { - if (this.isNearPlayer(serverLevel, pos) && serverLevel.getServer().isSpawnerBlockEnabled()) {
+ if (!serverLevel.sakuraConfig().environment.mobSpawner.requireNearbyPlayer || this.isNearPlayer(serverLevel, pos)) { // Sakura - configure mob spawner behaviour + if (!serverLevel.sakuraConfig().environment.mobSpawner.requireNearbyPlayer || this.isNearPlayer(serverLevel, pos)) { // Sakura - configure mob spawner behaviour
if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate if (this.spawnDelay < -tickDelay) { // Paper - Configurable mob spawner tick rate
this.delay(serverLevel, pos); this.delay(serverLevel, pos);

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/level/Level.java --- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java
@@ -109,7 +_,7 @@ @@ -114,7 +_,7 @@
public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); public final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList();
public final NeighborUpdater neighborUpdater; public final CollectingNeighborUpdater neighborUpdater;
private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList(); private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
- private boolean tickingBlockEntities; - private boolean tickingBlockEntities;
+ public boolean tickingBlockEntities; + public boolean tickingBlockEntities;
public final Thread thread; public final Thread thread;
private final boolean isDebug; private final boolean isDebug;
private int skyDarken; private int skyDarken;
@@ -159,6 +_,18 @@ @@ -164,6 +_,18 @@
return this.paperConfig; return this.paperConfig;
} }
// Paper end - add paper world config // Paper end - add paper world config
@@ -28,7 +28,7 @@
public static @Nullable BlockPos lastPhysicsProblem; // Spigot public static @Nullable BlockPos lastPhysicsProblem; // Spigot
private int tileTickPosition; private int tileTickPosition;
@@ -827,6 +_,7 @@ @@ -832,6 +_,7 @@
org.bukkit.World.Environment environment, // Paper org.bukkit.World.Environment environment, // Paper
java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config
io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config
@@ -36,7 +36,7 @@
java.util.concurrent.Executor executor // Paper - Anti-Xray java.util.concurrent.Executor executor // Paper - Anti-Xray
) { ) {
// Paper start - getblock optimisations - cache world height/sections // Paper start - getblock optimisations - cache world height/sections
@@ -840,6 +_,7 @@ @@ -845,6 +_,7 @@
// Paper end - getblock optimisations - cache world height/sections // Paper end - getblock optimisations - cache world height/sections
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/ServerExplosion.java --- a/net/minecraft/world/level/ServerExplosion.java
+++ b/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java
@@ -60,6 +_,7 @@ @@ -62,6 +_,7 @@
public float yield; public float yield;
// CraftBukkit end // CraftBukkit end
public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source
@@ -8,7 +8,7 @@
// Paper start - collisions optimisations // Paper start - collisions optimisations
private static final double[] CACHED_RAYS; private static final double[] CACHED_RAYS;
static { static {
@@ -326,6 +_,7 @@ @@ -328,6 +_,7 @@
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F;
this.yield = Double.isFinite(this.yield) ? this.yield : 0; // Paper - Don't allow infinite default yields this.yield = Double.isFinite(this.yield) ? this.yield : 0; // Paper - Don't allow infinite default yields
// Paper end - add yield // Paper end - add yield
@@ -16,7 +16,7 @@
} }
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
@@ -414,8 +_,7 @@ @@ -416,8 +_,7 @@
final double incZ = CACHED_RAYS[ray + 2]; final double incZ = CACHED_RAYS[ray + 2];
ray += 3; ray += 3;
@@ -26,7 +26,7 @@
do { do {
final int blockX = Mth.floor(currX); final int blockX = Mth.floor(currX);
@@ -622,7 +_,20 @@ @@ -610,7 +_,20 @@
.onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1));
} }

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/LiquidBlock.java --- a/net/minecraft/world/level/block/LiquidBlock.java
+++ b/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java
@@ -140,7 +_,7 @@ @@ -144,7 +_,7 @@
} }
// Paper start - Configurable speed for water flowing over lava // Paper start - Configurable speed for water flowing over lava
public int getFlowSpeed(Level level, BlockPos pos) { public int getFlowSpeed(Level level, BlockPos pos) {
@@ -9,7 +9,7 @@
if ( if (
isLava(level, pos.north(1)) || isLava(level, pos.north(1)) ||
isLava(level, pos.south(1)) || isLava(level, pos.south(1)) ||
@@ -150,7 +_,7 @@ @@ -154,7 +_,7 @@
return level.paperConfig().environment.waterOverLavaFlowSpeed; return level.paperConfig().environment.waterOverLavaFlowSpeed;
} }
} }
@@ -18,7 +18,7 @@
} }
private static boolean isLava(Level level, BlockPos pos) { private static boolean isLava(Level level, BlockPos pos) {
final FluidState fluidState = level.getFluidIfLoaded(pos); final FluidState fluidState = level.getFluidIfLoaded(pos);
@@ -189,6 +_,11 @@ @@ -193,6 +_,11 @@
for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) { for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) {
BlockPos blockPos = pos.relative(direction.getOpposite()); BlockPos blockPos = pos.relative(direction.getOpposite());

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java --- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
@@ -70,8 +_,11 @@ @@ -71,8 +_,11 @@
int i = -1; int i = -1;
int i1 = 1; int i1 = 1;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/chunk/LevelChunkSection.java --- a/net/minecraft/world/level/chunk/LevelChunkSection.java
+++ b/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java
@@ -310,12 +_,18 @@ @@ -306,12 +_,18 @@
public void fillBiomesFromNoise(BiomeResolver biomeResolver, Climate.Sampler climateSampler, int x, int y, int z) { public void fillBiomesFromNoise(BiomeResolver biomeResolver, Climate.Sampler climateSampler, int x, int y, int z) {
PalettedContainer<Holder<Biome>> palettedContainer = this.biomes.recreate(); PalettedContainer<Holder<Biome>> palettedContainer = this.biomes.recreate();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/material/FlowingFluid.java --- a/net/minecraft/world/level/material/FlowingFluid.java
+++ b/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java
@@ -152,12 +_,12 @@ @@ -153,12 +_,12 @@
} }
protected void spread(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) { protected void spread(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) {
@@ -15,7 +15,7 @@
Fluid type = newLiquid.getType(); Fluid type = newLiquid.getType();
if (fluidState1.canBeReplacedWith(level, blockPos, type, Direction.DOWN) && canHoldSpecificFluid(level, blockPos, blockState1, type)) { if (fluidState1.canBeReplacedWith(level, blockPos, type, Direction.DOWN) && canHoldSpecificFluid(level, blockPos, blockState1, type)) {
// CraftBukkit start // CraftBukkit start
@@ -199,6 +_,11 @@ @@ -200,6 +_,11 @@
BlockPos blockPos = pos.relative(direction); BlockPos blockPos = pos.relative(direction);
final BlockState blockStateIfLoaded = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent chunk loading from fluid flowing final BlockState blockStateIfLoaded = level.getBlockStateIfLoaded(blockPos); // Paper - Prevent chunk loading from fluid flowing
if (blockStateIfLoaded == null) continue; // Paper - Prevent chunk loading from fluid flowing if (blockStateIfLoaded == null) continue; // Paper - Prevent chunk loading from fluid flowing
@@ -27,7 +27,7 @@
// CraftBukkit start // CraftBukkit start
org.bukkit.block.Block source = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); org.bukkit.block.Block source = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos);
org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); org.bukkit.event.block.BlockFromToEvent event = new org.bukkit.event.block.BlockFromToEvent(source, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction));
@@ -213,17 +_,83 @@ @@ -214,17 +_,83 @@
} }
} }
@@ -113,7 +113,7 @@
if (fluidState.isSource()) { if (fluidState.isSource()) {
i1++; i1++;
} }
@@ -236,19 +_,11 @@ @@ -237,19 +_,11 @@
BlockState blockState1 = level.getBlockState(mutableBlockPos.setWithOffset(pos, Direction.DOWN)); BlockState blockState1 = level.getBlockState(mutableBlockPos.setWithOffset(pos, Direction.DOWN));
FluidState fluidState1 = blockState1.getFluidState(); FluidState fluidState1 = blockState1.getFluidState();
if (blockState1.isSolid() || this.isSourceBlockOfThisType(fluidState1)) { if (blockState1.isSolid() || this.isSourceBlockOfThisType(fluidState1)) {
@@ -135,7 +135,7 @@
} }
// Paper start - fluid method optimisations // Paper start - fluid method optimisations
@@ -414,7 +_,7 @@ @@ -417,7 +_,7 @@
if (blockState == null) continue; // Paper - Prevent chunk loading from fluid flowing if (blockState == null) continue; // Paper - Prevent chunk loading from fluid flowing
FluidState fluidState = blockState.getFluidState(); FluidState fluidState = blockState.getFluidState();
if (this.canMaybePassThrough(level, pos, state, direction, blockPos, blockState, fluidState)) { if (this.canMaybePassThrough(level, pos, state, direction, blockPos, blockState, fluidState)) {
@@ -144,7 +144,7 @@
if (canHoldSpecificFluid(level, blockPos, blockState, newLiquid.getType())) { if (canHoldSpecificFluid(level, blockPos, blockState, newLiquid.getType())) {
if (spreadContext == null) { if (spreadContext == null) {
spreadContext = new FlowingFluid.SpreadContext(level, pos); spreadContext = new FlowingFluid.SpreadContext(level, pos);
@@ -465,6 +_,11 @@ @@ -468,6 +_,11 @@
} }
private static boolean canHoldSpecificFluid(BlockGetter level, BlockPos pos, BlockState state, Fluid fluid) { private static boolean canHoldSpecificFluid(BlockGetter level, BlockPos pos, BlockState state, Fluid fluid) {
@@ -156,7 +156,7 @@
return !(state.getBlock() instanceof LiquidBlockContainer liquidBlockContainer) || liquidBlockContainer.canPlaceLiquid(null, level, pos, state, fluid); return !(state.getBlock() instanceof LiquidBlockContainer liquidBlockContainer) || liquidBlockContainer.canPlaceLiquid(null, level, pos, state, fluid);
} }
@@ -477,7 +_,7 @@ @@ -480,7 +_,7 @@
@Override @Override
public void tick(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) { public void tick(ServerLevel level, BlockPos pos, BlockState blockState, FluidState fluidState) {
if (!fluidState.isSource()) { if (!fluidState.isSource()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/material/LavaFluid.java --- a/net/minecraft/world/level/material/LavaFluid.java
+++ b/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java
@@ -189,12 +_,20 @@ @@ -190,12 +_,20 @@
@Override @Override
public int getTickDelay(LevelReader level) { public int getTickDelay(LevelReader level) {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Client Visibility Settings
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 5e6fed659a9c10697e8a029e484fdb25594bfb51..3f437cbafc601af4f37ed875cf2159c87d6c7c67 100644 index b140ed057d6a0abe51cc2853b46abd61dc11ba9f..dd8d6eed46846364ca8e98efd6f4cfa49e0f4af1 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2328,6 +2328,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa @@ -2272,6 +2272,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
handle.expToDrop = data.getIntOr("expToDrop", 0); handle.expToDrop = data.getIntOr("expToDrop", 0);
handle.keepLevel = data.getBooleanOr("keepLevel", false); handle.keepLevel = data.getBooleanOr("keepLevel", false);
}); });
@@ -20,7 +20,7 @@ index 5e6fed659a9c10697e8a029e484fdb25594bfb51..3f437cbafc601af4f37ed875cf2159c8
} }
public void setExtraData(ValueOutput output) { public void setExtraData(ValueOutput output) {
@@ -2349,6 +2354,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa @@ -2293,6 +2298,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
paper.putLong("LastLogin", handle.loginTime); paper.putLong("LastLogin", handle.loginTime);
paper.putLong("LastSeen", System.currentTimeMillis()); paper.putLong("LastSeen", System.currentTimeMillis());
// Paper end // Paper end
@@ -31,7 +31,7 @@ index 5e6fed659a9c10697e8a029e484fdb25594bfb51..3f437cbafc601af4f37ed875cf2159c8
} }
@Override @Override
@@ -3022,6 +3031,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa @@ -2871,6 +2880,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
return this.getHandle().allowsListing(); return this.getHandle().allowsListing();
} }

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -179,7 +_,7 @@ @@ -178,7 +_,7 @@
.defaultOptions(PaperConfigurations::defaultOptions); .defaultOptions(PaperConfigurations::defaultOptions);
} }
@@ -9,7 +9,7 @@
return options.serializers(builder -> builder return options.serializers(builder -> builder
.register(MapSerializer.TYPE, new MapSerializer(false)) .register(MapSerializer.TYPE, new MapSerializer(false))
.register(new EnumValueSerializer()) .register(new EnumValueSerializer())
@@ -341,7 +_,7 @@ @@ -340,7 +_,7 @@
} }
} }
@@ -18,7 +18,7 @@
return List.of( return List.of(
MergeMap.DEFINITION MergeMap.DEFINITION
); );
@@ -483,7 +_,7 @@ @@ -482,7 +_,7 @@
} }
// Symlinks are not correctly checked in createDirectories // Symlinks are not correctly checked in createDirectories

View File

@@ -1,14 +1,14 @@
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1048,6 +_,7 @@ @@ -992,6 +_,7 @@
org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot
this.console.paperConfigurations.reloadConfigs(this.console); this.console.paperConfigurations.reloadConfigs(this.console);
+ this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - sakura configuration files; missing comment above :< + this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - sakura configuration files; missing comment above :<
for (ServerLevel world : this.console.getAllLevels()) { for (ServerLevel world : this.console.getAllLevels()) {
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && world.getGameRules().getBoolean(GameRules.RULE_SPAWN_MONSTERS)); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
@@ -1079,6 +_,7 @@ @@ -1023,6 +_,7 @@
this.reloadData(); this.reloadData();
org.spigotmc.SpigotConfig.registerCommands(); // Spigot org.spigotmc.SpigotConfig.registerCommands(); // Spigot
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -294,6 +_,12 @@ @@ -295,6 +_,12 @@
).isValid(); ).isValid();
} }
// Paper end // Paper end

View File

@@ -1,6 +1,6 @@
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -237,6 +_,18 @@ @@ -244,6 +_,18 @@
this.firstPlayed = System.currentTimeMillis(); this.firstPlayed = System.currentTimeMillis();
} }

View File

@@ -0,0 +1,6 @@
package me.samsuik.sakura.explosion;
import net.minecraft.world.phys.Vec3;
public record ExplosionToSend(Vec3 position, int blocksDestroyed) {
}

View File

@@ -3,7 +3,7 @@ package me.samsuik.sakura.explosion;
import ca.spottedleaf.moonrise.common.util.WorldUtil; import ca.spottedleaf.moonrise.common.util.WorldUtil;
import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices;
import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup; import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup;
import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.*;
import me.samsuik.sakura.mechanics.MechanicVersion; import me.samsuik.sakura.mechanics.MechanicVersion;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -12,23 +12,25 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ExplosionDamageCalculator; import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.ServerExplosion; import net.minecraft.world.level.ServerExplosion;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.NullMarked;
import java.util.Arrays; import java.util.*;
import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@NullMarked @NullMarked
public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplosion { public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplosion {
private static final double ENTITY_DISPATCH_DISTANCE = Math.pow(32.0, 2.0); private static final double ENTITY_DISPATCH_DISTANCE_SQR = 32.0 * 32.0;
protected final T cause; // preferred over source protected final T cause; // preferred over source
private Vec3 impactPosition; private Vec3 dispatchPosition;
protected final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); private final List<Vec3> bufferedExplosions = new ObjectArrayList<>();
private final Consumer<SpecialisedExplosion<T>> applyEffects; private AABB bounds;
private final Set<BlockPos> gameEvents = new ObjectOpenHashSet<>();
private final Deque<ExplosionToSend> explosionsToSend = new ArrayDeque<>();
public SpecialisedExplosion( public SpecialisedExplosion(
final ServerLevel level, final ServerLevel level,
@@ -38,50 +40,80 @@ public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplo
final Vec3 center, final Vec3 center,
final float power, final float power,
final boolean createFire, final boolean createFire,
final BlockInteraction destructionType, final BlockInteraction destructionType
final Consumer<SpecialisedExplosion<T>> applyEffects
) { ) {
super(level, entity, damageSource, behavior, center, power, createFire, destructionType); super(level, entity, damageSource, behavior, center, power, createFire, destructionType);
this.cause = entity; this.cause = entity;
this.impactPosition = center; this.dispatchPosition = center;
this.applyEffects = applyEffects; this.bounds = new AABB(center, center);
}
public final Queue<ExplosionToSend> getExplosionsToSend() {
return this.explosionsToSend;
} }
protected double getExplosionOffset() { protected double getExplosionOffset() {
return (double) this.cause.getBbHeight() * 0.0625D; return 0.0;
} }
protected abstract void beginExplosion(); protected abstract int handleExplosion();
@Override @Override
public final void explode() { public final int explode() {
this.createBlockCache(); this.createBlockCache();
this.beginExplosion(); // search for blocks, impact entities, finalise if necessary final int blocksDestroyed = this.handleExplosion();
this.clearBlockCache(); this.clearBlockCache();
return blocksDestroyed;
} }
protected final boolean requiresImpactEntities(final List<BlockPos> blocks, final Vec3 center) { protected final List<BlockPos> collectBlocksAndImpactEntities(final boolean interactWithBlocks, final boolean dispatch) {
if (this.impactPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE) { if (interactWithBlocks && this.gameEvents.add(BlockPos.containing(this.center))) {
this.impactPosition = center; this.level().gameEvent(this.source, GameEvent.EXPLODE, this.center);
}
// Collect all the blocks to explode
final List<BlockPos> blocksToExplode = interactWithBlocks
? this.calculateExplodedPositions()
: List.of();
// Buffer explosions to reduce the amount of calculations and improve locality
final Vec3 center = this.center;
this.bounds = this.bounds.expand(center);
this.bufferedExplosions.add(center);
// Dispatch the buffered explosions
if (dispatch || this.needToDispatchEntities(blocksToExplode, center)) {
this.locateAndImpactEntitiesInBounds(this.bounds, this.bufferedExplosions);
this.bounds = new AABB(center, center);
this.bufferedExplosions.clear();
}
return blocksToExplode;
}
protected final boolean needToDispatchEntities(final List<BlockPos> blocksToBlow, final Vec3 center) {
if (this.dispatchPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE_SQR) {
this.dispatchPosition = center;
this.gameEvents.clear();
return true; return true;
} }
return !blocks.isEmpty(); return !blocksToBlow.isEmpty();
} }
protected final boolean finalizeExplosionAndParticles(final List<BlockPos> blocks) { protected final int finalizeExplosionAndParticles(final List<BlockPos> blocksToBlow, final boolean lastCycle) {
this.wasCanceled = false; this.wasCanceled = false;
final List<BlockPos> explodedPositions = new ObjectArrayList<>(blocks); final List<BlockPos> explodedPositions = new ObjectArrayList<>(blocksToBlow);
this.interactWithBlocks(explodedPositions); this.interactWithBlocks(explodedPositions);
if (!this.wasCanceled) { if (!this.wasCanceled && !lastCycle) {
this.applyEffects.accept(this); // Packets are sent after the explosion
this.getHitPlayers().clear(); this.explosionsToSend.add(new ExplosionToSend(this.center, explodedPositions.size()));
} }
return !explodedPositions.isEmpty() && !this.wasCanceled; return this.wasCanceled ? 0 : explodedPositions.size();
} }
protected void postExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) { protected void nextExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) {
// Reuse the block cache between explosions. This can help a lot when searching for blocks and raytracing. // Reuse the block cache between explosions. This can help a lot when searching for blocks and raytracing.
// This is disabled by default as it's incompatible with plugins that modify blocks in the explosion event. // This is disabled by default as it's incompatible with plugins that modify blocks in the explosion event.
if (this.level().sakuraConfig().cannons.explosion.reuseBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) { if (this.level().sakuraConfig().cannons.explosion.reuseBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) {
@@ -188,7 +220,7 @@ public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplo
distance = (float) distance; distance = (float) distance;
} }
if (distance != 0.0D) { if (distance >= 1.0e-5 || distance != 0.0 && this.mechanicsTarget.before(MechanicVersion.v1_21_9)) {
x /= distance; x /= distance;
y /= distance; y /= distance;
z /= distance; z /= distance;

View File

@@ -1,7 +1,6 @@
package me.samsuik.sakura.explosion; package me.samsuik.sakura.explosion;
import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet; import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.samsuik.sakura.entity.EntityState; import me.samsuik.sakura.entity.EntityState;
import me.samsuik.sakura.entity.merge.MergeLevel; import me.samsuik.sakura.entity.merge.MergeLevel;
import me.samsuik.sakura.entity.merge.MergeableEntity; import me.samsuik.sakura.entity.merge.MergeableEntity;
@@ -13,13 +12,11 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.PrimedTnt; import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.level.ExplosionDamageCalculator; import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.NullMarked;
import java.util.List; import java.util.List;
import java.util.function.Consumer;
@NullMarked @NullMarked
public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> { public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
@@ -27,8 +24,6 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
private static final int FOUND_ALL_BLOCKS = ALL_DIRECTIONS + 12; private static final int FOUND_ALL_BLOCKS = ALL_DIRECTIONS + 12;
private final Vec3 originalPosition; private final Vec3 originalPosition;
private final List<Vec3> explosions = new ObjectArrayList<>();
private AABB bounds;
private int swinging = 0; private int swinging = 0;
private boolean moved = false; private boolean moved = false;
@@ -40,19 +35,17 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
final Vec3 center, final Vec3 center,
final float power, final float power,
final boolean createFire, final boolean createFire,
final BlockInteraction destructionType, final BlockInteraction destructionType
final Consumer<SpecialisedExplosion<PrimedTnt>> applyEffects
) { ) {
super(level, tnt, damageSource, behavior, center, power, createFire, destructionType, applyEffects); super(level, tnt, damageSource, behavior, center, power, createFire, destructionType);
this.originalPosition = center; this.originalPosition = center;
this.bounds = new AABB(center, center);
} }
@Override @Override
protected double getExplosionOffset() { protected double getExplosionOffset() {
return this.mechanicsTarget.before(MechanicVersion.v1_10) return this.mechanicsTarget.before(MechanicVersion.v1_10)
? (double) 0.49f ? (double) 0.49f
: super.getExplosionOffset(); : (double) this.cause.getBbHeight() * 0.0625D;
} }
private void mergeEntitiesBeforeExploding() { private void mergeEntitiesBeforeExploding() {
@@ -89,41 +82,28 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
} }
@Override @Override
protected void beginExplosion() { protected int handleExplosion() {
int blocksDestroyed = 0;
for (int remaining = this.mergeAndGetExplosionPotential() - 1; remaining >= 0; --remaining) { for (int remaining = this.mergeAndGetExplosionPotential() - 1; remaining >= 0; --remaining) {
final boolean lastCycle = remaining == 0; final boolean lastCycle = remaining == 0;
final List<BlockPos> toBlow = this.midExplosion(lastCycle); // search for blocks and impact entities final List<BlockPos> blocksToBlow = this.collectBlocksAndImpactEntities(this.swinging < FOUND_ALL_BLOCKS, lastCycle);
final boolean destroyedBlocks = this.finalizeExplosionAndParticles(toBlow); // call events, break blocks and send particles blocksDestroyed = this.finalizeExplosionAndParticles(blocksToBlow, lastCycle);
if (!lastCycle) { if (!lastCycle) {
// The source velocity has to be calculated before nextExplosion as it clears the blockCache
final EntityState entityState = this.nextSourceVelocity(); final EntityState entityState = this.nextSourceVelocity();
this.postExplosion(toBlow, destroyedBlocks); final boolean destroyedBlocks = blocksDestroyed > 0;
this.nextExplosion(blocksToBlow, destroyedBlocks);
this.updateExplosionPosition(entityState, destroyedBlocks); this.updateExplosionPosition(entityState, destroyedBlocks);
} }
} }
}
private List<BlockPos> midExplosion(final boolean lastCycle) { return blocksDestroyed;
final List<BlockPos> explodedPositions = this.swinging < FOUND_ALL_BLOCKS
? this.calculateExplodedPositions()
: List.of();
final Vec3 center = this.center;
this.bounds = this.bounds.expand(center);
this.explosions.add(center);
if (lastCycle || this.requiresImpactEntities(explodedPositions, center)) {
this.locateAndImpactEntitiesInBounds(this.bounds, this.explosions);
this.bounds = new AABB(center, center);
this.explosions.clear();
}
return explodedPositions;
} }
@Override @Override
protected void postExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) { protected void nextExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) {
super.postExplosion(foundBlocks, destroyedBlocks); super.nextExplosion(foundBlocks, destroyedBlocks);
if (this.swinging >= ALL_DIRECTIONS) { if (this.swinging >= ALL_DIRECTIONS) {
// Increment "swinging" if no blocks have been found, and it has swung in every direction. // Increment "swinging" if no blocks have been found, and it has swung in every direction.
// This is used to skip expensive exploded block calculations. // This is used to skip expensive exploded block calculations.

View File

@@ -23,7 +23,7 @@ public final class EntityBehaviour {
final Vec3 newEntityPosition; final Vec3 newEntityPosition;
if (mechanicsTarget.is(MechanicVersion.v1_21_5)) { if (mechanicsTarget.is(MechanicVersion.v1_21_5)) {
newEntityPosition = manglePosition(position, relativeMovement); newEntityPosition = manglePosition(position, relativeMovement);
entity.addMovementThisTick(new Entity.Movement(position, newPosition, true)); entity.addMovementThisTick(new Entity.Movement(position, newPosition, relativeMovement));
} else { } else {
newEntityPosition = newPosition; newEntityPosition = newPosition;
} }
@@ -33,7 +33,7 @@ public final class EntityBehaviour {
private static Vec3 manglePosition(final Vec3 position, final Vec3 relativeMovement) { private static Vec3 manglePosition(final Vec3 position, final Vec3 relativeMovement) {
Vec3 newPosition = position; Vec3 newPosition = position;
for (final Direction.Axis axis : Entity.axisStepOrder(relativeMovement)) { for (final Direction.Axis axis : Direction.axisStepOrder(relativeMovement)) {
final double movement = relativeMovement.get(axis); final double movement = relativeMovement.get(axis);
if (movement != 0.0) { if (movement != 0.0) {
newPosition = newPosition.relative(axis.getPositive(), movement); newPosition = newPosition.relative(axis.getPositive(), movement);

View File

@@ -36,6 +36,7 @@ public final class LegacyDamageMapping {
LEGACY_ITEM_DAMAGE_MAP.put(Items.WOODEN_AXE, 3.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.WOODEN_AXE, 3.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.GOLDEN_AXE, 3.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.GOLDEN_AXE, 3.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.STONE_AXE, 4.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.STONE_AXE, 4.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.COPPER_AXE, 4.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.IRON_AXE, 5.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.IRON_AXE, 5.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0); LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0);

View File

@@ -11,7 +11,13 @@ import org.jspecify.annotations.NullMarked;
public final class DataComponentHelper { public final class DataComponentHelper {
public static int bucketMaxStackSize() { public static int bucketMaxStackSize() {
final GlobalConfiguration config = GlobalConfiguration.get(); final GlobalConfiguration config = GlobalConfiguration.get();
return config == null || !config.players.bucketStackSize.isDefined() ? -1 : config.players.bucketStackSize.intValue(); return config != null && config.players.bucketStackSize.isDefined()
? config.players.bucketStackSize.intValue()
: -1;
}
public static DataComponentMap updateBucketMaxStackSize(final DataComponentMap components) {
return copyComponentsAndModifyMaxStackSize(components, bucketMaxStackSize());
} }
@SuppressWarnings("OptionalAssignedToNull") @SuppressWarnings("OptionalAssignedToNull")
@@ -20,7 +26,7 @@ public final class DataComponentHelper {
} }
public static DataComponentMap copyComponentsAndModifyMaxStackSize(final DataComponentMap componentMap, final int maxItemSize) { public static DataComponentMap copyComponentsAndModifyMaxStackSize(final DataComponentMap componentMap, final int maxItemSize) {
if (maxItemSize > 0 && maxItemSize <= 99) { if (maxItemSize > 1 && maxItemSize <= 99) {
return DataComponentMap.builder() return DataComponentMap.builder()
.addAll(componentMap) .addAll(componentMap)
.set(DataComponents.MAX_STACK_SIZE, maxItemSize) .set(DataComponents.MAX_STACK_SIZE, maxItemSize)

View File

@@ -1,9 +1,10 @@
package me.samsuik.sakura.player.item; package me.samsuik.sakura.player.item;
import me.samsuik.sakura.configuration.GlobalConfiguration; import me.samsuik.sakura.configuration.GlobalConfiguration;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.DataComponents;
import net.minecraft.core.component.PatchedDataComponentMap;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.NullMarked;
@NullMarked @NullMarked
@@ -13,10 +14,17 @@ public final class MilkBucketItem extends Item {
} }
@Override @Override
public void verifyComponentsAfterLoad(final ItemStack stack) { public DataComponentMap components() {
final int maxStackSize = DataComponentHelper.bucketMaxStackSize(); final DataComponentMap components = super.components();
if (maxStackSize > 0 && maxStackSize < 100 && stackableMilkBuckets()) { return stackableMilkBuckets()
stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize); ? DataComponentHelper.updateBucketMaxStackSize(components)
: components;
}
@Override
public void modifyComponentsSentToClient(final PatchedDataComponentMap components) {
if (stackableMilkBuckets()) {
components.set(DataComponents.MAX_STACK_SIZE, DataComponentHelper.bucketMaxStackSize());
} }
} }

View File

@@ -1,8 +1,9 @@
package me.samsuik.sakura.player.item; package me.samsuik.sakura.player.item;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents; import net.minecraft.core.component.DataComponents;
import net.minecraft.core.component.PatchedDataComponentMap;
import net.minecraft.world.item.BucketItem; import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.material.Fluid; import net.minecraft.world.level.material.Fluid;
import org.jspecify.annotations.NullMarked; import org.jspecify.annotations.NullMarked;
@@ -13,11 +14,15 @@ public final class StackableBucketItem extends BucketItem {
} }
@Override @Override
public void verifyComponentsAfterLoad(final ItemStack stack) { public DataComponentMap components() {
// It's also possible to override the components method and modify the stack size through the DataComponentHelper return DataComponentHelper.updateBucketMaxStackSize(super.components());
}
@Override
public void modifyComponentsSentToClient(final PatchedDataComponentMap components) {
final int maxStackSize = DataComponentHelper.bucketMaxStackSize(); final int maxStackSize = DataComponentHelper.bucketMaxStackSize();
if (maxStackSize > 0 && maxStackSize < 100) { if (maxStackSize > 1 && maxStackSize <= 99) {
stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize); components.set(DataComponents.MAX_STACK_SIZE, maxStackSize);
} }
} }
} }

View File

@@ -40,7 +40,7 @@ fi
for i in $(find . -name \*.rej); do for i in $(find . -name \*.rej); do
base=$(echo "$i" | sed 's/.rej//g') base=$(echo "$i" | sed 's/.rej//g')
if [ -f "$i" ]; then if [ -f "$i" ]; then
sed -e 's/^diff a\/\(.*\) b\/\(.*\)[[:space:]].*rejected.*$/--- \1\n+++ \2/' -i $i && wiggle -v -l --replace "$base" "$i" sed -e 's/^diff a\/\(.*\) b\/\(.*\)[[:space:]].*rejected.*$/--- \1\n+++ \2/' -i '' $i && wiggle -v -l --replace "$base" "$i"
rm "$base.porig" "$i" rm "$base.porig" "$i"
else else
echo "No such file: $base" echo "No such file: $base"

View File

@@ -15,7 +15,7 @@ fi
echo "Updating paper: $oldHash -> $newHash" echo "Updating paper: $oldHash -> $newHash"
sed -i "s/$oldHash/$newHash/g" gradle.properties sed -i '' "s/$oldHash/$newHash/g" gradle.properties
git add gradle.properties git add gradle.properties
./gradlew cleanCache ./gradlew cleanCache