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

Backport to 1.19.4

This commit is contained in:
Samsuik
2024-01-21 23:16:08 +00:00
parent fb091042cc
commit 4eee2a1062
72 changed files with 1167 additions and 1416 deletions

View File

@@ -8,11 +8,3 @@
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
minecraft net.minecraft.world.level.block.piston.PistonStructureResolver
minecraft net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket
minecraft net.minecraft.world.item.ItemNameBlockItem
minecraft net.minecraft.world.level.block.FallingBlock
minecraft net.minecraft.world.level.block.piston.MovingPistonBlock
minecraft net.minecraft.world.level.block.piston.PistonHeadBlock
minecraft net.minecraft.world.level.block.LadderBlock
minecraft net.minecraft.world.level.block.Blocks

View File

@@ -3,7 +3,7 @@ import io.papermc.paperweight.util.constants.PAPERCLIP_CONFIG
plugins {
java
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
id("io.papermc.paperweight.patcher") version "1.5.11"
id("io.papermc.paperweight.patcher") version "1.5.5"
}
repositories {
@@ -14,7 +14,7 @@ repositories {
}
dependencies {
remapper("net.fabricmc:tiny-remapper:0.8.10:fat")
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
paperclip("io.papermc:paperclip:3.0.3")
}

View File

@@ -1,8 +1,8 @@
group=me.samsuik.sakura
version=1.20.4-R0.1-SNAPSHOT
version=1.19.4-R0.1-SNAPSHOT
mcVersion=1.20.4
paperRef=07b956e3a30d9cd192111829b59bdf4372f128b1
mcVersion=1.19.4
paperRef=483368e480eb2ec060d8e68b30e14ec96aba6c4e
org.gradle.jvmargs=-Xmx2G

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Customise Version Command
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 884902cb7f86c0b56594ccafc7d05c6c7a23ab53..d38fbaf2ee60036f5b24566b38cfcee3080bd822 100644
index b0bc2df41506770e2854a287813f1c53f003eda1..0a5e8d88f0f18a8e5295ead8f5c75be7d3fd2d2b 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -128,6 +128,20 @@ public final class Bukkit {
@@ -126,6 +126,20 @@ public final class Bukkit {
// Paper end
}
@@ -30,22 +30,24 @@ index 884902cb7f86c0b56594ccafc7d05c6c7a23ab53..d38fbaf2ee60036f5b24566b38cfcee3
* Gets the name of this server implementation.
*
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
index fd5d9881abfd930bb883120f018f76dc78b62b14..5fdafa08fb8932333cacd1a6ddb701e96f89bec2 100644
index e40f017f87d6b6b4770501b106c76dc69ec69abb..ac781fdd9dac6e124f53a15560c97aa3df314b08 100644
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -32,6 +32,11 @@ import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
// Paper end - version command 2.0
@@ -25,6 +25,13 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
+// Sakura start
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.event.HoverEvent;
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
+// Sakura end
public class VersionCommand extends BukkitCommand {
private VersionFetcher versionFetcher; // Paper - version command 2.0
@@ -43,6 +48,15 @@ public class VersionCommand extends BukkitCommand {
private VersionFetcher versionFetcher;
@@ -36,6 +43,15 @@ public class VersionCommand extends BukkitCommand {
return versionFetcher;
}
@@ -61,7 +63,7 @@ index fd5d9881abfd930bb883120f018f76dc78b62b14..5fdafa08fb8932333cacd1a6ddb701e9
public VersionCommand(@NotNull String name) {
super(name);
@@ -54,12 +68,18 @@ public class VersionCommand extends BukkitCommand {
@@ -47,12 +63,18 @@ public class VersionCommand extends BukkitCommand {
@Override
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {

View File

@@ -153,12 +153,12 @@ index 0000000000000000000000000000000000000000..0483f5a19ff3d4e5e6528c3e4be549fd
+
+}
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index 962283d336e6d53941cebbc3a995d403ff989f66..8022f89793a557e0c8c03b78b4a1c5b3aa983306 100644
index 88c4885569d2b8b22fce55601d50608ac8e9388c..02d14c899446cd22e9ad1b85706cc87d521d0a5e 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -54,6 +54,15 @@ import org.jetbrains.annotations.Nullable;
@@ -44,6 +44,15 @@ import org.jetbrains.annotations.Nullable;
*/
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, com.destroystokyo.paper.network.NetworkClient { // Paper
+ // Sakura start
+ /**

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] isPushedByFluid API
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
index 1d0fd7ff8449f815a7d980af0b378181ea8bf8d8..e0ef6e5a4664b69a5797afeafac2c6436137cab3 100644
index a2a423d4e4c2702ba5967223cab0432dd7d04732..9b5e4db5f258ca30ef9a7bfbd0ff867340199e8f 100644
--- a/src/main/java/org/bukkit/entity/Entity.java
+++ b/src/main/java/org/bukkit/entity/Entity.java
@@ -111,6 +111,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
@@ -108,6 +108,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
*/
public boolean isInWater();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Falling Block Parity API
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
index f3d5cd5fd2418e493fffed3a3735c00bf04e214d..b6fd3b11cf41aae59d81974ced37ca7722df29ca 100644
index 3b4c83aab5e646266d91a2f3cb0f57a242941069..8d9909eb6aef5a1b7643e4249e28729543f1d78c 100644
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
@@ -183,4 +183,19 @@ public interface FallingBlock extends Entity, me.samsuik.sakura.entity.merge.Mer
@@ -122,4 +122,19 @@ public interface FallingBlock extends Entity, me.samsuik.sakura.entity.merge.Mer
*/
void shouldAutoExpire(boolean autoExpires);
// Paper End - Auto expire setting

View File

@@ -153,10 +153,10 @@ index 0000000000000000000000000000000000000000..0f7da96d434cd699470e050898712898
+
+}
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
index 567a36a4887da8994c9170e2885aa8cc357efa0c..b123dcd80955c7e9dc40a7ecb4307c7d977135fd 100644
index 72f1576b8ce5b55b50f053f346ce42c52db4b568..1ed79a517ae5f330fa88c0720b71acba7b331b8a 100644
--- a/src/main/java/org/bukkit/World.java
+++ b/src/main/java/org/bukkit/World.java
@@ -155,6 +155,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
@@ -129,6 +129,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
return new Location(this, x, y, z);
}
// Paper end

View File

@@ -27,10 +27,10 @@ index ee3057c7969956b9c552ac5ceb2f5e38a30e9cdf..58f220a3f48a8cc1a25249d4a56cf356
public boolean equals(Object o) {
diff --git a/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java
new file mode 100644
index 0000000000000000000000000000000000000000..b27a757b6d3d43df589947fa65857011da920529
index 0000000000000000000000000000000000000000..227306a2f37756d646e619f572be9fc24bc925b3
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java
@@ -0,0 +1,94 @@
@@ -0,0 +1,93 @@
+package me.samsuik.sakura.physics;
+
+public enum PhysicsVersion {
@@ -49,7 +49,6 @@ index 0000000000000000000000000000000000000000..b27a757b6d3d43df589947fa65857011
+ v1_17("1.17", 1_17_0),
+ v1_18_2("1.18.2", 1_18_2),
+ v1_19_3("1.19.3", 1_19_3),
+ v1_20("1.20", 1_20_0),
+ // refers to the latest mechanic version
+ LATEST("latest", 9_99_9);
+

View File

@@ -6,25 +6,25 @@ Subject: [PATCH] Branding changes
From ForkPaper.
diff --git a/build.gradle.kts b/build.gradle.kts
index 58da26ad2f128ba0b66f86820f60853f4be352f0..732d617578b58c0430b42d1c84efc54fb3c43b5e 100644
index 4f2fa65ade89c5703451dad4f80eeef162b277d1..dfc51ca038c922aa04cbdfbd5a12fd8623221ef4 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
val alsoShade: Configuration by configurations.creating
@@ -7,8 +7,12 @@ plugins {
}
dependencies {
- implementation(project(":paper-api"))
- implementation(project(":paper-mojangapi"))
+ // Sakura start
+ implementation(project(":sakura-api"))
+ implementation("io.papermc.paper:paper-mojangapi:1.20.4-R0.1-SNAPSHOT") {
+ implementation("io.papermc.paper:paper-mojangapi:1.19.4-R0.1-SNAPSHOT") {
+ exclude("io.papermc.paper", "paper-api")
+ }
+ // Sakura end
// Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -70,7 +74,7 @@ tasks.jar {
@@ -62,7 +66,7 @@ tasks.jar {
attributes(
"Main-Class" to "org.bukkit.craftbukkit.Main",
"Implementation-Title" to "CraftBukkit",
@@ -34,10 +34,10 @@ index 58da26ad2f128ba0b66f86820f60853f4be352f0..732d617578b58c0430b42d1c84efc54f
"Specification-Title" to "Bukkit",
"Specification-Version" to project.version,
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 34f19ac897a30c0c4e3ab406013fcca1c8b7db93..6e1c140d0d26728d64b827f6f3e5a450a37942c0 100644
index 9f15d9dbdfa74a0640b1a2b4ff695609d4758a4c..d52e24f1d5073c7b534a7dd571f6f0128ca6280e 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1866,7 +1866,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1682,7 +1682,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@DontObfuscate
public String getServerModName() {
@@ -47,10 +47,10 @@ index 34f19ac897a30c0c4e3ab406013fcca1c8b7db93..6e1c140d0d26728d64b827f6f3e5a450
public SystemReport fillSystemReport(SystemReport details) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 142d2c48239d4ebe3896218536656d116cd24d7c..8e47a8a4fde1eb390b4df5b02cb7bc9170bc1e12 100644
index 9f2536d9a73bdb15b5b3004d4da79ca32cee205b..0c1ce3c44490cc7b46a8b91833a85b57e6341d7d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -264,7 +264,7 @@ import javax.annotation.Nullable; // Paper
@@ -262,7 +262,7 @@ import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
public final class CraftServer implements Server {

View File

@@ -39,16 +39,3 @@ index 50a9f33aa31e9273c7c52d4bb2b02f0f884f7ba5..5fb7573022c5af775b2e737dcd05c53c
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java
index 9a2de546dc2af2ad4bf5d32ca6583f0e1f3f70d8..1e97f781c8cf1bc182bd802bbed1c19077d23bcd 100644
--- a/src/main/java/net/minecraft/world/level/block/Blocks.java
+++ b/src/main/java/net/minecraft/world/level/block/Blocks.java
@@ -1215,7 +1215,7 @@ public class Blocks {
}
private static Boolean ocelotOrParrot(BlockState state, BlockGetter world, BlockPos pos, EntityType<?> type) {
- return (boolean)type == EntityType.OCELOT || type == EntityType.PARROT;
+ return type == EntityType.OCELOT || type == EntityType.PARROT; // Sakura - decompile fix
}
private static Block bed(DyeColor color) {

View File

@@ -4,11 +4,23 @@ Date: Sun, 5 Sep 2021 18:01:34 +0100
Subject: [PATCH] Sakura Configuration Files
diff --git a/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java b/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java
index 7a4a7a654fe2516ed894a68f2657344df9d70f4c..dae98d95597f303020c3404d5bf4d983cb20b603 100644
--- a/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java
+++ b/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java
@@ -1,6 +1,6 @@
package io.papermc.paper.configuration;
-abstract class ConfigurationPart {
+public abstract class ConfigurationPart { // Sakura
public static abstract class Post extends ConfigurationPart {
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
index c01b4393439838976965823298f12e4762e72eff..1489f7066615bd1e0dfc1dd6d99d240ccc4fd334 100644
index 9ef6712c70fcd8912a79f3f61e351aac09572cf3..4cb0c8291833cd10d9704cdbe4f0332827c02ae2 100644
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
@@ -93,7 +93,7 @@ public abstract class Configurations<G, W> {
@@ -88,7 +88,7 @@ public abstract class Configurations<G, W> {
};
}
@@ -17,20 +29,51 @@ index c01b4393439838976965823298f12e4762e72eff..1489f7066615bd1e0dfc1dd6d99d240c
return node -> {
ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type));
ObjectMapper.Mutable<T> mutable = (ObjectMapper.Mutable<T>) factory.get(type);
@@ -226,7 +226,7 @@ public abstract class Configurations<G, W> {
@@ -206,7 +206,7 @@ public abstract class Configurations<G, W> {
.path(worldConfigFile)
.build();
final ConfigurationNode worldNode = worldLoader.load();
- if (newFile) { // set the version field if new file
+ if (newFile && this instanceof PaperConfigurations) { // Sakura - hack this into working // set the version field if new file
worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion());
} else {
this.verifyWorldConfigVersion(contextMap, worldNode);
worldNode.node(Configuration.VERSION_FIELD).set(WorldConfiguration.CURRENT_VERSION);
}
this.applyWorldConfigTransformations(contextMap, worldNode);
diff --git a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java
index a0aa1f1a7adf986d500a2135aa42e138aa3c4f08..c9a351d02b0b5f5a9856fde433c1d64ece46cdee 100644
--- a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java
+++ b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java
@@ -17,7 +17,7 @@ import java.util.Map;
import static io.leangen.geantyref.GenericTypeReflector.erase;
-final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Object>> {
+public final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Object>> { // Sakura
private final Map<Class<?>, Object> instanceMap = new HashMap<>();
private final Map<Class<?>, Object> overrides;
@@ -55,7 +55,7 @@ final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Obje
}
}, "Object must be a unique ConfigurationPart");
- InnerClassFieldDiscoverer(Map<Class<?>, Object> overrides) {
+ public InnerClassFieldDiscoverer(Map<Class<?>, Object> overrides) { // Sakura
this.overrides = overrides;
}
@@ -136,7 +136,7 @@ final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Obje
return new InnerClassFieldDiscoverer(overrides);
}
- static FieldDiscoverer<?> globalConfig() {
+ public static FieldDiscoverer<?> globalConfig() { // Sakura
return new InnerClassFieldDiscoverer(Collections.emptyMap());
}
}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
index fa1c0aee8c3a4d0868482cf5c703bbfd08e09874..9ea2e60095526e63a1f4a0087cfd59067bb92c7e 100644
index f6b9d216c24d8858802f85209fe1a869e5a9be31..d120f4fed605261cc68033875c35a21b7bfbb83c 100644
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -457,7 +457,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
@@ -431,7 +431,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
}
// Symlinks are not correctly checked in createDirectories
@@ -39,48 +82,6 @@ index fa1c0aee8c3a4d0868482cf5c703bbfd08e09874..9ea2e60095526e63a1f4a0087cfd5906
if (!Files.isDirectory(path)) {
Files.createDirectories(path);
}
diff --git a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceFactory.java b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceFactory.java
index cec678ae24a7d99a46fa672be907f4c28fe4da96..9906ef363c72ade71c16d8141a0d6d79d72d4eff 100644
--- a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceFactory.java
+++ b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceFactory.java
@@ -11,13 +11,13 @@ import org.spongepowered.configurate.serialize.SerializationException;
import static io.leangen.geantyref.GenericTypeReflector.erase;
-final class InnerClassInstanceFactory implements FieldDiscoverer.MutableInstanceFactory<Map<Field, Object>> {
+public final class InnerClassInstanceFactory implements FieldDiscoverer.MutableInstanceFactory<Map<Field, Object>> { // Sakura
private final InnerClassInstanceSupplier instanceSupplier;
private final FieldDiscoverer.MutableInstanceFactory<Map<Field, Object>> fallback;
private final AnnotatedType targetType;
- InnerClassInstanceFactory(final InnerClassInstanceSupplier instanceSupplier, final FieldDiscoverer.MutableInstanceFactory<Map<Field, Object>> fallback, final AnnotatedType targetType) {
+ public InnerClassInstanceFactory(final InnerClassInstanceSupplier instanceSupplier, final FieldDiscoverer.MutableInstanceFactory<Map<Field, Object>> fallback, final AnnotatedType targetType) { // Sakura
this.instanceSupplier = instanceSupplier;
this.fallback = fallback;
this.targetType = targetType;
diff --git a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java
index 8d8bc050441c02cf65dfcb6400978363d6b8ef10..5872095a811452037cc0772ba2a31bf9a795cc82 100644
--- a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java
+++ b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java
@@ -19,7 +19,7 @@ import static io.leangen.geantyref.GenericTypeReflector.erase;
* {@link ConfigurationPart}. Only 1 instance of each {@link ConfigurationPart} should be present for each instance
* of the field discoverer this is used in.
*/
-final class InnerClassInstanceSupplier implements CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> {
+public final class InnerClassInstanceSupplier implements CheckedFunction<AnnotatedType, @Nullable Supplier<Object>, SerializationException> { // Sakua - :<
private final Map<Class<?>, Object> instanceMap = new HashMap<>();
private final Map<Class<?>, Object> initialOverrides;
@@ -27,7 +27,7 @@ final class InnerClassInstanceSupplier implements CheckedFunction<AnnotatedType,
/**
* @param initialOverrides map of types to objects to preload the config objects with.
*/
- InnerClassInstanceSupplier(final Map<Class<?>, Object> initialOverrides) {
+ public InnerClassInstanceSupplier(final Map<Class<?>, Object> initialOverrides) { // Sakura
this.initialOverrides = initialOverrides;
}
diff --git a/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..9b5af05f7a4593eb44f36fff90d94e98d6999c7f
@@ -384,20 +385,16 @@ index 0000000000000000000000000000000000000000..ebdb73fa24fd2600925bf5664ceda202
+}
diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java
new file mode 100644
index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7e04d493e
index 0000000000000000000000000000000000000000..03b5e3243831b64b30c431134681ad37b220ed8e
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java
@@ -0,0 +1,240 @@
@@ -0,0 +1,222 @@
+package me.samsuik.sakura.configuration;
+
+import com.google.common.collect.Table;
+import com.mojang.logging.LogUtils;
+import io.leangen.geantyref.TypeToken;
+import io.papermc.paper.configuration.ConfigurationPart;
+import io.papermc.paper.configuration.Configurations;
+import io.papermc.paper.configuration.NestedSetting;
+import io.papermc.paper.configuration.PaperConfigurations;
+import io.papermc.paper.configuration.mapping.InnerClassFieldDiscoverer;
+import io.papermc.paper.configuration.*;
+import io.papermc.paper.configuration.serializer.*;
+import io.papermc.paper.configuration.serializer.collections.FastutilMapSerializer;
+import io.papermc.paper.configuration.serializer.collections.MapSerializer;
@@ -405,10 +402,9 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer;
+import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer;
+import io.papermc.paper.configuration.type.BooleanOrDefault;
+import io.papermc.paper.configuration.type.DoubleOrDefault;
+import io.papermc.paper.configuration.type.Duration;
+import io.papermc.paper.configuration.type.DurationOrDisabled;
+import io.papermc.paper.configuration.type.number.DoubleOr;
+import io.papermc.paper.configuration.type.number.IntOr;
+import io.papermc.paper.configuration.type.IntOr;
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Reference2LongMap;
@@ -516,8 +512,8 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+ }
+
+ @Override
+ public GlobalConfiguration initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException {
+ GlobalConfiguration configuration = super.initializeGlobalConfiguration(registryAccess);
+ public GlobalConfiguration initializeGlobalConfiguration() throws ConfigurateException {
+ GlobalConfiguration configuration = super.initializeGlobalConfiguration();
+ GlobalConfiguration.set(configuration);
+ return configuration;
+ }
@@ -544,7 +540,6 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+
+ @Override
+ protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) {
+ final RegistryAccess access = contextMap.require(REGISTRY_ACCESS);
+ return super.createWorldConfigLoaderBuilder(contextMap)
+ .defaultOptions(options -> options
+ .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap))
@@ -555,15 +550,14 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+ .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer())
+ .register(IntOr.Default.SERIALIZER)
+ .register(IntOr.Disabled.SERIALIZER)
+ .register(DoubleOr.Default.SERIALIZER)
+ .register(DoubleOrDefault.SERIALIZER)
+ .register(BooleanOrDefault.SERIALIZER)
+ .register(Duration.SERIALIZER)
+ .register(DurationOrDisabled.SERIALIZER)
+ .register(NbtPathSerializer.SERIALIZER)
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, access, Registries.ENTITY_TYPE, true))
+ .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true))
+ .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true))
+ .register(new RegistryHolderSerializer<>(new TypeToken<ConfiguredFeature<?, ?>>() {}, access, Registries.CONFIGURED_FEATURE, false))
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, Registries.ENTITY_TYPE, true))
+ .register(new RegistryValueSerializer<>(Item.class, Registries.ITEM, true))
+ .register(new RegistryValueSerializer<>(Block.class, Registries.BLOCK, true))
+ .register(new RegistryHolderSerializer<>(new TypeToken<ConfiguredFeature<?, ?>>() {}, Registries.CONFIGURED_FEATURE, false))
+ )
+ );
+ }
@@ -583,20 +577,10 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+ return ConfigurationPart.class.isAssignableFrom(erase(type));
+ }
+
+ @Override
+ protected int globalConfigVersion() {
+ return GlobalConfiguration.CURRENT_VERSION;
+ }
+
+ @Override
+ protected int worldConfigVersion() {
+ return WorldConfiguration.CURRENT_VERSION;
+ }
+
+ public void reloadConfigs(MinecraftServer server) {
+ try {
+ this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GlobalConfiguration.get()));
+ this.initializeWorldDefaultsConfiguration(server.registryAccess());
+ this.initializeWorldDefaultsConfiguration();
+ for (ServerLevel level : server.getAllLevels()) {
+ this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.sakuraConfig()));
+ }
@@ -606,15 +590,14 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+ }
+
+ private static ContextMap createWorldContextMap(ServerLevel level) {
+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.registryAccess());
+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location());
+ }
+
+ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey, RegistryAccess registryAccess) {
+ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey) {
+ return ContextMap.builder()
+ .put(WORLD_DIRECTORY, dir)
+ .put(WORLD_NAME, levelName)
+ .put(WORLD_KEY, worldKey)
+ .put(REGISTRY_ACCESS, registryAccess)
+ .build();
+ }
+
@@ -630,7 +613,7 @@ index 0000000000000000000000000000000000000000..74d4e257440842d40bfd72ff0741f1d7
+}
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..9bbd239ee24fb0d31d216287af480a70b93ca192
index 0000000000000000000000000000000000000000..46599109e55da0e4ce91c9b0c137d286a8cca78c
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
@@ -0,0 +1,171 @@
@@ -641,7 +624,7 @@ index 0000000000000000000000000000000000000000..9bbd239ee24fb0d31d216287af480a70
+import io.papermc.paper.configuration.ConfigurationPart;
+import io.papermc.paper.configuration.NestedSetting;
+import io.papermc.paper.configuration.PaperConfigurations;
+import io.papermc.paper.configuration.type.number.IntOr;
+import io.papermc.paper.configuration.type.IntOr;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
+import me.samsuik.sakura.entity.merge.MergeLevel;
+import me.samsuik.sakura.explosion.durable.DurableMaterial;
@@ -886,10 +869,10 @@ index 0000000000000000000000000000000000000000..141b15887ca075fef5d36ff15125b3e0
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 6e1c140d0d26728d64b827f6f3e5a450a37942c0..dbd88282420e73df44b7a2ea52a7abcbab7e51c9 100644
index d52e24f1d5073c7b534a7dd571f6f0128ca6280e..d0789c1e01255017e8a54e8b2e80f4c4dcf3dba4 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -306,6 +306,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -308,6 +308,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public final double[] recentTps = new double[ 3 ];
// Spigot end
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations;
@@ -897,19 +880,19 @@ index 6e1c140d0d26728d64b827f6f3e5a450a37942c0..dbd88282420e73df44b7a2ea52a7abcb
public static long currentTickLong = 0L; // Paper
public volatile Thread shutdownThread; // Paper
@@ -414,6 +415,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -410,6 +411,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
// Paper end
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
// CraftBukkit end
this.paperConfigurations = services.paperConfigurations(); // Paper
+ // Sakura start
+ final var sakuraConfigDirPath = ((File) options.valueOf("sakura-settings-directory")).toPath();
+ this.sakuraConfigurations = me.samsuik.sakura.configuration.SakuraConfigurations.setup(sakuraConfigDirPath);
+ // Sakura end
}
// CraftBukkit end
private void readScoreboard(DimensionDataStorage persistentStateManager) {
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index 58536aabf607015939a1326f80207c0a06eed8ff..102c5bb9a1702b06ed6418bfe9e4131993aabec3 100644
index a7e133f3495e9132a5fdae2c24f225e7b026295a..710dfc2ef53944bb5d6e6cc916dc4ca340b08350 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -221,6 +221,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
@@ -917,31 +900,31 @@ index 58536aabf607015939a1326f80207c0a06eed8ff..102c5bb9a1702b06ed6418bfe9e41319
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
// Paper end
+ // Sakura start
+ sakuraConfigurations.initializeGlobalConfiguration(this.registryAccess());
+ sakuraConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
+ sakuraConfigurations.initializeGlobalConfiguration();
+ sakuraConfigurations.initializeWorldDefaultsConfiguration();
+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this);
+ // Sakura end
this.setPvpAllowed(dedicatedserverproperties.pvp);
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 7c31f619a6e8e3539c547fc43d821d2cce7df7e7..033f24f57cca49bba4a36c50c4b1860645d95440 100644
index 45804711255f04110e9509df8d60900314aa10b7..174802d3ae69cc9a1f0ae16c078dca79be9d6335 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -698,7 +698,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -527,7 +527,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
// Holder holder = worlddimension.type(); // CraftBukkit - decompile error
// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess())), executor); // Paper - Async-Anti-Xray - Pass executor
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess())), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), minecraftserver.registryAccess())), executor); // Paper - Async-Anti-Xray - Pass executor
- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), executor); // Paper - Async-Anti-Xray - Pass executor
+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location())), executor); // Paper - Async-Anti-Xray - Pass executor
this.pvpMode = minecraftserver.isPvpAllowed();
this.convertable = convertable_conversionsession;
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 6403341f2e9d7ac4251336cb0bcc5d79dbb7bb0e..98086f40f83cc1af71dde06cb3b682edaddb0369 100644
index 973ecd50f9cb6b86c353586e84d15dcb118ccb60..1efb7002cd1efe4b22a101cb95251f10751634c1 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -177,6 +177,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -175,6 +175,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.paperConfig;
}
// Paper end
@@ -954,7 +937,7 @@ index 6403341f2e9d7ac4251336cb0bcc5d79dbb7bb0e..98086f40f83cc1af71dde06cb3b682ed
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
@@ -213,9 +219,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -274,9 +280,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract ResourceKey<LevelStem> getTypeKey();
@@ -967,18 +950,18 @@ index 6403341f2e9d7ac4251336cb0bcc5d79dbb7bb0e..98086f40f83cc1af71dde06cb3b682ed
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 8e47a8a4fde1eb390b4df5b02cb7bc9170bc1e12..2e6c093a381110105ad2f8c0fae8e23dee0fb88e 100644
index 0c1ce3c44490cc7b46a8b91833a85b57e6341d7d..56013a3c04b3aa3b8e4f0695d3c1c15d042eea20 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1037,6 +1037,7 @@ public final class CraftServer implements Server {
@@ -979,6 +979,7 @@ public final class CraftServer implements Server {
org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
this.console.paperConfigurations.reloadConfigs(this.console);
+ this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - missing comment above
for (ServerLevel world : this.console.getAllLevels()) {
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
@@ -1067,6 +1068,7 @@ public final class CraftServer implements Server {
@@ -1009,6 +1010,7 @@ public final class CraftServer implements Server {
this.reloadData();
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
@@ -987,10 +970,10 @@ index 8e47a8a4fde1eb390b4df5b02cb7bc9170bc1e12..2e6c093a381110105ad2f8c0fae8e23d
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index a74a8a027c99eef199c1a6a54232ac2c8ffb9d08..0bf24ee26eb96f02918fd82b5967681e3df2ce85 100644
index bfa091f72d6f477bcaf63d364639a1b4df9b1987..a563e1f3cd6090c22a075527f215e19bee92a411 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -174,6 +174,14 @@ public class Main {
@@ -173,6 +173,14 @@ public class Main {
.describedAs("Jar file");
// Paper end

View File

@@ -219,10 +219,10 @@ index 0000000000000000000000000000000000000000..fbd877356594f0cf8934452522cef434
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index dbd88282420e73df44b7a2ea52a7abcbab7e51c9..b5e2ae560431cd3ecfc780deb25488016c0ad0e7 100644
index d0789c1e01255017e8a54e8b2e80f4c4dcf3dba4..8cb71110c16789a9fbc0b7f76f76f9d4260e62b9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1744,6 +1744,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1573,6 +1573,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
this.profiler.pop();
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
@@ -231,10 +231,10 @@ index dbd88282420e73df44b7a2ea52a7abcbab7e51c9..b5e2ae560431cd3ecfc780deb2548801
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 98086f40f83cc1af71dde06cb3b682edaddb0369..646433f2db609f19dcc9da64232f3a3ab4a9d171 100644
index 1efb7002cd1efe4b22a101cb95251f10751634c1..4f0b68f33c4fca1fa9f983f966b3899e75b837b8 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -183,6 +183,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -181,6 +181,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.sakuraConfig;
}
// Sakura end
@@ -249,10 +249,10 @@ index 98086f40f83cc1af71dde06cb3b682edaddb0369..646433f2db609f19dcc9da64232f3a3a
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 38d842bc0fb7d9c39a3673983a643248e9563fe2..39f120071c5ebb939fb5effefd3f0beb0d5c4fb1 100644
index 8f0234296397ca2d4a607dcea6093c6c606dc7d2..62ab2c3607a636cf9d4c36286497f11f37a2ffda 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -237,6 +237,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
@@ -230,6 +230,13 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
// Paper end

View File

@@ -114,10 +114,10 @@ index 0000000000000000000000000000000000000000..6027e4741e2de7c6d3bd7b094c196a21
+}
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java
new file mode 100644
index 0000000000000000000000000000000000000000..d5bd47426a219a3825deaa0b62386c88d17b4aac
index 0000000000000000000000000000000000000000..aaffe63cec82e8d89a9b6cd6e1749ca983dc6a13
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java
@@ -0,0 +1,119 @@
@@ -0,0 +1,120 @@
+package me.samsuik.sakura.player.visibility;
+
+import me.samsuik.sakura.configuration.GlobalConfiguration;
@@ -127,6 +127,7 @@ index 0000000000000000000000000000000000000000..d5bd47426a219a3825deaa0b62386c88
+import net.kyori.adventure.text.format.NamedTextColor;
+import net.kyori.adventure.text.format.TextColor;
+import net.kyori.adventure.text.format.TextDecoration;
+import net.kyori.adventure.text.minimessage.MiniMessage;
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
@@ -227,10 +228,10 @@ index 0000000000000000000000000000000000000000..d5bd47426a219a3825deaa0b62386c88
+ String state = visibility.isEnabled(setting) ? "Enabled" : "Disabled";
+
+ // Send message to player
+ player.sendRichMessage(GlobalConfiguration.get().fps.message,
+ player.sendMessage(MiniMessage.miniMessage().deserialize(GlobalConfiguration.get().fps.message,
+ Placeholder.unparsed("name", setting.friendlyName()),
+ Placeholder.unparsed("state", state)
+ );
+ ));
+ },
+ slot
+ ));
@@ -238,7 +239,7 @@ index 0000000000000000000000000000000000000000..d5bd47426a219a3825deaa0b62386c88
+
+}
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
index e3f355c85eb7cc8c1683e3009502c10a5ed32daa..349e56d5caad3fc38e83eac6ffff83e2fb30eaa7 100644
index 7c6a6693760638a07b7c7c330aaeffd9fa454845..84299c755d4dd0fe507f57ac86b082d6c7de22a6 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java
@@ -16,7 +16,7 @@ public class ClientboundSectionBlocksUpdatePacket implements Packet<ClientGamePa
@@ -247,14 +248,14 @@ index e3f355c85eb7cc8c1683e3009502c10a5ed32daa..349e56d5caad3fc38e83eac6ffff83e2
private final short[] positions;
- private final BlockState[] states;
+ public final BlockState[] states; // Sakura - private -> public
private final boolean suppressLightUpdates;
public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) {
this.sectionPos = sectionPos;
public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section, boolean noLightingUpdates) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index b5e2ae560431cd3ecfc780deb25488016c0ad0e7..73dc4f245039805b635f9e89438104e3b7a93e7b 100644
index 8cb71110c16789a9fbc0b7f76f76f9d4260e62b9..f948882c013afa3df1f55d01eaf1c92f51f96aa0 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1745,6 +1745,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1574,6 +1574,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.profiler.pop();
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
worldserver.localConfig().expire(currentTickLong); // Sakura
@@ -263,12 +264,12 @@ index b5e2ae560431cd3ecfc780deb25488016c0ad0e7..73dc4f245039805b635f9e89438104e3
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index ecb09c74153349e78bb81d1188c282e4be4000bf..f3d4f8ba3bc148e28cab1a4d3def805081391ecc 100644
index fbe209a66c77c47935ad026dd3e45e682af91fd8..fd2109958a05348d72231fbb0ed8231d6c0e1eb1 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1434,6 +1434,22 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
}
// Paper end - check Y
@@ -1617,6 +1617,22 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
double d2 = d0 * d0;
boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player);
+ // Sakura start - visibility api
+ if (this.entity.isPrimedTNT && player.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.TNT_VISIBILITY)
@@ -287,13 +288,13 @@ index ecb09c74153349e78bb81d1188c282e4be4000bf..f3d4f8ba3bc148e28cab1a4d3def8050
+ }
+ // Sakura end
// CraftBukkit start - respect vanish API
if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
if (!player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) {
flag = false;
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af3063bfa5 100644
index b7fd8e70413c38923d0719aff803449e392383ac..2028e0371e933852635bbebc660e1555ba6a59dc 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -47,6 +47,13 @@ import net.minecraft.util.Mth;
@@ -49,6 +49,13 @@ import net.minecraft.util.Mth;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerVelocityEvent;
// CraftBukkit end
@@ -307,7 +308,7 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af
public class ServerEntity {
@@ -284,6 +291,18 @@ public class ServerEntity {
@@ -293,6 +300,19 @@ public class ServerEntity {
this.entity.startSeenByPlayer(player);
}
@@ -316,39 +317,40 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af
+ if (entity.isPrimedTNT && entityplayer.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
+ return new ClientboundAddEntityPacket(entity.getId(), entity.getUUID(),
+ entity.getX(), entity.getY(), entity.getZ(), 0, 0, EntityType.FALLING_BLOCK,
+ Block.getId(Blocks.TNT.defaultBlockState()), entity.getDeltaMovement(), entity.getYHeadRot());
+ Block.getId(Blocks.TNT.defaultBlockState()), entity.getDeltaMovement(), entity.getYHeadRot()
+ );
+ } else {
+ return entity.getAddEntityPacket();
+ }
+ }
+ // Sakura end
+
public void sendPairingData(ServerPlayer player, Consumer<Packet<ClientGamePacketListener>> sender) {
public void sendPairingData(Consumer<Packet<ClientGamePacketListener>> consumer, ServerPlayer entityplayer) { // CraftBukkit - add player
if (this.entity.isRemoved()) {
// CraftBukkit start - Remove useless error spam, just return
@@ -292,12 +311,19 @@ public class ServerEntity {
@@ -301,12 +321,20 @@ public class ServerEntity {
// CraftBukkit end
}
- Packet<ClientGamePacketListener> packet = this.entity.getAddEntityPacket();
+ Packet<ClientGamePacketListener> packet = this.createEntityPacket(this.entity, player); // Sakura - visibility api
+ Packet<ClientGamePacketListener> packet = this.createEntityPacket(this.entity, entityplayer); // Sakura - visibility api
this.yHeadRotp = Mth.floor(this.entity.getYHeadRot() * 256.0F / 360.0F);
sender.accept(packet);
consumer.accept(packet);
if (this.trackedDataValues != null) {
- sender.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), this.trackedDataValues));
consumer.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), this.trackedDataValues));
+ // Sakura start - visibility api
+ if (this.entity.isPrimedTNT && player.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
+ if (this.entity.isPrimedTNT && entityplayer.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
+ // Could modifying this break something elsewhere?
+ trackedDataValues.removeIf((data) -> data.id() == 8);
+ trackedDataValues.removeIf(data -> data.id() == 8);
+ }
+
+ sender.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), trackedDataValues));
+ consumer.accept(new ClientboundSetEntityDataPacket(this.entity.getId(), trackedDataValues));
+ // Sakura end
}
boolean flag = this.trackDelta;
@@ -367,6 +393,32 @@ public class ServerEntity {
@@ -390,6 +418,32 @@ public class ServerEntity {
}
}
@@ -367,8 +369,8 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af
+ }
+ }
+
+ for (var connection : trackedPlayers) {
+ var player = connection.getPlayer();
+ for (ServerPlayerConnection connection : trackedPlayers) {
+ ServerPlayer player = connection.getPlayer();
+
+ if (!this.entity.isPrimedTNT || !player.visibility.isToggled(Visibility.Setting.FLASHING_TNT)) {
+ connection.send(packet0);
@@ -381,7 +383,7 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af
private void sendDirtyEntityData() {
SynchedEntityData datawatcher = this.entity.getEntityData();
@@ -374,7 +426,7 @@ public class ServerEntity {
@@ -397,7 +451,7 @@ public class ServerEntity {
if (list != null) {
this.trackedDataValues = datawatcher.getNonDefaultValues();
@@ -391,31 +393,31 @@ index 35674f92a67f93382103c2766df4b678ba5c862f..83c4639c2bdca4dc4281d9f5eca104af
if (this.entity instanceof LivingEntity) {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 033f24f57cca49bba4a36c50c4b1860645d95440..5eee6ce1122ea21bd3ceaf4bb1ac365b9aa0d6da 100644
index 174802d3ae69cc9a1f0ae16c078dca79be9d6335..93386603037da776a7c6405293aa64f04c99a679 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1962,7 +1962,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1756,7 +1756,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
- if (entityplayer.distanceToSqr(x, y, z) < 4096.0D) {
+ if (entityplayer.distanceToSqr(x, y, z) < 4096.0D && !entityplayer.visibility.isToggled(me.samsuik.sakura.player.visibility.Visibility.Setting.EXPLOSIONS)) { // Sakura - visibility api
entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer), explosion.getBlockInteraction(), explosion.getSmallExplosionParticles(), explosion.getLargeExplosionParticles(), explosion.getExplosionSound()));
entityplayer.connection.send(new ClientboundExplodePacket(x, y, z, power, explosion.getToBlow(), (Vec3) explosion.getHitPlayers().get(entityplayer)));
}
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index be05a52be037042c6158100e2ce880b8ed415d53..3b2b020c5a756a9eb3f100277d96c95a10b2de29 100644
index 98df2463bf41fc736aa6a2b6ddf89e5abde6eb39..acc8be3069f5453701796ba4926d4fee7cfab9aa 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -261,6 +261,7 @@ public class ServerPlayer extends Player {
@@ -256,6 +256,7 @@ public class ServerPlayer extends Player {
public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper
// Paper end - mob spawning rework
public final int[] mobBackoffCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper - per player mob count backoff
public final com.destroystokyo.paper.util.PooledHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> cachedSingleMobDistanceMap;
// Paper end
+ public final me.samsuik.sakura.player.visibility.Visibility visibility = new me.samsuik.sakura.player.visibility.Visibility(); // Sakura - visiblity api
// CraftBukkit start
public String displayName;
@@ -567,6 +568,15 @@ public class ServerPlayer extends Player {
@@ -514,6 +515,15 @@ public class ServerPlayer extends Player {
this.respawnDimension = (ResourceKey) dataresult1.resultOrPartial(logger1::error).orElse(Level.OVERWORLD);
}
}
@@ -431,7 +433,7 @@ index be05a52be037042c6158100e2ce880b8ed415d53..3b2b020c5a756a9eb3f100277d96c95a
}
@@ -633,6 +643,13 @@ public class ServerPlayer extends Player {
@@ -580,6 +590,13 @@ public class ServerPlayer extends Player {
});
}
this.getBukkitEntity().setExtraData(nbt); // CraftBukkit
@@ -445,13 +447,13 @@ index be05a52be037042c6158100e2ce880b8ed415d53..3b2b020c5a756a9eb3f100277d96c95a
}
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index d28d0ef6105ddeb562ddf31ae9088739856941fc..0328179cb0134b54e61a4b60b98a780d9abeeaba 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -40,6 +40,23 @@ import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerResourcePackStatusEvent;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index aa287d7f37f38d938d195114408cb6dbda59063d..5b31f47fa33faa9ad7edc3259685d99f544996ab 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -246,6 +246,23 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.SmithingInventory;
// CraftBukkit end
+// Sakura start
+import com.mojang.datafixers.util.Pair;
@@ -471,9 +473,9 @@ index d28d0ef6105ddeb562ddf31ae9088739856941fc..0328179cb0134b54e61a4b60b98a780d
+import net.minecraft.world.level.block.piston.PistonHeadBlock;
+// Sakura end
public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener {
public class ServerGamePacketListenerImpl implements ServerPlayerConnection, TickablePacketListener, ServerGamePacketListener {
@@ -247,6 +264,61 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -2153,6 +2170,61 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
} else if (packet instanceof ClientboundSetDefaultSpawnPositionPacket) {
ClientboundSetDefaultSpawnPositionPacket packet6 = (ClientboundSetDefaultSpawnPositionPacket) packet;
this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld());
@@ -500,7 +502,7 @@ index d28d0ef6105ddeb562ddf31ae9088739856941fc..0328179cb0134b54e61a4b60b98a780d
+ packet = new ClientboundSetEquipmentPacket(equipment.getEntity(), slots);
+ } else if (packet instanceof ClientboundBlockEntityDataPacket blockdata
+ && player.visibility.isToggled(Setting.SPAWNERS)
+ && player.level().getBlockIfLoaded(blockdata.getPos()) == Blocks.SPAWNER) {
+ && player.level.getBlockIfLoaded(blockdata.getPos()) == Blocks.SPAWNER) {
+ packet = new ClientboundBlockUpdatePacket(blockdata.getPos(), Blocks.BLACK_STAINED_GLASS.defaultBlockState());
+ } else if (packet instanceof ClientboundBlockUpdatePacket updatePacket) {
+ if (player.visibility.isToggled(Setting.SPAWNERS) && updatePacket.blockState.getBlock() == Blocks.SPAWNER) {
@@ -534,25 +536,19 @@ index d28d0ef6105ddeb562ddf31ae9088739856941fc..0328179cb0134b54e61a4b60b98a780d
+ // Sakura end
}
// CraftBukkit end
boolean flag = !this.suspendFlushingOnServerThread || !this.server.isSameThread();
@@ -257,8 +329,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -2162,8 +2234,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
CrashReport crashreport = CrashReport.forThrowable(throwable, "Sending packet");
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Packet being sent");
+ // Sakura start - this has to be effectively final as we're modifying the packet above
+ var packetFinal = packet;
+ final Packet<?> finalPacket = packet; // Sakura - this has to be final as we're modifying the packet above
crashreportsystemdetails.setDetail("Packet class", () -> {
- return packet.getClass().getCanonicalName();
+ return packetFinal.getClass().getCanonicalName();
+ // Sakura end
+ return finalPacket.getClass().getCanonicalName(); // Sakura
});
throw new ReportedException(crashreport);
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 8b630fc4da8a7fda08c416e70c22463f04c3b6b5..6d9cf8bb81597489729b57a8834bf0293471fbea 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3114,6 +3114,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
@@ -3193,6 +3266,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
event.setCancelled(cancelled);
AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224
@@ -561,23 +557,23 @@ index 8b630fc4da8a7fda08c416e70c22463f04c3b6b5..6d9cf8bb81597489729b57a8834bf029
if (this.player.containerMenu != oldContainer) {
return;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1be10c57e374ad4018c08d96cfb69397a2f541d3..33a317696c62243952bbf686ff3e52a776672599 100644
index 280ee1838106201f5e3ba7753caced6d030f7e55..038ee401a003cbf0f96eee1f60fbb13bb6622b5b 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -535,6 +535,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -544,6 +544,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.teleportTo(worldserver, null);
}
// Paper end - make end portalling safe
+ public boolean isPrimedTNT; // Sakura
+ public boolean isFallingBlock; // Sakura
public boolean isLegacyTrackingEntity = false;
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 45c07733f03b5c11f6d8e820f65dc950c70d9a67..3ec931c9aa9e2857e0c24eeb47c1048ace05f6fe 100644
index 536856300da929c101f50da5827677bada5feb50..c7bf257a4c5a36c1a6b54fe23701d7169da13100 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -73,6 +73,7 @@ public class FallingBlockEntity extends Entity {
@@ -71,6 +71,7 @@ public class FallingBlockEntity extends Entity {
this.blockState = Blocks.SAND.defaultBlockState();
this.dropItem = true;
this.fallDamageMax = 40;
@@ -586,10 +582,10 @@ index 45c07733f03b5c11f6d8e820f65dc950c70d9a67..3ec931c9aa9e2857e0c24eeb47c1048a
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index c3e47426382296d650fa00ce0bc1a82bf23c7877..62a3cd512d473d5ed673386d5c15091a09426945 100644
index dfdf7e7fc1070975ec18fd215c724f4fc84d3705..23ba4fc50c0d45f1e5d666ff583b91665cab19f0 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -38,6 +38,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -28,6 +28,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public PrimedTnt(EntityType<? extends PrimedTnt> type, Level world) {
super(type, world);
this.blocksBuilding = true;
@@ -598,10 +594,10 @@ index c3e47426382296d650fa00ce0bc1a82bf23c7877..62a3cd512d473d5ed673386d5c15091a
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 646433f2db609f19dcc9da64232f3a3ab4a9d171..1d00a1499d9921ff66eaaf405fbbc0f44497fa0d 100644
index 4f0b68f33c4fca1fa9f983f966b3899e75b837b8..303c4a47b275e6c53a809c65482ad66734945622 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -226,6 +226,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -287,6 +287,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public abstract ResourceKey<LevelStem> getTypeKey();
@@ -611,11 +607,11 @@ index 646433f2db609f19dcc9da64232f3a3ab4a9d171..1d00a1499d9921ff66eaaf405fbbc0f4
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index da63b4050be25dcb91d04df8c2fcc643cbb0751d..2331c21068720528d87bdb9e3f1bb76ea6fd45dd 100644
index be64633c8bcee96f2ad5247525cac965b7b031b1..a8f7a0a2d4d44fb019ee26ce2b10dc7d33b3db9f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -494,6 +494,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().displayName = name == null ? this.getName() : name;
@@ -504,6 +504,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().displayName = name == null ? getName() : name;
}
+ // Sakura start - visiblity api

View File

@@ -1,134 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Tue, 1 Mar 2022 18:40:09 +0000
Subject: [PATCH] Optimise rayTracing
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index c790418ff4584af20db006a3e8770f261bab271e..87897b21c422a6301a08b388a69b3cec650bdfb5 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -295,7 +295,7 @@ public class Explosion {
}
}
- if (!collision.isEmpty() && collision.clip(from, to, currPos) != null) {
+ if (!collision.isEmpty() && collision.clipDirect(from, to, currPos)) { // Sakura
return true;
}
}
diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
index 6bd6385ad82481a099f3556ed2dbd3744888fc34..157dc1c815cb15818fd6fb103a9e806ca2f3d68c 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java
@@ -695,6 +695,110 @@ public abstract class VoxelShape {
// Paper end - optimise collisions
}
+ // Sakura start
+ // As of 1.20.2 paper has their own version of the pufferfish patch that this patch expanded on.
+ // A bit this patch is now obsolete such as simple AABB clipping.
+ // We will still use our method when a detailed hit result isn't required.
+ public boolean clipDirect(Vec3 start, Vec3 end, BlockPos pos) {
+ if (this.isEmpty) {
+ return false;
+ }
+
+ double vec3_x = end.x - start.x;
+ double vec3_y = end.y - start.y;
+ double vec3_z = end.z - start.z;
+ double vec3_lengthSqr = (vec3_x * vec3_x) + (vec3_y * vec3_y) + (vec3_z * vec3_z);
+
+ if (vec3_lengthSqr < 1.0E-7D) {
+ return false;
+ }
+
+ AABB singleAABB = this.singleAABBRepresentation;
+ //noinspection ConstantValue
+ if (singleAABB != null) {
+ return clipWithBBDirect(singleAABB, vec3_x, vec3_y, vec3_z, start, pos);
+ }
+
+ return clipWithBBsDirect(vec3_x, vec3_y, vec3_z, start, pos);
+ }
+
+ protected boolean clipWithBBDirect(AABB single, double deltaX, double deltaY, double deltaZ, Vec3 from, BlockPos pos) {
+ double posX = pos.getX();
+ double posY = pos.getY();
+ double posZ = pos.getZ();
+
+ return clipPointBB(single, from, posX, posY, posZ, deltaX, deltaY, deltaZ)
+ || clipInsideDirectBB(single, deltaX, deltaY, deltaZ, from, pos);
+ }
+
+ protected boolean clipWithBBsDirect(double deltaX, double deltaY, double deltaZ, Vec3 from, BlockPos pos) {
+ double posX = pos.getX();
+ double posY = pos.getY();
+ double posZ = pos.getZ();
+
+ for (AABB bb : toAabbs()) { // err
+ if (clipPointBB(bb, from, posX, posY, posZ, deltaX, deltaY, deltaZ)) {
+ return true;
+ }
+ }
+
+ return clipInsideDirectBBs(deltaX, deltaY, deltaZ, from, pos);
+ }
+
+ @SuppressWarnings("SuspiciousNameCombination")
+ protected static boolean clipPointBB(AABB box, Vec3 p, double posX, double posY, double posZ, double deltaX, double deltaY, double deltaZ) {
+ double minX = box.minX + posX;
+ double minY = box.minY + posY;
+ double minZ = box.minZ + posZ;
+ double maxX = box.maxX + posX;
+ double maxY = box.maxY + posY;
+ double maxZ = box.maxZ + posZ;
+
+ // todo: this could be simplified by using the centre of the bb
+ // if the bb dimensions are not the same then either scale or subtract from the result.
+ double closestX = deltaX > 1.0E-7D ? minX : maxX;
+ double closestY = deltaY > 1.0E-7D ? minY : maxY;
+ double closestZ = deltaZ > 1.0E-7D ? minZ : maxZ;
+
+ return clipPoint(deltaX, deltaY, deltaZ, closestX, minY, maxY, minZ, maxZ, p.x, p.y, p.z)
+ || clipPoint(deltaY, deltaZ, deltaX, closestY, minZ, maxZ, minX, maxX, p.y, p.z, p.x)
+ || clipPoint(deltaZ, deltaX, deltaY, closestZ, minX, maxX, minY, maxY, p.z, p.x, p.y);
+ }
+
+ private static boolean clipPoint(double deltaX, double deltaY, double deltaZ, double begin, double minX, double maxX, double minZ, double maxZ, double startX, double startY, double startZ) {
+ double d = (begin - startX) / deltaX;
+ double e = startY + d * deltaY;
+ double f = startZ + d * deltaZ;
+ return (d > 0.0D && d < 1.0) && (minX - 1.0E-7D < e && maxX + 1.0E-7D > e) && (minZ - 1.0E-7D < f && maxZ + 1.0E-7D > f);
+ }
+
+ // Absolutely horrendous code that takes a toll on all clip misses.
+ // This cannot be removed to maintain edge cases caused by this code existing in vanilla.
+ protected boolean clipInsideDirectBB(AABB single, double vec3_x, double vec3_y, double vec3_z, Vec3 start, BlockPos pos) {
+ double fromBehindX = start.x + (vec3_x * 0.001D);
+ double fromBehindY = start.y + (vec3_y * 0.001D);
+ double fromBehindZ = start.z + (vec3_z * 0.001D);
+
+ double fromBehindOffsetX = fromBehindX - (double) pos.getX();
+ double fromBehindOffsetY = fromBehindY - (double) pos.getY();
+ double fromBehindOffsetZ = fromBehindZ - (double) pos.getZ();
+
+ return single.contains(fromBehindOffsetX, fromBehindOffsetY, fromBehindOffsetZ);
+ }
+
+ protected boolean clipInsideDirectBBs(double vec3_x, double vec3_y, double vec3_z, Vec3 start, BlockPos pos) {
+ double fromBehindX = start.x + (vec3_x * 0.001D);
+ double fromBehindY = start.y + (vec3_y * 0.001D);
+ double fromBehindZ = start.z + (vec3_z * 0.001D);
+
+ int indexX = this.findIndex(Direction.Axis.X, fromBehindX - (double)pos.getX());
+ int indexY = this.findIndex(Direction.Axis.Y, fromBehindY - (double)pos.getY());
+ int indexZ = this.findIndex(Direction.Axis.Z, fromBehindZ - (double)pos.getZ());
+
+ return this.shape.isFullWide(indexX, indexY, indexZ);
+ }
+ // Sakura end
+
public Optional<Vec3> closestPointTo(Vec3 target) {
// Paper start - optimise collisions
if (this.isEmpty) {

View File

@@ -5,19 +5,20 @@ Subject: [PATCH] Reduce deltaMovement Allocations
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 33a317696c62243952bbf686ff3e52a776672599..8cae7a1ac496995ebe59ad88c56fbc424ca98930 100644
index 038ee401a003cbf0f96eee1f60fbb13bb6622b5b..8363fb274fafb06253272bc5706c8d209856e7ab 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1237,7 +1237,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.tryCheckInsideBlocks();
float f = this.getBlockSpeedFactor();
@@ -1166,8 +1166,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f));
+ this.multiplyDeltaMovement((double) f, 1.0D, (double) f); // Sakura - reduce movement allocations
this.tryCheckInsideBlocks();
float f2 = this.getBlockSpeedFactor();
-
- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f2, 1.0D, (double) f2));
+ this.multiplyDeltaMovement((double) f2, 1.0D, (double) f2); // Sakura - reduce movement allocations
// Paper start - remove expensive streams from here
boolean noneMatch = true;
AABB fireSearchBox = this.getBoundingBox().deflate(1.0E-6D);
@@ -2053,6 +2053,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1900,6 +1899,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
public void moveTo(double x, double y, double z, float yaw, float pitch) {
// Paper - cancel entity velocity if teleported
if (!preserveMotion) {
@@ -25,7 +26,7 @@ index 33a317696c62243952bbf686ff3e52a776672599..8cae7a1ac496995ebe59ad88c56fbc42
this.deltaMovement = Vec3.ZERO;
} else {
this.preserveMotion = false;
@@ -3455,29 +3456,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3218,29 +3218,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public void onAboveBubbleCol(boolean drag) {
@@ -67,7 +68,7 @@ index 33a317696c62243952bbf686ff3e52a776672599..8cae7a1ac496995ebe59ad88c56fbc42
this.resetFallDistance();
}
@@ -4471,16 +4476,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4225,16 +4229,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
vec3d = vec3d.normalize();
}
@@ -90,7 +91,7 @@ index 33a317696c62243952bbf686ff3e52a776672599..8cae7a1ac496995ebe59ad88c56fbc42
}
this.fluidHeight.put(tag, d1);
@@ -4551,11 +4559,53 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4301,11 +4308,53 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.chunkPosition;
}
@@ -144,7 +145,7 @@ index 33a317696c62243952bbf686ff3e52a776672599..8cae7a1ac496995ebe59ad88c56fbc42
synchronized (this.posLock) { // Paper
this.deltaMovement = velocity;
} // Paper
@@ -4566,7 +4616,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4316,7 +4365,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public void setDeltaMovement(double x, double y, double z) {
@@ -158,10 +159,10 @@ index 33a317696c62243952bbf686ff3e52a776672599..8cae7a1ac496995ebe59ad88c56fbc42
public final int getBlockX() {
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 3ec931c9aa9e2857e0c24eeb47c1048ace05f6fe..ec8488a2ab16950052a3bff04be6e3ecc3b44891 100644
index c7bf257a4c5a36c1a6b54fe23701d7169da13100..2c1b7fae5f2ebbcb6ec77db9435a8658a569c65e 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -145,7 +145,7 @@ public class FallingBlockEntity extends Entity {
@@ -143,7 +143,7 @@ public class FallingBlockEntity extends Entity {
++this.time;
if (!this.isNoGravity()) {
@@ -170,16 +171,16 @@ index 3ec931c9aa9e2857e0c24eeb47c1048ace05f6fe..ec8488a2ab16950052a3bff04be6e3ec
}
this.move(MoverType.SELF, this.getDeltaMovement());
@@ -192,7 +192,7 @@ public class FallingBlockEntity extends Entity {
@@ -190,7 +190,7 @@ public class FallingBlockEntity extends Entity {
} else {
BlockState iblockdata = this.level().getBlockState(blockposition);
BlockState iblockdata = this.level.getBlockState(blockposition);
- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
+ this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations
if (!iblockdata.is(Blocks.MOVING_PISTON)) {
if (!this.cancelDrop) {
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP)));
@@ -259,7 +259,7 @@ public class FallingBlockEntity extends Entity {
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level, blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP)));
@@ -257,7 +257,7 @@ public class FallingBlockEntity extends Entity {
}
}
@@ -189,38 +190,38 @@ index 3ec931c9aa9e2857e0c24eeb47c1048ace05f6fe..ec8488a2ab16950052a3bff04be6e3ec
}
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 62a3cd512d473d5ed673386d5c15091a09426945..12067c0372ad2803ffa2501a8296496a9ce7b292 100644
index 23ba4fc50c0d45f1e5d666ff583b91665cab19f0..480d3025977b8f3710e4252a9127a1c018f532d1 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -74,7 +74,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -63,7 +63,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
public void tick() {
if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
if (!this.isNoGravity()) {
- this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D));
+ this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations
}
this.move(MoverType.SELF, this.getDeltaMovement());
@@ -84,9 +84,9 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -73,9 +73,9 @@ public class PrimedTnt extends Entity implements TraceableEntity {
return;
}
// Paper end
- this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
+ this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations
if (this.onGround()) {
if (this.onGround) {
- this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
+ this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations
}
int i = this.getFuse() - 1;
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 9cd244090c294927a7a92c920854d2282ea3f021..3d4a75302d72bdbe47d0efbe08c89401dbe22a87 100644
index 185f7b1d4df59f5db7b85b529a2de6402630bf35..3cb5306a2ccfc1c53f90ecd56980d17be4042093 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -619,10 +619,11 @@ public class Explosion {
d8 *= d13;
d9 *= d13;
d10 *= d13;
@@ -280,10 +280,11 @@ public class Explosion {
d8 *= d14;
d9 *= d14;
d10 *= d14;
- Vec3 vec3d1 = new Vec3(d8, d9, d10);
+ // Sakura - moved down
@@ -232,10 +233,10 @@ index 9cd244090c294927a7a92c920854d2282ea3f021..3d4a75302d72bdbe47d0efbe08c89401
if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Disable explosion knockback
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
index e21867d3956078bb0db4ceed45e5811e9acd7377..c2daf4421b5838fe57dc16184c4a5a8c190fa641 100644
index 4f91e4832a94c3facbc711fcae4cb5ad540a5ca0..004f6b0d27b5fd55b1e9c2896417c739336a6293 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -468,7 +468,7 @@ public class Block extends BlockBehaviour implements ItemLike {
@@ -457,7 +457,7 @@ public class Block extends BlockBehaviour implements ItemLike {
}
public void updateEntityAfterFallOn(BlockGetter world, Entity entity) {
@@ -243,4 +244,4 @@ index e21867d3956078bb0db4ceed45e5811e9acd7377..c2daf4421b5838fe57dc16184c4a5a8c
+ entity.multiplyDeltaMovement(1.0D, 0.0D, 1.0D); // Sakura
}
public ItemStack getCloneItemStack(LevelReader world, BlockPos pos, BlockState state) {
public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) {

View File

@@ -5,15 +5,15 @@ Subject: [PATCH] Optional Force Position Updates
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 12067c0372ad2803ffa2501a8296496a9ce7b292..c187a2714d5580a2d8db54d270999aa618c4c878 100644
index 480d3025977b8f3710e4252a9127a1c018f532d1..fd0c9d4afe8ae71ab428d05c93bac45825765415 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -107,6 +107,14 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -96,6 +96,14 @@ public class PrimedTnt extends Entity implements TraceableEntity {
}
}
+ // Sakura start - configurable force position updates
+ if (level().sakuraConfig().cannons.tnt.forcePositionUpdates) {
+ if (level.sakuraConfig().cannons.tnt.forcePositionUpdates) {
+ forcePositionUpdate();
+ }
+ }
@@ -21,5 +21,5 @@ index 12067c0372ad2803ffa2501a8296496a9ce7b292..c187a2714d5580a2d8db54d270999aa6
+ private void forcePositionUpdate() {
+ // Sakura end
// Paper start - Optional prevent TNT from moving in water
if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) {
if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig().fixes.preventTntFromMovingInWater) {
/*

View File

@@ -5,85 +5,68 @@ Subject: [PATCH] Load Chunks on Movement
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
index ee0331a6bc40cdde08d926fd8eb1dc642630c2e5..19086bbfdf3a015eafec5ca868c8d2451f554ef0 100644
index a87f6380b2c387fb0cdd40d5087b5c93492e3c88..04305ed8e75c5e83d08392c0f7f431cb77ac272e 100644
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -1569,6 +1569,7 @@ public final class CollisionUtil {
public static final int COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS = 1 << 1;
public static final int COLLISION_FLAG_CHECK_BORDER = 1 << 2;
public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3;
+ public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura
public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
@@ -1619,11 +1620,21 @@ public final class CollisionUtil {
@@ -457,6 +457,7 @@ public final class CollisionUtil {
final int minChunkZ = minBlockZ >> 4;
final int maxChunkZ = maxBlockZ >> 4;
final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0;
+ final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura
final ServerChunkCache chunkSource = (ServerChunkCache)world.getChunkSource();
+ final boolean addTicket = loadChunks && entity != null && (entity.isPrimedTNT || entity.isFallingBlock); // Sakura
final ServerChunkCache chunkProvider;
if (getter instanceof WorldGenRegion) {
chunkProvider = null;
@@ -483,6 +484,16 @@ public final class CollisionUtil {
chunk = loadChunks ? chunkProvider.getChunk(currChunkX, currChunkZ, true) : chunkProvider.getChunkAtIfLoadedImmediately(currChunkX, currChunkZ);
}
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
final ChunkAccess chunk = loadChunks ? chunkSource.getChunk(currChunkX, currChunkZ, ChunkStatus.FULL, true) : chunkSource.getChunkAtIfLoadedImmediately(currChunkX, currChunkZ);
+ // Sakura start - keep chunks loaded on movement
+ if (addTicket && chunk instanceof net.minecraft.world.level.chunk.LevelChunk levelChunk && levelChunk.movementLoadTicketRequiresUpdate()) {
+ chunkSource.chunkMap.getDistanceManager().getChunkHolderManager().addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, currChunkX, currChunkZ, 33, CoordinateUtils.getChunkKey(currChunkX, currChunkZ));
+ if (addTicket && chunkProvider != null && chunk instanceof net.minecraft.world.level.chunk.LevelChunk levelChunk && levelChunk.movementLoadTicketRequiresUpdate()) {
+ chunkProvider.chunkMap.getDistanceManager().getChunkHolderManager().addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, currChunkX, currChunkZ, 33, CoordinateUtils.getChunkKey(currChunkX, currChunkZ));
+ // This is known to work, uncomment if any issues
+ // var pos = new net.minecraft.world.level.ChunkPos(currChunkX, currChunkZ);
+ // chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, pos, 33, pos.toLong());
+ levelChunk.updatedMovementLoadTicket();
+ }
+ // Sakura end
+
if (chunk == null) {
if ((collisionFlags & COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS) != 0) {
if (collidesWithUnloaded) {
if (checkOnly) {
diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java
index 658e63ebde81dc14c8ab5850fb246dc0aab25dea..f1ff1a67fee37ee7b241ceaa164fa4ee64d3767b 100644
index 97d1ff2af23bac14e67bca5896843325aaa5bfc1..c90b265a9cd92d40960d5513d9585e47d93fed3c 100644
--- a/src/main/java/net/minecraft/server/level/TicketType.java
+++ b/src/main/java/net/minecraft/server/level/TicketType.java
@@ -37,6 +37,7 @@ public class TicketType<T> {
public static final TicketType<Long> NON_FULL_SYNC_LOAD = create("non_full_sync_load", Long::compareTo);
public static final TicketType<ChunkPos> DELAY_UNLOAD = create("delay_unload", Comparator.comparingLong(ChunkPos::toLong), 1);
@@ -35,6 +35,7 @@ public class TicketType<T> {
public static final TicketType<Long> POI_LOAD = create("poi_load", Long::compareTo);
public static final TicketType<Unit> UNLOAD_COOLDOWN = create("unload_cooldown", (u1, u2) -> 0, 5 * 20);
// Paper end - rewrite chunk system
+ public static final TicketType<Long> ENTITY_MOVEMENT = create("entity_movement", Long::compareTo, 10 * 20); // Sakura
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
return new TicketType<>(name, argumentComparator, 0L);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8cae7a1ac496995ebe59ad88c56fbc424ca98930..218866882e3b08b1eb46b2a286bc7fe480db9c74 100644
index 8363fb274fafb06253272bc5706c8d209856e7ab..f6f9f101899121afcf9df1426b56e49011a5bbcd 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -537,6 +537,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -546,6 +546,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
// Paper end - make end portalling safe
public boolean isPrimedTNT; // Sakura
public boolean isFallingBlock; // Sakura
+ // Sakura start
+ protected boolean loadChunks = false;
+
+ private int getExtraCollisionFlags() {
+ int flags = 0;
+
+ if (this.loadChunks) {
+ flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
+ }
+
+ return flags;
+ }
+ // Sakura end
+ protected boolean loadChunks = false; // Sakura - load chunks on movement
public boolean isLegacyTrackingEntity = false;
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1393,7 +1394,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
}
@@ -1498,7 +1511,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
- io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks,
+ io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, this.loadChunks, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, // Sakura
false, false, null, null);
io.papermc.paper.util.CollisionUtil.getCollisions(
world, this, collisionBox, potentialCollisionsVoxel, potentialCollisionsBB,
- io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER,
+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura
null, null
);
@@ -4886,7 +4899,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (collidingWithWorldBorder = io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) { // Paper - this line *is* correct, ignore the IDE warning about assignments being used as a condition
@@ -4618,7 +4619,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@Override
public boolean isAlwaysTicking() {
@@ -93,10 +76,10 @@ index 8cae7a1ac496995ebe59ad88c56fbc424ca98930..218866882e3b08b1eb46b2a286bc7fe4
public boolean mayInteract(Level world, BlockPos pos) {
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index ec8488a2ab16950052a3bff04be6e3ecc3b44891..1a018e1d2b6dd93be5e6209a2d52eade0b356f58 100644
index 2c1b7fae5f2ebbcb6ec77db9435a8658a569c65e..0bab2d4397dd4f24755a38e4c14320bbfda62425 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -74,6 +74,7 @@ public class FallingBlockEntity extends Entity {
@@ -72,6 +72,7 @@ public class FallingBlockEntity extends Entity {
this.dropItem = true;
this.fallDamageMax = 40;
this.isFallingBlock = true; // Sakura
@@ -105,10 +88,10 @@ index ec8488a2ab16950052a3bff04be6e3ecc3b44891..1a018e1d2b6dd93be5e6209a2d52eade
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index c187a2714d5580a2d8db54d270999aa618c4c878..0be7c39fbb19a0cdca3f5dc779c2690df5f08647 100644
index fd0c9d4afe8ae71ab428d05c93bac45825765415..6e842da33ca43c8e22f35c59afd41ddff629c28c 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -39,6 +39,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -29,6 +29,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
super(type, world);
this.blocksBuilding = true;
this.isPrimedTNT = true; // Sakura
@@ -117,13 +100,13 @@ index c187a2714d5580a2d8db54d270999aa618c4c878..0be7c39fbb19a0cdca3f5dc779c2690d
public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index fa170cc1ce7011d201295b89718292d696c7fc24..2f48ac198610ee2a379bff4e056a6afe5f7f8a04 100644
index d190bad5d287766ed4165ed827d9901a9d878687..e9aa742b01bf89269b477d3a858cfe7b9c3f410f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -218,6 +218,17 @@ public class LevelChunk extends ChunkAccess {
@@ -354,6 +354,17 @@ public class LevelChunk extends ChunkAccess {
}
}
// Paper end
// Paper end - optimise checkDespawn
+ // Sakura start
+ private long lastMovementLoadTicket = 0;
+

View File

@@ -418,10 +418,10 @@ index 0000000000000000000000000000000000000000..8a94b1a2cb1ff57664c97a7b471c99ec
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 73dc4f245039805b635f9e89438104e3b7a93e7b..39081c0052a333580b22da10310d86de73693b2c 100644
index f948882c013afa3df1f55d01eaf1c92f51f96aa0..0a5aa9404f3c6af54d6130f883a7b334977ed108 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1126,6 +1126,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1098,6 +1098,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
@@ -429,27 +429,27 @@ index 73dc4f245039805b635f9e89438104e3b7a93e7b..39081c0052a333580b22da10310d86de
// Paper End
// Spigot End
@@ -1192,6 +1193,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
curTime = Util.getNanos();
@@ -1154,6 +1155,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
{
final long diff = curTime - tickSection;
java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
+ tickTracking.secondSample(levels.values(), currentTps.doubleValue()); // Sakura
tps1.add(currentTps, diff);
tps5.add(currentTps, diff);
tps15.add(currentTps, diff);
@@ -1219,6 +1221,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.tickServer(flag ? () -> {
return false;
} : this::haveTime);
@@ -1177,6 +1179,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.startMetricsRecordingTick();
this.profiler.push("tick");
this.tickServer(this::haveTime);
+ tickTracking.tickSample((System.nanoTime() - curTime) / 1_000_000L); // Sakura
this.profiler.popPush("nextTickWait");
this.mayHaveDelayedTasks = true;
this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + i, this.nextTickTimeNanos);
this.delayedTasksMaxNextTickTime = Math.max(Util.getMillis() + 50L, this.nextTickTime);
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
index 6e212f672579a3e08dc362c287be59ca5170d717..bc0f6555e9c3fcccf2d9a3bd47c76e6433dd6bff 100644
index ca84eddbdb1e198b899750e5f6b3eafd25ce970f..ff10d085124ce4dd1eb2dea134535acd9d688a02 100644
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -74,6 +74,12 @@ public class ServerChunkCache extends ChunkSource {
@@ -77,6 +77,12 @@ public class ServerChunkCache extends ChunkSource {
private final LevelChunk[] lastLoadedChunks = new LevelChunk[4 * 4];
@@ -463,10 +463,10 @@ index 6e212f672579a3e08dc362c287be59ca5170d717..bc0f6555e9c3fcccf2d9a3bd47c76e64
return x & 3 | ((z & 3) << 2);
}
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index c33c9cb3a0e574e5284e48ffaf8d0945061ea388..f48eaebb0f9a10fb77e85619b2d2a4996e461195 100644
index 93386603037da776a7c6405293aa64f04c99a679..4a19da041971d9f9031af70ae39798233287b3c9 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -194,7 +194,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -190,7 +190,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
public final ServerChunkCache chunkSource;
private final MinecraftServer server;
public final PrimaryLevelData serverLevelData; // CraftBukkit - type
@@ -493,7 +493,7 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..1fcce60790cab6e7b137464ccd87e678
// Paper - replace with better logic, do not delay removals
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 68602dfb171d47e47fd0710b4324013ef05214d0..6f21afd958fbb7037611ca01458b6848b93cc208 100644
index 612c3169c3463d702b85975e1db79ae6e47d60d0..2063a6c6ab0786aee51be027950c2a936f593b55 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -283,7 +283,7 @@ public class SpigotConfig

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise New Liquid Level
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..6d59f8b68d644cb43939bcdf5239fa1caf54ed47 100644
index bf4de7b8fd630c596e096a411a8c84c64c13ebf7..83b74887363164c3b938e8fc9741d502921e73d1 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -137,7 +137,7 @@ public abstract class FlowingFluid extends Fluid {
@@ -135,7 +135,7 @@ public abstract class FlowingFluid extends Fluid {
BlockState iblockdata = world.getBlockState(fluidPos);
BlockPos blockposition1 = fluidPos.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
@@ -17,7 +17,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..6d59f8b68d644cb43939bcdf5239fa1c
if (this.canSpreadTo(world, fluidPos, iblockdata, Direction.DOWN, blockposition1, iblockdata1, world.getFluidState(blockposition1), fluid1.getType())) {
// CraftBukkit start
@@ -197,6 +197,25 @@ public abstract class FlowingFluid extends Fluid {
@@ -195,6 +195,25 @@ public abstract class FlowingFluid extends Fluid {
}
protected FluidState getNewLiquid(Level world, BlockPos pos, BlockState state) {
@@ -43,7 +43,7 @@ index e21f4c5aff3a8e97101f6efc1349fbecf326b5ea..6d59f8b68d644cb43939bcdf5239fa1c
int i = 0;
int j = 0;
Iterator iterator = Direction.Plane.HORIZONTAL.iterator();
@@ -227,17 +246,10 @@ public abstract class FlowingFluid extends Fluid {
@@ -225,17 +244,10 @@ public abstract class FlowingFluid extends Fluid {
}
}

View File

@@ -19,18 +19,18 @@ The current packets modified/obfuscated are the following:
# with packets instead of every single player within tracking distance
diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06ff0f9e15 100644
index ff7ba7a161cfed7521354bc6e3f21ba0f17f3760..bced07e0b6075cf0fa10f5498451ec53600ce02f 100644
--- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
+++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java
@@ -39,6 +39,7 @@ public class SynchedEntityData {
private static final int GROW_FACTOR = 8;
private SynchedEntityData.DataItem<?>[] itemsArray = new SynchedEntityData.DataItem<?>[DEFAULT_ENTRY_COUNT];
// Paper end
@@ -34,6 +34,7 @@ public class SynchedEntityData {
private final Int2ObjectMap<SynchedEntityData.DataItem<?>> itemsById = new Int2ObjectOpenHashMap();
// private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Spigot - not required
private boolean isDirty;
+ private boolean isForeignDirty; // Slice
public SynchedEntityData(Entity trackedEntity) {
this.entity = trackedEntity;
@@ -165,6 +166,16 @@ public class SynchedEntityData {
@@ -139,6 +140,16 @@ public class SynchedEntityData {
}
public <T> void set(EntityDataAccessor<T> key, T value, boolean force) {
@@ -47,7 +47,7 @@ index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06
SynchedEntityData.DataItem<T> datawatcher_item = this.getItem(key);
if (force || ObjectUtils.notEqual(value, datawatcher_item.getValue())) {
@@ -174,6 +185,12 @@ public class SynchedEntityData {
@@ -148,6 +159,12 @@ public class SynchedEntityData {
this.isDirty = true;
}
@@ -60,7 +60,7 @@ index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06
}
// CraftBukkit start - add method from above
@@ -183,6 +200,12 @@ public class SynchedEntityData {
@@ -157,6 +174,12 @@ public class SynchedEntityData {
}
// CraftBukkit end
@@ -73,7 +73,7 @@ index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06
public boolean isDirty() {
return this.isDirty;
}
@@ -215,6 +238,29 @@ public class SynchedEntityData {
@@ -189,6 +212,29 @@ public class SynchedEntityData {
return list;
}
@@ -103,7 +103,7 @@ index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06
@Nullable
public List<SynchedEntityData.DataValue<?>> getNonDefaultValues() {
List<SynchedEntityData.DataValue<?>> list = null;
@@ -339,11 +385,14 @@ public class SynchedEntityData {
@@ -296,11 +342,14 @@ public class SynchedEntityData {
T value;
private final T initialValue;
private boolean dirty;
@@ -118,7 +118,7 @@ index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06
}
public EntityDataAccessor<T> getAccessor() {
@@ -370,6 +419,35 @@ public class SynchedEntityData {
@@ -327,6 +376,35 @@ public class SynchedEntityData {
return this.initialValue.equals(this.value);
}
@@ -155,10 +155,10 @@ index a043c382c37058032548a5192e17f5f816abe5a6..8e84afc92bef8192320dfe405609bf06
return SynchedEntityData.DataValue.create(this.accessor, this.value);
}
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index 83c4639c2bdca4dc4281d9f5eca104af3063bfa5..f7d8aaededd39ce52a9d0105f66fd759635b5288 100644
index 2028e0371e933852635bbebc660e1555ba6a59dc..18c5473923f8ce53be59b2496f347b31934ecc92 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -148,7 +148,7 @@ public class ServerEntity {
@@ -149,7 +149,7 @@ public class ServerEntity {
}
}
@@ -167,7 +167,7 @@ index 83c4639c2bdca4dc4281d9f5eca104af3063bfa5..f7d8aaededd39ce52a9d0105f66fd759
int i;
int j;
@@ -395,11 +395,23 @@ public class ServerEntity {
@@ -420,11 +420,23 @@ public class ServerEntity {
}
// Sakura start - visibility api
@@ -193,7 +193,7 @@ index 83c4639c2bdca4dc4281d9f5eca104af3063bfa5..f7d8aaededd39ce52a9d0105f66fd759
var copyOfDirtyItems = Lists.newArrayList(packedValues);
copyOfDirtyItems.removeIf((data) -> data.id() == 8);
@@ -426,7 +438,7 @@ public class ServerEntity {
@@ -451,7 +463,7 @@ public class ServerEntity {
if (list != null) {
this.trackedDataValues = datawatcher.getNonDefaultValues();
@@ -203,10 +203,10 @@ index 83c4639c2bdca4dc4281d9f5eca104af3063bfa5..f7d8aaededd39ce52a9d0105f66fd759
if (this.entity instanceof LivingEntity) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 218866882e3b08b1eb46b2a286bc7fe480db9c74..7fad22ee8a24399acbae6a9bc07ad5de39d41020 100644
index f6f9f101899121afcf9df1426b56e49011a5bbcd..7e2a9c3b356e2ac46c1a0badb82c444def901045 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3399,7 +3399,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3149,7 +3149,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID);
return;
}
@@ -216,10 +216,10 @@ index 218866882e3b08b1eb46b2a286bc7fe480db9c74..7fad22ee8a24399acbae6a9bc07ad5de
}
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 1a018e1d2b6dd93be5e6209a2d52eade0b356f58..0cf39ea76902e62b712057fe1bb80e3af8190fc4 100644
index 0bab2d4397dd4f24755a38e4c14320bbfda62425..aa88218a06366ade96797d370ef08baafb9dfa61 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -110,7 +110,7 @@ public class FallingBlockEntity extends Entity {
@@ -108,7 +108,7 @@ public class FallingBlockEntity extends Entity {
}
public void setStartPos(BlockPos pos) {
@@ -229,10 +229,10 @@ index 1a018e1d2b6dd93be5e6209a2d52eade0b356f58..0cf39ea76902e62b712057fe1bb80e3a
public BlockPos getStartPos() {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 0be7c39fbb19a0cdca3f5dc779c2690df5f08647..cc30c119f519e7cd947ab40beae56e493e977176 100644
index 6e842da33ca43c8e22f35c59afd41ddff629c28c..6097d495252c9c7ee54f7017ca2b39d42e5046fe 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -196,7 +196,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -171,7 +171,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
}
public void setFuse(int fuse) {
@@ -242,10 +242,10 @@ index 0be7c39fbb19a0cdca3f5dc779c2690df5f08647..cc30c119f519e7cd947ab40beae56e49
public int getFuse() {
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index ccc1caafb0ada52c7b99b7358253826f5390843e..ad8114246633498c22d615f1bc669ea83f97c930 100644
index 0629c471d38a77c44fc1c86ccdfcb0690f61ca17..c125c963c1f0266fccf7a83ccd01641d5ea2a980 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -644,7 +644,7 @@ public abstract class Player extends LivingEntity {
@@ -641,7 +641,7 @@ public abstract class Player extends LivingEntity {
public void increaseScore(int score) {
int j = this.getScore();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Use Optimised TrackedEntityMap
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index f3d4f8ba3bc148e28cab1a4d3def805081391ecc..24e0eaf25b2b366fd0e63a530c90f233c11d1bca 100644
index fd2109958a05348d72231fbb0ed8231d6c0e1eb1..e6d9ff38f2674e00b7e246015d2b3bda5eb7a445 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -251,7 +251,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -298,7 +298,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
// Paper - rewrite chunk system
this.tickingGenerated = new AtomicInteger();
this.playerMap = new PlayerMap();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Copy EntityList methods to BasicEntityList
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
index 7e8dc9e8f381abfdcce2746edc93122d623622d1..2d79633d86007c7d40eecf5f9271fa3f351b72b5 100644
index f597d65d56964297eeeed6c7e77703764178fee0..1d6b96fd6dae9524c31e71a778351e8b2d325b7f 100644
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
@@ -25,6 +25,8 @@ import java.util.Iterator;
@@ -24,6 +24,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;
@@ -17,7 +17,7 @@ index 7e8dc9e8f381abfdcce2746edc93122d623622d1..2d79633d86007c7d40eecf5f9271fa3f
public final class ChunkEntitySlices {
protected final int minSection;
@@ -303,6 +305,13 @@ public final class ChunkEntitySlices {
@@ -298,6 +300,13 @@ public final class ChunkEntitySlices {
protected static final class BasicEntityList<E extends Entity> {
@@ -31,7 +31,7 @@ index 7e8dc9e8f381abfdcce2746edc93122d623622d1..2d79633d86007c7d40eecf5f9271fa3f
protected static final Entity[] EMPTY = new Entity[0];
protected static final int DEFAULT_CAPACITY = 4;
@@ -325,55 +334,52 @@ public final class ChunkEntitySlices {
@@ -320,55 +329,52 @@ public final class ChunkEntitySlices {
return this.size;
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add utility methods to EntitySlices
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
index 2d79633d86007c7d40eecf5f9271fa3f351b72b5..d917a19c838ed3d74322abd85e1f737e852b5d7b 100644
index 1d6b96fd6dae9524c31e71a778351e8b2d325b7f..ce231d8b230d4983b21c597357c0b22377e4bcca 100644
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
@@ -251,6 +251,12 @@ public final class ChunkEntitySlices {
@@ -246,6 +246,12 @@ public final class ChunkEntitySlices {
return true;
}
@@ -21,7 +21,7 @@ index 2d79633d86007c7d40eecf5f9271fa3f351b72b5..d917a19c838ed3d74322abd85e1f737e
public void getHardCollidingEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
this.hardCollidingEntities.getEntities(except, box, into, predicate);
@@ -429,6 +435,18 @@ public final class ChunkEntitySlices {
@@ -424,6 +430,18 @@ public final class ChunkEntitySlices {
this.nonEmptyBitset[sectionIndex >>> 6] ^= (1L << (sectionIndex & (Long.SIZE - 1)));
}
}
@@ -41,10 +41,10 @@ index 2d79633d86007c7d40eecf5f9271fa3f351b72b5..d917a19c838ed3d74322abd85e1f737e
public void getEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
if (this.count == 0) {
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 8fd4d63fdbff9c454d903f4797ec9281df7266fc..9ef1d77dd87793577223402808ff7a6baad42ee4 100644
index 303c4a47b275e6c53a809c65482ad66734945622..45e6a37fc304d89cc7b152bcb3ff5ae0f2e3bde5 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -228,6 +228,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -289,6 +289,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api

View File

@@ -6,23 +6,20 @@ Subject: [PATCH] Store Entity Data/State
diff --git a/src/main/java/me/samsuik/sakura/entity/EntityState.java b/src/main/java/me/samsuik/sakura/entity/EntityState.java
new file mode 100644
index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b98f4e8d10
index 0000000000000000000000000000000000000000..c579b375994652f2331a454210986bcc4b5eddcc
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/entity/EntityState.java
@@ -0,0 +1,41 @@
@@ -0,0 +1,37 @@
+package me.samsuik.sakura.entity;
+
+import net.minecraft.core.BlockPos;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.phys.AABB;
+import net.minecraft.world.phys.Vec3;
+
+import java.util.Optional;
+
+public record EntityState(Vec3 position, Vec3 momentum, AABB bb, Vec3 stuckSpeed, Optional<BlockPos> supportingPos, boolean onGround, float fallDistance) {
+public record EntityState(Vec3 position, Vec3 momentum, AABB bb, Vec3 stuckSpeed, boolean onGround, float fallDistance) {
+
+ public static EntityState of(Entity entity) {
+ return new EntityState(entity.position(), entity.getDeltaMovement(), entity.getBoundingBox(), entity.stuckSpeedMultiplier(), entity.mainSupportingBlockPos, entity.onGround(), entity.fallDistance);
+ return new EntityState(entity.position(), entity.getDeltaMovement(), entity.getBoundingBox(), entity.stuckSpeedMultiplier(), entity.onGround, entity.fallDistance);
+ }
+
+ public void apply(Entity entity) {
@@ -33,7 +30,6 @@ index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b9
+ //noinspection DataFlowIssue
+ entity.makeStuckInBlock(null, stuckSpeed);
+ entity.onGround = onGround;
+ entity.mainSupportingBlockPos = supportingPos;
+ entity.fallDistance = fallDistance;
+ }
+
@@ -52,13 +48,13 @@ index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b9
+
+}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 7fad22ee8a24399acbae6a9bc07ad5de39d41020..393e951102c49d45a135b37ccd876283c5355710 100644
index 7e2a9c3b356e2ac46c1a0badb82c444def901045..1bd5db8e0919d126d18e250bb1cb35cb96d63f5c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -550,6 +550,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return flags;
}
// Sakura end
@@ -547,6 +547,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
public boolean isPrimedTNT; // Sakura
public boolean isFallingBlock; // Sakura
protected boolean loadChunks = false; // Sakura - load chunks on movement
+ // Sakura start - entity state (from start of tick)
+ private @Nullable me.samsuik.sakura.entity.EntityState entityState = null;
+
@@ -88,13 +84,13 @@ index 7fad22ee8a24399acbae6a9bc07ad5de39d41020..393e951102c49d45a135b37ccd876283
+ }
+ // Sakura end
public boolean isLegacyTrackingEntity = false;
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index bf361855ecf8c1d5dee2e735278243b836bf0f2a..902ec524d209ab56a6dadb260559910c76dbf96b 100644
index 45e6a37fc304d89cc7b152bcb3ff5ae0f2e3bde5..9bf8b4d67a5a2295ad994fd6fdb4df77c84c2486 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -1342,6 +1342,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -949,6 +949,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public <T extends Entity> void guardEntityTick(Consumer<T> tickConsumer, T entity) {
try {

View File

@@ -138,10 +138,10 @@ index 0000000000000000000000000000000000000000..90f36b2d3847e058cfa2b748838fc6ea
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 39081c0052a333580b22da10310d86de73693b2c..08e8de35fddcd54c5f466edb264aa454a5935c42 100644
index 0a5aa9404f3c6af54d6130f883a7b334977ed108..9a15ce8aef1c52b915ea9131a31e60065d667a4a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1749,6 +1749,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1578,6 +1578,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
worldserver.localConfig().expire(currentTickLong); // Sakura
worldserver.minimalTNT.clear(); // Sakura - visibility api
@@ -150,18 +150,18 @@ index 39081c0052a333580b22da10310d86de73693b2c..08e8de35fddcd54c5f466edb264aa454
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 431af1cc839e89e5d9831cd8533971a50a01d7c8..620966965f3d73cd6fdbf03dabe2605c45d51d57 100644
index 4a19da041971d9f9031af70ae39798233287b3c9..3ace813ccce8b836edef76a16b92ca99762af7b1 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -899,6 +899,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -708,6 +708,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
org.spigotmc.ActivationRange.activateEntities(this); // Spigot
this.timings.entityTick.startTiming(); // Spigot
timings.entityTick.startTiming(); // Spigot
+ Entity[] previousEntity = new Entity[1]; // Sakura
this.entityTickList.forEach((entity) -> {
if (!entity.isRemoved()) {
if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed
@@ -918,6 +919,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -727,6 +728,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
entity.stopRiding();
}
@@ -178,10 +178,10 @@ index 431af1cc839e89e5d9831cd8533971a50a01d7c8..620966965f3d73cd6fdbf03dabe2605c
this.guardEntityTick(this::tickNonPassenger, entity);
gameprofilerfiller.pop();
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 393e951102c49d45a135b37ccd876283c5355710..8562e2794fc2cc29e55d34186480e820bffe1237 100644
index 1bd5db8e0919d126d18e250bb1cb35cb96d63f5c..bc7a65dc8c8718f2e02249ff251764a4fb13f9a7 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -578,6 +578,107 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -575,6 +575,107 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return BlockPos.asLong(v.getBlockX(), v.getBlockY(), v.getBlockZ());
}
// Sakura end
@@ -287,9 +287,9 @@ index 393e951102c49d45a135b37ccd876283c5355710..8562e2794fc2cc29e55d34186480e820
+ }
+ // Sakura end
public boolean isLegacyTrackingEntity = false;
@@ -656,6 +757,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -621,6 +722,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.getEntityData().registrationLocked = true; // Spigot
this.setPos(0.0D, 0.0D, 0.0D);
this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions);
@@ -297,19 +297,19 @@ index 393e951102c49d45a135b37ccd876283c5355710..8562e2794fc2cc29e55d34186480e820
}
public boolean isColliding(BlockPos pos, BlockState state) {
@@ -2521,6 +2623,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
nbttagcompound.putBoolean("Paper.FreezeLock", true);
@@ -2337,6 +2439,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
nbt.putBoolean("Paper.FreezeLock", true);
}
// Paper end
+ // Sakura start
+ if (stacked > 0) {
+ nbttagcompound.putInt("Sakura.Stacked", stacked);
+ nbt.putInt("Sakura.Stacked", stacked);
+ }
+ // Sakura end
return nbttagcompound;
return nbt;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2668,6 +2775,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2505,6 +2612,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
freezeLocked = nbt.getBoolean("Paper.FreezeLock");
}
// Paper end
@@ -321,7 +321,7 @@ index 393e951102c49d45a135b37ccd876283c5355710..8562e2794fc2cc29e55d34186480e820
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
@@ -4882,6 +4994,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4619,6 +4731,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return;
}
// Paper end - rewrite chunk system
@@ -330,14 +330,14 @@ index 393e951102c49d45a135b37ccd876283c5355710..8562e2794fc2cc29e55d34186480e820
+ level.mergeHistory.markPositions(this);
+ }
+ // Sakura end
final boolean alreadyRemoved = this.removalReason != null;
if (this.removalReason == null) {
this.removalReason = reason;
}
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 0cf39ea76902e62b712057fe1bb80e3af8190fc4..3a0d82cd7a0d7ec20138effd6d84eee60ffab788 100644
index aa88218a06366ade96797d370ef08baafb9dfa61..2113c330d309819c4b24b5ab63574ae481e2f77d 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -132,6 +132,58 @@ public class FallingBlockEntity extends Entity {
@@ -130,6 +130,58 @@ public class FallingBlockEntity extends Entity {
return !this.isRemoved();
}
@@ -360,7 +360,7 @@ index 0cf39ea76902e62b712057fe1bb80e3af8190fc4..3a0d82cd7a0d7ec20138effd6d84eee6
+
+ while (stacked-- >= 1) {
+ // Unlike PrimedTnt we have to try respawn each stacked entity
+ FallingBlockEntity fallingBlock = new FallingBlockEntity(EntityType.FALLING_BLOCK, level());
+ FallingBlockEntity fallingBlock = new FallingBlockEntity(EntityType.FALLING_BLOCK, level);
+
+ // Try to stack the falling block
+ this.entityState().apply(fallingBlock);
@@ -396,19 +396,19 @@ index 0cf39ea76902e62b712057fe1bb80e3af8190fc4..3a0d82cd7a0d7ec20138effd6d84eee6
@Override
public void tick() {
// Paper start - fix sand duping
@@ -211,6 +263,7 @@ public class FallingBlockEntity extends Entity {
@@ -209,6 +261,7 @@ public class FallingBlockEntity extends Entity {
return;
}
// CraftBukkit end
+ if (this.respawnMerged()) return; // Sakura
if (this.level().setBlock(blockposition, this.blockState, 3)) {
((ServerLevel) this.level()).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level().getBlockState(blockposition)));
if (this.level.setBlock(blockposition, this.blockState, 3)) {
((ServerLevel) this.level).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level.getBlockState(blockposition)));
this.discard();
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index cc30c119f519e7cd947ab40beae56e493e977176..811a5224a02bb3badb1b8d6de370b7166d9f877c 100644
index 6097d495252c9c7ee54f7017ca2b39d42e5046fe..2bdd46350317a9fadf362b1a341993c92d7a9651 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -71,6 +71,44 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -60,6 +60,44 @@ public class PrimedTnt extends Entity implements TraceableEntity {
return !this.isRemoved();
}
@@ -431,7 +431,7 @@ index cc30c119f519e7cd947ab40beae56e493e977176..811a5224a02bb3badb1b8d6de370b716
+ protected boolean respawnMerged() {
+ if (stacked <= 1) return false;
+
+ PrimedTnt tnt = new PrimedTnt(EntityType.TNT, level());
+ PrimedTnt tnt = new PrimedTnt(EntityType.TNT, level);
+
+ while (stacked-- > 1) {
+ this.setFuse(100); // Prevent unwanted explosions while ticking
@@ -452,20 +452,20 @@ index cc30c119f519e7cd947ab40beae56e493e977176..811a5224a02bb3badb1b8d6de370b716
+
@Override
public void tick() {
if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
@@ -96,6 +134,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
@@ -85,6 +123,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
if (i <= 0) {
// 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.respawnMerged(); // Sakura
if (!this.level().isClientSide) {
if (!this.level.isClientSide) {
this.explode();
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 902ec524d209ab56a6dadb260559910c76dbf96b..467ac21893d2e2ee07bc3ce7852ceb87dfe56cdf 100644
index 9bf8b4d67a5a2295ad994fd6fdb4df77c84c2486..86e8bcaee950d233b062b906bc9fc12d7708e125 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -237,6 +237,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -298,6 +298,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return slices.getSectionEntities(chunkY);
}
// Sakura end
@@ -474,10 +474,10 @@ index 902ec524d209ab56a6dadb260559910c76dbf96b..467ac21893d2e2ee07bc3ce7852ceb87
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
index 73911b81f4e927026657953a0c68ddda9a8f93c1..c64ab06b62334e5ab1ab5ad78fa400de45c15723 100644
index 05778023c3b2809c52c148efdfc8677dcc087a7b..90df6530606e0a487dc70a1663980092f6f0b120 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
@@ -14,6 +14,28 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
@@ -15,6 +15,28 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
super(server, entity);
}
@@ -505,12 +505,12 @@ index 73911b81f4e927026657953a0c68ddda9a8f93c1..c64ab06b62334e5ab1ab5ad78fa400de
+
@Override
public FallingBlockEntity getHandle() {
return (FallingBlockEntity) this.entity;
return (FallingBlockEntity) entity;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
index 3f32c683ddc6999b89f2e4051eb6ae784b296b8f..1ccf2153d82403a9b4fb3c972d1b7809c8efde2d 100644
index 06540d3771949daff641e518219090559f363959..9b03ba0b3a7b491fafad5afae606cb6b8a6b53e6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java
@@ -12,6 +12,28 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
@@ -13,6 +13,28 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed {
super(server, entity);
}

View File

@@ -142,17 +142,15 @@ index 0000000000000000000000000000000000000000..3f6f34cc617efaad420485a7f613cfca
+}
diff --git a/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java
new file mode 100644
index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb3c9e2037
index 0000000000000000000000000000000000000000..31eec14e78612e4cd6941c09f8b9093f324dce7e
--- /dev/null
+++ b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java
@@ -0,0 +1,403 @@
@@ -0,0 +1,381 @@
+package me.samsuik.sakura.explosion;
+
+import me.samsuik.sakura.entity.EntityState;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.particles.ParticleOptions;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.sounds.SoundEvent;
+import net.minecraft.util.Mth;
+import net.minecraft.world.damagesource.DamageSource;
+import net.minecraft.world.entity.Entity;
@@ -166,6 +164,7 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+import net.minecraft.world.level.Explosion;
+import net.minecraft.world.level.ExplosionDamageCalculator;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.phys.AABB;
+import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -195,8 +194,8 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+
+ private final Level level;
+
+ public SakuraExplosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType, ParticleOptions particle, ParticleOptions emitterParticle, SoundEvent soundEvent) {
+ super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType, particle, emitterParticle, soundEvent);
+ public SakuraExplosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType) {
+ super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType);
+ this.level = world;
+ }
+
@@ -213,7 +212,6 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ }
+
+ List<Vec3> positions = new ArrayList<>(source.getStacked());
+ ExplosionBlockCache[] blockCache = createBlockCache();
+
+ EntityState entityState = null;
+ AABB bounds = new AABB(x, y, z, x, y, z);
@@ -233,15 +231,9 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+
+ // search for blocks if necessary
+ if (wrapped < 7 + 12) {
+ int blockX = Mth.floor(x);
+ int blockY = Mth.floor(y);
+ int blockZ = Mth.floor(z);
+
+ long key = BlockPos.asLong(blockX, blockY, blockZ);
+ ExplosionBlockCache center = getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true);
+
+ if (interactsWithBlocks() && isDestructibleBlock(center.blockState) && isRegionUnprotected()) {
+ searchForBlocks(blockCache);
+ BlockState state = level.getBlockState(BlockPos.containing(x, y, z));
+ if (interactsWithBlocks() && isDestructibleBlock(state) && isRegionUnprotected()) {
+ searchForBlocks();
+ }
+ }
+
@@ -259,26 +251,14 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ // Possible optimisation here is making our own finalize explosion for this special case.
+ // If this is after the explosion event we can take better advantage of protection plugins.
+ if (isFinalExplosion || !getToBlow().isEmpty()) {
+ locateAndImpactEntities(positions, bounds, blockCache);
+ locateAndImpactEntities(positions, bounds);
+ bounds = new AABB(position, position);
+ positions.clear();
+ }
+
+ if (!isFinalExplosion) {
+ BlockPos.MutableBlockPos mbp = new BlockPos.MutableBlockPos();
+
+ // Calculate next source velocity
+ entityState = calculateNextVelocity(position, mbp, blockCache);
+
+ // The purpose of this is to make sure papers blockCache doesn't become
+ // outdated by flushing the map and removing stale entries from the recent
+ // cache array. If there is any case where tnt can provide its self delta
+ // movement and then start moving without blocks this may break stuff to
+ // fix it see the note above or add a boolean to mark the cache as dirty
+ // outside this loop and then invalidate before the final impact entities.
+ if (!getToBlow().isEmpty()) {
+ invalidateBlockCache(blockCache);
+ }
+ entityState = calculateNextVelocity(position);
+
+ // Could be viable in the future to have a configuration option to reduce explosion events
+ super.finalizeExplosion(false);
@@ -292,8 +272,6 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ }
+ }
+ }
+
+ clearBlockCache();
+ }
+
+ private void calculateNextPosition(EntityState entityState) {
@@ -315,14 +293,14 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ z = source.getZ();
+ }
+
+ private EntityState calculateNextVelocity(Vec3 position, BlockPos.MutableBlockPos mbp, ExplosionBlockCache[] blockCache) {
+ private EntityState calculateNextVelocity(Vec3 position) {
+ PrimedTnt tnt = new PrimedTnt(EntityType.TNT, level);
+ source.entityState().apply(tnt);
+ impactEntityIdle(tnt, new Entity[0], position, 1, radius * 2.0f, mbp, blockCache);
+ impactEntityIdle(tnt, new Entity[0], position, 1, radius * 2.0f);
+ return EntityState.of(tnt);
+ }
+
+ private void locateAndImpactEntities(List<Vec3> positions, AABB bb, ExplosionBlockCache[] blockCache) {
+ private void locateAndImpactEntities(List<Vec3> positions, AABB bb) {
+ double radius = this.radius * 2.0f;
+
+ int minSection = io.papermc.paper.util.WorldUtil.getMinSection(level);
@@ -341,8 +319,6 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+
+ boolean moved = change != 0.0;
+
+ BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); // Paper - optimise explosions
+
+ io.papermc.paper.chunk.system.entity.EntityLookup entityLookup = ((ServerLevel) level).getEntityLookup();
+
+ // impact entities already has a range check there is no reason to also
@@ -358,9 +334,9 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+
+ for (int chunkY = minChunkY; chunkY <= maxChunkY; ++chunkY) {
+ if (moved) {
+ impactEntities(chunk.getSectionEntities(chunkY), positions, center, blockPos, blockCache, radius, maxDistanceSqr);
+ impactEntities(chunk.getSectionEntities(chunkY), positions, center, radius, maxDistanceSqr);
+ } else {
+ impactEntitiesIdle(chunk.getSectionEntities(chunkY), positions.get(0), positions.size(), blockPos, blockCache, radius);
+ impactEntitiesIdle(chunk.getSectionEntities(chunkY), positions.get(0), positions.size(), radius);
+ }
+ }
+ }
@@ -368,19 +344,19 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ }
+
+ // swinging case: more than 1 position and actively changing positions.
+ private void impactEntities(Entity[] entities, List<Vec3> positions, Vec3 center, BlockPos.MutableBlockPos blockPos, ExplosionBlockCache[] blockCache, double radius, double maxDistanceSqr) {
+ private void impactEntities(Entity[] entities, List<Vec3> positions, Vec3 center, double radius, double maxDistanceSqr) {
+ for (int i = 0; i < entities.length; ++i) {
+ Entity entity = entities[i];
+ if (entity == null) break;
+
+ if (entity != source && !entity.ignoreExplosion(this) && entity.distanceToSqr(center.x, center.y, center.z) <= maxDistanceSqr) {
+ if (entity != source && !entity.ignoreExplosion() && entity.distanceToSqr(center.x, center.y, center.z) <= maxDistanceSqr) {
+ int key = DensityCache.createKey(entity, center);
+ DensityCache.Density data = level.densityCache.retrieveCache(key);
+ Vec3 position = entity.position();
+
+ if (data != null && data.isObscured(position)) {
+ continue;
+ } else if (impactEntity(entity, entities, positions, radius, blockPos, blockCache) == 1 && data != null) {
+ } else if (impactEntity(entity, entities, positions, radius) == 1 && data != null) {
+ data.obscure(position);
+ }
+ }
@@ -392,7 +368,7 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ }
+ }
+
+ private int impactEntity(Entity entity, Entity[] section, List<Vec3> positions, double radius, BlockPos.MutableBlockPos blockPos, ExplosionBlockCache[] blockCache) {
+ private int impactEntity(Entity entity, Entity[] section, List<Vec3> positions, double radius) {
+ int found = 0;
+
+ //noinspection ForLoopReplaceableByForEach
@@ -413,7 +389,7 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ x /= distance;
+ y /= distance;
+ z /= distance;
+ double density = this.getBlockDensity(pos, entity, blockCache, blockPos); // Paper - Optimize explosions // Paper - optimise explosions
+ double density = this.getBlockDensity(pos, entity); // Paper - Optimize explosions // Paper - optimise explosions
+ double exposure = (1.0D - distanceFromBottom) * density;
+
+ int visible = density != 0.0 ? 1 : 0;
@@ -424,20 +400,20 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ continue;
+ }
+
+ impactNonLiving(entity, pos, section, x, y, z, exposure, blockPos, blockCache);
+ impactNonLiving(entity, pos, section, x, y, z, exposure, radius);
+ }
+
+ return found;
+ }
+
+ // stationary case: 1 position or stationary
+ private void impactEntitiesIdle(Entity[] entities, Vec3 position, int potential, BlockPos.MutableBlockPos blockPos, ExplosionBlockCache[] blockCache, double radius) {
+ private void impactEntitiesIdle(Entity[] entities, Vec3 position, int potential, double radius) {
+ for (int i = 0; i < entities.length; ++i) {
+ Entity entity = entities[i];
+ if (entity == null) break;
+
+ if (entity != source && !entity.ignoreExplosion(this)) {
+ impactEntityIdle(entity, entities, position, potential, radius, blockPos, blockCache);
+ if (entity != source && !entity.ignoreExplosion()) {
+ impactEntityIdle(entity, entities, position, potential, radius);
+ }
+
+ // chunk entities can change while we're affecting entities
@@ -447,7 +423,7 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ }
+ }
+
+ private void impactEntityIdle(Entity entity, Entity[] section, Vec3 pos, int potential, double radius, BlockPos.MutableBlockPos blockPos, ExplosionBlockCache[] blockCache) {
+ private void impactEntityIdle(Entity entity, Entity[] section, Vec3 pos, int potential, double radius) {
+ double distanceFromBottom = Math.sqrt(entity.distanceToSqr(pos)) / radius;
+
+ if (distanceFromBottom <= 1.0) {
@@ -460,7 +436,7 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ x /= distance;
+ y /= distance;
+ z /= distance;
+ double density = this.getBlockDensity(pos, entity, blockCache, blockPos); // Paper - Optimize explosions // Paper - optimise explosions
+ double density = this.getBlockDensity(pos, entity); // Paper - Optimize explosions // Paper - optimise explosions
+ double exposure = (1.0D - distanceFromBottom) * density;
+
+ if (entity.isPrimedTNT || entity.isFallingBlock) {
@@ -477,51 +453,53 @@ index 0000000000000000000000000000000000000000..b87748ae90863abe8f85dcbdc5a202cb
+ }
+ } else {
+ for (int i = 0; i < potential; ++i) {
+ impactNonLiving(entity, pos, section, x, y, z, exposure, blockPos, blockCache);
+ impactNonLiving(entity, pos, section, x, y, z, exposure, radius);
+ }
+ }
+ }
+ }
+ }
+
+ private void impactNonLiving(Entity entity, Vec3 pos, Entity[] section, double x, double y, double z, double exposure, BlockPos.MutableBlockPos blockPos, ExplosionBlockCache[] blockCache) {
+ if (this.damageCalculator.shouldDamageEntity(this, entity)) {
+ // CraftBukkit start
+ private void impactNonLiving(Entity entity, Vec3 pos, Entity[] section, double x, double y, double z, double exposure, double radius) {
+ // CraftBukkit start
+
+ // Special case ender dragon only give knockback if no damage is cancelled
+ // Thinks to note:
+ // - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed)
+ // - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon
+ // - Damaging EntityEnderDragon does nothing
+ // - EntityEnderDragon hitbock always covers the other parts and is therefore always present
+ if (entity instanceof EnderDragonPart) {
+ return;
+ }
+ // Special case ender dragon only give knockback if no damage is cancelled
+ // Thinks to note:
+ // - Setting a velocity to a ComplexEntityPart is ignored (and therefore not needed)
+ // - Damaging ComplexEntityPart while forward the damage to EntityEnderDragon
+ // - Damaging EntityEnderDragon does nothing
+ // - EntityEnderDragon hitbock always covers the other parts and is therefore always present
+ if (entity instanceof EnderDragonPart) {
+ return;
+ }
+
+ CraftEventFactory.entityDamage = this.source;
+ entity.lastDamageCancelled = false;
+ CraftEventFactory.entityDamage = this.source;
+ entity.lastDamageCancelled = false;
+
+ if (entity instanceof EnderDragon) {
+ for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) {
+ for (Entity ent : section) {
+ // Calculate damage separately for each EntityComplexPart
+ if (ent == null) break;
+ if (ent == entityComplexPart) {
+ entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entityComplexPart, getSeenFraction(pos, entityComplexPart, null, blockCache, blockPos))); // Sakura // Paper - actually optimise explosions and use the right entity to calculate the damage
+ if (entity instanceof EnderDragon) {
+ for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) {
+ for (Entity ent : section) {
+ // Calculate damage separately for each EntityComplexPart
+ if (ent == null) break;
+ if (ent == entityComplexPart) {
+ double d7part;
+ if ((d7part = Math.sqrt(entityComplexPart.distanceToSqr(pos)) / radius) <= 1.0D) {
+ double d13part = (1.0D - d7part) * Explosion.getSeenPercent(pos, entityComplexPart, null); // Sakura
+ entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d13part * d13part + d13part) / 2.0D * 7.0D * radius + 1.0D)));
+ }
+ }
+ }
+ } else {
+ entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getSeenFraction(pos, entity, null, blockCache, blockPos))); // Sakura // Paper - actually optimise explosions
+ }
+
+ CraftEventFactory.entityDamage = null;
+ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled
+ return;
+ }
+ // CraftBukkit end
+ } else {
+ entity.hurt(this.damageSource, (float) ((int) ((exposure * exposure + exposure) / 2.0D * 7.0D * radius + 1.0D)));
+ }
+
+ CraftEventFactory.entityDamage = null;
+ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled
+ return;
+ }
+ // CraftBukkit end
+
+ double force;
+
+ if (entity instanceof LivingEntity) {
@@ -620,10 +598,10 @@ index 0000000000000000000000000000000000000000..e0387f16ff49031fdcbc8990613417da
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 08e8de35fddcd54c5f466edb264aa454a5935c42..26b0c5d77fe10153300030c0f0fb0f63b552121a 100644
index 9a15ce8aef1c52b915ea9131a31e60065d667a4a..a9049e2cf29bdf90eb308f6b15a4374779032eec 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1750,6 +1750,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1579,6 +1579,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.localConfig().expire(currentTickLong); // Sakura
worldserver.minimalTNT.clear(); // Sakura - visibility api
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
@@ -632,10 +610,10 @@ index 08e8de35fddcd54c5f466edb264aa454a5935c42..26b0c5d77fe10153300030c0f0fb0f63
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 620966965f3d73cd6fdbf03dabe2605c45d51d57..a25b1e73e33459dc0a4c8d64f35d5731ec44e5cc 100644
index 3ace813ccce8b836edef76a16b92ca99762af7b1..c2452f6c47533c7d921c55c4997c1be6471fe942 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1967,6 +1967,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1761,6 +1761,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
explosion.clearToBlow();
}
@@ -648,7 +626,7 @@ index 620966965f3d73cd6fdbf03dabe2605c45d51d57..a25b1e73e33459dc0a4c8d64f35d5731
Iterator iterator = this.players.iterator();
while (iterator.hasNext()) {
@@ -1977,7 +1983,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
@@ -1771,7 +1777,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
}
}
@@ -658,10 +636,10 @@ index 620966965f3d73cd6fdbf03dabe2605c45d51d57..a25b1e73e33459dc0a4c8d64f35d5731
@Override
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 811a5224a02bb3badb1b8d6de370b7166d9f877c..1b8d43cf54999c9a005459bc59d7b5a50bb9c1ee 100644
index 2bdd46350317a9fadf362b1a341993c92d7a9651..7b5d96670c6818949a0be556b547347e559dd93a 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -86,6 +86,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -75,6 +75,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|| tnt.entityState().fallDistance() > 2.5f && fallDistance > 2.5f);
}
@@ -669,7 +647,7 @@ index 811a5224a02bb3badb1b8d6de370b7166d9f877c..1b8d43cf54999c9a005459bc59d7b5a5
@Override
protected boolean respawnMerged() {
if (stacked <= 1) return false;
@@ -107,6 +108,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -96,6 +97,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
return true;
}
@@ -678,7 +656,7 @@ index 811a5224a02bb3badb1b8d6de370b7166d9f877c..1b8d43cf54999c9a005459bc59d7b5a5
@Override
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c517d64c09 100644
index 3cb5306a2ccfc1c53f90ecd56980d17be4042093..3a622a84b3846e368b099a27bbc44afe03290db2 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -55,14 +55,16 @@ public class Explosion {
@@ -701,105 +679,42 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
+ protected final DamageSource damageSource;
+ protected final ExplosionDamageCalculator damageCalculator;
+ // Sakura end
private final ParticleOptions smallExplosionParticles;
private final ParticleOptions largeExplosionParticles;
private final SoundEvent explosionSound;
@@ -136,6 +138,12 @@ public class Explosion {
}
}
+ // Sakura start
+ if (me.samsuik.sakura.configuration.GlobalConfiguration.get().cannons.explosion.reducedSearchRays) {
+ me.samsuik.sakura.utils.ExplosionUtil.reduceRays(rayCoords);
+ }
+ // Sakura end
+
CACHED_RAYS = rayCoords.toDoubleArray();
private final ObjectArrayList<BlockPos> toBlow;
private final Map<Player, Vec3> hitPlayers;
public boolean wasCanceled = false; // CraftBukkit - add field
@@ -96,11 +98,70 @@ public class Explosion {
this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior;
}
@@ -143,14 +151,14 @@ public class Explosion {
private static final int CHUNK_CACHE_MASK = (1 << CHUNK_CACHE_SHIFT) - 1;
private static final int CHUNK_CACHE_WIDTH = 1 << CHUNK_CACHE_SHIFT;
- private static final int BLOCK_EXPLOSION_CACHE_SHIFT = 3;
- private static final int BLOCK_EXPLOSION_CACHE_MASK = (1 << BLOCK_EXPLOSION_CACHE_SHIFT) - 1;
+ protected static final int BLOCK_EXPLOSION_CACHE_SHIFT = 3; // Sakura - protected
+ protected static final int BLOCK_EXPLOSION_CACHE_MASK = (1 << BLOCK_EXPLOSION_CACHE_SHIFT) - 1; // Sakura - protected
private static final int BLOCK_EXPLOSION_CACHE_WIDTH = 1 << BLOCK_EXPLOSION_CACHE_SHIFT;
// resistance = (res + 0.3F) * 0.3F;
// so for resistance = 0, we need res = -0.3F
private static final Float ZERO_RESISTANCE = Float.valueOf(-0.3f);
- private it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<ExplosionBlockCache> blockCache = null;
+ protected it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<ExplosionBlockCache> blockCache = null; // Sakura - protected
public static final class ExplosionBlockCache {
@@ -177,7 +185,7 @@ public class Explosion {
private long[] chunkPosCache = null;
private net.minecraft.world.level.chunk.LevelChunk[] chunkCache = null;
- private ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z,
+ protected ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z, // Sakura - private -> protected
final long key, final boolean calculateResistance) {
ExplosionBlockCache ret = this.blockCache.get(key);
if (ret != null) {
@@ -327,7 +335,8 @@ public class Explosion {
}
}
- private float getSeenFraction(final Vec3 source, final Entity target,
+ protected float getSeenFraction(final Vec3 source, final Entity target, // Sakura - protected
+ final @Nullable me.samsuik.sakura.explosion.DensityCache.Density data, // Sakura - pass density
final ExplosionBlockCache[] blockCache,
final BlockPos.MutableBlockPos blockPos) {
final AABB boundingBox = target.getBoundingBox();
@@ -365,7 +374,11 @@ public class Explosion {
Math.fma(dz, diffZ, offZ)
);
- if (!this.clipsAnything(from, source, context, blockCache, blockPos)) {
+ // Sakura start
+ if (data != null && data.isExpandable() && data.has(from)) {
+ missedRays += (int) data.density();
+ } else if (!this.clipsAnything(from, source, context, blockCache, blockPos)) {
+ // Sakura end
++missedRays;
}
}
@@ -375,12 +388,70 @@ public class Explosion {
return (float)missedRays / (float)totalRays;
}
// Paper end - optimise collisions
+ // Sakura start
+ protected ExplosionBlockCache[] createBlockCache() {
+ this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
+ private static final double[] BLOCK_RAYCAST_VECTORS;
+
+ this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
+ java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS);
+ static {
+ it.unimi.dsi.fastutil.doubles.DoubleArrayList vectorList = new it.unimi.dsi.fastutil.doubles.DoubleArrayList();
+
+ this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
+ for (int k = 0; k < 16; ++k) {
+ for (int i = 0; i < 16; ++i) {
+ for (int j = 0; j < 16; ++j) {
+ if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) {
+ double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
+ double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F);
+ double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
+ double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
+
+ return new ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH];
+ }
+ d0 /= d3;
+ d1 /= d3;
+ d2 /= d3;
+
+ protected void clearBlockCache() {
+ this.blockCache = null; // Paper - optimise explosions
+ this.chunkPosCache = null; // Paper - optimise explosions
+ this.chunkCache = null; // Paper - optimise explosions
+ }
+
+ protected void invalidateBlockCache(ExplosionBlockCache[] blockCaches) {
+ for (BlockPos blow : getToBlow()) {
+ final int cacheKey =
+ (blow.getX() & BLOCK_EXPLOSION_CACHE_MASK) |
+ (blow.getY() & BLOCK_EXPLOSION_CACHE_MASK) << (BLOCK_EXPLOSION_CACHE_SHIFT) |
+ (blow.getZ() & BLOCK_EXPLOSION_CACHE_MASK) << (BLOCK_EXPLOSION_CACHE_SHIFT + BLOCK_EXPLOSION_CACHE_SHIFT);
+
+ blockCaches[cacheKey] = null;
+ vectorList.add(d0 * 0.30000001192092896D);
+ vectorList.add(d1 * 0.30000001192092896D);
+ vectorList.add(d2 * 0.30000001192092896D);
+ }
+ }
+ }
+ }
+
+ blockCache.clear();
+ me.samsuik.sakura.utils.ExplosionUtil.reduceRays(vectorList);
+ BLOCK_RAYCAST_VECTORS = vectorList.toDoubleArray();
+ }
+
+ protected boolean isDestructibleBlock(@Nullable BlockState state) {
@@ -829,7 +744,7 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
+ return true;
+ }
+ // Sakura end
+
private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) {
return (ExplosionDamageCalculator) (entity == null ? Explosion.EXPLOSION_DAMAGE_CALCULATOR : new EntityBasedExplosionDamageCalculator(entity));
}
@@ -839,73 +754,145 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
AABB axisalignedbb = entity.getBoundingBox();
double d0 = 1.0D / ((axisalignedbb.maxX - axisalignedbb.minX) * 2.0D + 1.0D);
double d1 = 1.0D / ((axisalignedbb.maxY - axisalignedbb.minY) * 2.0D + 1.0D);
@@ -400,7 +471,11 @@ public class Explosion {
@@ -120,7 +181,11 @@ public class Explosion {
double d10 = Mth.lerp(d7, axisalignedbb.minZ, axisalignedbb.maxZ);
Vec3 vec3d1 = new Vec3(d8 + d3, d9, d10 + d4);
- if (entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
- if (entity.level.clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
+ // Sakura start
+ if (data != null && data.isExpandable() && data.has(vec3d1)) {
+ i += (int) data.density();
+ } else if (entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
+ } else if (entity.level.clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
+ // Sakura end
++i;
}
@@ -429,7 +504,29 @@ public class Explosion {
@@ -141,34 +206,75 @@ public class Explosion {
return;
}
// CraftBukkit end
+ // Sakura start
+ ExplosionBlockCache[] blockCache = createBlockCache();
+
+ // block at explosion position
+ int blockX = Mth.floor(x);
+ int blockY = Mth.floor(y);
+ int blockZ = Mth.floor(z);
+ long key = BlockPos.asLong(blockX, blockY, blockZ);
+ ExplosionBlockCache center = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true);
+
+ if (interactsWithBlocks() && isDestructibleBlock(center.blockState) && isRegionUnprotected()) {
+ searchForBlocks(blockCache);
+ BlockState state = level.getBlockState(BlockPos.containing(x, y, z));
+ if (interactsWithBlocks() && isDestructibleBlock(state) && isRegionUnprotected()) {
+ searchForBlocks();
+ }
+
+ // Checking if this explosion occurred inside a block is not a viable optimisation.
+ // If an entity is 1.0e-7 away from the position no matter it will be affected no matter what.
+ locateAndImpactEntities(blockCache);
+ clearBlockCache();
+ locateAndImpactEntities();
+ }
+
+ protected void searchForBlocks(ExplosionBlockCache[] blockCache) {
+ protected void searchForBlocks() {
this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z));
+ // Sakura end
Set<BlockPos> set = Sets.newHashSet();
boolean flag = true;
@@ -437,14 +534,7 @@ public class Explosion {
int j;
- int i;
- int j;
+ it.unimi.dsi.fastutil.longs.LongSet found = new it.unimi.dsi.fastutil.longs.LongOpenHashSet();
+ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
+ net.minecraft.server.level.ServerChunkCache chunkProvider = (net.minecraft.server.level.ServerChunkCache) level.getChunkSource();
// Paper start - optimise explosions
- this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>();
- for (int k = 0; k < 16; ++k) {
- for (i = 0; i < 16; ++i) {
- for (j = 0; j < 16; ++j) {
- if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) {
- double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F);
- double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F);
- double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F);
- double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
+ for (int i = 0; i < BLOCK_RAYCAST_VECTORS.length; i += 3) {
+ {
+ {
+ {
+ double d0 = BLOCK_RAYCAST_VECTORS[0];
+ double d1 = BLOCK_RAYCAST_VECTORS[1];
+ double d2 = BLOCK_RAYCAST_VECTORS[2];
- d0 /= d3;
- d1 /= d3;
- d2 /= d3;
float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F);
double d4 = this.x;
double d5 = this.y;
double d6 = this.z;
+ float resistance = 0.0f;
+ int prevX = Integer.MIN_VALUE, prevY = prevX, prevZ = prevX;
+ int lastChunkX = Integer.MIN_VALUE, lastChunkZ = lastChunkX;
+ net.minecraft.world.level.chunk.LevelChunk chunk = null;
+
for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) {
- BlockPos blockposition = BlockPos.containing(d4, d5, d6);
- BlockState iblockdata = this.level.getBlockState(blockposition);
- if (!iblockdata.isDestroyable()) continue; // Paper
+ final int blockX = Mth.floor(d4);
+ final int blockY = Mth.floor(d5);
+ final int blockZ = Mth.floor(d6);
+
+ d4 += d0;
+ d5 += d1;
+ d6 += d2;
+
+ if (blockX == prevX && blockY == prevY && blockZ == prevZ) {
+ f += resistance;
+ continue;
+ }
+
+ final int chunkX = blockX >> 4;
+ final int chunkZ = blockZ >> 4;
+
+ if (chunkX != lastChunkX || chunkZ != lastChunkZ) {
+ chunk = chunkProvider.getChunkAtIfLoadedMainThread(chunkX, chunkZ);
+
+ lastChunkX = chunkX;
+ lastChunkZ = chunkZ;
+ }
+
+ mutableBlockPos.set(blockX, blockY, blockZ);
+
+ BlockPos blockposition = mutableBlockPos;
+ BlockState iblockdata = chunk.getBlockState(blockposition);
+ if (!iblockdata.isDestroyable()) break; // Paper
+ // Sakura end
FluidState fluid = iblockdata.getFluidState(); // Paper
if (!this.level.isInWorldBounds(blockposition)) {
@@ -181,8 +287,9 @@ public class Explosion {
f -= ((Float) optional.get() + 0.3F) * 0.3F;
}
+ resistance = f; // Sakura
if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockposition, iblockdata, f)) {
- set.add(blockposition);
+ found.add(mutableBlockPos.asLong()); // Sakura
// Paper start - prevent headless pistons from forming
if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) {
BlockEntity extension = this.level.getBlockEntity(blockposition);
@@ -193,21 +300,25 @@ public class Explosion {
}
// Paper end
}
-
- this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
- java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS);
-
- this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH];
-
- final ExplosionBlockCache[] blockCache = new ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH];
+ // Sakura - move up
// use initial cache value that is most likely to be used: the source position
final ExplosionBlockCache initialCache;
{
@@ -541,10 +631,15 @@ public class Explosion {
- d4 += d0 * 0.30000001192092896D;
- d5 += d1 * 0.30000001192092896D;
- d6 += d2 * 0.30000001192092896D;
+ // Sakura - move up
}
}
}
}
}
this.toBlow.addAll(set);
- this.toBlow.addAll(set);
+ // Sakura start
+ for (long position : found) {
+ this.toBlow.add(BlockPos.of(position));
+ }
+ }
+
+ protected void locateAndImpactEntities(ExplosionBlockCache[] blockCache) {
+ protected void locateAndImpactEntities() {
float f2 = this.radius * 2.0F;
- i = Mth.floor(this.x - (double) f2 - 1.0D);
@@ -916,33 +903,17 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
int l = Mth.floor(this.y - (double) f2 - 1.0D);
int i1 = Mth.floor(this.y + (double) f2 + 1.0D);
int j1 = Mth.floor(this.z - (double) f2 - 1.0D);
@@ -591,11 +686,11 @@ public class Explosion {
for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) {
// Calculate damage separately for each EntityComplexPart
if (list.contains(entityComplexPart)) {
- entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entityComplexPart, getSeenFraction(vec3d, entityComplexPart, blockCache, blockPos))); // Paper - actually optimise explosions and use the right entity to calculate the damage
+ entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entityComplexPart, getSeenFraction(vec3d, entityComplexPart, null, blockCache, blockPos))); // Sakura // Paper - actually optimise explosions and use the right entity to calculate the damage
}
@@ -254,7 +365,7 @@ public class Explosion {
// Calculate damage separately for each EntityComplexPart
double d7part;
if (list.contains(entityComplexPart) && (d7part = Math.sqrt(entityComplexPart.distanceToSqr(vec3d)) / f2) <= 1.0D) {
- double d13part = (1.0D - d7part) * Explosion.getSeenPercent(vec3d, entityComplexPart);
+ double d13part = (1.0D - d7part) * Explosion.getSeenPercent(vec3d, entityComplexPart, null); // Sakura
entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d13part * d13part + d13part) / 2.0D * 7.0D * (double) f2 + 1.0D)));
}
} else {
- entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getSeenFraction(vec3d, entity, blockCache, blockPos))); // Paper - actually optimise explosions
+ entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getSeenFraction(vec3d, entity, null, blockCache, blockPos))); // Sakura // Paper - actually optimise explosions
}
CraftEventFactory.entityDamage = null;
@@ -635,9 +730,7 @@ public class Explosion {
}
}
- this.blockCache = null; // Paper - optimise explosions
- this.chunkPosCache = null; // Paper - optimise explosions
- this.chunkCache = null; // Paper - optimise explosions
+ // Sakura - move up
}
public void finalizeExplosion(boolean particles) {
@@ -705,6 +798,12 @@ public class Explosion {
if (this.wasCanceled) {
@@ -362,6 +473,12 @@ public class Explosion {
this.wasCanceled = true;
return;
}
+
@@ -954,15 +925,15 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
// CraftBukkit end
objectlistiterator = this.toBlow.iterator();
@@ -851,15 +950,22 @@ public class Explosion {
@@ -525,15 +642,22 @@ public class Explosion {
private BlockInteraction() {}
}
// Paper start - Optimize explosions
- private float getBlockDensity(Vec3 vec3d, Entity entity, ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Paper - optimise explosions
- private float getBlockDensity(Vec3 vec3d, Entity entity) {
- if (!this.level.paperConfig().environment.optimizeExplosions) {
- return this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions
- return getSeenPercent(vec3d, entity);
+ // Sakura start
+ protected float getBlockDensity(Vec3 vec3d, Entity entity, ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Paper - optimise explosions
+ protected float getBlockDensity(Vec3 vec3d, Entity entity) { // Paper - optimise explosions
+ int key = me.samsuik.sakura.explosion.DensityCache.createKey(entity, vec3d);
+ me.samsuik.sakura.explosion.DensityCache.Density data = level.densityCache.retrieveCache(key);
+
@@ -972,10 +943,10 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
- CacheKey key = new CacheKey(this, entity.getBoundingBox());
- Float blockDensity = this.level.explosionDensityCache.get(key);
- if (blockDensity == null) {
- blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions;
- blockDensity = getSeenPercent(vec3d, entity);
- this.level.explosionDensityCache.put(key, blockDensity);
+
+ float blockDensity = this.getSeenFraction(vec3d, entity, data, blockCache, blockPos); // Paper - optimise explosions;
+ float blockDensity = getSeenPercent(vec3d, entity, data); // Paper - optimise explosions;
+
+ if (data == null || !data.isExpandable() && (blockDensity == 0.0f || blockDensity == 1.0f)) {
+ level.densityCache.createCache(key, entity, vec3d, blockDensity);
@@ -985,24 +956,11 @@ index 3d4a75302d72bdbe47d0efbe08c89401dbe22a87..1e6e9b6709298b611ae2f77720baa9c5
}
return blockDensity;
diff --git a/src/main/java/net/minecraft/world/level/ExplosionDamageCalculator.java b/src/main/java/net/minecraft/world/level/ExplosionDamageCalculator.java
index f529f5d0f28533ec89f3ee712e59745991d068ee..d0ff7710577c1cfedae494796e6db420fef2bd08 100644
--- a/src/main/java/net/minecraft/world/level/ExplosionDamageCalculator.java
+++ b/src/main/java/net/minecraft/world/level/ExplosionDamageCalculator.java
@@ -23,7 +23,7 @@ public class ExplosionDamageCalculator {
@io.papermc.paper.annotation.DoNotUse @Deprecated // Paper
public float getEntityDamageAmount(Explosion explosion, Entity entity) {
// Paper start - actually optimise explosions
- return this.getEntityDamageAmount(explosion, entity, Explosion.getSeenPercent(explosion.center(), entity));
+ return this.getEntityDamageAmount(explosion, entity, Explosion.getSeenPercent(explosion.center(), entity, null)); // Sakura
}
public float getEntityDamageAmount(Explosion explosion, Entity entity, double seenPercent) {
// Paper end - actually optimise explosions
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 467ac21893d2e2ee07bc3ce7852ceb87dfe56cdf..1bb8c3c3a64826261bab23cfb3098596ac972084 100644
index 86e8bcaee950d233b062b906bc9fc12d7708e125..378197b05a074fc69ac2508d02acdc788242b49c 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -238,6 +238,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -299,6 +299,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
// Sakura end
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
@@ -1010,18 +968,18 @@ index 467ac21893d2e2ee07bc3ce7852ceb87dfe56cdf..1bb8c3c3a64826261bab23cfb3098596
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
@@ -1430,7 +1431,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -1020,7 +1021,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
}
Explosion.BlockInteraction explosion_effect1 = explosion_effect;
- Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent);
- Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1);
+ // Sakura start
+ Explosion explosion;
+
+ if (explosionSourceType == ExplosionInteraction.TNT) {
+ explosion = new me.samsuik.sakura.explosion.SakuraExplosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent);
+ explosion = new me.samsuik.sakura.explosion.SakuraExplosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1);
+ } else {
+ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent);
+ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1);
+ }
+ // Sakura end

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise Fast Movement
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e21b4f641a 100644
index bc7a65dc8c8718f2e02249ff251764a4fb13f9a7..c3a028ef2fe49b9afb48b6f871b370b38976a09e 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1220,6 +1220,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1135,6 +1135,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
// Paper end - detailed watchdog information
@@ -26,7 +26,7 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ }
+ }
+
+ this.level().getProfiler().push("move");
+ this.level.getProfiler().push("move");
+ if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) {
+ movement = movement.multiply(this.stuckSpeedMultiplier);
+ this.stuckSpeedMultiplier = Vec3.ZERO;
@@ -41,7 +41,7 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ // NOTE: if there are any blocks in the future that rely on fall distance make sure this is correct.
+ // The only block I am aware of is powdered snow that has a special case for falling blocks.
+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !isFallingBlock) {
+ BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
+ BlockHitResult movingobjectpositionblock = this.level.clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
+
+ if (movingobjectpositionblock.getType() != HitResult.Type.MISS) {
+ this.resetFallDistance();
@@ -51,8 +51,8 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z);
+ }
+
+ this.level().getProfiler().pop();
+ this.level().getProfiler().push("rest");
+ this.level.getProfiler().pop();
+ this.level.getProfiler().push("rest");
+ boolean flag = !Mth.equal(movement.x, vec3d1.x);
+ boolean flag1 = !Mth.equal(movement.z, vec3d1.z);
+
@@ -65,13 +65,13 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ this.minorHorizontalCollision = false;
+ }
+
+ this.setOnGroundWithKnownMovement(this.verticalCollisionBelow, vec3d1);
+ this.onGround = this.verticalCollision && movement.y < 0.0D;
+ BlockPos blockposition = this.getOnPosLegacy();
+ BlockState iblockdata = this.level().getBlockState(blockposition);
+ BlockState iblockdata = this.level.getBlockState(blockposition);
+
+ this.checkFallDamage(vec3d1.y, this.onGround(), iblockdata, blockposition);
+ this.checkFallDamage(vec3d1.y, this.onGround, iblockdata, blockposition);
+ if (this.isRemoved()) {
+ this.level().getProfiler().pop();
+ this.level.getProfiler().pop();
+ } else {
+ if (this.horizontalCollision) {
+ Vec3 vec3d2 = this.getDeltaMovement();
@@ -82,20 +82,20 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ Block block = iblockdata.getBlock();
+
+ if (movement.y != vec3d1.y) {
+ block.updateEntityAfterFallOn(this.level(), this);
+ block.updateEntityAfterFallOn(this.level, this);
+ }
+
+ if (this.onGround()) {
+ if (this.onGround) {
+ // used for slowing down entities on top of slime
+ block.stepOn(this.level(), blockposition, iblockdata, this);
+ block.stepOn(this.level, blockposition, iblockdata, this);
+ }
+
+ this.tryCheckInsideBlocks();
+
+ float f = this.getBlockSpeedFactor();
+ float f2 = this.getBlockSpeedFactor();
+
+ this.multiplyDeltaMovement((double) f, 1.0D, (double) f); // Sakura - reduce movement allocations
+ this.level().getProfiler().pop();
+ this.multiplyDeltaMovement((double) f2, 1.0D, (double) f2); // Sakura - reduce movement allocations
+ this.level.getProfiler().pop();
+ }
+ }
+ }
@@ -104,7 +104,7 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
public void move(MoverType movementType, Vec3 movement) {
// Paper start - detailed watchdog information
io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main");
@@ -1597,6 +1686,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1486,6 +1575,92 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return offsetFactor;
}
@@ -115,20 +115,19 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ }
+
+ final boolean scan = movement.lengthSqr() >= 12.0;
+ final List<AABB> potentialCollisionsBB = new java.util.ArrayList<>(8);
+ final List<VoxelShape> potentialCollisionsVoxel = new java.util.ArrayList<>(2);
+ final List<AABB> potentialCollisions = new java.util.ArrayList<>(2);
+ final AABB currBoundingBox = getBoundingBox();
+
+ if (scan) {
+ return scanAndCollide(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
+ return scanAndCollide(movement, currBoundingBox, potentialCollisions);
+ } else {
+ final AABB bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z);
+ collectCollisions(bb, potentialCollisionsVoxel, potentialCollisionsBB);
+ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
+ collectCollisions(bb, potentialCollisions);
+ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions);
+ }
+ }
+
+ private Vec3 scanAndCollide(Vec3 movement, AABB currBoundingBox, List<VoxelShape> voxelList, List<AABB> bbList) {
+ private Vec3 scanAndCollide(Vec3 movement, AABB currBoundingBox, List<AABB> bbList) {
+ double x = movement.x;
+ double y = movement.y;
+ double z = movement.z;
@@ -136,7 +135,7 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ final boolean xSmaller = Math.abs(x) < Math.abs(z);
+
+ if (y != 0.0) {
+ y = scanY(currBoundingBox, y, voxelList, bbList);
+ y = scanY(currBoundingBox, y, bbList);
+
+ if (y != 0.0) {
+ currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetY(currBoundingBox, y);
@@ -144,7 +143,7 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ }
+
+ if (xSmaller && z != 0.0) {
+ z = scanZ(currBoundingBox, z, voxelList, bbList);
+ z = scanZ(currBoundingBox, z, bbList);
+
+ if (z != 0.0) {
+ currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetZ(currBoundingBox, z);
@@ -152,7 +151,7 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ }
+
+ if (x != 0.0) {
+ x = scanX(currBoundingBox, x, voxelList, bbList);
+ x = scanX(currBoundingBox, x, bbList);
+
+ if (x != 0.0) {
+ currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetX(currBoundingBox, x);
@@ -160,51 +159,49 @@ index 8562e2794fc2cc29e55d34186480e820bffe1237..b25ee7bf3ff5d8d533055f737c17e0e2
+ }
+
+ if (!xSmaller && z != 0.0) {
+ z = scanZ(currBoundingBox, z, voxelList, bbList);
+ z = scanZ(currBoundingBox, z, bbList);
+ }
+
+ return new Vec3(x, y, z);
+ }
+
+ private void collectCollisions(AABB collisionBox, List<VoxelShape> voxelList, List<AABB> bbList) {
+ private void collectCollisions(AABB collisionBox, List<AABB> bbList) {
+ // Copied from the collide method below
+ io.papermc.paper.util.CollisionUtil.getCollisions(
+ level, this, collisionBox, voxelList, bbList,
+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura
+ null, null
+ );
+ io.papermc.paper.util.CollisionUtil.getCollisions(level, this, collisionBox, bbList, this.loadChunks, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, // Sakura
+ false, false, null, null);
+
+ if (collidingWithWorldBorder = io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(level.getWorldBorder(), collisionBox)) { // Paper - this line *is* correct, ignore the IDE warning about assignments being used as a condition
+ io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(level.getWorldBorder().getCollisionShape(), collisionBox, bbList);
+ }
+ }
+
+ private double scanX(AABB currBoundingBox, double x, List<VoxelShape> voxelList, List<AABB> bbList) {
+ private double scanX(AABB currBoundingBox, double x, List<AABB> bbList) {
+ AABB scanBox = currBoundingBox.expandTowards(x, 0.0, 0.0);
+ collectCollisions(scanBox, voxelList, bbList);
+ x = io.papermc.paper.util.CollisionUtil.performAABBCollisionsX(currBoundingBox, x, bbList);
+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsX(currBoundingBox, x, voxelList);
+ collectCollisions(scanBox, bbList);
+ return io.papermc.paper.util.CollisionUtil.performCollisionsX(currBoundingBox, x, bbList);
+ }
+
+ private double scanY(AABB currBoundingBox, double y, List<VoxelShape> voxelList, List<AABB> bbList) {
+ private double scanY(AABB currBoundingBox, double y, List<AABB> bbList) {
+ AABB scanBox = currBoundingBox.expandTowards(0.0, y, 0.0);
+ collectCollisions(scanBox, voxelList, bbList);
+ y = io.papermc.paper.util.CollisionUtil.performAABBCollisionsY(currBoundingBox, y, bbList);
+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsY(currBoundingBox, y, voxelList);
+ collectCollisions(scanBox, bbList);
+ return io.papermc.paper.util.CollisionUtil.performCollisionsY(currBoundingBox, y, bbList);
+ }
+
+ private double scanZ(AABB currBoundingBox, double z, List<VoxelShape> voxelList, List<AABB> bbList) {
+ private double scanZ(AABB currBoundingBox, double z, List<AABB> bbList) {
+ AABB scanBox = currBoundingBox.expandTowards(0.0, 0.0, z);
+ collectCollisions(scanBox, voxelList, bbList);
+ z = io.papermc.paper.util.CollisionUtil.performAABBCollisionsZ(currBoundingBox, z, bbList);
+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsZ(currBoundingBox, z, voxelList);
+ collectCollisions(scanBox, bbList);
+ return io.papermc.paper.util.CollisionUtil.performCollisionsZ(currBoundingBox, z, bbList);
+ }
+ // Sakura end
+
private Vec3 collide(Vec3 movement) {
// Paper start - optimise collisions
final boolean xZero = movement.x == 0.0;
// This is a copy of vanilla's except that it uses strictly AABB math
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 3a0d82cd7a0d7ec20138effd6d84eee60ffab788..b7f9c8a6de4c07f230f99b6bfa1332166e696b49 100644
index 2113c330d309819c4b24b5ab63574ae481e2f77d..bc1aeb4a7601027ca5c537d4f22ddf68e6558b27 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -201,7 +201,7 @@ public class FallingBlockEntity extends Entity {
@@ -199,7 +199,7 @@ public class FallingBlockEntity extends Entity {
this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations
}
@@ -214,15 +211,15 @@ index 3a0d82cd7a0d7ec20138effd6d84eee60ffab788..b7f9c8a6de4c07f230f99b6bfa133216
// Paper start - fix sand duping
if (this.isRemoved()) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 1b8d43cf54999c9a005459bc59d7b5a50bb9c1ee..ebfd24f9fb90071288f0c872c0e3fbd58bb3f2b9 100644
index 7b5d96670c6818949a0be556b547347e559dd93a..95cfce87dd4057d7c24fb45629ac0df5f4dc814d 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -118,7 +118,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -107,7 +107,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations
}
- this.move(MoverType.SELF, this.getDeltaMovement());
+ this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura
// Paper start - Configurable TNT entity height nerf
if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
if (this.level.paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
this.discard();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Limited Get Entities
diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981ab3af1df0 100644
index 61c170555c8854b102c640b0b6a615f9f732edbf..40c075c90993cdc7d0e6b908ed0f290a78286960 100644
--- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
@@ -522,6 +522,128 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
@@ -459,6 +459,128 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
return slices;
}
@@ -42,7 +42,7 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a
+ for (int currZ = minZ; currZ <= maxZ; ++currZ) {
+ for (int currX = minX; currX <= maxX; ++currX) {
+ final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT));
+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) {
+ if (chunk == null || !chunk.status.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) {
+ continue;
+ }
+
@@ -82,7 +82,7 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a
+ for (int currZ = minZ; currZ <= maxZ; ++currZ) {
+ for (int currX = minX; currX <= maxX; ++currX) {
+ final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT));
+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) {
+ if (chunk == null || !chunk.status.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) {
+ continue;
+ }
+
@@ -122,7 +122,7 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a
+ for (int currZ = minZ; currZ <= maxZ; ++currZ) {
+ for (int currX = minX; currX <= maxX; ++currX) {
+ final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT));
+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) {
+ if (chunk == null || !chunk.status.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) {
+ continue;
+ }
+
@@ -138,10 +138,10 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a
final int minChunkX = (Mth.floor(box.minX) - 2) >> 4;
final int minChunkZ = (Mth.floor(box.minZ) - 2) >> 4;
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
index d917a19c838ed3d74322abd85e1f737e852b5d7b..1ba10713c85d6f19f075cc267602a04c7e048252 100644
index ce231d8b230d4983b21c597357c0b22377e4bcca..91b0e10a60173b428612e2515fdcfd62110a7a3e 100644
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
@@ -258,6 +258,30 @@ public final class ChunkEntitySlices {
@@ -253,6 +253,30 @@ public final class ChunkEntitySlices {
}
// Sakura end
@@ -172,7 +172,7 @@ index d917a19c838ed3d74322abd85e1f737e852b5d7b..1ba10713c85d6f19f075cc267602a04c
public void getHardCollidingEntities(final Entity except, final AABB box, final List<Entity> into, final Predicate<? super Entity> predicate) {
this.hardCollidingEntities.getEntities(except, box, into, predicate);
}
@@ -448,6 +472,155 @@ public final class ChunkEntitySlices {
@@ -443,6 +467,155 @@ public final class ChunkEntitySlices {
}
// Sakura end
@@ -329,10 +329,10 @@ index d917a19c838ed3d74322abd85e1f737e852b5d7b..1ba10713c85d6f19f075cc267602a04c
if (this.count == 0) {
return;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index c63c5c1451d5678ddea0d570ff2628af258490ae..a2f8040da7e8baa120e5dcdacb3c5b22f2f2eb46 100644
index 378197b05a074fc69ac2508d02acdc788242b49c..ae3dac2e1e1508c65b7464f64e74e470a42d668e 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -240,6 +240,39 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -301,6 +301,39 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
public final me.samsuik.sakura.explosion.DensityCache densityCache = new me.samsuik.sakura.explosion.DensityCache(); // Sakura

View File

@@ -5,18 +5,18 @@ Subject: [PATCH] isPushedByFluid API
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index b25ee7bf3ff5d8d533055f737c17e0e21b4f641a..1e5378f02dd51607dbb14e8886f2ab2b978bc92f 100644
index c3a028ef2fe49b9afb48b6f871b370b38976a09e..9e8847f1a8e54002f7ccf534dbe9da42a26794e0 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -679,6 +679,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -676,6 +676,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
discard();
}
// Sakura end
+ public boolean pushedByFluid = true; // Sakura
public boolean isLegacyTrackingEntity = false;
@@ -4235,7 +4236,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -3972,7 +3973,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public boolean isPushedByFluid() {
@@ -26,10 +26,10 @@ index b25ee7bf3ff5d8d533055f737c17e0e21b4f641a..1e5378f02dd51607dbb14e8886f2ab2b
public static double getViewScale() {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 1c3e1153d08b59d29b3613fc3b50a4780aa7a3ac..859e534d2880f4d14a2d066b4146e32cb1acfa25 100644
index 56c75029a94e8812c9e0ce5375aaa7cbcda90b87..322abc06dbcfbca328738f2528cc3b8c945f9654 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -200,6 +200,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
@@ -534,6 +534,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
return this.entity.isInWater();
}
@@ -47,4 +47,4 @@ index 1c3e1153d08b59d29b3613fc3b50a4780aa7a3ac..859e534d2880f4d14a2d066b4146e32c
+
@Override
public World getWorld() {
return this.entity.level().getWorld();
return entity.level.getWorld();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Cannon Mechanics
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index b7f9c8a6de4c07f230f99b6bfa1332166e696b49..7de6f027fc8a9e7d44ae1e5fa99690dcb04a89c7 100644
index bc1aeb4a7601027ca5c537d4f22ddf68e6558b27..5d386a3cb040854e724474ebf20119ed7661171e 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -67,6 +67,7 @@ public class FallingBlockEntity extends Entity {
@@ -65,6 +65,7 @@ public class FallingBlockEntity extends Entity {
public CompoundTag blockData;
protected static final EntityDataAccessor<BlockPos> DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS);
public boolean autoExpire = true; // Paper - Auto expire setting
@@ -16,7 +16,7 @@ index b7f9c8a6de4c07f230f99b6bfa1332166e696b49..7de6f027fc8a9e7d44ae1e5fa99690dc
public FallingBlockEntity(EntityType<? extends FallingBlockEntity> type, Level world) {
super(type, world);
@@ -75,6 +76,7 @@ public class FallingBlockEntity extends Entity {
@@ -73,6 +74,7 @@ public class FallingBlockEntity extends Entity {
this.fallDamageMax = 40;
this.isFallingBlock = true; // Sakura
this.loadChunks = world.sakuraConfig().cannons.sand.loadsChunks; // Sakura - load chunks
@@ -24,7 +24,7 @@ index b7f9c8a6de4c07f230f99b6bfa1332166e696b49..7de6f027fc8a9e7d44ae1e5fa99690dc
}
public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) {
@@ -183,6 +185,12 @@ public class FallingBlockEntity extends Entity {
@@ -181,6 +183,12 @@ public class FallingBlockEntity extends Entity {
return itemEntity;
}
// Sakura end
@@ -38,10 +38,10 @@ index b7f9c8a6de4c07f230f99b6bfa1332166e696b49..7de6f027fc8a9e7d44ae1e5fa99690dc
@Override
public void tick() {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index ebfd24f9fb90071288f0c872c0e3fbd58bb3f2b9..d534bc3ff8d5995ced0f9f89261cdcf1835698f4 100644
index 95cfce87dd4057d7c24fb45629ac0df5f4dc814d..595853612890d9330095cd478e32fb48ac920881 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -53,6 +53,12 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -43,6 +43,12 @@ public class PrimedTnt extends Entity implements TraceableEntity {
this.yo = y;
this.zo = z;
this.owner = igniter;
@@ -54,20 +54,20 @@ index ebfd24f9fb90071288f0c872c0e3fbd58bb3f2b9..d534bc3ff8d5995ced0f9f89261cdcf1
}
@Override
@@ -255,7 +261,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -222,7 +228,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
// Paper start - Optional prevent TNT from moving in water
@Override
public boolean isPushedByFluid() {
- return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - convenience
- return !level.paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
+ return !level.paperConfig().fixes.preventTntFromMovingInWater && level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - convenience
}
// Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
index c64ab06b62334e5ab1ab5ad78fa400de45c15723..94667eab6d756ee170eb49e2e434c7a3b0df2d67 100644
index 90df6530606e0a487dc70a1663980092f6f0b120..a69e95451705feea6365dc25c069e7341aec8915 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java
@@ -34,6 +34,16 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
@@ -35,6 +35,16 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock {
public void setStacked(int stacked) {
getHandle().setStacked(stacked);
}

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Cache MovingBlockEntity collision shape
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index 1ef87580574919796dbba707f44a413ee5c5781b..a971bb30ef8620f016a5968a9da40187ee31a3ef 100644
index 221c5d080d55326e458c1182823d6b49224ef498..26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -43,6 +43,11 @@ public class PistonMovingBlockEntity extends BlockEntity {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Optimise TNT fluid state and pushing
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 1e5378f02dd51607dbb14e8886f2ab2b978bc92f..2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd 100644
index 9e8847f1a8e54002f7ccf534dbe9da42a26794e0..a7c380e4b1be65c1c252dd7644d92a3c85ca6529 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2182,7 +2182,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2021,7 +2021,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.isInWater() || flag;
}
@@ -18,10 +18,10 @@ index 1e5378f02dd51607dbb14e8886f2ab2b978bc92f..2beb43acfd1e4cc26e50ae11fd1eec60
if (entity instanceof Boat) {
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index d534bc3ff8d5995ced0f9f89261cdcf1835698f4..dcb28daa8daf8fc2af020a7a94e3c9e51a2df63e 100644
index 595853612890d9330095cd478e32fb48ac920881..60254479c91de9770c32161ac3482f7e6a7177cf 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -116,6 +116,19 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -105,6 +105,19 @@ public class PrimedTnt extends Entity implements TraceableEntity {
}
*/
// Sakura end

View File

@@ -5,18 +5,18 @@ Subject: [PATCH] Optimise LivingEntity#pushEntities
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 45b1a182acf6b2aef40b714d31ca125d8f74619a..b01c09e45bf7452a40a7d9ad4eb1e1da08314d7d 100644
index 95a27d28f73039693ca64601954af62028413634..fe6fa875258ba64cf4ad90813c8b7c39c0af7245 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3557,7 +3557,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3472,7 +3472,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
return;
}
// Paper end - don't run getEntities if we're not going to use its result
- List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule
- List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, level.paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule
+ // Sakura start - optimise entity pushing
+ int limit = Math.max(i, this.level().paperConfig().collisions.maxEntityCollisions);
+ int limit = Math.max(i, this.level.paperConfig().collisions.maxEntityCollisions);
+ int search = limit * limit;
+ List<Entity> list = this.level().getLimitedEntities(this, this.getBoundingBox(), EntitySelector.pushable(this, level().paperConfig().collisions.fixClimbingBypassingCrammingRule), limit, search); // Paper - fix climbing bypassing cramming rule
+ List<Entity> list = this.level.getLimitedEntities(this, this.getBoundingBox(), EntitySelector.pushable(this, level.paperConfig().collisions.fixClimbingBypassingCrammingRule), limit, search); // Paper - fix climbing bypassing cramming rule
+ // Sakura end
if (!list.isEmpty()) {

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Wed, 15 Nov 2023 13:04:16 +0000
Subject: [PATCH] Despawn falling blocks inside moving pistons
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 5d386a3cb040854e724474ebf20119ed7661171e..c09f5ab720dbf67b4464d75727728caba24fc621 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -240,7 +240,7 @@ public class FallingBlockEntity extends Entity {
}
}
- if (!this.onGround && !flag1) {
+ if (!this.onGround && !flag1 || level.sakuraConfig().cannons.sand.despawnInsideMovingPistons && autoExpire && this.time > 600) { // Sakura
if (!this.level.isClientSide && ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level.getMinBuildHeight() || blockposition.getY() > this.level.getMaxBuildHeight()) || (this.time > 600 && autoExpire))) { // Paper - Auto expire setting
if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.spawnAtLocation((ItemLike) block);

View File

@@ -5,46 +5,46 @@ Subject: [PATCH] Configure Entity Knockback
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index b01c09e45bf7452a40a7d9ad4eb1e1da08314d7d..558c862f082d4e48c2c0d7ecf900f9354387d32b 100644
index fe6fa875258ba64cf4ad90813c8b7c39c0af7245..b4567ecd8e18e1afd8c4df99c2e521a5f40e0919 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1539,7 +1539,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1463,7 +1463,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
d0 = (Math.random() - Math.random()) * 0.01D;
}
- this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper
+ this.knockback((float) level().sakuraConfig().players.knockback.knockbackHorizontal, d0, d1, entity1); // Sakura // Paper
+ this.knockback((float) level.sakuraConfig().players.knockback.knockbackHorizontal, d0, d1, entity1); // Sakura // Paper
if (!flag) {
this.indicateDamage(d0, d1);
}
@@ -1586,7 +1586,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1511,7 +1511,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
protected void blockedByShield(LivingEntity target) {
- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper
+ target.knockback((float) level().sakuraConfig().players.knockback.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Sakura - configurable knockback // Paper
+ target.knockback((float) level.sakuraConfig().players.knockback.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Sakura - configurable knockback // Paper
}
private boolean checkTotemDeathProtection(DamageSource source) {
@@ -1903,13 +1903,23 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1823,13 +1823,24 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
public void knockback(double strength, double x, double z, Entity knockingBackEntity) {
// Paper end - add knockbacking entity parameter
- strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE);
+ strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * level().sakuraConfig().players.knockback.knockbackResistanceModifier; // Sakura
+ strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * level.sakuraConfig().players.knockback.knockbackResistanceModifier; // Sakura
if (strength > 0.0D) {
this.hasImpulse = true;
Vec3 vec3d = this.getDeltaMovement();
Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength);
- this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z);
+ // Sakura start - configure knockback
+ double velocityX = vec3d.x / 2.0D - vec3d1.x;
+ double velocityY = vec3d.y / 2.0D + (float) level().sakuraConfig().players.knockback.knockbackVertical;
+ double velocityY = vec3d.y / 2.0D + (float) level.sakuraConfig().players.knockback.knockbackVertical;
+ double velocityZ = vec3d.z / 2.0D - vec3d1.z;
+
+ if (!level().sakuraConfig().players.knockback.verticalLimitRequireGround || this.onGround()) {
+ velocityY = Math.min(velocityY, (float) level().sakuraConfig().players.knockback.knockbackVerticalLimit);
+ if (!level.sakuraConfig().players.knockback.verticalLimitRequireGround || this.onGround) {
+ velocityY = Math.min(velocityY, (float) level.sakuraConfig().players.knockback.knockbackVerticalLimit);
+ }
+
+ this.setDeltaMovement(velocityX, velocityY, velocityZ);
@@ -53,10 +53,10 @@ index b01c09e45bf7452a40a7d9ad4eb1e1da08314d7d..558c862f082d4e48c2c0d7ecf900f935
Vec3 currentMovement = this.getDeltaMovement();
org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z);
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index c3170384afa8d3bc4b1b428ecea04b1276621136..d0742bbf6f94705e378972e3bc0fab4682f3d78f 100644
index c125c963c1f0266fccf7a83ccd01641d5ea2a980..95b1e0c116fc070fe8c692f8c1aff63bd1825d99 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -183,6 +183,7 @@ public abstract class Player extends LivingEntity {
@@ -186,6 +186,7 @@ public abstract class Player extends LivingEntity {
public boolean affectsSpawning = true;
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET;
// Paper end
@@ -64,16 +64,16 @@ index c3170384afa8d3bc4b1b428ecea04b1276621136..d0742bbf6f94705e378972e3bc0fab46
// CraftBukkit start
public boolean fauxSleeping;
@@ -1272,7 +1273,7 @@ public abstract class Player extends LivingEntity {
@@ -1270,7 +1271,7 @@ public abstract class Player extends LivingEntity {
byte b0 = 0;
int i = b0 + EnchantmentHelper.getKnockbackBonus(this);
- if (this.isSprinting() && flag) {
+ if (this.isSprinting() && (!level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura
+ if (this.isSprinting() && (!level.sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura
sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility
++i;
flag1 = true;
@@ -1322,10 +1323,20 @@ public abstract class Player extends LivingEntity {
@@ -1320,10 +1321,20 @@ public abstract class Player extends LivingEntity {
if (flag5) {
if (i > 0) {
@@ -82,8 +82,8 @@ index c3170384afa8d3bc4b1b428ecea04b1276621136..d0742bbf6f94705e378972e3bc0fab46
+ long millis = System.currentTimeMillis();
+ long sinceLastKnockback = millis - lastSprintKnockback;
+
+ if (flag1 && sinceLastKnockback >= level().sakuraConfig().players.knockback.sprinting.knockbackDelay.value().orElse(0)) {
+ extraKnockback += -0.5F + (float) level().sakuraConfig().players.knockback.sprinting.extraKnockback;
+ if (flag1 && sinceLastKnockback >= level.sakuraConfig().players.knockback.sprinting.knockbackDelay.value().orElse(0)) {
+ extraKnockback += -0.5F + (float) level.sakuraConfig().players.knockback.sprinting.extraKnockback;
+ lastSprintKnockback = millis;
+ }
if (target instanceof LivingEntity) {
@@ -96,12 +96,12 @@ index c3170384afa8d3bc4b1b428ecea04b1276621136..d0742bbf6f94705e378972e3bc0fab46
}
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));
@@ -1347,7 +1358,7 @@ public abstract class Player extends LivingEntity {
@@ -1345,7 +1356,7 @@ public abstract class Player extends LivingEntity {
if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
// CraftBukkit start - Only apply knockback if the damage hits
if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API
- entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Pa
+ entityliving.knockback((float) level().sakuraConfig().players.knockback.sweepingEdgeKnockback, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Sakura // Pa
+ entityliving.knockback((float) level.sakuraConfig().players.knockback.sweepingEdgeKnockback, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Sakura // Pa
}
// CraftBukkit end
}

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Wed, 15 Nov 2023 13:04:16 +0000
Subject: [PATCH] Despawn falling blocks inside moving pistons
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 69f5f03a8e43f1e7370981009fe2376294b7253a..78fe35df4ef92f56d5ea2e80131fb7f4e71c9bea 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -242,7 +242,7 @@ public class FallingBlockEntity extends Entity {
}
}
- if (!this.onGround() && !flag1) {
+ if (!this.onGround() && !flag1 || level().sakuraConfig().cannons.sand.despawnInsideMovingPistons && autoExpire && this.time > 600) { // Sakura
if (!this.level().isClientSide && ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level().getMinBuildHeight() || blockposition.getY() > this.level().getMaxBuildHeight()) || (this.time > 600 && autoExpire))) { // Paper - Auto expire setting
if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.spawnAtLocation((ItemLike) block);

View File

@@ -74,10 +74,10 @@ index 0000000000000000000000000000000000000000..2e11ba36e9e820f17839d696e5d7d876
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 26b0c5d77fe10153300030c0f0fb0f63b552121a..5b85d87ae230b17c295ee54258293b5c4521e0a3 100644
index a9049e2cf29bdf90eb308f6b15a4374779032eec..cd095a5a921d1c1dd7cbc2adc2f3111801d23a5c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1751,6 +1751,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1580,6 +1580,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.minimalTNT.clear(); // Sakura - visibility api
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
worldserver.densityCache.clear(); // Sakura
@@ -86,13 +86,14 @@ index 26b0c5d77fe10153300030c0f0fb0f63b552121a..5b85d87ae230b17c295ee54258293b5c
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java b/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
index a8008c7550488be34b51f4280f5569170b1ebd1d..b10cfec6da6dfab89e585c5d4d39ae04f7d2e43d 100644
index a8008c7550488be34b51f4280f5569170b1ebd1d..2e5c4d610d648ec8608ff0e5bbe0f3b2bdc3973d 100644
--- a/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
+++ b/src/main/java/net/minecraft/world/item/ItemNameBlockItem.java
@@ -7,6 +7,33 @@ public class ItemNameBlockItem extends BlockItem {
@@ -6,6 +6,33 @@ public class ItemNameBlockItem extends BlockItem {
public ItemNameBlockItem(Block block, Item.Properties settings) {
super(block, settings);
}
+
+ // Sakura start
+ @Override
+ public net.minecraft.world.InteractionResult useOn(net.minecraft.world.item.context.UseOnContext context) {
@@ -112,43 +113,41 @@ index a8008c7550488be34b51f4280f5569170b1ebd1d..b10cfec6da6dfab89e585c5d4d39ae04
+ }
+
+ private void sendPotatoMessage(net.minecraft.world.entity.player.Player player, int remaining, int durability) {
+ player.getBukkitEntity().sendRichMessage(
+ player.getBukkitEntity().sendMessage(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(
+ me.samsuik.sakura.configuration.GlobalConfiguration.get().players.potatoMessage,
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.unparsed("remaining", String.valueOf(remaining)),
+ net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.unparsed("durability", String.valueOf(durability))
+ );
+ ));
+ }
+ // Sakura end
+
@Override
public String getDescriptionId() {
return this.getOrCreateDescriptionId();
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index fdc0a863aaf6fee90cea28966009088a9926cb1b..423f72ef68972f7023cf1716442f693ba4df7dc0 100644
index 3a622a84b3846e368b099a27bbc44afe03290db2..1f0e98d8cfb93511be2841dd4823a9006f8be8be 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -212,6 +212,17 @@ public class Explosion {
@@ -283,6 +283,16 @@ public class Explosion {
Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState);
Optional<Float> optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockposition, iblockdata, fluid);
+ // Sakura start - durable materials
+ if (calculateResistance) {
+ Block block = blockState.getBlock();
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(pos).durableMaterials.get(block);
+ // Sakura start - durable materials
+ // todo: on 1.20.2+ and higher this logic is only ran once, here it is every ray -> new block
+ Block block = iblockdata.getBlock();
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(mutableBlockPos).durableMaterials.get(block);
+
+ if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
+ resistance = Optional.of(material.resistance());
+ }
+ }
+ // Sakura end
+ if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
+ optional = Optional.of(material.resistance());
+ }
+ // Sakura end
+
ret = new ExplosionBlockCache(
key, pos, blockState, fluidState,
(resistance.orElse(ZERO_RESISTANCE).floatValue() + 0.3f) * 0.3f,
@@ -812,6 +823,16 @@ public class Explosion {
// CraftBukkit start - TNTPrimeEvent
if (optional.isPresent()) {
f -= ((Float) optional.get() + 0.3F) * 0.3F;
}
@@ -487,6 +497,16 @@ public class Explosion {
BlockState iblockdata = this.level.getBlockState(blockposition);
Block block = iblockdata.getBlock();
// CraftBukkit start - TNTPrimeEvent
+ // Sakura start - durable materials
+ if (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt) {
+ me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(blockposition).durableMaterials.get(block);
@@ -163,10 +162,10 @@ index fdc0a863aaf6fee90cea28966009088a9926cb1b..423f72ef68972f7023cf1716442f693b
Entity sourceEntity = this.source == null ? null : this.source;
BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.x, this.y, this.z) : null;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a2f8040da7e8baa120e5dcdacb3c5b22f2f2eb46..374d600692975a2e8514e8e99c7fa18599ef8dfc 100644
index ae3dac2e1e1508c65b7464f64e74e470a42d668e..dc5b4d9e98ed8feb55b0714270518b4d5beaa7e3 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -239,6 +239,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -300,6 +300,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
// Sakura end
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
public final me.samsuik.sakura.explosion.DensityCache densityCache = new me.samsuik.sakura.explosion.DensityCache(); // Sakura

View File

@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:59:04 +0000
Subject: [PATCH] Destroy Waterlogged Blocks
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 1f0e98d8cfb93511be2841dd4823a9006f8be8be..13606d7165bb2df19a45f95536f85fcad17c1375 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -281,6 +281,12 @@ public class Explosion {
break;
}
+ // Sakura start - destroy water logged blocks
+ if (!iblockdata.isAir() && this.level.sakuraConfig().cannons.explosion.destroyWaterloggedBlocks) {
+ fluid = Blocks.AIR.defaultBlockState().getFluidState();
+ }
+ // Sakura end
+
Optional<Float> optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockposition, iblockdata, fluid);
// Sakura start - durable materials

View File

@@ -341,10 +341,10 @@ index 0000000000000000000000000000000000000000..455e51b93c50f8bf3e84d11f373be7b1
+
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 5b85d87ae230b17c295ee54258293b5c4521e0a3..ae4930eef9b82d28e798b20b545da589e364cae0 100644
index cd095a5a921d1c1dd7cbc2adc2f3111801d23a5c..20ef1c7c94e4159bc1d177b2aaa9c7739d35b04f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1752,6 +1752,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1581,6 +1581,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.mergeHistory.expire(currentTickLong); // Sakura - merge cannoning entities
worldserver.densityCache.clear(); // Sakura
worldserver.durabilityManager.expire(currentTickLong); // Sakura
@@ -353,10 +353,10 @@ index 5b85d87ae230b17c295ee54258293b5c4521e0a3..ae4930eef9b82d28e798b20b545da589
this.isIteratingOverLevels = false; // Paper
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 374d600692975a2e8514e8e99c7fa18599ef8dfc..09ff77ec8967645df0de253f6e8ee8cb6b998c0d 100644
index dc5b4d9e98ed8feb55b0714270518b4d5beaa7e3..4aad7fd1abafef27dd27062c988154a8de0069c2 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -240,6 +240,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -301,6 +301,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura
public final me.samsuik.sakura.explosion.DensityCache densityCache = new me.samsuik.sakura.explosion.DensityCache(); // Sakura
public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura
@@ -364,19 +364,19 @@ index 374d600692975a2e8514e8e99c7fa18599ef8dfc..09ff77ec8967645df0de253f6e8ee8cb
// Sakura start - limited get entities
public void getLimitedEntities(Entity except, AABB box, Predicate<? super Entity> predicate, List<Entity> into, int limit, int search) {
@@ -1021,6 +1022,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
} else {
BlockState iblockdata2 = this.getBlockState(pos);
@@ -636,6 +637,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
this.getProfiler().pop();
}
+ this.redstoneTracker.invalidate(pos, iblockdata1, state); // Sakura
/*
if (iblockdata2 == iblockdata) {
if (iblockdata1 != iblockdata2) {
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
index 507be06ad51b7a212e28d3ca6680e0e4b00f4233..82bde0e37971e806b19d17fbf48c663c82399739 100644
index 5ea09cc455bd86beb450f0e0275d7c6c8da98084..cee593d1a0ac363ec863aa60d858c43df4bb3769 100644
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -382,7 +382,15 @@ public class RedStoneWireBlock extends Block {
@@ -375,7 +375,15 @@ public class RedStoneWireBlock extends Block {
}
if (oldPower != i) {
// CraftBukkit end
@@ -392,7 +392,7 @@ index 507be06ad51b7a212e28d3ca6680e0e4b00f4233..82bde0e37971e806b19d17fbf48c663c
world.setBlock(pos, (BlockState) state.setValue(RedStoneWireBlock.POWER, i), 2);
}
@@ -403,8 +411,17 @@ public class RedStoneWireBlock extends Block {
@@ -396,8 +404,17 @@ public class RedStoneWireBlock extends Block {
while (iterator.hasNext()) {
BlockPos blockposition1 = (BlockPos) iterator.next();

View File

@@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Thu, 16 Nov 2023 00:59:04 +0000
Subject: [PATCH] Destroy Waterlogged Blocks
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 01e1e59db95e1d47cd0dd2c10108934ff54de446..eaf260a9661d99f0991fdb5575b79990acfd60f9 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -210,6 +210,12 @@ public class Explosion {
BlockState blockState = chunk.getBlockStateFinal(x, y, z);
FluidState fluidState = blockState.getFluidState();
+ // Sakura start - destroy water logged blocks
+ if (calculateResistance && !blockState.isAir() && this.level.sakuraConfig().cannons.explosion.destroyWaterloggedBlocks) {
+ fluidState = Blocks.AIR.defaultBlockState().getFluidState();
+ }
+ // Sakura end
+
Optional<Float> resistance = !calculateResistance ? Optional.empty() : this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState);
// Sakura start - durable materials

View File

@@ -5,28 +5,30 @@ Subject: [PATCH] Falling Block Stacking Restrictions
diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
index 376322d8e47e24a76c7162d6379c7f71debd7505..872b874649ff5383af73f6b07dd59fdabea3ffb2 100644
index 46599109e55da0e4ce91c9b0c137d286a8cca78c..2aa7dbad27dfd5dc37b36a1f05e4d3e2f9d36339 100644
--- a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java
@@ -69,7 +69,7 @@ public class WorldConfiguration extends ConfigurationPart {
@@ -69,8 +69,8 @@ public class WorldConfiguration extends ConfigurationPart {
public boolean preventAtWorldHeight = false;
public boolean isFallingBlockInBounds(FallingBlockEntity entity) {
- return (!preventAgainstBorder || !io.papermc.paper.util.CollisionUtil.isAlmostCollidingOnBorder(entity.level().getWorldBorder(), entity.getBoundingBox()))
+ return (!preventAgainstBorder || !io.papermc.paper.util.CollisionUtil.isCollidingWithBorder(entity.level().getWorldBorder(), entity.getBoundingBox().inflate(0.01)))
&& (!preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxBuildHeight() - 1);
- && (!preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxBuildHeight() - 1);
+ return (!preventAgainstBorder || !io.papermc.paper.util.CollisionUtil.isAlmostCollidingOnBorder(entity.level.getWorldBorder(), entity.getBoundingBox().inflate(0.01)))
+ && (!preventAtWorldHeight || entity.blockPosition().getY() < entity.level.getMaxBuildHeight() - 1);
}
}
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index d7a3d869417983ea3758c2fab2de78c098826b19..6274c005f4f53f3cec0c94b7d40cdb7070b190e0 100644
index c09f5ab720dbf67b4464d75727728caba24fc621..254833aa760910e12123c795354ce531b7cb5567 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -260,7 +260,7 @@ public class FallingBlockEntity extends Entity {
boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1);
boolean flag4 = this.blockState.canSurvive(this.level(), blockposition) && !flag3;
@@ -258,7 +258,7 @@ public class FallingBlockEntity extends Entity {
boolean flag3 = FallingBlock.isFree(this.level.getBlockState(blockposition.below())) && (!flag || !flag1);
boolean flag4 = this.blockState.canSurvive(this.level, blockposition) && !flag3;
- if (flag2 && flag4) {
+ if (flag2 && flag4 && level().sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura
if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level().getFluidState(blockposition).getType() == Fluids.WATER) {
+ if (flag2 && flag4 && level.sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura
if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level.getFluidState(blockposition).getType() == Fluids.WATER) {
this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true);
}

View File

@@ -5,20 +5,20 @@ Subject: [PATCH] Added list of ItemEntity's that ignore explosions
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index a39db702063887cf530f272deaf4f334047cc7d4..1a29d35db958c60e014198536d65c4f903863049 100644
index d47b3ac633e7936d30abfda6fc46c2c7412d76fe..4f0d7581a15c7696eb33251591bae89b5cfeb063 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -578,6 +578,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -552,6 +552,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
}
+ // Sakura start
+ @Override
+ public boolean ignoreExplosion(net.minecraft.world.level.Explosion explosion) {
+ if (this.level().sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) {
+ public boolean ignoreExplosion() {
+ if (this.level.sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) {
+ return true;
+ } else {
+ return super.ignoreExplosion(explosion);
+ return super.ignoreExplosion();
+ }
+ }
+ // Sakura end

View File

@@ -5,15 +5,15 @@ Subject: [PATCH] Add option to disable entity ai
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 5af48151159135b869ec4753bbcf79dd257c1570..0b807081ad85ea91ecf397f6c29c6910010f8638 100644
index 02cb6b8c1d59855ff4a8aad3024fe12007eca0ee..3e8d3ec9fe19d2e16d93144d54bde351cc6060e8 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -897,7 +897,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
@@ -889,7 +889,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
@Override
protected final void serverAiStep() {
++this.noActionTime;
// Paper start - Allow nerfed mobs to jump and float
- if (!this.aware) {
+ if (!this.aware || this.level().sakuraConfig().entity.disableMobAi) { // Sakura
- if (!this.aware) { // Paper start - Allow nerfed mobs to jump, float and take water damage
+ if (!this.aware || this.level.sakuraConfig().entity.disableMobAi) { // Sakura // Paper start - Allow nerfed mobs to jump, float and take water damage
if (goalFloat != null) {
if (goalFloat.canUse()) goalFloat.tick();
this.getJumpControl().tick();

View File

@@ -5,13 +5,13 @@ Subject: [PATCH] Consistent Explosion Radius
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index eaf260a9661d99f0991fdb5575b79990acfd60f9..d13ba91f2c633517d46f59eaa938fd81d441fedb 100644
index 13606d7165bb2df19a45f95536f85fcad17c1375..b017d33ece7563af8fc4d5fdc080b6b8bda79c7d 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -580,7 +580,7 @@ public class Explosion {
double d2 = CACHED_RAYS[ray + 2];
ray += 3;
// Paper end - optimise explosions
@@ -235,7 +235,7 @@ public class Explosion {
double d1 = BLOCK_RAYCAST_VECTORS[1];
double d2 = BLOCK_RAYCAST_VECTORS[2];
- float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F);
+ float f = this.radius * (0.7F + (this.level.sakuraConfig().cannons.explosion.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura
double d4 = this.x;

View File

@@ -5,14 +5,14 @@ Subject: [PATCH] Remove spigot max tnt per tick
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index dcb28daa8daf8fc2af020a7a94e3c9e51a2df63e..8ee03ac1c824fd2476339202c073239292ef62a2 100644
index 60254479c91de9770c32161ac3482f7e6a7177cf..aa65887b72a96d87f0cad98047deffd01d60ec3f 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -132,7 +132,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -121,7 +121,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@Override
public void tick() {
- if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
- if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot
+ // Sakura - remove max tnt per tick
if (!this.isNoGravity()) {
this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations

View File

@@ -5,15 +5,15 @@ Subject: [PATCH] Option to configure entity water sensitivity
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 558c862f082d4e48c2c0d7ecf900f9354387d32b..7728492fd3623670482f4ca89e0934e7bcb972e1 100644
index b4567ecd8e18e1afd8c4df99c2e521a5f40e0919..7d1d3495e3a80732faadd5053ed09fdd86122366 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3502,7 +3502,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -3418,7 +3418,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
}
// Paper end
- if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
+ if (!this.level().isClientSide && this.level().sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura
- if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) {
+ if (!this.level.isClientSide && this.level.sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura
this.hurt(this.damageSources().drown(), 1.0F);
}

View File

@@ -5,25 +5,24 @@ Subject: [PATCH] Configure cannon physics by version
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
index 19086bbfdf3a015eafec5ca868c8d2451f554ef0..a40dcbde87860fd6d3b60d0b9e2d5e63e18e69b7 100644
index 04305ed8e75c5e83d08392c0f7f431cb77ac272e..9132adee72a2ae9c1c069a4f385c2b8d101484ba 100644
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -1495,6 +1495,14 @@ public final class CollisionUtil {
public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb,
final List<VoxelShape> voxels,
final List<AABB> aabbs) {
+ // Sakura start
+ return performCollisions(moveVector, axisalignedbb, voxels, aabbs, null);
@@ -248,7 +248,13 @@ public final class CollisionUtil {
return value;
}
+ // Sakura start
public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb, final List<AABB> potentialCollisions) {
+ return performCollisions(moveVector, axisalignedbb, potentialCollisions, null);
+ }
+ public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb,
+ final List<VoxelShape> voxels,
+ final List<AABB> aabbs,
+ final me.samsuik.sakura.physics.PhysicsVersion physics) {
+
+ public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb, final List<AABB> potentialCollisions, final me.samsuik.sakura.physics.PhysicsVersion physics) {
+ // Sakura end
if (voxels.isEmpty()) {
// fast track only AABBs
return performAABBCollisions(moveVector, axisalignedbb, aabbs);
@@ -1512,7 +1520,10 @@ public final class CollisionUtil {
double x = moveVector.x;
double y = moveVector.y;
double z = moveVector.z;
@@ -260,7 +266,10 @@ public final class CollisionUtil {
}
}
@@ -34,12 +33,12 @@ index 19086bbfdf3a015eafec5ca868c8d2451f554ef0..a40dcbde87860fd6d3b60d0b9e2d5e63
+ // Sakura end
if (xSmaller && z != 0.0) {
z = performAABBCollisionsZ(axisalignedbb, z, aabbs);
z = performCollisionsZ(axisalignedbb, z, potentialCollisions);
diff --git a/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java
index b87748ae90863abe8f85dcbdc5a202cb3c9e2037..a291516ec7bdb9d8b840f41ca52e6bbaf8e2e08a 100644
index 31eec14e78612e4cd6941c09f8b9093f324dce7e..45759424f389fb8a930688592a86332069d7f9fe 100644
--- a/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java
+++ b/src/main/java/me/samsuik/sakura/explosion/SakuraExplosion.java
@@ -163,7 +163,7 @@ public class SakuraExplosion extends Explosion {
@@ -141,7 +141,7 @@ public class SakuraExplosion extends Explosion {
// update explosion position
x = source.getX();
@@ -48,7 +47,7 @@ index b87748ae90863abe8f85dcbdc5a202cb3c9e2037..a291516ec7bdb9d8b840f41ca52e6bba
z = source.getZ();
}
@@ -256,10 +256,17 @@ public class SakuraExplosion extends Explosion {
@@ -232,10 +232,17 @@ public class SakuraExplosion extends Explosion {
if (distanceFromBottom > 1.0) continue;
double x = entity.getX() - pos.x;
@@ -67,7 +66,7 @@ index b87748ae90863abe8f85dcbdc5a202cb3c9e2037..a291516ec7bdb9d8b840f41ca52e6bba
if (distance == 0.0D) continue;
x /= distance;
@@ -304,10 +311,17 @@ public class SakuraExplosion extends Explosion {
@@ -280,10 +287,17 @@ public class SakuraExplosion extends Explosion {
if (distanceFromBottom <= 1.0) {
double x = entity.getX() - pos.x;
@@ -87,10 +86,10 @@ index b87748ae90863abe8f85dcbdc5a202cb3c9e2037..a291516ec7bdb9d8b840f41ca52e6bba
x /= distance;
y /= distance;
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac13d2b334 100644
index a7c380e4b1be65c1c252dd7644d92a3c85ca6529..888801fc3468970bffe63fbefbae63e1d851f403 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -378,7 +378,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -363,7 +363,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
private final double[] pistonDeltas;
private long pistonDeltasGameTime;
private EntityDimensions dimensions;
@@ -99,7 +98,7 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
public boolean isInPowderSnow;
public boolean wasInPowderSnow;
public boolean wasOnFire;
@@ -680,6 +680,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -677,6 +677,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
// Sakura end
public boolean pushedByFluid = true; // Sakura
@@ -111,18 +110,9 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
+ }
+ // Sakura end
public boolean isLegacyTrackingEntity = false;
@@ -1166,7 +1173,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) {
- if (onGround) {
+ if (onGround && this.physics.afterOrEqual(1_20_0)) { // Sakura - physics version
AABB axisalignedbb = this.getBoundingBox();
AABB axisalignedbb1 = new AABB(axisalignedbb.minX, axisalignedbb.minY - 1.0E-6D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ);
Optional<BlockPos> optional = this.level.findSupportingBlock(this, axisalignedbb1);
@@ -1228,7 +1235,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -1143,7 +1150,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.noPhysics) {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
@@ -131,7 +121,7 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
movement = this.limitPistonMovement(movement);
if (movement.equals(Vec3.ZERO)) {
return;
@@ -1246,10 +1253,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1161,10 +1168,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Vec3 vec3d1 = this.collideScan(movement);
double d0 = vec3d1.lengthSqr();
@@ -141,10 +131,10 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
// The only block I am aware of is powdered snow that has a special case for falling blocks.
- if (this.fallDistance != 0.0F && d0 >= 1.0D && !isFallingBlock) {
+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !isFallingBlock && this.physics.afterOrEqual(1_18_2)) { // Sakura - physics version api
BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
BlockHitResult movingobjectpositionblock = this.level.clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
if (movingobjectpositionblock.getType() != HitResult.Type.MISS) {
@@ -1285,6 +1292,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1200,6 +1207,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.horizontalCollision) {
Vec3 vec3d2 = this.getDeltaMovement();
@@ -157,7 +147,7 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
}
@@ -1325,7 +1338,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1240,7 +1253,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z);
} else {
this.wasOnFire = this.isOnFire();
@@ -166,7 +156,7 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper
this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper
movement = this.limitPistonMovement(movement);
@@ -1352,8 +1365,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1267,8 +1280,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
Vec3 vec3d1 = this.collide(movement);
double d0 = vec3d1.lengthSqr();
@@ -174,10 +164,10 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
- if (this.fallDistance != 0.0F && d0 >= 1.0D) {
+ if (d0 > 1.0E-7D || this.physics.before(1_14_0)) { // Sakura - physics version api
+ if (this.fallDistance != 0.0F && d0 >= 1.0D && this.physics.afterOrEqual(1_18_2)) { // Sakura - physics version api
BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
BlockHitResult movingobjectpositionblock = this.level.clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this));
if (movingobjectpositionblock.getType() != HitResult.Type.MISS) {
@@ -1389,6 +1402,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1304,6 +1317,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
if (this.horizontalCollision) {
Vec3 vec3d2 = this.getDeltaMovement();
@@ -190,7 +180,7 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z);
}
@@ -1712,7 +1731,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1600,7 +1619,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
double y = movement.y;
double z = movement.z;
@@ -201,17 +191,17 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
+ // Sakura end
if (y != 0.0) {
y = scanY(currBoundingBox, y, voxelList, bbList);
@@ -1828,7 +1850,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return movement;
}
y = scanY(currBoundingBox, y, bbList);
@@ -1707,7 +1729,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions);
}
- final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB);
+ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB, this.physics); // Sakura - physics version api
- final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions);
+ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions, this.physics); // Sakura - physics version api
if (stepHeight > 0.0
&& (onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0))
@@ -1944,8 +1966,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (stepHeight > 0.0
&& (this.onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0))
@@ -1826,8 +1848,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
protected void checkInsideBlocks() {
AABB axisalignedbb = this.getBoundingBox();
@@ -223,13 +213,13 @@ index 2beb43acfd1e4cc26e50ae11fd1eec6080d7c1fd..599706984734b8979b432b1bbc15f8ac
+ BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset);
+ // Sakura end
if (this.level().hasChunksAt(blockposition, blockposition1)) {
if (this.level.hasChunksAt(blockposition, blockposition1)) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5b37d6b0a 100644
index 254833aa760910e12123c795354ce531b7cb5567..855f6797611846dad7b2cab3bde816d898cfcc0b 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -89,6 +89,8 @@ public class FallingBlockEntity extends Entity {
@@ -87,6 +87,8 @@ public class FallingBlockEntity extends Entity {
this.yo = y;
this.zo = z;
this.setStartPos(this.blockPosition());
@@ -238,9 +228,9 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
}
public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) {
@@ -101,7 +103,11 @@ public class FallingBlockEntity extends Entity {
@@ -99,7 +101,11 @@ public class FallingBlockEntity extends Entity {
FallingBlockEntity entityfallingblock = new FallingBlockEntity(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) ? (BlockState) iblockdata.setValue(BlockStateProperties.WATERLOGGED, false) : iblockdata);
if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit
if (CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) return entityfallingblock; // CraftBukkit
- world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3);
+ // Sakura start - physics version api
@@ -251,7 +241,7 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit
return entityfallingblock;
}
@@ -188,7 +194,44 @@ public class FallingBlockEntity extends Entity {
@@ -186,7 +192,44 @@ public class FallingBlockEntity extends Entity {
// Sakura start
@Override
public final double getEyeY() {
@@ -278,26 +268,26 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
+
+ private boolean isAbleToStackOnBlock() {
+ BlockPos pos = BlockPos.containing(this.getX(), this.getY() - 0.001f, this.getZ());
+ BlockState state = this.level().getBlockState(pos);
+ BlockState state = this.level.getBlockState(pos);
+ return !FallingBlock.isFree(state);
+ }
+
+ private void removeBlockOnFall(Block block) {
+ BlockPos blockposition = this.blockPosition();
+ BlockState blockstate = this.level().getBlockState(blockposition);
+ BlockState blockstate = this.level.getBlockState(blockposition);
+
+ if (blockstate.is(block) && CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) {
+ this.level().removeBlock(blockposition, false);
+ if (blockstate.is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ this.level.removeBlock(blockposition, false);
+ } else {
+ if (blockstate.is(block)) {
+ ((ServerLevel) level()).getChunkSource().blockChanged(blockposition);
+ ((ServerLevel) level).getChunkSource().blockChanged(blockposition);
+ }
+ this.discard();
+ }
}
// Sakura end
@@ -204,9 +247,16 @@ public class FallingBlockEntity extends Entity {
@@ -202,9 +245,16 @@ public class FallingBlockEntity extends Entity {
} else {
Block block = this.blockState.getBlock();
@@ -315,7 +305,7 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
}
this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura
@@ -227,8 +277,16 @@ public class FallingBlockEntity extends Entity {
@@ -225,8 +275,16 @@ public class FallingBlockEntity extends Entity {
return;
}
// Paper end
@@ -323,7 +313,7 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
+ if (this.physics.before(1_12_0)) {
+ this.scaleDeltaMovement(0.98F);
+ }
if (!this.level().isClientSide) {
if (!this.level.isClientSide) {
- BlockPos blockposition = this.blockPosition();
+ // Patching the floating point issue on modern versions can break some cannons that rely on it.
+ // However, it makes sense for legacy versions pre-1.17 before the world height change.
@@ -331,11 +321,11 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
+ // Sakura end
+
boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER);
boolean flag1 = flag && this.level.getFluidState(blockposition).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr();
@@ -253,8 +311,11 @@ public class FallingBlockEntity extends Entity {
@@ -251,8 +309,11 @@ public class FallingBlockEntity extends Entity {
} else {
BlockState iblockdata = this.level().getBlockState(blockposition);
BlockState iblockdata = this.level.getBlockState(blockposition);
- this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations
- if (!iblockdata.is(Blocks.MOVING_PISTON)) {
@@ -345,9 +335,9 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
+ if (!iblockdata.is(Blocks.MOVING_PISTON) && (flag1 || !this.physics.isWithin(1_9_0, 1_12_0) || this.isAbleToStackOnBlock())) {
+ // Sakura end
if (!this.cancelDrop) {
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP)));
boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1);
@@ -321,7 +382,12 @@ public class FallingBlockEntity extends Entity {
boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level, blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP)));
boolean flag3 = FallingBlock.isFree(this.level.getBlockState(blockposition.below())) && (!flag || !flag1);
@@ -319,7 +380,12 @@ public class FallingBlockEntity extends Entity {
}
}
@@ -362,10 +352,10 @@ index 6274c005f4f53f3cec0c94b7d40cdb7070b190e0..586c957d33a4ffbdc584267e1f10c8e5
}
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 8ee03ac1c824fd2476339202c073239292ef62a2..5e588332f5916355293553012c73a647b1f4bd89 100644
index aa65887b72a96d87f0cad98047deffd01d60ec3f..c3c053884101b818274400f0ebcd66909e95c239 100644
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
@@ -59,6 +59,13 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -49,6 +49,13 @@ public class PrimedTnt extends Entity implements TraceableEntity {
case Y -> multiplyDeltaMovement(0, 1, 0);
}
// Sakura end
@@ -379,7 +369,7 @@ index 8ee03ac1c824fd2476339202c073239292ef62a2..5e588332f5916355293553012c73a647
}
@Override
@@ -129,12 +136,30 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -118,12 +125,30 @@ public class PrimedTnt extends Entity implements TraceableEntity {
}
}
// Sakura end
@@ -411,14 +401,14 @@ index 8ee03ac1c824fd2476339202c073239292ef62a2..5e588332f5916355293553012c73a647
}
this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura
@@ -144,15 +169,18 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -133,15 +158,18 @@ public class PrimedTnt extends Entity implements TraceableEntity {
return;
}
// Paper end
- this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations
+ double drag = this.physics.before(1_14_0) ? 0.98F : 0.98D;
+ this.scaleDeltaMovement(drag); // Sakura - reduce movement allocations
if (this.onGround()) {
if (this.onGround) {
- this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations
+ double friction = this.physics.before(1_14_0) ? 0.7F : 0.7D;
+ this.multiplyDeltaMovement(friction, -0.5D, friction); // Sakura - reduce movement allocations
@@ -433,71 +423,71 @@ index 8ee03ac1c824fd2476339202c073239292ef62a2..5e588332f5916355293553012c73a647
// 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.respawnMerged(); // Sakura
@@ -205,7 +233,10 @@ public class PrimedTnt extends Entity implements TraceableEntity {
ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity());
@@ -196,7 +224,10 @@ public class PrimedTnt extends Entity implements TraceableEntity {
this.level.getCraftServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
- this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
+ // Sakura start - physics version api
+ double pos = this.physics.before(1_10_0) ? this.getY() + (double) 0.49f : this.getY(0.0625D);
+ this.level().explode(this, this.getX(), pos, this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
+ this.level.explode(this, this.getX(), pos, this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT);
+ // Sakura end
}
// CraftBukkit end
}
@@ -274,7 +305,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@@ -241,7 +272,7 @@ public class PrimedTnt extends Entity implements TraceableEntity {
// Paper start - Optional prevent TNT from moving in water
@Override
public boolean isPushedByFluid() {
- return !level().paperConfig().fixes.preventTntFromMovingInWater && level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - convenience
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && !this.physics.isLegacy() && level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - physics version // Sakura - convenience
- return !level.paperConfig().fixes.preventTntFromMovingInWater && level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - convenience
+ return !level.paperConfig().fixes.preventTntFromMovingInWater && !this.physics.isLegacy() && level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - physics version // Sakura - convenience
}
// Paper end
}
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 5a10afb92fd62f433be9be6751e5222f3666c9f3..d92798d848754bb02f2de9ee91e1342ceb8e150c 100644
index b017d33ece7563af8fc4d5fdc080b6b8bda79c7d..8646302289669685cd44bb70231a110b4b09affc 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -74,6 +74,7 @@ public class Explosion {
public boolean wasCanceled = false;
public float yield;
// CraftBukkit end
@@ -68,6 +68,7 @@ public class Explosion {
private final ObjectArrayList<BlockPos> toBlow;
private final Map<Player, Vec3> hitPlayers;
public boolean wasCanceled = false; // CraftBukkit - add field
+ protected final me.samsuik.sakura.physics.PhysicsVersion physics; // Sakura - physics version
public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) {
return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source));
@@ -111,6 +112,7 @@ public class Explosion {
this.largeExplosionParticles = emitterParticle;
this.explosionSound = soundEvent;
this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit
public Explosion(Level world, @Nullable Entity entity, double x, double y, double z, float power, List<BlockPos> affectedBlocks) {
this(world, entity, x, y, z, power, false, Explosion.BlockInteraction.DESTROY_WITH_DECAY, affectedBlocks);
@@ -96,6 +97,7 @@ public class Explosion {
this.blockInteraction = destructionType;
this.damageSource = damageSource == null ? world.damageSources().explosion(this) : damageSource;
this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior;
+ this.physics = entity != null ? entity.physics() : world.localConfig().config(BlockPos.containing(x, y, z)).physicsVersion; // Sakura
}
// Paper start - optimise collisions
@@ -489,9 +491,17 @@ public class Explosion {
// Sakura start
@@ -182,9 +184,17 @@ public class Explosion {
Vec3 vec3d1 = new Vec3(d8 + d3, d9, d10 + d4);
// Sakura start
+ final net.minecraft.world.phys.HitResult.Type hitResult;
if (data != null && data.isExpandable() && data.has(vec3d1)) {
- i += (int) data.density();
- } else if (entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
- } else if (entity.level.clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType() == HitResult.Type.MISS) {
+ hitResult = data.density() == 1.0 ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK;
+ } else {
+ if (entity.physics().afterOrEqual(1_14_0)) {
+ hitResult = entity.level().rayTrace(vec3d1, source);
+ hitResult = entity.level.rayTrace(vec3d1, source);
+ } else {
+ hitResult = entity.level().clip(new ClipContext(vec3d1, source, entity.physics().afterOrEqual(1_16_0) ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getType();
+ hitResult = entity.level.clip(new ClipContext(vec3d1, source, entity.physics().afterOrEqual(1_16_0) ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getType();
+ }
+ }
+ if (hitResult == net.minecraft.world.phys.HitResult.Type.MISS) {
// Sakura end
++i;
}
@@ -605,6 +615,10 @@ public class Explosion {
}
@@ -278,6 +288,10 @@ public class Explosion {
FluidState fluid = iblockdata.getFluidState(); // Paper
if (cachedBlock.outOfWorld) {
if (!this.level.isInWorldBounds(blockposition)) {
+ // Sakura start - physics version api
+ if (this.physics.before(1_17_0))
+ continue;
@@ -505,7 +495,7 @@ index 5a10afb92fd62f433be9be6751e5222f3666c9f3..d92798d848754bb02f2de9ee91e1342c
break;
}
@@ -675,10 +689,17 @@ public class Explosion {
@@ -350,10 +364,17 @@ public class Explosion {
if (d7 <= 1.0D) {
double d8 = entity.getX() - this.x;
@@ -524,27 +514,11 @@ index 5a10afb92fd62f433be9be6751e5222f3666c9f3..d92798d848754bb02f2de9ee91e1342c
if (d11 != 0.0D) {
d8 /= d11;
d9 /= d11;
@@ -986,7 +1007,14 @@ public class Explosion {
return data.density();
}
- float blockDensity = this.getSeenFraction(vec3d, entity, data, blockCache, blockPos); // Paper - optimise explosions;
+ // Sakura start - physics version api
+ final float blockDensity;
+ if (this.physics.afterOrEqual(1_16_0)) {
+ blockDensity = this.getSeenFraction(vec3d, entity, data, blockCache, blockPos); // Paper - optimise explosions;
+ } else {
+ blockDensity = this.getSeenPercent(vec3d, entity, data);
+ }
+ // Sakura end
if (data == null || !data.isExpandable() && (blockDensity == 0.0f || blockDensity == 1.0f)) {
level.densityCache.createCache(key, entity, vec3d, blockDensity);
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 3292c06d040b6c1996f27a34532ed098f9e7a6c9..cd022e636bf31186b7be36d671932b8e0355d948 100644
index 4aad7fd1abafef27dd27062c988154a8de0069c2..da90ed4be7a5ca14576f8de93a17bdba5a6b5457 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -274,6 +274,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -335,6 +335,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return this.getLimitedEntities(except, box, net.minecraft.world.entity.EntitySelector.NO_SPECTATORS, limit, search);
}
// Sakura end
@@ -751,10 +725,10 @@ index 3292c06d040b6c1996f27a34532ed098f9e7a6c9..cd022e636bf31186b7be36d671932b8e
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, RegistryAccess iregistrycustom, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, Supplier<me.samsuik.sakura.configuration.WorldConfiguration> sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
diff --git a/src/main/java/net/minecraft/world/level/block/FallingBlock.java b/src/main/java/net/minecraft/world/level/block/FallingBlock.java
index 1079a99d6a6c9fba36414a863e1454bb2a7f298a..4ee105548df2a730f192d4b511a399d129824df6 100644
index 5b634fe75c52ecf7a930baabd55dcee1a241ddce..585bd9c8592ae6e78789ed326c5d3cfa8f08f58f 100644
--- a/src/main/java/net/minecraft/world/level/block/FallingBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FallingBlock.java
@@ -35,6 +35,15 @@ public abstract class FallingBlock extends Block implements Fallable {
@@ -32,6 +32,15 @@ public class FallingBlock extends Block implements Fallable {
return super.updateShape(state, direction, neighborState, world, pos, neighborPos);
}
@@ -771,10 +745,10 @@ index 1079a99d6a6c9fba36414a863e1454bb2a7f298a..4ee105548df2a730f192d4b511a399d1
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
if (isFree(world.getBlockState(pos.below())) && pos.getY() >= world.getMinBuildHeight()) {
diff --git a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java b/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java
index 6524272aab5a876e2a2164181da72c765959b550..4c242b501e7e5c7af6676b9554b00405838c4eb0 100644
index baaf648f65042a9c6bf41eaba595dce2aa6bb187..80ffca333158208c2c179464873ded8a1b09a125 100644
--- a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java
@@ -180,8 +180,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock {
@@ -152,8 +152,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock {
}
// CraftBukkit end
@@ -791,10 +765,10 @@ index 6524272aab5a876e2a2164181da72c765959b550..4c242b501e7e5c7af6676b9554b00405
world.playSound((Player) null, pos, flag1 ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F);
world.gameEvent((Entity) null, flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos);
diff --git a/src/main/java/net/minecraft/world/level/block/LadderBlock.java b/src/main/java/net/minecraft/world/level/block/LadderBlock.java
index de87b54895d5a63d32c1734ccdac63246c9f2c5f..79bced0e284430d57d4a7ec80a57d717249e7e36 100644
index 6bcc83245e8046518921b82d948d45900ae0c8db..f907079bb99855c946a8943ff0ed5480eeb3e909 100644
--- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LadderBlock.java
@@ -28,6 +28,21 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
@@ -26,14 +26,39 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
protected static final VoxelShape WEST_AABB = Block.box(13.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D);
protected static final VoxelShape SOUTH_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 3.0D);
protected static final VoxelShape NORTH_AABB = Block.box(0.0D, 0.0D, 13.0D, 16.0D, 16.0D, 16.0D);
@@ -814,9 +788,8 @@ index de87b54895d5a63d32c1734ccdac63246c9f2c5f..79bced0e284430d57d4a7ec80a57d717
+ }
+ // Sakura end
@Override
public MapCodec<LadderBlock> codec() {
@@ -39,8 +54,18 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock {
protected LadderBlock(BlockBehaviour.Properties settings) {
super(settings);
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false)));
}
@@ -836,10 +809,10 @@ index de87b54895d5a63d32c1734ccdac63246c9f2c5f..79bced0e284430d57d4a7ec80a57d717
case NORTH:
return NORTH_AABB;
diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
index 2bd097203f1e92d3fc343f91dc37220e09dd5066..2fe44dae063eb0cd7d4813fb6b2937830d432e51 100644
index 43e8ef1d6a65d4fd3fe53a587639ffb814368217..28bdb44599a8862d58cfb2e087119b843f25f311 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -192,8 +192,26 @@ public class LiquidBlock extends Block implements BucketPickup {
@@ -154,8 +154,26 @@ public class LiquidBlock extends Block implements BucketPickup {
BlockPos blockposition1 = pos.relative(enumdirection.getOpposite());
if (world.getFluidState(blockposition1).is(FluidTags.WATER)) {
@@ -869,10 +842,10 @@ index 2bd097203f1e92d3fc343f91dc37220e09dd5066..2fe44dae063eb0cd7d4813fb6b293783
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, pos, block.defaultBlockState())) {
this.fizz(world, pos);
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
index 82bde0e37971e806b19d17fbf48c663c82399739..570694ba570135542d4184ac9d03f29132b28df8 100644
index cee593d1a0ac363ec863aa60d858c43df4bb3769..7da6447f41606bfe25b0dc6106e3419998ed1443 100644
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -685,6 +685,10 @@ public class RedStoneWireBlock extends Block {
@@ -678,6 +678,10 @@ public class RedStoneWireBlock extends Block {
public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
if (!player.getAbilities().mayBuild) {
return InteractionResult.PASS;
@@ -884,18 +857,18 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..570694ba570135542d4184ac9d03f291
if (RedStoneWireBlock.isCross(state) || RedStoneWireBlock.isDot(state)) {
BlockState iblockdata1 = RedStoneWireBlock.isCross(state) ? this.defaultBlockState() : this.crossState;
diff --git a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java b/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
index b6105d178778b326c11b7d29c5e4d8aa2c3a3875..7ff78fb671dc2791378802cda89c358eda15f2ae 100644
index bd4295f8d24ca9fd8c3af31abcd13da24db1c5d5..648a50e55baabc37fb7376aa061ae63110297c2e 100644
--- a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java
@@ -21,6 +21,7 @@ public class WaterlilyBlock extends BushBlock {
@@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
public class WaterlilyBlock extends BushBlock {
public static final MapCodec<WaterlilyBlock> CODEC = simpleCodec(WaterlilyBlock::new);
protected static final VoxelShape AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 1.5D, 15.0D);
+ protected static final VoxelShape LEGACY_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 0.25D, 16.0D); // Sakura
@Override
public MapCodec<WaterlilyBlock> codec() {
@@ -46,8 +47,18 @@ public class WaterlilyBlock extends BushBlock {
protected WaterlilyBlock(BlockBehaviour.Properties settings) {
super(settings);
@@ -32,8 +33,18 @@ public class WaterlilyBlock extends BushBlock {
}
@@ -915,10 +888,10 @@ index b6105d178778b326c11b7d29c5e4d8aa2c3a3875..7ff78fb671dc2791378802cda89c358e
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
index d3d1ad7901411574b85b0febd1c7ddaa8ad7c9f4..cc2c601032b2a2d94aa74cc3ad7169c202b354ab 100644
index 968f4447e64b7bb98edc3a63cd01ddf23c2462d6..fb09ba283389bd834d45a68c6dff4ae1080b9cb3 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java
@@ -111,6 +111,17 @@ public class MovingPistonBlock extends BaseEntityBlock {
@@ -103,6 +103,17 @@ public class MovingPistonBlock extends BaseEntityBlock {
@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) {
PistonMovingBlockEntity pistonMovingBlockEntity = this.getBlockEntity(world, pos);
@@ -937,10 +910,10 @@ index d3d1ad7901411574b85b0febd1c7ddaa8ad7c9f4..cc2c601032b2a2d94aa74cc3ad7169c2
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index b9025fcc6a4db9533cdc42034c9e77323d0785fa..fd7563a8b6ab8165c1ba7b4959a3bf9369d20e75 100644
index f456ad8a74464414f69b616a48ee9a2c1cee4d90..bd1ebeccb75408b59cdf8ebe600da1a06f042131 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -170,6 +170,11 @@ public class PistonBaseBlock extends DirectionalBlock {
@@ -157,6 +157,11 @@ public class PistonBaseBlock extends DirectionalBlock {
// }
// PAIL: checkME - what happened to setTypeAndData?
// CraftBukkit end
@@ -953,10 +926,10 @@ index b9025fcc6a4db9533cdc42034c9e77323d0785fa..fd7563a8b6ab8165c1ba7b4959a3bf93
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
index 5301095fa3baac1bde3767153ee2343026596688..1ef830d5e34f25c08d53d693db99a6eb641ebbe5 100644
index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..df6e859688c5b45a541b11f2046395474c083c1b 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java
@@ -139,6 +139,11 @@ public class PistonHeadBlock extends DirectionalBlock {
@@ -132,6 +132,11 @@ public class PistonHeadBlock extends DirectionalBlock {
@Override
public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos.relative(state.getValue(FACING).getOpposite()));
@@ -968,7 +941,7 @@ index 5301095fa3baac1bde3767153ee2343026596688..1ef830d5e34f25c08d53d693db99a6eb
return this.isFittingBase(state, blockState) || blockState.is(Blocks.MOVING_PISTON) && blockState.getValue(FACING) == state.getValue(FACING);
}
@@ -146,6 +151,10 @@ public class PistonHeadBlock extends DirectionalBlock {
@@ -139,6 +144,10 @@ public class PistonHeadBlock extends DirectionalBlock {
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) {
if (state.canSurvive(world, pos)) {
world.neighborChanged(pos.relative(state.getValue(FACING).getOpposite()), sourceBlock, sourcePos);
@@ -980,7 +953,7 @@ index 5301095fa3baac1bde3767153ee2343026596688..1ef830d5e34f25c08d53d693db99a6eb
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index a971bb30ef8620f016a5968a9da40187ee31a3ef..68bac9ea693f4457a8ced072cae85aef076eeb71 100644
index 26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8..21ede03d8e630169119d7432227cfba40461760f 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -159,6 +159,13 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -1179,10 +1152,10 @@ index a971bb30ef8620f016a5968a9da40187ee31a3ef..68bac9ea693f4457a8ced072cae85aef
}
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 6d59f8b68d644cb43939bcdf5239fa1caf54ed47..96ccad764cb6424ffe561c558cd11200d89ff541 100644
index 83b74887363164c3b938e8fc9741d502921e73d1..f8c1926a0db9c45fee7e794d14f1fe540918a1e2 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -528,7 +528,7 @@ public abstract class FlowingFluid extends Fluid {
@@ -517,7 +517,7 @@ public abstract class FlowingFluid extends Fluid {
this.spread(world, pos, state);
}
@@ -1192,7 +1165,7 @@ index 6d59f8b68d644cb43939bcdf5239fa1caf54ed47..96ccad764cb6424ffe561c558cd11200
}
diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
index c3f8e1e2dd89c168b8b4a15b589109db486bc8d7..1dab5318d8693d15ee879456dff3a1916cfad335 100644
index 783e315d92227cbcb5cd207b0a06a12e0778d14b..ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -175,7 +175,10 @@ public abstract class LavaFluid extends FlowingFluid {
@@ -1208,7 +1181,7 @@ index c3f8e1e2dd89c168b8b4a15b589109db486bc8d7..1dab5318d8693d15ee879456dff3a191
@Override
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
index d280c98aed5262c4ce39526c917de884f25a8584..521b8084e490d5f3ecacd1d7368dddee22647aa9 100644
index 82e85fbbd45244d02df90fa00c9046e7f51275a2..43df400227429a8a1a18d5ad6fce8a57b198e766 100644
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
@@ -104,7 +104,10 @@ public abstract class WaterFluid extends FlowingFluid {

View File

@@ -5,12 +5,12 @@ Subject: [PATCH] Allow water in the nether
diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java
index aa0f09a18ea781e027ea70928b30d3e93061120f..3dafde37bcddd81cbe7a7ba938db5b1cbe14a42f 100644
index 5c6aa9c464784ad5ee366412d080c72d3d22a76f..4f21231d6ede7bf1b82185f115b2c48b87732c14 100644
--- a/src/main/java/net/minecraft/world/item/BucketItem.java
+++ b/src/main/java/net/minecraft/world/item/BucketItem.java
@@ -195,7 +195,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
@@ -166,7 +166,7 @@ public class BucketItem extends Item implements DispensibleContainerItem {
// CraftBukkit end
if (!flag2) {
if (!flag1) {
return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (BlockHitResult) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit
- } else if (world.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) {
+ } else if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { // Sakura
@@ -18,10 +18,10 @@ index aa0f09a18ea781e027ea70928b30d3e93061120f..3dafde37bcddd81cbe7a7ba938db5b1c
int j = blockposition.getY();
int k = blockposition.getZ();
diff --git a/src/main/java/net/minecraft/world/level/block/IceBlock.java b/src/main/java/net/minecraft/world/level/block/IceBlock.java
index 4ab6997dad5b112f5105f786a6cee78c6c5667e8..c7dd921ab70ac53559208c58fbf9dec991b1f26b 100644
index 5ecf02ce83b7496c977adfeb203b8eadb05f9da5..48bac53bc807d51a0d81103063fd8bf8e06c0c64 100644
--- a/src/main/java/net/minecraft/world/level/block/IceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/IceBlock.java
@@ -41,7 +41,7 @@ public class IceBlock extends HalfTransparentBlock {
@@ -31,7 +31,7 @@ public class IceBlock extends HalfTransparentBlock {
public void afterDestroy(Level world, BlockPos pos, ItemStack tool) {
// Paper end
if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) {
@@ -30,7 +30,7 @@ index 4ab6997dad5b112f5105f786a6cee78c6c5667e8..c7dd921ab70ac53559208c58fbf9dec9
world.removeBlock(pos, false);
return;
}
@@ -69,7 +69,7 @@ public class IceBlock extends HalfTransparentBlock {
@@ -59,7 +59,7 @@ public class IceBlock extends HalfTransparentBlock {
return;
}
// CraftBukkit end
@@ -38,4 +38,4 @@ index 4ab6997dad5b112f5105f786a6cee78c6c5667e8..c7dd921ab70ac53559208c58fbf9dec9
+ if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura
world.removeBlock(pos, false);
} else {
world.setBlockAndUpdate(pos, IceBlock.meltsInto());
world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState());

View File

@@ -5,15 +5,15 @@ Subject: [PATCH] Configure concrete solidifying in water
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
index 99887ed1044cff244074a4584729df50239e9e9a..bdea4539bd3c0448c16ccb19bb4a7a932fcef9e1 100644
index 855f6797611846dad7b2cab3bde816d898cfcc0b..f82095eaa4d1d276e69024ecf1e22418409e815c 100644
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
@@ -287,7 +287,7 @@ public class FallingBlockEntity extends Entity {
@@ -285,7 +285,7 @@ public class FallingBlockEntity extends Entity {
BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition();
// Sakura end
- boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
+ boolean flag = this.level().sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura
boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER);
+ boolean flag = this.level.sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura
boolean flag1 = flag && this.level.getFluidState(blockposition).is(FluidTags.WATER);
double d0 = this.getDeltaMovement().lengthSqr();

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Option for fast nether dimension lava
diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
index 1dab5318d8693d15ee879456dff3a1916cfad335..cae1adf85ff35947a9747a21ff887a2ec0a4367a 100644
index ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a..2d3d991c826286083377b5e92bf6d807c1836253 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -183,7 +183,7 @@ public abstract class LavaFluid extends FlowingFluid {

View File

@@ -5,21 +5,10 @@ Subject: [PATCH] Allow explosions to destroy lava
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 7bef41c62d6c96062532233c80b96d6e65a523c8..505ccb379c074cfe87a47523ecfe048cbb89b55e 100644
index 8646302289669685cd44bb70231a110b4b09affc..8dd53e7c714657fe357757cdbfdfd7182b8a73eb 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -228,6 +228,10 @@ public class Explosion {
if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) {
resistance = Optional.of(material.resistance());
}
+
+ if (this.level.sakuraConfig().cannons.explosion.explodeLava && blockState.is(Blocks.LAVA)) {
+ resistance = Optional.of(0.0f); // 1.0 might be better here, 0.0 seems too much.
+ }
}
// Sakura end
@@ -443,6 +447,12 @@ public class Explosion {
@@ -136,6 +136,12 @@ public class Explosion {
return false;
}
@@ -32,3 +21,16 @@ index 7bef41c62d6c96062532233c80b96d6e65a523c8..505ccb379c074cfe87a47523ecfe048c
float power = radius * 1.3f;
float blockRes = state.getBlock().getExplosionResistance();
float fluidRes = state.getFluidState().getExplosionResistance();
@@ -313,6 +319,12 @@ public class Explosion {
}
// Sakura end
+ // Sakura start
+ if (this.level.sakuraConfig().cannons.explosion.explodeLava && iblockdata.is(Blocks.LAVA)) {
+ optional = Optional.of(0.0f); // 1.0 might be better here, 0.0 seems too much.
+ }
+ // Sakura end
+
if (optional.isPresent()) {
f -= ((Float) optional.get() + 0.3F) * 0.3F;
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Disable bubble columns affecting cannon entities
diff --git a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
index 115506fceb9a406e844880fb523d2ff09a66cf7b..c55202aa366869dc34ef11a7786acdc11cef183d 100644
index 461288cb56793f11e8dac80720b36cb9b42da518..662c5eff975ad0638298aab11e614e102e6f83e9 100644
--- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java
@@ -48,6 +48,7 @@ public class BubbleColumnBlock extends Block implements BucketPickup {
@@ -39,6 +39,7 @@ public class BubbleColumnBlock extends Block implements BucketPickup {
@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper

View File

@@ -0,0 +1,76 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Sun, 26 Nov 2023 17:57:50 +0000
Subject: [PATCH] Treat all collidable blocks as full while moving fast
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
index 9132adee72a2ae9c1c069a4f385c2b8d101484ba..7ff34421298f48d75066db0b2accca4d0dfa5dcf 100644
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -467,6 +467,7 @@ public final class CollisionUtil {
final int maxChunkZ = maxBlockZ >> 4;
final boolean addTicket = loadChunks && entity != null && (entity.isPrimedTNT || entity.isFallingBlock); // Sakura
+ final boolean fullBlocks = entity != null && entity.isTreatingBlocksAsFull(); // Sakura
final ServerChunkCache chunkProvider;
if (getter instanceof WorldGenRegion) {
chunkProvider = null;
@@ -531,7 +532,7 @@ public final class CollisionUtil {
final int maxY = currChunkY == maxChunkYIterate ? maxYIterate & 15 : 15; // coordinate in chunk
final int chunkYGlobalPos = currChunkY << 4;
- final boolean sectionHasSpecial = section.hasSpecialCollidingBlocks();
+ final boolean sectionHasSpecial = !fullBlocks && section.hasSpecialCollidingBlocks(); // Sakura
final int minXIterate;
final int maxXIterate;
@@ -637,11 +638,20 @@ public final class CollisionUtil {
BlockState blockData = blocks.get(localBlockIndex);
if ((edgeCount != 1 || blockData.shapeExceedsCube()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON)) {
- mutablePos.set(blockX, blockY, blockZ);
- if (collisionShape == null) {
- collisionShape = new LazyEntityCollisionContext(entity);
+ // Sakura start - treat all collidable block as full
+ final VoxelShape voxelshape2;
+
+ if (fullBlocks) {
+ voxelshape2 = Shapes.block();
+ } else {
+ mutablePos.set(blockX, blockY, blockZ);
+ if (collisionShape == null) {
+ collisionShape = new LazyEntityCollisionContext(entity);
+ }
+
+ voxelshape2 = blockData.getCollisionShape(getter, mutablePos, collisionShape);
}
- VoxelShape voxelshape2 = blockData.getCollisionShape(getter, mutablePos, collisionShape);
+ // Sakura end
if (voxelshape2 != Shapes.empty()) {
VoxelShape voxelshape3 = voxelshape2.move((double)blockX, (double)blockY, (double)blockZ);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 888801fc3468970bffe63fbefbae63e1d851f403..a15d5cd0acfba3e3e8ed46dda9fbab671eca4112 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -684,6 +684,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
return this.physics;
}
// Sakura end
+ // Sakura start - treat all collidable blocks as full
+ public boolean isTreatingBlocksAsFull() {
+ if (level.sakuraConfig().cannons.treatAllBlocksAsFullWhenMoving && (this.isPrimedTNT || this.isFallingBlock)) {
+ this.syncDeltaMovement();
+ double horizontalMovementSqr = this.movementX*this.movementX + this.movementZ*this.movementZ;
+ if (horizontalMovementSqr > Math.pow(this.level.sakuraConfig().cannons.treatAllBlocksAsFullWhenMovingFasterThan, 2.0)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ // Sakura end
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add redstone implementation API
diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557b1e57b5c 100644
index 7da6447f41606bfe25b0dc6106e3419998ed1443..3eb8ea8945932da7394a067971db1438da8a149e 100644
--- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java
@@ -269,7 +269,7 @@ public class RedStoneWireBlock extends Block {
@@ -262,7 +262,7 @@ public class RedStoneWireBlock extends Block {
* Note: Added 'source' argument so as to help determine direction of information flow
*/
private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, BlockPos source) {
@@ -17,7 +17,7 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557
turbo.updateSurroundingRedstone(worldIn, pos, state, source);
return;
}
@@ -293,7 +293,7 @@ public class RedStoneWireBlock extends Block {
@@ -286,7 +286,7 @@ public class RedStoneWireBlock extends Block {
int k = worldIn.getBestNeighborSignal(pos1);
this.shouldSignal = true;
@@ -26,7 +26,7 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557
// This code is totally redundant to if statements just below the loop.
if (k > 0 && k > j - 1) {
j = k;
@@ -307,7 +307,7 @@ public class RedStoneWireBlock extends Block {
@@ -300,7 +300,7 @@ public class RedStoneWireBlock extends Block {
// redstone wire will be set to 'k'. If 'k' is already 15, then nothing inside the
// following loop can affect the power level of the wire. Therefore, the loop is
// skipped if k is already 15.
@@ -35,7 +35,7 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557
for (Direction enumfacing : Direction.Plane.HORIZONTAL) {
BlockPos blockpos = pos1.relative(enumfacing);
boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ();
@@ -326,7 +326,7 @@ public class RedStoneWireBlock extends Block {
@@ -319,7 +319,7 @@ public class RedStoneWireBlock extends Block {
}
}
@@ -44,7 +44,7 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557
// The old code would decrement the wire value only by 1 at a time.
if (l > j) {
j = l - 1;
@@ -479,7 +479,7 @@ public class RedStoneWireBlock extends Block {
@@ -472,7 +472,7 @@ public class RedStoneWireBlock extends Block {
public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) {
if (!oldState.is(state.getBlock()) && !world.isClientSide) {
// Paper start - optimize redstone - replace call to updatePowerStrength
@@ -53,7 +53,7 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557
world.getWireHandler().onWireAdded(pos); // Alternate Current
} else {
this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft
@@ -512,7 +512,7 @@ public class RedStoneWireBlock extends Block {
@@ -505,7 +505,7 @@ public class RedStoneWireBlock extends Block {
}
// Paper start - optimize redstone - replace call to updatePowerStrength
@@ -62,7 +62,7 @@ index 82bde0e37971e806b19d17fbf48c663c82399739..8a2c9948aea1203c209948bdd3653557
world.getWireHandler().onWireRemoved(pos, state); // Alternate Current
} else {
this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft
@@ -553,7 +553,7 @@ public class RedStoneWireBlock extends Block {
@@ -546,7 +546,7 @@ public class RedStoneWireBlock extends Block {
if (!world.isClientSide) {
// Paper start - optimize redstone (Alternate Current)
// Alternate Current handles breaking of redstone wires in the WireHandler.

View File

@@ -1,79 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Sun, 26 Nov 2023 17:57:50 +0000
Subject: [PATCH] Treat all collidable blocks as full while moving fast
diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java
index a40dcbde87860fd6d3b60d0b9e2d5e63e18e69b7..d0bab6610a0ea8d3e6ba69034a25f4096dc00940 100644
--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java
+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java
@@ -1581,6 +1581,7 @@ public final class CollisionUtil {
public static final int COLLISION_FLAG_CHECK_BORDER = 1 << 2;
public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3;
public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura
+ public static final int COLLISION_FLAG_FULL_BLOCKS = 1 << 5; // Sakura
public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb,
final List<VoxelShape> intoVoxel, final List<AABB> intoAABB,
@@ -1632,6 +1633,7 @@ public final class CollisionUtil {
final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0;
final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura
+ final boolean fullBlocks = (collisionFlags & COLLISION_FLAG_FULL_BLOCKS) != 0; // Sakura
final ServerChunkCache chunkSource = (ServerChunkCache)world.getChunkSource();
for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
@@ -1673,7 +1675,7 @@ public final class CollisionUtil {
continue;
}
- final boolean hasSpecial = section.getSpecialCollidingBlocks() != 0;
+ final boolean hasSpecial = !fullBlocks && section.getSpecialCollidingBlocks() != 0; // Sakura
final int sectionAdjust = !hasSpecial ? 1 : 0;
final PalettedContainer<BlockState> blocks = section.states;
@@ -1707,12 +1709,20 @@ public final class CollisionUtil {
}
if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) {
- VoxelShape blockCollision = blockData.getConstantCollisionShape();
+ // Sakura start - if flag is set treat all block as full
+ VoxelShape blockCollision;
- if (blockCollision == null) {
- mutablePos.set(blockX, blockY, blockZ);
- blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
+ if (fullBlocks) {
+ blockCollision = Shapes.block();
+ } else {
+ blockCollision = blockData.getConstantCollisionShape();
+
+ if (blockCollision == null) {
+ mutablePos.set(blockX, blockY, blockZ);
+ blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape);
+ }
}
+ // Sakura end
AABB singleAABB = blockCollision.getSingleAABBRepresentation();
if (singleAABB != null) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 852276d9bedc51c3c8a28b60c85fdb23cf9cf818..7631e9c2d64bd153267ebd36648fe5e755906def 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -547,6 +547,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET;
}
+ if (this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMoving && (this.isPrimedTNT || this.isFallingBlock)) {
+ this.syncDeltaMovement();
+ double horizontalMovementSqr = this.movementX*this.movementX + this.movementZ*this.movementZ;
+ if (horizontalMovementSqr > Math.pow(this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMovingFasterThan, 2.0)) {
+ flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_FULL_BLOCKS;
+ }
+ }
+
return flags;
}
// Sakura end

View File

@@ -5,7 +5,7 @@ Subject: [PATCH] Reduce entity tracker player updates
diff --git a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
index 33d9131e9c75ef23cd637f5d6c39a2704a0c92a5..715994cbcb6c4dfa016eb9af49b40cde95ab16e7 100644
index 4b6e0fe2fabcc55007fd8979e81f66df9c0278b7..ab6219ca5c38a1ba469c629a5ae00a4c1361c9b0 100644
--- a/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
+++ b/src/main/java/net/minecraft/network/protocol/game/VecDeltaCodec.java
@@ -47,4 +47,10 @@ public class VecDeltaCodec {
@@ -20,10 +20,10 @@ index 33d9131e9c75ef23cd637f5d6c39a2704a0c92a5..715994cbcb6c4dfa016eb9af49b40cde
+ // Sakura end
}
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 24e0eaf25b2b366fd0e63a530c90f233c11d1bca..a09ac6167757b29ca2c6c78f1fd38039e8c19534 100644
index e6d9ff38f2674e00b7e246015d2b3bda5eb7a445..4827be7d5665d3b0a1b06f702f71993aff2789ec 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
@@ -1159,6 +1159,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1257,6 +1257,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
try {
for (TrackedEntity tracker : this.entityMap.values()) {
// update tracker entry
@@ -31,7 +31,7 @@ index 24e0eaf25b2b366fd0e63a530c90f233c11d1bca..a09ac6167757b29ca2c6c78f1fd38039
tracker.updatePlayers(tracker.entity.getPlayersInTrackRange());
}
} finally {
@@ -1333,6 +1334,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
@@ -1522,6 +1523,14 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
this.lastSectionPos = SectionPos.of((EntityAccess) entity);
}
@@ -47,11 +47,11 @@ index 24e0eaf25b2b366fd0e63a530c90f233c11d1bca..a09ac6167757b29ca2c6c78f1fd38039
com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> lastTrackerCandidates;
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
index f7d8aaededd39ce52a9d0105f66fd759635b5288..be3eb957c8cf1bb5f5e2f448be73c0a14f245a4a 100644
index 18c5473923f8ce53be59b2496f347b31934ecc92..7bd08de82a5389b283d5cd96c5aea75419ca3b3f 100644
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
@@ -64,7 +64,7 @@ public class ServerEntity {
private static final int FORCED_TELEPORT_PERIOD = 400;
@@ -63,7 +63,7 @@ public class ServerEntity {
private static final int TOLERANCE_LEVEL_ROTATION = 1;
private final ServerLevel level;
private final Entity entity;
- private final int updateInterval;
@@ -59,7 +59,7 @@ index f7d8aaededd39ce52a9d0105f66fd759635b5288..be3eb957c8cf1bb5f5e2f448be73c0a1
private final boolean trackDelta;
private final Consumer<Packet<?>> broadcast;
private final VecDeltaCodec positionCodec = new VecDeltaCodec();
@@ -82,6 +82,12 @@ public class ServerEntity {
@@ -81,6 +81,12 @@ public class ServerEntity {
// CraftBukkit start
final Set<ServerPlayerConnection> trackedPlayers; // Paper - private -> package

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add option for legacy lava block formation
diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
index 2fe44dae063eb0cd7d4813fb6b2937830d432e51..aaac136acbef15a1925b4b6e8da7bfc4f75360de 100644
index 28bdb44599a8862d58cfb2e087119b843f25f311..51dc3b81fcb76b1bc185486db26ca2a36ca36e98 100644
--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java
@@ -199,7 +199,15 @@ public class LiquidBlock extends Block implements BucketPickup {
@@ -161,7 +161,15 @@ public class LiquidBlock extends Block implements BucketPickup {
if (fluidState.isSource()) {
block = Blocks.OBSIDIAN;
} else {
@@ -26,7 +26,7 @@ index 2fe44dae063eb0cd7d4813fb6b2937830d432e51..aaac136acbef15a1925b4b6e8da7bfc4
// SANITY: In legacy a patch by paper removes the fluid level condition from vanilla.
if (physics.afterOrEqual(1_16_0) || physics.isLegacy()
diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
index cae1adf85ff35947a9747a21ff887a2ec0a4367a..56dcba3560fb13be9d13b400aea681de98ca800d 100644
index 2d3d991c826286083377b5e92bf6d807c1836253..1fb85a64eca4ef8a778f5b8652f774d1cfb707c4 100644
--- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java
@@ -177,7 +177,7 @@ public abstract class LavaFluid extends FlowingFluid {
@@ -39,7 +39,7 @@ index cae1adf85ff35947a9747a21ff887a2ec0a4367a..56dcba3560fb13be9d13b400aea681de
}
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
index 521b8084e490d5f3ecacd1d7368dddee22647aa9..7987b45130e2eeba1dca4bc8bba9efe0cd8b209c 100644
index 43df400227429a8a1a18d5ad6fce8a57b198e766..3a955377a13b67e955f90614b975f76f3fcfe9b8 100644
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
@@ -106,7 +106,7 @@ public abstract class WaterFluid extends FlowingFluid {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Configure mob spawner defaults
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index d88a23984dcea9c2119bdc245013af8b25448da3..0300e7af69ac41e3bd3a204104b3f9943e0ae05b 100644
index 31ac0e5ca26c7bdfa9b710d0bb78d846ddf6863e..cf75da36f7f10f86eee4667a04533ba487d349eb 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -49,7 +49,16 @@ public abstract class BaseSpawner {
@@ -47,7 +47,16 @@ public abstract class BaseSpawner {
public int spawnRange = 4;
private int tickDelay = 0; // Paper

View File

@@ -5,19 +5,19 @@ Subject: [PATCH] Add instant mob death animation
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 7728492fd3623670482f4ca89e0934e7bcb972e1..6192f6a957855c8f64fd6c909dc150dd08586eb6 100644
index 7d1d3495e3a80732faadd5053ed09fdd86122366..1faf5a6e3bbdb886018fcefb28336d958993f64e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1765,6 +1765,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1686,6 +1686,12 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
// Paper start
if (this.dead) { // Paper
+ // Sakura start
+ if (level().sakuraConfig().entity.instantDeathAnimation && !(this instanceof Player)) {
+ if (level.sakuraConfig().entity.instantDeathAnimation && !(this instanceof Player)) {
+ this.deathTime = 20;
+ return;
+ }
+ // Sakura end
this.level().broadcastEntityEvent(this, (byte) 3);
this.level.broadcastEntityEvent(this, (byte) 3);
this.setPose(Pose.DYING);
}
} // Paper

View File

@@ -5,17 +5,17 @@ Subject: [PATCH] Configure fluids breaking redstone
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
index 96ccad764cb6424ffe561c558cd11200d89ff541..cc6f05998f2d73b09350c337e10ef3f57a9e0e68 100644
index f8c1926a0db9c45fee7e794d14f1fe540918a1e2..ea1246f8a58e4cac83dff870aa1d218ef4b2feae 100644
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
@@ -480,6 +480,10 @@ public abstract class FlowingFluid extends Fluid {
LiquidBlockContainer ifluidcontainer = (LiquidBlockContainer) block;
@@ -465,6 +465,10 @@ public abstract class FlowingFluid extends Fluid {
return ifluidcontainer.canPlaceLiquid((Player) null, world, pos, state, fluid);
if (block instanceof LiquidBlockContainer) {
return ((LiquidBlockContainer) block).canPlaceLiquid(world, pos, state, fluid);
+ // Sakura start
+ } else if (world instanceof Level level && !level.sakuraConfig().technical.redstone.fluidsBreakRedstone && state.isSignalSource()) {
+ return false;
+ // Sakura end
} else {
return !(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && !state.is(Blocks.LADDER) && !state.is(Blocks.SUGAR_CANE) && !state.is(Blocks.BUBBLE_COLUMN) ? (!state.is(Blocks.NETHER_PORTAL) && !state.is(Blocks.END_PORTAL) && !state.is(Blocks.END_GATEWAY) && !state.is(Blocks.STRUCTURE_VOID) ? !state.blocksMotion() : false) : false;
}
} else if (!(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && !state.is(Blocks.LADDER) && !state.is(Blocks.SUGAR_CANE) && !state.is(Blocks.BUBBLE_COLUMN)) {
Material material = state.getMaterial();

View File

@@ -0,0 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Sat, 9 Dec 2023 00:25:11 +0000
Subject: [PATCH] Option to disable explosions hurting players
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 95b1e0c116fc070fe8c692f8c1aff63bd1825d99..4c2db001c8be0fbb96311605597fc20fda6cf807 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -930,7 +930,7 @@ public abstract class Player extends LivingEntity {
@Override
public boolean isInvulnerableTo(DamageSource damageSource) {
- return super.isInvulnerableTo(damageSource) ? true : (damageSource.is(DamageTypeTags.IS_DROWNING) ? !this.level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FALL) ? !this.level.getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FIRE) ? !this.level.getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FREEZING) ? !this.level.getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : false))));
+ return super.isInvulnerableTo(damageSource) ? true : (damageSource.is(DamageTypeTags.IS_DROWNING) ? !this.level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FALL) ? !this.level.getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FIRE) ? !this.level.getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FREEZING) ? !this.level.getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_EXPLOSION) ? !level.sakuraConfig().cannons.explosion.explosionsHurtPlayers : false))))); // Sakura
}
@Override

View File

@@ -5,17 +5,17 @@ Subject: [PATCH] Iron golems take fall damage
diff --git a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
index f383928fc5b331ddf128bdcb6a23010d8fe088d3..4dd778901f0327d30b993dffd73f75f631bb3a9b 100644
index 4fbbd74cda7e4f2c623db46c2c94d9697ca5df05..a1b1090b9dd11573e30c7cb39adb1c86da0527e5 100644
--- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
+++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java
@@ -240,6 +240,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
@@ -249,6 +249,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob {
}
+ // Sakura start
+ @Override
+ protected int calculateFallDamage(float fallDistance, float damageMultiplier) {
+ if (!this.level().sakuraConfig().entity.ironGolemsTakeFalldamage) {
+ if (!this.level.sakuraConfig().entity.ironGolemsTakeFalldamage) {
+ return super.calculateFallDamage(fallDistance, damageMultiplier);
+ } else {
+ net.minecraft.world.effect.MobEffectInstance mobeffect = this.getEffect(net.minecraft.world.effect.MobEffects.JUMP);

View File

@@ -1,19 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
Date: Sat, 9 Dec 2023 00:25:11 +0000
Subject: [PATCH] Option to disable explosions hurting players
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index d0742bbf6f94705e378972e3bc0fab4682f3d78f..9b6359b67b5840739dffdb174e591ea76601626c 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -933,7 +933,7 @@ public abstract class Player extends LivingEntity {
@Override
public boolean isInvulnerableTo(DamageSource damageSource) {
- return super.isInvulnerableTo(damageSource) ? true : (damageSource.is(DamageTypeTags.IS_DROWNING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FALL) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FIRE) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FREEZING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : false))));
+ return super.isInvulnerableTo(damageSource) ? true : (damageSource.is(DamageTypeTags.IS_DROWNING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FALL) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FIRE) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FREEZING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_EXPLOSION) ? !level().sakuraConfig().cannons.explosion.explosionsHurtPlayers : false))))); // Sakura
}
@Override

View File

@@ -5,19 +5,19 @@ Subject: [PATCH] Add explosions dropping items config
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 553dca07cee7cd5492bba63270a9b6d0ad1669e8..713394ce41e0c935caf2a41697c7ad7cd3412ad1 100644
index 8dd53e7c714657fe357757cdbfdfd7182b8a73eb..fda0aeae04276ff9ac3b041895f1344e8c6dd6fe 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -885,6 +885,12 @@ public class Explosion {
});
@@ -585,6 +585,12 @@ public class Explosion {
}
}
+ // Sakura start
+ if (!level.sakuraConfig().cannons.explosion.explosionsDropItems) {
+ list.clear();
+ objectarraylist.clear();
+ }
+ // Sakura end
+
Iterator iterator = list.iterator();
objectlistiterator = objectarraylist.iterator();
while (iterator.hasNext()) {
while (objectlistiterator.hasNext()) {

View File

@@ -5,14 +5,14 @@ Subject: [PATCH] Optimise check inside blocks and fluids
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index e6bcc60810c551e92e7f01f49cfbff58735b97ed..78787a972b9fbc6dd5caaad06e5047133f2a1993 100644
index a15d5cd0acfba3e3e8ed46dda9fbab671eca4112..2c6dbe4d6c1c9cd6ab67bee2885c3831b758fa09 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1980,18 +1980,37 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1867,14 +1867,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset);
// Sakura end
- if (this.level().hasChunksAt(blockposition, blockposition1)) {
- if (this.level.hasChunksAt(blockposition, blockposition1)) {
+ // Sakura start - optimise check inside blocks
+ if (blockposition1.getY() >= level.getMinBuildHeight() || blockposition.getY() < level.getMaxBuildHeight()) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
@@ -39,18 +39,14 @@ index e6bcc60810c551e92e7f01f49cfbff58735b97ed..78787a972b9fbc6dd5caaad06e504713
+ }
+
+ for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) {
if (!this.isAlive()) {
return;
}
blockposition_mutableblockposition.set(i, j, k);
- BlockState iblockdata = this.level().getBlockState(blockposition_mutableblockposition);
- BlockState iblockdata = this.level.getBlockState(blockposition_mutableblockposition);
+ BlockState iblockdata = chunk.getBlockState(blockposition_mutableblockposition);
+ // Sakura end
try {
iblockdata.entityInside(this.level(), blockposition_mutableblockposition, this);
@@ -4782,7 +4801,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
iblockdata.entityInside(this.level, blockposition_mutableblockposition, this);
@@ -4525,7 +4544,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
}
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
@@ -59,7 +55,7 @@ index e6bcc60810c551e92e7f01f49cfbff58735b97ed..78787a972b9fbc6dd5caaad06e504713
return false;
} else {
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
@@ -4799,11 +4818,30 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4542,11 +4561,30 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
int k1 = 0;
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
@@ -87,9 +83,9 @@ index e6bcc60810c551e92e7f01f49cfbff58735b97ed..78787a972b9fbc6dd5caaad06e504713
+
+ for (int i2 = k; i2 < l; ++i2) {
blockposition_mutableblockposition.set(l1, i2, j2);
- FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition);
- FluidState fluid = this.level.getFluidState(blockposition_mutableblockposition);
+ FluidState fluid = chunk.getFluidState(blockposition_mutableblockposition);
+ // Sakura end
if (fluid.is(tag)) {
double d2 = (double) ((float) i2 + fluid.getHeight(this.level(), blockposition_mutableblockposition));
double d2 = (double) ((float) i2 + fluid.getHeight(this.level, blockposition_mutableblockposition));

View File

@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 21 Jan 2024 22:12:30 +0000
Subject: [PATCH] fixup! Optimised Explosions
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index fda0aeae04276ff9ac3b041895f1344e8c6dd6fe..cd5ba771bd11549f9a9c2c03a31479d236f24e02 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -247,9 +247,9 @@ public class Explosion {
{
{
{
- double d0 = BLOCK_RAYCAST_VECTORS[0];
- double d1 = BLOCK_RAYCAST_VECTORS[1];
- double d2 = BLOCK_RAYCAST_VECTORS[2];
+ double d0 = BLOCK_RAYCAST_VECTORS[i];
+ double d1 = BLOCK_RAYCAST_VECTORS[i + 1];
+ double d2 = BLOCK_RAYCAST_VECTORS[i + 2];
float f = this.radius * (0.7F + (this.level.sakuraConfig().cannons.explosion.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura
double d4 = this.x;

View File

@@ -1,22 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 24 Dec 2023 16:56:39 +0000
Subject: [PATCH] Fix paper findSupportingBlock not updating last chunk
coordinates
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 5afbdbd07afc671c3c6db491a713abfa467fffa3..025429bad45b478c2aab20c4ffd2c240636be7ed 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -908,6 +908,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
if (chunkDiff != 0) {
lastChunk = chunkProvider.getChunkAtIfLoadedImmediately(newChunkX, newChunkZ);
+ // Sakura start
+ lastChunkX = newChunkX;
+ lastChunkZ = newChunkZ;
+ // Sakura end
}
if (lastChunk == null) {

View File

@@ -0,0 +1,21 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samsuik <kfian294ma4@gmail.com>
Date: Sun, 21 Jan 2024 23:14:26 +0000
Subject: [PATCH] fixup! Optimised Explosions
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index cd5ba771bd11549f9a9c2c03a31479d236f24e02..ee62cf3c8bbfdbf4bf6257322306bba232174380 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -285,6 +285,10 @@ public class Explosion {
lastChunkZ = chunkZ;
}
+ prevX = blockX;
+ prevY = blockY;
+ prevZ = blockZ;
+
mutableBlockPos.set(blockX, blockY, blockZ);
BlockPos blockposition = mutableBlockPos;